Reputation: 3130
I have a multiaxis chart bar char and line chart. My customizer class has following code snippet.
@Override
public void customize(final JFreeChart chart, final JRChart jasperChart) {
final Plot plot = chart.getPlot();
if (plot instanceof CategoryPlot) {
final CategoryPlot cPlot = (CategoryPlot) plot;
final ValueAxis axis = new NumberAxis();
axis.setMinorTickMarksVisible(true);
axis.setMinorTickCount(1);
cPlot.setRangeAxis(axis);
} else if (plot instanceof XYPlot) {
final XYPlot xyPlot = (XYPlot) plot;
xyPlot.setRangeMinorGridlinesVisible(true);
}
}
The chart looks like
The scales are messed up and are not on the same line.
How can i fix this issue.
Any help appreciated.
Thanks
Upvotes: 1
Views: 680
Reputation: 3130
Changed the above code to following and its all good
@Override
public void customize(final JFreeChart chart, final JRChart jasperChart) {
final Plot plot = chart.getPlot();
if (plot instanceof CategoryPlot) {
final CategoryPlot cPlot = (CategoryPlot) plot;
cPlot.getRangeAxis().setMinorTickCount(2);
cPlot.getRangeAxis().setMinorTickMarksVisible(true);
} else if (plot instanceof XYPlot) {
final XYPlot xyPlot = (XYPlot) plot;
xyPlot.setRangeMinorGridlinesVisible(true);
xyPlot.getRangeAxis().setMinorTickCount(2);
xyPlot.getRangeAxis().setMinorTickMarksVisible(true);
}
}
Upvotes: 1