DateTickUnit and label format in TimeSeriesChart

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

DateTickUnit and label format in TimeSeriesChart

Post by Fredrik » Mon Jan 27, 2003 10:03 pm

Hi
I have created a TimeSeriesChart via the factory, that contains a serie of values created by
new Minute(some_time, some_value)

The value serie is created by
new BasicTimeSeries("Indoor", Minute.class)

as I have temperature readings for each minut during 24h.

However, I don't want the x-axis label to be of the format hh:mm, I'd rather have just hh. To achieve this, I tried
((DateAxis)((XYPlot)(chart.getPlot())).getHorizontalValueAxis()).setTickUnit(new DateTickUnit(DateTickUnit.HOUR,1));

Now the strange thing, hours are not displayed on the x-axis, instead I get yyyy-mm-dd, why? And how should I correct it?

Fredrik

Re: DateTickUnit and label format in TimeSeriesChart

Post by Fredrik » Mon Jan 27, 2003 10:21 pm

Fixed the problem by using the constructor of DateTickUnit that takes a java.text.DateFormat as well, but why the odd behaviour when using the simpler constructor? Should not HOUR give HH as default?

David Gilbert

Re: DateTickUnit and label format in TimeSeriesChart

Post by David Gilbert » Wed Jan 29, 2003 12:44 am

The simple constructor just uses:

DateFormat.getDateInstance(DateFormat.SHORT)

...for the date format. For one hour, 'HH' makes sense, but what about 12 hours (where perhaps the chart displays five days of data at half day intervals)? It's just not easy to provide a sensible default for all cases, so I didn't try.

Regards,

Dave Gilbert

Locked