help

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

help

Post by Ronald » Sat Jun 01, 2002 3:43 pm

Hello,
I created a JFreeChart using an XYDataset : value = f(hour).
My problem is that all the hours of the legend are chifted of 2 hours and a half.
(for example, for 2h the legend is 4h30)
I can't understand it.
Thanks a lot,
Ronald.

Here are parts of my program :

BasicTimeSeries t = new BasicTimeSeries("Test", "Hour", "Value", Hour.class);
day = new Day(jour, mois, annee);
t.add(new Hour(heure, day), new Double(val));

JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xAxisLabel, yAxisLabel, data, true);

David Gilbert

Re: help

Post by David Gilbert » Sun Jun 02, 2002 6:32 am

Hi Ronald,

The half hour is due to the TimeSeriesCollection class returning the x-value from the middle of the Hour:

public Number getXValue(int series, int item) {

BasicTimeSeries ts = (BasicTimeSeries)data.get(series);
TimeSeriesDataPair dp = ts.getDataPair(item);
return new Long(dp.getPeriod().getMiddle(workingCalendar));

}

...but the axis draws labels at the start of every unit. It's an issue that should be fixed for the next release, although I haven't decided how to do it yet.

The two hours sounds like a time zone problem. The conversion from an Hour to a java.util.Date requires reference to a particular time zone...and if you don't supply one it should just use the local time zone. The date axis also uses the default time zone, so you should see these matching up...I'm puzzled.

Regards,

DG.

Locked