I've read a bunch of postings on how to format the dates, but I'm still not clear on this.
Currently I have a chart that plots data points every half hour of time Second. When I view the data though, the labels show up in the form hh:mm:ss all the time.
I can specify a format as follows:
TickUnits tickUnits = new TickUnits();
tickUnits.add(new DateTickUnit(DateTickUnit.SECOND,1,new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")));
((DateAxis)domainAxis).setStandardTickUnits(tickUnits);
But I have to specify that "1", saying how often to display the date. I wrote a servlet a while back and it somehow calculated what format to display and when to display it without me doing anything. When I would display a day's worth of data, it would display the hour/min/sec. When I would view a months worth of data, it would display a date at the beginning of each week. When I displayed a year, it would display at the beginning of each month. Now I am using cewolf and using a ChartPostProcessor to format the chart after it is created. I have access to the chart object so I can format it how I want. But what I want is for JFreeChart to do the thinking for me on this, since it seems that it did that before.
Is this possible? Does anyone know how to do this?
Thanks much.
Justin
Date Format on TimeSeris
Re: Date Format on TimeSeris
Hi Justin,
I think I may have to modify the date axis class so that it has multiple tick unit collections, to cover different lengths of the axis range. So there could be one for a range up to one hour, another for a range up to one day, another for a range up to one month, another for a range up to one year, and then one for everything larger than one year. But that is for a future version...
One thing you might try is leaving the tick unit collection as it is, and overriding the date format with the setDateFormatOverride(...) method (new in 0.9.5). This leaves the auto tick unit selection mechanism switched on, but allows you to override the label formatting with a single format.
Regards,
Dave Gilbert
I think I may have to modify the date axis class so that it has multiple tick unit collections, to cover different lengths of the axis range. So there could be one for a range up to one hour, another for a range up to one day, another for a range up to one month, another for a range up to one year, and then one for everything larger than one year. But that is for a future version...
One thing you might try is leaving the tick unit collection as it is, and overriding the date format with the setDateFormatOverride(...) method (new in 0.9.5). This leaves the auto tick unit selection mechanism switched on, but allows you to override the label formatting with a single format.
Regards,
Dave Gilbert
Re: Date Format on TimeSeris
It ends up that the JFreeChart code already does format the dates properly. My problem was, I was selecting the epoch (milliseconds since 1970-01-01 00:00:00) and then trying to create a Date object from it, and then create a Second object from the Date. However, I was using type int instead of long to store the epoch, which caused the epoch to get chopped and messed everything up!
So in the end, JFreeChart does exactly what I wanted it to do.

Thanks for your help.
Justin
So in the end, JFreeChart does exactly what I wanted it to do.

Thanks for your help.
Justin