We recently upgraded from Aspose 23.7 to 24.8. To get the Text of DataLabels on chart series points, we updated chart.Calculate()
to chart.Calculate(new ChartCalculateOptions() { UpdateAllPoints = true })
. But this is not working to get the data label text for all data points.
Specifically, the DataLabels.Text field for the 3rd data series in the first chart in the attached document is not being populated.
TimChartORama-source.zip (16.0 KB)
Code to reproduce:
Using Aspose 24.8 or 24.9:
using var workbook = new Workbook([path to unzipped file]);
var chart = workbook.Worksheets.SelectMany(x => x.Charts).ToList()[0];
chart.Calculate(new ChartCalculateOptions() { UpdateAllPoints = true });
for (var seriesIndex = 0; seriesIndex < chart.NSeries.Count; seriesIndex++)
{
var nSeries = chart.NSeries[seriesIndex];
for (var pointIndex = 0; pointIndex < nSeries.Points.Count; pointIndex++)
{
var point = nSeries.Points[pointIndex];
Console.WriteLine($"Series: {seriesIndex}, Point: {pointIndex}, Text: {point.DataLabels.Text}");
}
}
This gives:
Series: 0, Point: 0, Text: 100
Series: 0, Point: 1, Text: 200
Series: 0, Point: 2, Text: 300
Series: 0, Point: 3, Text: Custom Data Label 2
Series: 1, Point: 0, Text: 400
Series: 1, Point: 1, Text: Custom Data Label 1
Series: 1, Point: 2, Text: 800
Series: 1, Point: 3, Text: 1000
Series: 2, Point: 0, Text:
Series: 2, Point: 1, Text:
Series: 2, Point: 2, Text:
Series: 2, Point: 3, Text:
Note the missing text for Series 2.
In Aspose 23.7, the code above without the ChartCalculateOptions
returns the expected text for all points:
Series: 0, Point: 0, Text: 100
Series: 0, Point: 1, Text: 200
Series: 0, Point: 2, Text: 300
Series: 0, Point: 3, Text: Custom Data Label 2
Series: 1, Point: 0, Text: 400
Series: 1, Point: 1, Text: Custom Data Label 1
Series: 1, Point: 2, Text: 800
Series: 1, Point: 3, Text: 1000
Series: 2, Point: 0, Text: 100
Series: 2, Point: 1, Text: 500
Series: 2, Point: 2, Text: 900
Series: 2, Point: 3, Text: 1200
How do we get the data label text for the points in the third series in Aspose 24.8 or 24.9?
Thank you!
Laura Moon