Free Support Forum - aspose.com

Removing data points from chart does not adjust count

Hello,
Please review the print statements in the sample code. The expectation is that the ChartPointCollection object would update chartsc.getCount(). however, it seems that is not the case. If there is another way of doing it, please let us know. We are attempting to modify a chart’s map with a new set of values/data points that may not equal the previous number of values/data points.
Sample_Chart3.zip (12.0 KB)

@ibmlittleton,
We have logged the issue as “CELLSJAVA-43251” in our database for investigations. Once we will have some news for you, we will update you in this topic.

@ibmlittleton,
If you want to remove chart point ,please reset Series.Values.
ChartPointCollection.RemoveAt() method is only used to remove setting about chart point.

Can you please provide an example? @ahsaniqbalsidiqui

@ibmlittleton,
We are working on a sample code to achieve this functionality and will share it here soon.

1 Like

Good morning. I was wondering if the code sample was available so we can sort out our issue for the customer.

@ibmlittleton,
You may please try the following changes in the code and share the feedback.

1, Please reset the values to remove the first point as the following codes:
sheet.getCharts().get(0).getNSeries().get(0).setValues(“D23:N23”);
2,Please set Cell “C23” set zero,the first point will be visible too.

The resultant code will be like this:

Workbook workbook = new Workbook(fileName);

WorksheetCollection sheets = workbook.getWorksheets();
for (int i = 0; i < sheets.getCount(); i++)
 {
    Worksheet sheet = sheets.get(i);
    ChartCollection charts = sheet.getCharts();
    for (int j = 0; j < charts.getCount(); j++) 
    {
        Chart chart = sheet.getCharts().get(j);
        ChartPointCollection chartsc = sheet.getCharts().get(0).getNSeries().get(0).getPoints();
        System.out.println(chartsc.getCount());
        chart.getNSeries().get(0).setValues("D23:N23");
        sheet.getCells().get("C23").setValue(0);
        System.out.println(chartsc.getCount());
    }
}

Thank you. We will take a look and tell you how it goes.