Spire.Presentation provides a property "IsHidden" to enable developers to hide or show a specific series of a chart. This article demonstrates how we can accomplish this function using Spire.Presentation and C#.
Below is the screenshot of the original chart:
Detail steps:
Step 1: Instantiate a Presentation object and load the PowerPoint file.
Presentation ppt = new Presentation(); ppt.LoadFromFile("Input.pptx");
Step 2: Get the first slide.
ISlide slide = ppt.Slides[0];
Step 3: Get the first chart.
IChart chart = slide.Shapes[0] as IChart;
Step 4: Hide the first series of the chart.
//Hide the first series of the chart chart.Series[0].IsHidden = true; //Show the first series of the chart //chart.Series[0].IsHidden = false;
Step 5: Save the file.
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
Screenshot after hiding the first series:
using Spire.Presentation; using Spire.Presentation.Charts; namespace Hide_Chart_Series_in_PPT { class Program { static void Main(string[] args) { //Instantiate a Presentation object Presentation ppt = new Presentation(); //Load the PowerPoint file ppt.LoadFromFile("Input.pptx"); //Get the first slide ISlide slide = ppt.Slides[0]; //Get the first chart IChart chart = slide.Shapes[0] as IChart; //Hide the first series of the chart chart.Series[0].IsHidden = true; //Show the first series of the chart //chart.Series[0].IsHidden = false; //Save the file ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013); } } }