The value axis and renderer all works fine except that the Second category axis wrongly shows the category of first dataset not the second one.
I traced into the CategoryAxis, found it calls plot.getCategories() at line 816, which always return the categories of first dataset.
Is this a bug? BTW, the XYPlot is ok with multiple domain axis
Code: Select all
JFreeChart jfreechart = ChartFactory.createBarChart("Dual Axis Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, false, true, false);
CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
categoryplot.setDataset(1, createDataset2());
categoryplot.mapDatasetToRangeAxis(1, 1);
categoryplot.mapDatasetToDomainAxis(1, 1);
CategoryAxis categoryaxis = new CategoryAxis("Secondary domain axis");
categoryplot.setDomainAxis(1, categoryaxis);
NumberAxis numberaxis = new NumberAxis("Secondary range axis");
categoryplot.setRangeAxis(1, numberaxis);
LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
categoryplot.setRenderer(1, lineandshaperenderer);
return jfreechart;