Is this a limitation of DateAxis?
Is this a limitation of DateAxis?
I have created a dynamic chart using the DateAxis as the domain axis. What my chart does is this. I get cumulattive time values and I pass them to the chart(in milliseconds) to update the series at every time step. Everything seem to work fine untill the total time exceeds 24 hours (ie 86400000). i was expecting the tickunits to start again from zero(ie 00:00:00) but after a while a get tick units of strange dates(eg, i see months(jan, feb, etc) and later years starting from 1970). Why does the TickUnits show such values?
Your help will be much appreciated
ato
Your help will be much appreciated
ato
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Java's Date class represents points in time (with millisecond precision) as the number of milliseconds since the start of 1-Jan-1970 GMT. We use the same encoding for the DateAxis class.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hi Dave,
I get what you mean, however, my problem is with the AutoTickUnit. Why does it show strange labels for values greater than 86400000 milliseconds. how do i configure it to continue to display tick units of the pattern (HH:mm:ss) for values greater than 86400000 milliseconds. I tried to overwrite it with SimpleDateFormat(HH:mm:ss) but it wont work!!!
your insight would be much appreciated
ato
I get what you mean, however, my problem is with the AutoTickUnit. Why does it show strange labels for values greater than 86400000 milliseconds. how do i configure it to continue to display tick units of the pattern (HH:mm:ss) for values greater than 86400000 milliseconds. I tried to overwrite it with SimpleDateFormat(HH:mm:ss) but it wont work!!!
your insight would be much appreciated
ato
what you're seeing is a normal result of your domain values.
For 1 day, the axis will generate time only. For longer values a date is added.
You might add a dateFormatOverride to the axis but I doubt this would give you the results you want (as I guess you want the domain axis to display hours and minutes since the start of your period?).
Best thing to do is probably to create another style of axis and do your own transformation of the values to something you want to display.
For 1 day, the axis will generate time only. For longer values a date is added.
You might add a dateFormatOverride to the axis but I doubt this would give you the results you want (as I guess you want the domain axis to display hours and minutes since the start of your period?).
Best thing to do is probably to create another style of axis and do your own transformation of the values to something you want to display.
thanks guys for your contribution, see below a shot of my code:
DateAxis domain = new DateAxis("Time");
// set text for the Y (Population) axis
NumberAxis range = new NumberAxis("Population of Reacting Molecules");
/**
* create an XYPlot object to contain the
* dataset and the axes parameters
*/
XYPlot plot = new XYPlot();
DateAxis domain = new DateAxis("Time");
// set text for the Y (Population) axis
NumberAxis range = new NumberAxis("Population of Reacting Molecules");
/**
* create an XYPlot object to contain the
* dataset and the axes parameters
*/
XYPlot plot = new XYPlot();
sorry about that previous one i did not finish with the code:
// set text for the X (Time) axis of the chart
DateAxis domain = new DateAxis("Time");
// set text for the Y (Population) axis
NumberAxis range = new NumberAxis("Population of Reacting Molecules");
/**
* create an XYPlot object to contain the
* dataset and the axes parameters
*/
XYPlot plot = new XYPlot();
plot.setDataset(dataset);
// set the domain axis
plot.setDomainAxis(domain);
// set the range axis
plot.setRangeAxis(range);
the dataset in an XYSeriesCollection. Now I dont understand why the TickUnits interval continue to increase like that. After the first daythe interval is 1hr, 2 hrs the second day, 4hrs the third and then it moves to days, then i see jan, feb, march..whiles in actual sense the calculated total time i have on my counter reads say 345d 23:45:23 (d mean days here). how can I reflect this on the TickUnit...
your advice is more than appreciated..
atongo
// set text for the X (Time) axis of the chart
DateAxis domain = new DateAxis("Time");
// set text for the Y (Population) axis
NumberAxis range = new NumberAxis("Population of Reacting Molecules");
/**
* create an XYPlot object to contain the
* dataset and the axes parameters
*/
XYPlot plot = new XYPlot();
plot.setDataset(dataset);
// set the domain axis
plot.setDomainAxis(domain);
// set the range axis
plot.setRangeAxis(range);
the dataset in an XYSeriesCollection. Now I dont understand why the TickUnits interval continue to increase like that. After the first daythe interval is 1hr, 2 hrs the second day, 4hrs the third and then it moves to days, then i see jan, feb, march..whiles in actual sense the calculated total time i have on my counter reads say 345d 23:45:23 (d mean days here). how can I reflect this on the TickUnit...
your advice is more than appreciated..
atongo
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
First, you'll need a custom subclass of DateFormat to display millisecond values in the format "nnnd hh:mm:ss" where nnn is the number of days since 1-Jan-1970.atongo wrote:whiles in actual sense the calculated total time i have on my counter reads say 345d 23:45:23 (d mean days here). how can I reflect this on the TickUnit...
Next, you'll need to create your own tick unit collection (take a look at DateAxis.createStandardTickUnits() to see how the default collection is created) and specify your custom date formatter as the formatter for each tick size).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

