Changing x-axis values interpretation

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
84923331
Posts: 8
Joined: Fri Jun 12, 2009 2:04 pm

Changing x-axis values interpretation

Post by 84923331 » Thu Aug 06, 2009 4:09 pm

When I use data in the form of seconds as integers 50000, 50001, 50002 for the time axis in a time series plot the x-axis labels show up as 19:00:50.000, 19:00:50.001... Is there a way to change the default interpretation of x-axis data so that it will properly divide the number by 60 etc so that it will show up as a proper time? I am using my own implementation of the XYDataset interface and would prefer to keep the time data stored as integers.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Changing x-axis values interpretation

Post by david.gilbert » Sun Aug 09, 2009 8:58 pm

Your x-values are being interpreted using the convention that Java uses - milliseconds since 1-Jan-1970. That makes it easy for JFreeChart to reuse all the date formatting API calls provided in the standard Java runtime. If you prefer to store your time values as seconds since d-mmm-yyyy (where I guess you are defining the 'd-mmm-yyyy' somewhere) then you'll need to subclass the date axis to convert the data values from your encoding to the Java encoding (milliseconds). Or you could write a CustomDateAxis class from scratch, or you could just use a NumberAxis but write your own NumberFormat class that converts your x-values (seconds) into appropriate labels.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked