Chart Datalabel in aspose.words

Hi,

I have another problem with your product.
I can not to show the percentage in my Pie3D chart. In the DataLabels collection, I do not have any data, it’s empty (no null, but empty).

How can I do ?
Thanks for your answer.

Alida

Hi Alida,

Thanks for your inquiry. Please attach your expected Word document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,

Hello, You will find in attachment, the chart expected.

Thanks.

Alida

Hi Alida,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.InsertChart(ChartType.Pie, 432, 252);
Chart chart = shape.Chart;
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
string[] categories = new string[] { "Grapefruit", "Oranges", "Plums", "Pears", "Apples" };
// Specify all values as 20%
ChartSeries series = seriesColl.Add("Imported Fruits", categories, new double[] { 2, 2, 2, 2, 2 });
ChartDataLabelCollection dataLabelCollection = series.DataLabels;
ChartDataLabel chartDataLabel00 = dataLabelCollection.Add(0);
ChartDataLabel chartDataLabel01 = dataLabelCollection.Add(1);
ChartDataLabel chartDataLabel02 = dataLabelCollection.Add(2);
ChartDataLabel chartDataLabel03 = dataLabelCollection.Add(3);
ChartDataLabel chartDataLabel04 = dataLabelCollection.Add(4);
chartDataLabel00.ShowCategoryName = true;
chartDataLabel01.ShowCategoryName = true;
chartDataLabel02.ShowCategoryName = true;
chartDataLabel03.ShowCategoryName = true;
chartDataLabel04.ShowCategoryName = true;
chart.Legend.Position = LegendPosition.Left;
doc.Save(MyDir + @"15.9.0.docx");

I hope, this helps.

Best regards,