We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Deleting a series/category from a chart

Hi,


I was not able to find any java code snippet to delete a particular series and/or category from a chart. Kindly let me know how we can delete any of the series/category from the chart.

Also after deletion of series/chart I am adding some category and series too. Kindly guide me in using the api to achieve this.

Thanks,
Gaurang.

Hi Gaurang,

I have observed the requirements shared by you and like to share that you can add the specific chart series or categories using Aspose.Slides. Please try using the following sample code on your end to serve the purpose.

PresentationEx pres= new PresentationEx(“D:\Aspose Data\Presentation1NoTemplate.pptx”) ;

SlideEx slide= pres.getSlides().get_Item(1);

ChartEx chart=(ChartEx) slide.getShapes().get_Item(0);

ChartSeriesExCollection seriesExCol = chart.getChartData().getSeries();
Iterator<?> itr = seriesExCol.iterator();

//Removes the first series
seriesExCol.remove(chart.getChartData().getSeries().get_Item(0));

//Remove the series at index 1 (2nd series)
seriesExCol.removeAt(1);

//Remove the firsy categpry
chart.getChartData().getCategories().remove(chart.getChartData().getCategories().get_Item(0));

//Remove the categpry at index 1 (2nd category)
chart.getChartData().getCategories().removeAt(1);


Also, you can add new chart series and categories. Please visit this documentation link for your kind reference in this regard. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,


Thanks a lot for your quick reply once again. I will go throught the documents and let you know if I need furthur help.

Thanks,
Gaurang.