I know that gridlines are only drawn for the ticks on the primary axis. However my customer insist to draw gridlines for both primary and secondary axises.
I am trying to make the gridlines looks like drawn for both ticks by increasing the range of the axis with smaller calculateVisibleTickCount(), so that both axis has the same number of tick count and the gridlines seems drawn for both axis.
But I found that the calculateVisibleTickCount() function is returning the wrong value and the axis.getTickUnit().getSize() function just return 1 and which is not the real tick size show on the chart.
It seems that the setAutoTickUnitSelection function haven't initialize those values when I get it.
when is the plot calculate the tick size and tick count value?
how can I get the real tick size and tick count value?
All I want is to draw gridline for both primary and secondary axises, any other suggestion or workaround is welcome
Regards,
Andy
range gridlines for secondary axis workaround
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I would modify the XYPlot class. In the draw() method, you will find this line:
It draws all the axes and returns a state object for each one (among other things, the state object holds a list of the tick values for the axis). Later in the same method, the gridlines for the primary range axis are drawn:
It wouldn't be too difficult to add something to draw gridlines for the secondary axis (or axes) in the same way.
Code: Select all
Map axisStateMap = drawAxes(g2, area, dataArea);
Code: Select all
AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis());
if (rangeAxisState == null) {
if (parentState != null) {
rangeAxisState = (AxisState) parentState.getSharedAxisStates().get(
getRangeAxis());
}
}
if (rangeAxisState != null) {
drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks());
drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());
}
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

