DateAxis Tick labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

DateAxis Tick labels

Post by Rodney » Tue May 11, 2004 9:24 am

I've just upgraded from 0.9.10 to 0.9.18 and the wiz bang automatic Tick Label spacing of 0.9.10 has dissapeared. With 0.9.18 I get all the date tick labels overwriting each other. :(

Is there a way to trigger the automatic tick labelling that only labels the ticks that are written clearly (not overwritting each other) like in 0.9.10?

Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

Post by Rodney » Thu May 13, 2004 6:27 am

anyone?

Guest

Post by Guest » Thu May 13, 2004 4:31 pm


Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

Post by Rodney » Fri May 14, 2004 1:01 am

That patch doesn't compile with 0.9.18. :(

Thanks anyway...

Guest

Post by Guest » Fri May 14, 2004 5:12 pm

You may try it with jfreechart 0.9.17 or wait for 0.9.19. I'll make the patch work with 0.9.19 after it is released if 0.9.19 doesn't solve the label overlapping problem.

dbasten
Posts: 52
Joined: Fri Jul 25, 2003 4:29 pm

Post by dbasten » Tue May 25, 2004 9:21 pm

I noticed that DateAxis has been updated in the upcoming 0.9.19 release to correct the overlap of date labels. I downloaded it and it worked for me.

Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

Post by Rodney » Fri Jun 04, 2004 6:05 am

This still doesn't work for me. They still overwrite each other with 0.9.19.

Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

Post by Rodney » Tue Jun 08, 2004 7:49 am

Bump, anyone else with the same problem? This what code I've got:

DateAxis axis = new DateAxis("Time");
axis.setRange(fromDate, toDate);
DateFormat formatter = new SimpleDateFormat(" dd HHmm'Z' MMMyy ");
axis.setDateFormatOverride(formatter);
axis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1));
axis.setTickMarkPosition(DateTickMarkPosition.START);
plot.setDomainAxis(axis);

I can have up to 70 days of data, so I get 70 dates along the domain access overwriting each other. Only happened since I upgraded to 0.9.19 from 0.9.10. :(

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Jun 08, 2004 11:41 am

In your code you have set a tick unit of 1 day - this overrides the auto-tick unit selection mechanism, and can result in overlapping labels. If you remove the line:

Code: Select all

axis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1)); 
...you should see a difference.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

dchen9

Post by dchen9 » Wed Jun 09, 2004 5:08 pm

Take out

Code: Select all

axis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1));
may work. But in cases you have to use axis.setTickUnit(...) or use Timeline for ticks, the auto-tick unit selection mechanism is disable. In these cases, the tick labels may overlap. Now there is not other mechanism for detecting tick and item labels overlapping. I strongly suggest adding an overlap detection mechanism to the API.

I just updated the overlap detection patch for 0.9.20. See http://sourceforge.net/tracker/index.ph ... tid=315494
This patch is not perfect, but it is very simple. It uses java.awt.geom.Area to detect overlapping.
See the LabelOverlapDemo to see how to use this patch.

Dan

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Jun 09, 2004 5:14 pm

dchen9 wrote:But in cases you have to use axis.setTickUnit(...) or use Timeline for ticks, the auto-tick unit selection mechanism is disable.
Give me an example of the situation where you *have* to use setTickUnit() but still need to drop some tick labels. You can probably achieve the same thing by setting up a custom tick label collection, but if not I'd like to understand what you are doing so I can see if there is some enhancement required.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

dchen9

Post by dchen9 » Wed Jun 09, 2004 5:59 pm

David,

We use jfreechart to draw clinic lab test report over a period (1 or 2 years) for patients. In the period, some patients may have only 1 or 2 data points while others may 20+ points and the data points are not distributed evenly. The physicians like the date tick label displayed on the time where there is a data point. For exmaple, if a patient has only 2 data points and using auto-unit selection, the report will have 10 date tick labels. It looks too busy. The physicians like to display only two labels in this case. So I use data point's time to create a timeline to force the tick labels displayed on the data point's time. But if the data points are very dense, the tick labels will overlap. Same for item labels.

Dan

Locked