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.

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.

@ibmlittleton,
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.

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

@ibmlittleton,

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

Workbook workbook = new Workbook(sourceFileDir + "Sample_Chart3.xlsx");
          ChangePoints(workbook,"Oct");
          ChangePoints(workbook, "Apr");
          ChangePoints(workbook, "Nov");
      }
      private static void ChangePoints(Workbook w,  String month)
{
          w.getWorksheets().get(1).getCells().get("C2").putValue(month);
          w.calculateFormula();
Chart chart = w.getWorksheets().get(1).getCharts().get(0);
         System.out.println(chart.getNSeries().get(0).getPoints().getCount());
      }

``` 

Hope, this helps a bit.