Hi Team,
In the attached excel, I have a 3D Pie chart with 4 sectors.
I want to set different colors for these 4 sectors.
Could you please share some sample code in JAVA for this requirement.
Thanks in advance,
Sanjeev
3DPieChartSlicesColoring.zip (9.1 KB)
@sanjeevkumarambti,
Thanks for the template file.
See the following sample code on how to apply different color to different Pie chart slices and its border color for your reference. I used your template file and modify different slices (series points) color for the existing chart in the worksheet:
e.g
Sample code:
Workbook book = new Workbook("f:\\files\\3DPieChartSlicesColoring.xlsx");
ChartCollection charts = book.getWorksheets().get(0).getCharts();
Chart chart = charts.get(0);
Series series = chart.getNSeries().get(0);
//Define colors, I will get the colors from default color palette.
Color[] colors = book.getColors();
for (int j = 0; j <series.getPoints().getCount(); j++)
{
ChartPoint p = series.getPoints().get(j);
p.getArea().getFillFormat().getSolidFill().setColor(colors[j]);
p.getBorder().setColor(colors[j+1]);
}
book.save("f:\\files\\out1.xlsx");
Hope, this helps a bit.