I'm having a weird problem with pie charts, I'm wondering if anyone can point me in the right direction.
Here's the problem: The colors aren't being rendered correctly on the chart, but the legend has it fine:

After another trip through the event queue where the whole dataset gets rebuilt again, it works fine.
Here's the order I do things in:
1) Create a DefaultCategoryDataset
2) Create a pie chart with that dataset. Instantiate a ChartPanel with it. Return chartPanel
3) Populate the data in the dataset
4) Once the dataset is populated, I go through the whole dataset, and call setSectionPaint(). The code looks something like this:
Code: Select all
// Preconditions: mainPieChart is a jFreeChart
// mainChartDataset is a DefaultCategoryDataset
MultiplePiePlot piePlot = (MultiplePiePlot) mainPieChart.getPlot();
JFreeChart chart = piePlot.getPieChart();
PiePlot mainPiePlot = (PiePlot) chart.getPlot();
for(String key : (List<String>)mainChartDataset.getRowKeys()) {
int rowIndex = mainChartDataset.getRowIndex(key);
if(rowIndex >= 0) {
final Color col = # Some kind of thing that picks a color. I'm pulling it from a hashmap;
mainPiePlot.setSectionPaint(rowIndex, col);
}
}
I've tried triggering repaint on a whole bunch of different things near the end of the function, but nothing seems to change what you see here. For example, mainPieChart.repaint() seems the obvious candidate, but no effect.
This manifests with both jfreechart-1.0.13 and 1.0.14, I haven't tried earlier versions.
Any suggestions would be greatly appreciated,
Gary (-;
PS I bought the developer guide a while ago, but it doesn't seem to have an updated version for 1.0.14 available yet; is that in the pipeline?