Set tickLabelFormatter in DateAxis

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

Set tickLabelFormatter in DateAxis

Post by Del » Fri Jan 10, 2003 7:18 am

Hi,

Is there a way to set the tickLabelFormatter in the HorizontalDateAxis without setting it in the long constructor (using the no arguments constructor and then calling some set method)??

Thanks,

David Gilbert

Re: Set tickLabelFormatter in DateAxis

Post by David Gilbert » Fri Jan 10, 2003 10:14 pm

In 0.9.4, the formatting is all controlled by the DateTickUnit class. The tickLabelFormatter in the constructor is a "leftover" and has been removed for the upcoming 0.9.5 release.

By default, the axis will auto-select one of the units from the "standard" collection - see the createStandardDateTickUnits() method in the DateAxis class. You can replace this collection with your own if you want to.

Otherwise, you can manually set the tick unit via the setTickUnit(...) method, which turns off the auto-select feature.

Regards,

Dave Gilbert

Del

Re: Set tickLabelFormatter in DateAxis

Post by Del » Mon Jan 13, 2003 2:05 am

David, as you have suggested I have tried using the setTickUnit method, this is great in that I was able to specify the format of the dates and the timezone to use. However, this has caused the problem in that the dates when they are too close together overlap each other, since I have to specify the unit and count. Can you give me some suggestions on how I can overcome this problem. Is it possible to use auto setting but at the same time specify the timezone? Thanks for your help.

David Gilbert

Re: Set tickLabelFormatter in DateAxis

Post by David Gilbert » Mon Jan 13, 2003 4:45 pm

In 0.9.4, you have to create your own TickUnits collection and then call the setStandardTickUnits(...) method in the DateAxis class. This is just replacing the default collection, JFreeChart will then choose the smallest TickUnit in the collection such that the labels don't overlap.

In 0.9.5, there will be a new method setDateFormatOverride(...) that will allow you to set one DateFormat that will override the date formats in the TickUnits collection...that might work in some cases.

Regards,

Dave Gilbert

Locked