How to make XYDataset from the 2-Dimensional array

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Kishore

How to make XYDataset from the 2-Dimensional array

Post by Kishore » Tue Oct 29, 2002 10:55 am

Hi,
Is it Possible to Construct a XYDataset from the 2-Dimensional array.
my requirement is that, i do have a two-dimentional array,and i want to pass that array to the XYPlot() constructor to make the plot.
But, XYPlot constructor will allow only XYDataset.
code is given below.
XYPlot plot1 = new XYPlot(XYDataset instance, null, null);
how do i convert Existing Two-demensional array to XYDtaset,so that i can pass it to the XYPlot constructor.
Any API available???

Thanks,
Kishore.

Dave Gilbert

Re: How to make XYDataset from the 2-Dimensional array

Post by Dave Gilbert » Wed Oct 30, 2002 10:19 am

There's nothing available to do that. If you have a 2D array of values, for example:

1.2 5.4 9.7
4.3 4.7 6.3
2.3 8.4 9.3
2.7 9.1 5.7

...what are the (x, y) pairs? Is the first column the x-values, and the remaining columns y1, y2 etc?

Or did you mean just two columns of x and y values (which I guess is just the simplest case of the above):

1.2 5.4
4.3 4.7
2.3 8.4
2.7 9.1

You might also look at SampleXYDataset2 in the com.jrefinery.chart.demo package. It uses two arrays (one for the x-values and one for the y-values), allowing for multiple series (with independent x-values between the series). It could be modified to be a general dataset rather than a demo dataset.

Regards,

DG

P.S. I'd be happy to see some extensions to support what you are asking for. Time is limited for me right now though.

Locked