I want to customize the colors in my stackedBarChart, because I don't like the default ones.
I managed to do it this way :
Code: Select all
JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", resultDataSet, PlotOrientation.VERTICAL, true, true, false);
final CategoryPlot plot = chart.getCategoryPlot();
CategoryItemRenderer renderer = new CustomRenderer();
plot.setRenderer(renderer);
private class CustomRenderer extends StackedBarRenderer {
private Paint[] colors;
public CustomRenderer() {
this.colors = new Paint[] {Color.green, Color.red, Color.blue, Color.yellow, Color.orange, Color.cyan};
}
public Paint getItemPaint(final int row, final int column) {
return (this.colors[row % this.colors.length]);
}
}
Any idea to solve that? I can't find a LegendRenderer or something like that...
Thanks for your help.
Jean-Marie