Need XY-Chart filled with arrays

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
howard0
Posts: 2
Joined: Mon Mar 26, 2007 5:41 pm

Need XY-Chart filled with arrays

Post by howard0 » Mon Mar 26, 2007 5:48 pm

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

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Tue Mar 27, 2007 4:32 pm

Use XYSeries class, adding your x,y points, looping through your array:

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);
You should have a look in the samples provided with JFreeChart and in the JFC javadoc.

Regards,

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Mar 28, 2007 11:59 am

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.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

howard0
Posts: 2
Joined: Mon Mar 26, 2007 5:41 pm

Post by howard0 » Wed Mar 28, 2007 5:57 pm

Thanks for your kind help.

I'll try the sample of williamt.


Cheers,

howard

Locked