Class required for creating dataset

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

Class required for creating dataset

Post by Paul Deason » Wed Feb 26, 2003 12:31 am

Hi,

I want to draw a line graph or maybe a time series one. However, I am having problems with getting a class which accepts a string(i.e. to represent a date) and values (i.e. a value for that date) as its constructor parameters.
I am using the below code, the ‘DefaultCategoryDataset’ does not allow any strings, just Number objects. I therefore need a class that takes a string and a double, and represents it as some kind of Dataset to plot the graphs. Does anyone know what class I can use to hold the data I require it to hold?

String[] seriesnames = new String [] {"Current Year", "Past Year"};
String[] categoryNames = new String[] {"First Quarter", "Second Quarter"};
Number[] categoryData = new Integer[]{new Integer(1),new Integer(5),new
Integer(10), new Integer(15),new Integer(20),new Integer(25)};

CategoryDataset categorydataset = new DefaultCategoryDataset(seriesnames, categoryNames, categoryData);

return ChartFactory.createLineChart("Sample XY Line Chart",
"Price",
"Date",
categorydataset,
true, true, true);

Thanks.

David Gilbert

Re: Class required for creating dataset

Post by David Gilbert » Wed Feb 26, 2003 12:34 am

The DefaultCategoryDataset class changed between 0.9.4 and 0.9.5. Take a look through the demo applications in the src/com/jrefinery/chart/demo directory to see examples of how to create datasets with the latest version of JFreeChart.

Regards,

Dave Gilbert

Locked