How do I change the date format for the axis in TimeSeries ?

Discussion about JFreeChart related to stockmarket charts.
Locked
AnonymousCoward

How do I change the date format for the axis in TimeSeries ?

Post by AnonymousCoward » Fri Jul 16, 2004 3:56 pm

I can't figure out how to change :
| |
| |
| |
| |
| |
-----------------------------
03-2004 48-2004 121-2004
(DD-YYYY)

into

| |
| |
| |
| |
| |
|----------------------------
03 48 121
(DD)

is this possible? Thanks for your help in advance.

hongping
Posts: 14
Joined: Thu Jul 29, 2004 1:32 am

Post by hongping » Mon Aug 16, 2004 5:31 pm

You could try using java.text.SimpleDateFormat:

Code: Select all

String dateFormat = "yyyy/MM/dd HH:mm";
Or if you just want the date

Code: Select all

String dateFormat = "dd";
Then override the dataformat in the horizontal axis:

Code: Select all

XYPlot plot = chart.getXYPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat(dateFormat));
Hope this helps.

Locked