I'm writing an application in C# that processes some CSV cost data and saves it as an xlsx file with two sheets: Data and Charts. The CSV data goes into the Data sheet and the application then creates a pivot table and corresponding pivot chart from this data in the Charts sheet. The chart is created alright but i see no option to add data labels to it using XlsIO. The chart is created as follows:
IChartShape pivotChart = chartsSheet.Charts.Add();
pivotChart.PivotSource = pivotTable;
pivotChart.PivotChartType = ExcelChartType.Pie;
I see an option to add or disable legend
pivotChart.HasLegend = false;
which works fine. I have tried adding a series to the chart but the DataPoints are empty:
IChartShape pivotChart = chartsSheet.Charts.Add();
pivotChart.PivotSource = pivotTable;
pivotChart.Series.Add(ExcelChartType.Pie);
pivotChart.Series[0].DataPoints[0].DataLabels.IsFormula = true;
Adding Values and CategoryLabels to the series does not help either since these are references to a pivot table and a standard range.
Is there any way to add data labels to a pivot chart?