We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set fill color for group level and data points in sunburst chart (C# .NET)

Hi,

I’m creating sunburst chart using aspose slide java and not able to set different fill color for each leaf and group level. it’s working only for whole series level.

when I set fill color for series it’s working fine and reflect all leaf has same color. if set fill color for each data point with different color then it’s not working. it’s showing default color.

@prabamkd,

Can you please share your requirements in form of sample so that we may further investigate to help you out.

Here is my code, I want to set different background color for each leaf and group.

  // branch 1
IChartCategory leaf = chart.getChartData().getCategories().add(wb.getCell(0, "C1", "Leaf1"));
leaf.getGroupingLevels().setGroupingItem(1, "Stem1");
leaf.getGroupingLevels().setGroupingItem(2, "Branch1");

chart.getChartData().getCategories().add(wb.getCell(0, "C2", "Leaf2"));

leaf = chart.getChartData().getCategories().add(wb.getCell(0, "C3", "Leaf3"));
leaf.getGroupingLevels().setGroupingItem(1, "Stem2");

chart.getChartData().getCategories().add(wb.getCell(0, "C4", "Leaf4"));

// branch 2
leaf = chart.getChartData().getCategories().add(wb.getCell(0, "C5", "Leaf5"));
leaf.getGroupingLevels().setGroupingItem(1, "Stem3");
leaf.getGroupingLevels().setGroupingItem(2, "Branch2");

chart.getChartData().getCategories().add(wb.getCell(0, "C6", "Leaf6"));

leaf = chart.getChartData().getCategories().add(wb.getCell(0, "C7", "Leaf7"));
leaf.getGroupingLevels().setGroupingItem(1, "Stem4");

chart.getChartData().getCategories().add(wb.getCell(0, "C8", "Leaf8"));

IChartSeries series = chart.getChartData().getSeries().add(ChartType.Sunburst);
series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#b52323"));

IChartDataPoint datapoint =
    series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D1", 4));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#2399b5"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D2", 5));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#24b523"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D3", 3));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#2334b5"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D4", 6));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#b52379"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D5", 9));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#b52323"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D6", 9));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#23adb5"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D7", 4));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#24b523"));

datapoint = series.getDataPoints().addDataPointForSunburstSeries(wb.getCell(0, "D8", 3));
datapoint.getFormat().getFill().setFillType(FillType.Solid);
datapoint.getFormat().getFill().getSolidFillColor().setColor(Color.decode("#b5b223")); 

Isunburst.png (52.3 KB)

I have attached my expected result

@prabamkd,

Can you please share sample file in form of presentation. I like to inform that if it is possible in PowerPoint than we can do this using Aspose.Slides.

Presentation1.zip (120.5 KB)
Please check the attached file

@prabamkd,

I have observed your requirements. I regret to inform that it is not possible in Aspose.Slides yet. A ticket with ID SLIDESNET-41274 has been created as in our issue tracking system as a new feature request. Our development team will look into the possibility of implementation of the requested feature. This thread has been associated with this new feature request, so that you can be automatically notified as soon as this issue is resolved.

The issues you have found earlier (filed as SLIDESNET-41274) have been fixed in this update.