Major Minor Ticks for NumberAxis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Tom
Posts: 32
Joined: Mon Dec 11, 2006 2:50 pm

Major Minor Ticks for NumberAxis

Post by Tom » Tue Mar 06, 2007 11:28 am

Hi @everybody,

im using a chart with a numberAxis as y-Axis. I need this axis to display major ticks with labels and, minor ticks without labels.

In addition to that, I need (if possible) a different (dashed) gridlineStroke for the gridlines at the minor ticks.

Any ideas how to achieve that?

TIA,

Tom

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 » Thu Mar 08, 2007 6:35 pm

It's not possible in JFreeChart at present. It would be a nice feature to add (you are not the first to ask!).
David Gilbert
JFreeChart Project Leader

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

wendygross
Posts: 2
Joined: Sun Oct 03, 2004 5:44 pm

How to fake-out minor ticks. Would annotations work?

Post by wendygross » Tue Apr 17, 2007 10:30 pm

Hello,

I too need to display major ticks with labels and, minor ticks without labels. I'm trying to figure out a work-around to fake-out minor ticks. Do you have any ideas?

Would annotations work if I am willing to sacrifice the use of "auto tick unit selection" and just have one major tick unit and one minor as in the following scenario?
Scenario:
Given that I want to display major ticks with labels every 50 units and minor (without labels) every 10. The following code:
XYPlot plot = myChart.getXYPlot();
ValueAxis axis = plot.getRangeAxis();
axis_setTickUnit(new NumberTickUnit(50.0));
would draw the major ticks and label. But - how to draw the minor ticks...
- I could simulate ticks by drawing annotations (as graphical lines)
every 10 units. However, since annotations cannot extend outside of
the plot boundaries, I would need to draw all ticks inside the plot
boundaries and let JFreeChart also draw ticks outside the plot for the
ticks that it labels.

Any ideas you have are greatly appreciated.

Thank you.
Wendy

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 Apr 18, 2007 9:18 am

I'd recommend overriding the drawTickMarksAndLabels() method in the ValueAxis class.
David Gilbert
JFreeChart Project Leader

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

Locked