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

Free Support Forum - aspose.com

Muli Series Charts - All series are the same colour

Hello,

I am trying to create a multi series chart using the latest version of Aspose.Slides (7.6.0.0), I have found all series in the chart end up the same colour.

If I remove the lines of code to clear the default series and categories the chart appears with the correct colours but with data that I do not want.

Here is the code used to generate the chart:

// --- add chart to slide ---
ChartEx ch = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, chartX, chartY, chartW, chartH);
ChartDataCellFactory fact = ch.ChartData.ChartDataCellFactory;
// ---

// --- Delete default generated series and categories ---
ch.ChartData.Series.Clear();
ch.ChartData.Categories.Clear();
// ---

int[,] arrData = new int[,] {
{ 1, 2, 3, 4 },
{ 2, 3, 4, 1 },
{ 3, 4, 1, 2 }
};
string[] arrSeries = new string[] { "1", "2", "3", "4" };
string[] arrLabels = new string[] { "A", "B", "C", "D" };

// --- ADD SERIES VALUES ---
for (int i = 0; i < arrData.GetLength(0); i++)
{
ChartSeriesEx series = ch.ChartData.Series[ch.ChartData.Series.Add(fact.GetCell(0, 0, 1 + i, arrSeries[i]), ch.Type)];
series.MarkerSymbol = MarkerStyleTypeEx.None;
for (int j = 0; j < arrData.GetLength(1); j++)
series.Values.Add(fact.GetCell(0, (j + 1), (i + 1), arrData[i, j]));
}
// ---

// --- ADD LABELS ---
for (int i = 0; i < arrLabels.Length; i++)
ch.ChartData.Categories.Add(fact.GetCell(0, (i + 1), 0, arrLabels[i]));
// ---

ch.Legend.Position = Aspose.Slides.Pptx.Charts.LegendPositionTypeEx.Right;

ch.DisplayBlanksAs = DisplayBlanksAsTypeEx.Gap;
ch.ValueAxis.MinorTickMark = TickMarkType.None;
ch.ValueAxis.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 10;
ch.CategoryAxis.MinorTickMark = TickMarkType.None;
ch.CategoryAxis.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 10;
ch.Legend.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 10;

Hi Neil,

Thanks for inquiring Aspose.Slides.

I have observed the requirement shared and like to share that you need to set the fill color for series independently. If you don’t set the color, the default blue color is selected for series. Please observe and use the sample code shared over this documentation link. Please share with us if there is still and issue and kindly use Aspose.Slides for .NET 7.7.0 on your end.

Many Thanks,