how can I change the color of every section in my PieChart3D,I tried like this:
private Color[] COLORS = {Color.red,Color.yellow,Color.blue,Color.black,Color.green};
private PieDataset createSampleDataset() {
final DefaultPieDataset result = new DefaultPieDataset();
result.setValue("Java", new Double(43.2));
result.setValue("Visual Basic", new Double(10.0));
result.setValue("C/C++", new Double(17.5));
result.setValue("PHP", new Double(32.5));
result.setValue("Perl", new Double(1.0));
return result;
}
private JFreeChart createChart(PieDataset dataset) {
final JFreeChart chart = ChartFactory.createPieChart3D(
"Pie Chart 3D Demo 1", // chart title
dataset, // data
true, // include legend
true,
false
);
final PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
for(int i=0;i<COLORS.length;i++){
plot.setSectionPaint(COLORS[i]);
}
plot.setForegroundAlpha(0.5f);
plot.setNoDataMessage("No data to display");
return chart;
}
but every time when I compile,all the sections will have the green color,thanks for any help
Is this something along the lines of what you're look for?
Custom Colours for Pie Charts in JFreeChart