2nd CategoryAxis doesn't show categories of 2nd dataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
folklayer
Posts: 3
Joined: Tue Aug 02, 2005 10:58 pm

2nd CategoryAxis doesn't show categories of 2nd dataset

Post by folklayer » Tue Aug 02, 2005 11:14 pm

I created a CategoryPlot containing two CategoryAxis (domain) and two NumberAxis (range). Two datasets were added into the plot and mapping to different domain axis / value axis / rederer.

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;


Locked