Changing x-axis values interpretation
Changing x-axis values interpretation
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.
-
- 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
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

