1

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

enter image description here

The scales are messed up and are not on the same line.

How can i fix this issue.

Any help appreciated.

Thanks

Coder
  • 3,090
  • 8
  • 49
  • 85

1 Answers1

1

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);

        }

    }
Coder
  • 3,090
  • 8
  • 49
  • 85