Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Pie Chart & XY plot (jfreechart)

$
0
0

I have made one pic chart with jfree chart.


PImage chartImage;

void setup(){
  size(500, 300);

 DefaultPieDataset pieDataset = new DefaultPieDataset();
pieDataset.setValue("JavaWorld", new Integer(75));
pieDataset.setValue("Other", new Integer(25));
JFreeChart chart = ChartFactory.createPieChart("Pie Chart",pieDataset,true,false,false);
 chartImage = new PImage(chart.createBufferedImage(500,300));
}


void draw(){
  // display chart image on screen
 image(chartImage, 0, 0);
}

I have attached 2 files jcommon & jfreechart. & its working ok.

Now I have change pie chart to line chart but it show error XYPlot function() could not find.

Can some one help me to solve this. Here is the code.

PImage chartImage;

void setup(){
  size(500, 300);

XYSeries series = new XYSeries("Average Size");
series.add(20.0, 10.0);
series.add(40.0, 20.0);
series.add(70.0, 50.0);
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createAreaXYChart("Sample XY Chart","Height","Weight",xyDataset,true);


  // create image from chart
  chartImage = new PImage(chart.createBufferedImage(500,300));
}


void draw(){
  // display chart image on screen
 image(chartImage, 0, 0);
}

Need Help.


Viewing all articles
Browse latest Browse all 2896

Trending Articles