Modifying DateAxis for customizable range of tick marks

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Erik
Posts: 2
Joined: Wed Jul 12, 2006 7:25 pm

Modifying DateAxis for customizable range of tick marks

Post by Erik » Wed Jul 12, 2006 7:32 pm

Hi all,

I'm new to JFreeChart, and have been banging my head against the wall for a day or so trying to getit to behave how I want it to. I have a list of data coming in from a SQL query, which contains (for the sake of simplicity) a weekStartDate attribute and a count, which I want to display in a line chart. Now, when I set that up, I can do something like this:

DateTickUnit dt = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("MM/dd/yyyy"));
domainAxis.setTickUnit(dt);

and get the appropriate level of granularity on tick marks. However, the tick marks line up against the first day of the first month being displayed, not against the data. So, if the dates I'm displaying start with March 4th, I get tick marks at the 7th, 14th, 21st, etc, whereas I'd like them to be on the 4th, 11th, etc. I've tried manually changing the DateRange associated with the axis, but that doesn't seem to affect where the tick marks are drawn, and I don't see any obvious way to get JFreeChart to exhibit the behavior I want it to. I'm willing to write my own subclass, but don't really know where to begin. Any help would be much appreciated.

Thanks!

--Erik

Locked