IsFiltered series and ChartCalculateOptions

Hi Aspose team,
It seems we have an issue if I enable “filtered” series (so not visible in the chart) by changing IsFiltered to false, indeed after a full chart calculation the datapoints seems to be empty…

I have a chart with 4 series.
2 are enabled and 2 are disabled:
image.png (46.6 KB)

Via code, I enable the two previous disabled series. (via the FilteredNSeries)
After I am doing a full calculation to get all the datapoints.

As you can see in the logs below, I have no datapoints for Data 2 and scatter2 which were disabled previously and enabled… it is not expected… I need to get the X and Y pixels position…

var pathWorkbook = @"...\\TestHadrienDataLabel.xlsx";
            var wbtest = new Workbook(pathWorkbook);
            Worksheet sheettest = wbtest.Worksheets[0];
            Chart charttest = sheettest.Charts[0];

// Enable the desired series
            for (int i = charttest.FilteredNSeries.Count - 1; i >= 0; i--)
            {
                var series = charttest.FilteredNSeries[i];
                if (series.DisplayName == "Data 2" || series.DisplayName == "Scatter 2")
                {
                    series.IsFiltered = false;
                }
            }

            // Create an instance of ChartCalculateOptions
            var options = new ChartCalculateOptions
            {
                UpdateAllPoints = true // Set the property to update all data points
            };

            charttest.Calculate(options); // calculate all the datapoints for the NSeries

            foreach (var series in charttest.NSeries)
            {
                Console.WriteLine(series.DisplayName);
                foreach (ChartPoint point in series.Points)
                {
                    // Do not collect points with negative coordinates. No real values.
                    if (point.ShapeXPx < 0 || point.ShapeYPx < 0) continue;

                    // Collect data points
                    var topLeftX = point.ShapeXPx;
                    var topLeftY = point.ShapeYPx;

                    // Print the coordinates
                    Console.WriteLine($"topLeftX: {topLeftX}, topLeftY: {topLeftY}");
                }
            }

Result:

**Data 1**
**topLeftX: 131, topLeftY: 337**
**topLeftX: 330, topLeftY: 272**
**topLeftX: 528, topLeftY: 208**
**topLeftX: 727, topLeftY: 144**
*Data 2*
**Scatter 1**
**topLeftX: 131, topLeftY: 144**
*Scatter 2*

Could you have a look please ?

cf the file attached:
TestHadrienDataLabel.zip (12.7 KB)

image.png (33.5 KB)

image.png (12.8 KB)
And if I enable the 2 series manually in excel I have a chart with data:

image.png (20.5 KB)

Thanks for your help,

@hormancey

It appears you are facing an issue with the chart series in Aspose.Cells where enabling filtered series does not produce the expected data points after calculation.

When you set IsFiltered to false for the series, ensure that the data source for those series is correctly defined and that the data is available. If the series were previously filtered, they may not have valid data points until the chart is recalculated.

Here are some suggestions to troubleshoot and potentially resolve the issue:

  1. Check Data Source: Verify that the data source for “Data 2” and “Scatter 2” is correctly set and contains valid data.

  2. Recalculate Chart: After enabling the series, you are using ChartCalculateOptions with UpdateAllPoints = true, which is correct. However, ensure that the data in the worksheet is also updated before the calculation.

  3. Manual Check: Since enabling the series manually in Excel works, this indicates that the data is valid. Compare the programmatic approach with the manual method to identify any discrepancies.

  4. Debugging: Implement logging to check the values of the series and their data points before and after the calculation to ensure they are being set correctly.

Here’s a modified version of your code that includes a check for data points:

// Enable the desired series
for (int i = charttest.FilteredNSeries.Count - 1; i >= 0; i--)
{
    var series = charttest.FilteredNSeries[i];
    if (series.DisplayName == "Data 2" || series.DisplayName == "Scatter 2")
    {
        series.IsFiltered = false;
    }
}

// Create an instance of ChartCalculateOptions
var options = new ChartCalculateOptions
{
    UpdateAllPoints = true // Set the property to update all data points
};

charttest.Calculate(options); // Calculate all the data points for the NSeries

foreach (var series in charttest.NSeries)
{
    Console.WriteLine(series.DisplayName);
    foreach (ChartPoint point in series.Points)
    {
        // Check if the point has valid coordinates
        if (point.ShapeXPx >= 0 && point.ShapeYPx >= 0)
        {
            Console.WriteLine($"topLeftX: {point.ShapeXPx}, topLeftY: {point.ShapeYPx}");
        }
        else
        {
            Console.WriteLine($"Invalid point for {series.DisplayName}: X={point.ShapeXPx}, Y={point.ShapeYPx}");
        }
    }
}

This code will help you identify if the points are being calculated correctly. If the issue persists, consider reaching out to Aspose support with your specific case, including the workbook and any relevant logs.

@hormancey
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-59119

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

FYI:
I did a test and same problem in version aspose 24.10 and 25.9.
I believed this issue was linked to the upgrade of the lib but it does not seem.

@hormancey

Yes, it is an issue existing in those versions. Now that we have created the ticket for it, please spare us time to look into it, and we will try to fix it according to its priority in the task queue.

1 Like