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;