Formatting date labels of BasicTimeSeries chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Kenny Dubuisson

Formatting date labels of BasicTimeSeries chart

Post by Kenny Dubuisson » Wed Oct 30, 2002 10:14 pm

I would like to format my Y-axis lables on a BasicTimeSeries chart from "DD-MON-YYYY" to "MM/DD/YYYY". Does anyone know how to do this? Thanks,
Kenny

Dave Gilbert

Re: Formatting date labels of BasicTimeSeries chart

Post by Dave Gilbert » Thu Oct 31, 2002 11:02 am

Hi Kenny,

There's currently two approaches:

1) Set a fixed tick size and format using the setTickUnit(...) method in the DateAxis class. The only problem is when you resize your chart (if you allow that) you might find the tick labels overlap.

2) Create your own collection of TickUnits with the formatting you require. The default TickUnits are created in the createStandardDateTickUnits() method of the DateAxis class. You should use some similar code (the number of units you create is not important, usually you will want at least 2) and when you TickUnits collection is ready, call the setStandardTickUnits(...) method that is inherited from the ValueAxis class.

This sets up a collection of "standard" tick sizes, and JFreeChart will choose the smallest one such that the tick labels do not overlap.

Regards,

DG.

Locked