Free Support Forum -

Removing data points from chart does not adjust count

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. (12.0 KB)

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.

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

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.

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:
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();

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