I’m using jFreeChart 1.0.14. I have graph with a horizontal DateAxis. And I’m trying to center the tick labels so that they would be within two subsequent ticks.
JFreeChart aligns tick labels in common case this way:
----+------------+------------+----
Mon Tue Wed
But I’d like to align tick labels this way:
----+------------+------------+------------+----
Mon Tue Wed
The tick labels on images are aligned by hand in graphic editor by editing the original image. It’s not output of jFreeChart library.
Is there any way, how to do it through the API of DateAxis? Any help is appreciated… 🙂
Thanks a lot for any help or idea.
Honza (sporak)


Since nobody helped me any trick, I tried to overide DateAxis to get Axis with tick labels alignment. I named it ‘
AlignedDateAxis‘. It extendsDateAxisand overrides only methods that are used for tick labels rendering. It can render tick labels in two ways: in standard way that places labels under ticks, and in required way that centers labels in the middle of interval.Because I don’t know much about JFreeCharts library understanding some classes and methods wasn’t easy for me. I hope it will work fine in all common cases.
My class contains javadoc and comments only in my native language, so I won’t post them complete here.
This axis-class (AlignedDateAxis) works fine for me and I’m using it in my project.
Honza (sporak)