Creating Default XYDataSet

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

Creating Default XYDataSet

Post by Krazey » Fri May 24, 2002 9:15 am

Hi,

Can anyone post a sample of creating a DefaultXYDataSet ? PLz i'm french and my boss beat me !

Thx

David Gilbert

Re: Creating Default XYDataSet

Post by David Gilbert » Fri May 24, 2002 9:40 am

Your boss is right to beat you, because this example comes straight out of the DemoDatasetFactory class that you can find easily in the download:

/**
* Creates and returns a XYDataset for the demo charts.
*/
public static XYDataset createTestXYDataset() {

Object[][][] data = new Object[][][] { {
{ createDateTime(2000, Calendar.OCTOBER, 18, 9, 5), new Double(10921.0) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 10, 6), new Double(10886.7) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 11, 6), new Double(10846.6) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 12, 6), new Double(10843.7) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 13, 6), new Double(10841.2) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 14, 6), new Double(10830.7) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 15, 6), new Double(10795.8) },
{ createDateTime(2000, Calendar.OCTOBER, 18, 16, 7), new Double(10733.8) }
} };

return new DefaultXYDataset(data);

}

You should also try the XYSeriesCollection class, as I suggested here:

http://www.object-refinery.com/phorum-3 ... 271&t=2270

Regards,

DG.

P.S. I was joking about the beating...even though you deserve it, it should never happen!

Krazey

Re: Creating Default XYDataSet

Post by Krazey » Mon May 27, 2002 9:04 am

thx

Locked