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
Major Minor Ticks for NumberAxis
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 2
- Joined: Sun Oct 03, 2004 5:44 pm
How to fake-out minor ticks. Would annotations work?
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
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
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I'd recommend overriding the drawTickMarksAndLabels() method in the ValueAxis class.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

