Hi Folks,
I found a strange bug by creating / modifying charts with Aspose.Slides under .NET
For example I have 3 categories and 1 series the legend shows the series name(s) - so far everything is correct.
But if i color only one datapoint with this code:
{code}
chart.ChartData.Series[0].DataPoints[1].Format.Fill.FillType = FillType.Solid;
chart.ChartData.Series[0].DataPoints[1].Format.Fill.SolidFillColor.Color = Color.Black;
{/code}
The legend no longer shows the series - now it display the list of categories… and it is not possible to change it to the series list - not even in powerpoint…
Examples:
- With Coloring -> Attachment: “AsposeChart_error.pptx”
- Without Coloring -> Attachment: “AsposeChart_success.pptx”
Here are my full code:
{code}
Presentation pres = new Presentation();
ISlide sld = pres.Slides[0];
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredBar, 100, 100, 400, 400);
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, “a”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, “b”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, “c”));
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “series”), chart.Type);
chart.ChartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 0));
chart.ChartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 9.553967186161332));
chart.ChartData.Series[0].DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 5.473745114704258));
chart.HasLegend = true;
// with this code - the legend show the categories and not the series list
// chart.ChartData.Series[0].DataPoints[1].Format.Fill.FillType = FillType.Solid;
// chart.ChartData.Series[0].DataPoints[1].Format.Fill.SolidFillColor.Color = Color.Black;
//
License licence = new License();
licence.SetLicense(“Aspose.Slides.lic”);
pres.Save(“AsposeChart.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);
{/code}
I work under Windows 7 64 Bit with Aspose.Slides 15.4.0 .NET
Many Thanks,
Marius W.
Hi Marius,