How to Change Color of Pie Chart Series using .NET

Hello, we have purchased license.
We need to change color of pie chart slices programmically, but we didn’t find any information about this in aspose words documentation, this feature not supported yet? Are you planning to implement it in the future?

@buryginl

We have added new APIs in the latest version of Aspose.Words for .NET 21.6 to set the fill and stroke formatting for chart series, data points and markers.

Following code example shows how to set chart series color.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.InsertChart(ChartType.Column, 432, 252);

Chart chart = shape.Chart;
ChartSeriesCollection seriesColl = chart.Series;

// Delete default generated series.
seriesColl.Clear();

// Create category names array.
string[] categories = new string[] { "AW Category 1", "AW Category 2" };

// Adding new series. Value and category arrays must be the same size.
ChartSeries series1 = seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
ChartSeries series2 = seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
ChartSeries series3 = seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });

// Set series color.
series1.Format.Fill.ForeColor = Color.Red;
series2.Format.Fill.ForeColor = Color.Yellow;
series3.Format.Fill.ForeColor = Color.Blue;

doc.Save(MyDir + "ColumnColor.docx");

Following code example shows how to set Pie chart colors.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
 
Shape shape = builder.InsertChart(ChartType.Pie, 432, 252);
Chart chart = shape.Chart;
 
// Delete default generated series.
chart.Series.Clear();
 
// Adding new series.
ChartSeries series = chart.Series.Add("Series 1",
    new string[] { "Category1", "Category2", "Category3" },
    new double[] { 2.7, 3.2, 0.8 });
 
// Set data point color.
ChartDataPointCollection dataPoints = series.DataPoints;
dataPoints[0].Format.Fill.ForeColor = Color.Red;
dataPoints[1].Format.Fill.ForeColor = Color.Yellow;
dataPoints[2].Format.Fill.ForeColor = Color.Green;
 
doc.Save(MyDir + "PieColor.docx");