Hi Folks,
as I'm completely new in JFreeChart and i do need it for a project at School (reading from a microchip device and using NetBeans) i would like to ask for your kind help.
Recieving the values from the device and reading it in, i need to create a chart with x and y values (where x is a time constant and y a volume) showing the developing of the measured points.
I'm working with arrays (might be the problem) or FileReader.
Would be really great if somebody can help me.
Regards,
Howard
Need XY-Chart filled with arrays
Use XYSeries class, adding your x,y points, looping through your array:
You should have a look in the samples provided with JFreeChart and in the JFC javadoc.
Regards,
Code: Select all
XYSeries something= new XYSeries("series title");
for(int i=0; i < array.length;i++) {
something.add(x,y); // add your points here
}
XYSeriesCollection foo = new XYSeriesCollection(something);
JFreeChart jfc = (JFreeChart)ChartFactory.createXYLineChart("title",null,null,foo,PlotOrientation.VERTICAL,false,false,false);
Regards,
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The DefaultXYDataset class wraps data that is stored in arrays. You should look at the sources - it may fit your array format already, or you may be able to adapt it to fit.
William's suggestion will work, but it does involve copying your data, which you can avoid.
William's suggestion will work, but it does involve copying your data, which you can avoid.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

