I want to know how to delete a specific series or delete a specific datapoint of a series from ms chart using aspose.slides python via .net?
Thank you for contacting support.
I am working on the question and will get back to you as soon as possible.
For example, let’s assume the first shape is a chart:
with slides.Presentation("test.pptx") as presentation: chart = presentation.slides.shapes
Then you can remove a series from a chart like this:
or remove a data point like this:
Thanks for the reply. Although, it can delete the series but its not deleting the data when you go to chart data in PowerPoint and it also removes the mapping identifier( I am referring to the color schemes used to identify series and category) from chart data.
before.png (15.3 KB)
after.png (13.8 KB)
chart.chart_data.series.remove_at(1) -> I have used this code to remove the second series and have attached the actual chart data(before.png) before running the code and the resulted chart data(after.png) after running the code.
chart.chart_data.series.data_points.remove_at(0) -> also I used this code to remove the first data point from the first series but it didn’t work
Please suggest what’s the solution where I can actually delete the data from chart data as well as retain the mapping identifier.
Thank you for the information. Could you please share the presentation file with the chart you used?
Aspose test.zip (45.3 KB)
attached the powerpoint file.
Thank you for the sample files. I’ve reproduced the problems you described.
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): SLIDESNET-44211 (Failed to remove series data from a chart) SLIDESNET-44212 (Failed to remove a data point from a chart)
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.
Regarding deleting a series from the chart, please note that if you delete a series in the PowerPoint interface, the data will also remain.
Please try using the following code example to remove series data:
using Presentation presentation = new Presentation("Aspose test.pptx"); IChart chart = (IChart)presentation.Slides.Shapes; foreach (IChartDataCell nameCell in chart.ChartData.Series.Name.AsCells) nameCell.Value = null; foreach (IChartDataPoint point in chart.ChartData.Series.DataPoints) point.Value.AsCell.Value = null; chart.ChartData.Series.RemoveAt(0); presentation.Save("output.pptx", SaveFormat.Pptx);
To delete a chart data point, please try using the following code snippet:
// Delete the first data point from the first sreries. chart.ChartData.Series.DataPoints.Value.AsCell.Value = null; chart.ChartData.Series.DataPoints.RemoveAt(0);
The snippets you have shared are not in python. Please share a python based solution.
However, I tried to convert the second snippet into python that you shared. It’s not working actually. The problem that I mentioned in the original message(it deletes value from chart data but visually you won’t see any changes in the actual chart, I shared some attachments to support this as well) is still there.
I apologize for my mistake. I will get back to you as soon as possible.
Please try using the following code snippets.
To delete a chart data series:
with slides.Presentation("Aspose test.pptx") as presentation: chart = presentation.slides.shapes for name_cell in chart.chart_data.series.name.as_cells: name_cell.value = None for point in chart.chart_data.series.data_points: point.value.as_cell.value = None chart.chart_data.series.remove_at(0) presentation.save("output.pptx", slides.export.SaveFormat.PPTX)
To delete a chart data point:
with slides.Presentation("Aspose test.pptx") as presentation: chart = presentation.slides.shapes chart.chart_data.series.data_points.value.as_cell.value = None chart.chart_data.series.data_points.remove_at(0) presentation.save("output.pptx", slides.export.SaveFormat.PPTX)
I used Aspose.Slides for Python 23.9.
Thanks so much for the solution Andrey . It’s working without any error.
Thank you for using Aspose.Slides.
The issues you have found earlier (filed as SLIDESNET-44212,SLIDESNET-44211) have been fixed in this update. This message was posted using Bugs notification tool by asad.ali