Skip to content

Instantly share code, notes, and snippets.

@swartzrock
Created June 24, 2011 04:52
Show Gist options
  • Save swartzrock/1044251 to your computer and use it in GitHub Desktop.
Save swartzrock/1044251 to your computer and use it in GitHub Desktop.
Serial Graph with Processing and JFreeChart
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.title.*;
import org.jfree.data.general.*;
import java.awt.*;
void showMeter(int value ) {
ValueDataset data = new DefaultValueDataset( value );
MeterPlot plot = new MeterPlot( data );
plot.setUnits( "%" );
TextTitle title = new TextTitle( "Light Sensitivity" );
title.setPaint( Color.WHITE );
JFreeChart chart = new JFreeChart( plot );
chart.setTitle( title );
chart.setBackgroundPaint( Color.decode("#000000") );
PImage chartImage = new PImage(chart.createBufferedImage(400, 300));
image( chartImage, 0, 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment