TimeSeries Chart using months

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

TimeSeries Chart using months

Post by Jorge Urroz » Thu Apr 11, 2002 2:07 pm

How can I get the chart to use months class instead of day like in the demo? Seems I cant get it to work.

Thanks.

David Gilbert

Re: TimeSeries Chart using months

Post by David Gilbert » Fri Apr 12, 2002 10:42 am

Hi Jorge,

There is a new demo application in version 0.8.1 (TimeSeriesDemo) that shows how to create a time series chart for Quarterly data...here's the important part of the code:

this.series = new BasicTimeSeries("Quarterly Data", Quarter.class);
this.series.add(new Quarter(1, 2001), 500.2);
this.series.add(new Quarter(2, 2001), 694.1);
this.series.add(new Quarter(3, 2001), 734.4);
this.series.add(new Quarter(4, 2001), 453.2);
this.series.add(new Quarter(1, 2002), 500.2);
this.series.add(new Quarter(2, 2002), null);
this.series.add(new Quarter(3, 2002), 734.4);
this.series.add(new Quarter(4, 2002), 453.2);
TimeSeriesCollection dataset = new TimeSeriesCollection(series);
JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo", "Time", "Value", dataset, true);

If you change Quarter.class to Month.class and also change each of the Quarter constructors to an appropriate Month constructor, then the example should work in exactly the same way.

Ask again if that doesn't help...

Regards,

DG.

Jorge Urroz

Re: TimeSeries Chart using months

Post by Jorge Urroz » Fri Apr 12, 2002 9:14 pm

Thanks D.G.

Locked