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.

This code removes one of the bar values for “Dec”.
Please advise on how to remove the December point from the chart entirely.

To elaborate on my above statement. Please do the following. Go to the attached sheet (in the original thread) and in the picklist set the month to “November”. Observe that the chart changes to include all the points but gets smaller and excludes “Dec”. Please advise on how to mimic the chart behavior in aspose.

Thank you for sharing this information. We have logged it with the ticket and will consider it while working on this issue.

@ahsaniqbalsidiqui Thank you. The ticket is marked “won’t fix” as you have stated that this is not a defect. I was asking for you to elaborate on how to achieve the above required functionality. Since this is a “won’t fix” i’m concerned that you comment stating that it is included in the issue indicates that i won’t hear back regarding this request.

We have observed the issue in the output and reopened the ticket for further investigation. We will update you here soon.


Please change the value of C2 in worksheet “sheet”, then the count of chart point will be changed too. See following sample code:
Sample code:

Workbook workbook = new Workbook(sourceFileDir + "Sample_Chart3.xlsx");
          ChangePoints(workbook, "Apr");
          ChangePoints(workbook, "Nov");
      private static void ChangePoints(Workbook w,  String month)
Chart chart = w.getWorksheets().get(1).getCharts().get(0);


Hope, this helps a bit.