How to set Y-Axis to display time values?

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

How to set Y-Axis to display time values?

Post by Michael Rauch » Fri Nov 22, 2002 6:44 pm

hi,

i'm using a XYChart to display a chart for orienteering races. the x-axis represents the controls (the progress) and the y-axis shows the time (or to be more precise the time difference of the athletes to the leader). now i would like the y-axis to display the time in a format like [mm:ss]. the time is stored in milliseconds in the dataset.

i have noticed that there is a HorizontalDateAxis that implements DataAxis, but no VerticalDateAxis. does this mean that i have to implement the VerticalDataAxis by myself ? .. or has anybody another solution.

cheers,
#!michael

Dave Gilbert

Re: How to set Y-Axis to display time values?

Post by Dave Gilbert » Fri Nov 22, 2002 6:49 pm

Hi Michael,

There's never been a requirement for a VerticalDateAxis, so the code has never been written. If you look at the difference between the HorizontalNumberAxis class and the VerticalNumberAxis class, you'll see that it is mostly just changes in the drawing code, so it shouldn't be that difficult to create a VerticalDateAxis based on the HorizontalDateAxis class.

Regards,

DG

Michael Rauch

Re: How to set Y-Axis to display time values?

Post by Michael Rauch » Mon Nov 25, 2002 1:02 am

Hi Dave,

Thanks for your tip, implementing a VerticalDateAxis was quiet straightforward. If you are interested in the resulting code, you can access it via our projects web CVS interface:

http://www.hta-bi.bfh.ch/Resources/Comp ... eAxis.java

Maybe you can incorporate it in a future jfreechart release. It seems to work as I expect it to work, but as I don't fully understand the entire jfreechart architecture it is possible that I have overseen something.

I also implemented isInverted() in my code, though this method is not defined in DateAxis but it is in NumberAxis and I need this feature. Further I have overloaded the static createStandardDateTickUnits() method with one that takes a DateFormat as argument. This was necessary because I want to use a specific DateFormat to format the tick labels. There is a constructor for DateAxis that takes a DateFormat as parameter, but the DateFormat is then nowhere used. I guess this is feature that is not yet implemented.

cheers
#!michael

btw: jfreechart really rocks! ;)

Locked