Chart Series in PowerPoint

30 Aug 202421 minutes to read

In a chart, a series represents a set of related data points, often depicted using lines, bars, or markers to show data trends or comparisons. Using Presentation, you can customize the series in the chart.

Set the Series Name

The following code snippet illustrates how to set the series name in chart.

//Set name to chart series.
chart.Series[0].Name = "Sum of Purchases";
//Set name to chart series.
chart.Series[0].Name = "Sum of Purchases";
' Set name to chart series.
chart.Series(0).Name = "Sum of Purchases"

Set the Series Type

The following code snippet illustrates how to set the series type.

//Set the series type.
chart.Series[0].SerieType = OfficeChartType.Line_Markers;
//Set the series type.
chart.Series[0].SerieType = OfficeChartType.Line_Markers;
' Set the series type.
chart.Series(0).SerieType = OfficeChartType.Line_Markers

Customize the Series Color

The following code snippet illustrates how to customize the series color.

// Configure the fill settings for the first series in the chart.
chart.Series[0].SerieFormat.Fill.FillType = OfficeFillType.Gradient;
chart.Series[0].SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chart.Series[0].SerieFormat.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
chart.Series[0].SerieFormat.Fill.ForeColor = Syncfusion.Drawing.Color.Red;
// Configure the fill settings for the first series in the chart.
chart.Series[0].SerieFormat.Fill.FillType = OfficeFillType.Gradient;
chart.Series[0].SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chart.Series[0].SerieFormat.Fill.BackColor = Color.FromArgb(205, 217, 234);
chart.Series[0].SerieFormat.Fill.ForeColor = Color.Red;
' Configure the fill settings for the first series in the chart.
chart.Series(0).SerieFormat.Fill.FillType = OfficeFillType.Gradient
chart.Series(0).SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor
chart.Series(0).SerieFormat.Fill.BackColor = Color.FromArgb(205, 217, 234)
chart.Series(0).SerieFormat.Fill.ForeColor = Color.Red

Customize the Series Border

The following code snippet illustrates how to customize the series border.

//Customize series border.
chart.Series[0].SerieFormat.LineProperties.LineColor = Syncfusion.Drawing.Color.Red;
chart.Series[0].SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline;
//Customize series border.
chart.Series[0].SerieFormat.LineProperties.LineColor = Color.Red;
chart.Series[0].SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline;
' Customize series border.
chart.Series(0).SerieFormat.LineProperties.LineColor = Color.Red
chart.Series(0).SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot
chart.Series(0).SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline

The complete code snippet illustrating the above options is shown below.

FileStream fileStreamPath = new FileStream("Data/Template.pptx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
 //Open an existing PowerPoint Presentation.
 using (IPresentation pptxDoc = Presentation.Open(fileStreamPath))
 {
     //Gets the first slide.
     ISlide slide = pptxDoc.Slides[0];
     //Gets the chart in slide.
     IPresentationChart chart = slide.Shapes[0] as IPresentationChart;

     //Sets chart type and title.
     chart.ChartTitle = "Purchase Details";
     chart.ChartTitleArea.FontName = "Calibri";
     chart.ChartTitleArea.Size = 14;
     chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.Solid;

     //Sets series type.
     chart.Series[0].SerieType = OfficeChartType.Line_Markers;
     chart.Series[1].SerieType = OfficeChartType.Bar_Clustered;

     chart.PrimaryCategoryAxis.Title = "Products";
     chart.PrimaryValueAxis.Title = "In Dollars";

     // Configure the fill settings for the first series in the chart.
     chart.Series[1].SerieFormat.Fill.FillType = OfficeFillType.Gradient;
     chart.Series[1].SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor;
     chart.Series[1].SerieFormat.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
     chart.Series[1].SerieFormat.Fill.ForeColor = Syncfusion.Drawing.Color.Red;
     //Customize series border.
     chart.Series[1].SerieFormat.LineProperties.LineColor = Syncfusion.Drawing.Color.Red;
     chart.Series[1].SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot;
     chart.Series[1].SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline;

     //Sets position of legend.
     chart.Legend.Position = OfficeLegendPosition.Bottom;

     using (FileStream outputStream = new FileStream("Result.pptx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
     {
         //Save the PowerPoint Presentation.
         pptxDoc.Save(outputStream);
     }
 }
//Open an existing PowerPoint Presentation.
 using (IPresentation pptxDoc = Presentation.Open("Template.pptx"))
 {
     //Gets the first slide.
     ISlide slide = pptxDoc.Slides[0];
     //Gets the chart in slide.
     IPresentationChart chart = slide.Shapes[0] as IPresentationChart;

     //Sets chart type and title.
     chart.ChartTitle = "Purchase Details";
     chart.ChartTitleArea.FontName = "Calibri";
     chart.ChartTitleArea.Size = 14;
     chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.Solid;

     //Sets series type.
     chart.Series[0].SerieType = OfficeChartType.Line_Markers;
     chart.Series[1].SerieType = OfficeChartType.Bar_Clustered;

     chart.PrimaryCategoryAxis.Title = "Products";
     chart.PrimaryValueAxis.Title = "In Dollars";

     // Configure the fill settings for the first series in the chart.
     chart.Series[1].SerieFormat.Fill.FillType = OfficeFillType.Gradient;
     chart.Series[1].SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor;
     chart.Series[1].SerieFormat.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
     chart.Series[1].SerieFormat.Fill.ForeColor = Syncfusion.Drawing.Color.Red;
     //Customize series border.
     chart.Series[1].SerieFormat.LineProperties.LineColor = Syncfusion.Drawing.Color.Red;
     chart.Series[1].SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot;
     chart.Series[1].SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline;

     //Sets position of legend.
     chart.Legend.Position = OfficeLegendPosition.Bottom;
     //Save the PowerPoint Presentation.
     pptxDoc.Save("Result.pptx");
 }
' Open an existing PowerPoint Presentation.
Using pptxDoc As IPresentation = Presentation.Open("Template.pptx")
    ' Gets the first slide.
    Dim slide As ISlide = pptxDoc.Slides(0)
    ' Gets the chart in slide.
    Dim chart As IPresentationChart = TryCast(slide.Shapes(0), IPresentationChart)

    ' Sets chart type and title.
    chart.ChartTitle = "Purchase Details"
    chart.ChartTitleArea.FontName = "Calibri"
    chart.ChartTitleArea.Size = 14
    chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.Solid

    ' Sets series type.
    chart.Series(0).SerieType = OfficeChartType.Line_Markers
    chart.Series(1).SerieType = OfficeChartType.Bar_Clustered

    chart.PrimaryCategoryAxis.Title = "Products"
    chart.PrimaryValueAxis.Title = "In Dollars"

    ' Configure the fill settings for the first series in the chart.
    chart.Series(1).SerieFormat.Fill.FillType = OfficeFillType.Gradient
    chart.Series(1).SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor
    chart.Series(1).SerieFormat.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234)
    chart.Series(1).SerieFormat.Fill.ForeColor = Syncfusion.Drawing.Color.Red

    ' Customize series border.
    chart.Series(1).SerieFormat.LineProperties.LineColor = Syncfusion.Drawing.Color.Red
    chart.Series(1).SerieFormat.LineProperties.LinePattern = OfficeChartLinePattern.Dot
    chart.Series(1).SerieFormat.LineProperties.LineWeight = OfficeChartLineWeight.Hairline

    ' Sets position of legend.
    chart.Legend.Position = OfficeLegendPosition.Bottom

    ' Save the PowerPoint Presentation.
    pptxDoc.Save("Result.pptx")
End Using

You can download a complete working sample from GitHub.

Set the DataPoint as Total

The following code snippet illustrates how to set the Data Point as total in chart.

//Data point settings as total in chart.
chart.Series[0].DataPoints[3].SetAsTotal = true;
//Data point settings as total in chart.
chart.Series[0].DataPoints[3].SetAsTotal = true;
' Data point settings as total in chart.
chart.Series(0).DataPoints(3).SetAsTotal = True

Set the connector lines between data points

The following code snippet illustrates how to set the connector lines between data points.

//Showing the connector lines between data points.
chart.Series[0].SerieFormat.ShowConnectorLines = true;
//Showing the connector lines between data points.
chart.Series[0].SerieFormat.ShowConnectorLines = true;
' Showing the connector lines between data points.
chart.Series(0).SerieFormat.ShowConnectorLines = True

Add space between bars

The following code snippet illustrates how to add space between bars.

//Adding space between bars of different series of single category.
 chart.Series[0].SerieFormat.CommonSerieOptions.Overlap = -40;

 //Adding space between bars of different categories.
 chart.Series[0].SerieFormat.CommonSerieOptions.GapWidth = 100;
//Adding space between bars of different series of single category.
 chart.Series[0].SerieFormat.CommonSerieOptions.Overlap = -40;

 //Adding space between bars of different categories.
 chart.Series[0].SerieFormat.CommonSerieOptions.GapWidth = 100;
' Adding space between bars of different series of a single category.
chart.Series(0).SerieFormat.CommonSerieOptions.Overlap = -40

' Adding space between bars of different categories.
chart.Series(0).SerieFormat.CommonSerieOptions.GapWidth = 100

You can download a complete working sample from GitHub.

Add High-Low Lines

The following code snippet illustrates how to add high-low lines.

//Set HasHighLowLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasHighLowLines = true;

//Apply formats to HighLowLines.
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LineColor = Syncfusion.Drawing.Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LineWeight = OfficeChartLineWeight.Hairline;
//Set HasHighLowLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasHighLowLines = true;

//Apply formats to HighLowLines.
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LineColor = Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.HighLowLines.LineWeight = OfficeChartLineWeight.Hairline;
' Set HasHighLowLines property to true.
chart.Series(0).SerieFormat.CommonSerieOptions.HasHighLowLines = True

' Apply formats to HighLowLines.
chart.Series(0).SerieFormat.CommonSerieOptions.HighLowLines.LineColor = Color.Red
chart.Series(0).SerieFormat.CommonSerieOptions.HighLowLines.LinePattern = OfficeChartLinePattern.Dot
chart.Series(0).SerieFormat.CommonSerieOptions.HighLowLines.LineWeight = OfficeChartLineWeight.Hairline

You can download a complete working sample from GitHub.

Add Drop Lines

The following code snippet illustrates how to add drop lines.

//Set the HasDropLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasDropLines = true;

//Apply formats to DropLines.
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LineColor = Syncfusion.Drawing.Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LineWeight = OfficeChartLineWeight.Hairline;
//Set the HasDropLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasDropLines = true;

//Apply formats to DropLines.
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LineColor = Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.DropLines.LineWeight = OfficeChartLineWeight.Hairline;
' Set HasDropLines property to true.
chart.Series(0).SerieFormat.CommonSerieOptions.HasDropLines = True

' Apply formats to DropLines.
chart.Series(0).SerieFormat.CommonSerieOptions.DropLines.LineColor = Color.Red
chart.Series(0).SerieFormat.CommonSerieOptions.DropLines.LinePattern = OfficeChartLinePattern.Dot
chart.Series(0).SerieFormat.CommonSerieOptions.DropLines.LineWeight = OfficeChartLineWeight.Hairline

You can download a complete working sample from GitHub.

Add Series Lines

The following code snippet illustrates how to add series lines in chart.

//Set HasSeriesLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasSeriesLines = true;

//Apply formats to SeriesLines.
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LineColor = Syncfusion.Drawing.Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LineWeight = OfficeChartLineWeight.Hairline;
//Set HasSeriesLines property to true.
chart.Series[0].SerieFormat.CommonSerieOptions.HasSeriesLines = true;

//Apply formats to SeriesLines.
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LineColor = Color.Red;
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LinePattern = OfficeChartLinePattern.Dot;
chart.Series[0].SerieFormat.CommonSerieOptions.PieSeriesLine.LineWeight = OfficeChartLineWeight.Hairline;
' Set HasSeriesLines property to true.
chart.Series(0).SerieFormat.CommonSerieOptions.HasSeriesLines = True

' Apply formats to SeriesLines.
chart.Series(0).SerieFormat.CommonSerieOptions.PieSeriesLine.LineColor = Color.Red
chart.Series(0).SerieFormat.CommonSerieOptions.PieSeriesLine.LinePattern = OfficeChartLinePattern.Dot
chart.Series(0).SerieFormat.CommonSerieOptions.PieSeriesLine.LineWeight = OfficeChartLineWeight.Hairline

You can download a complete working sample from GitHub.

Different Marker Properties

The following code snippet illustrates how to customize the marker properties.

//Set the marker style of the first series in the chart.
chart.Series[0].SerieFormat.MarkerStyle = OfficeChartMarkerType.Star;

//Customize the marker style.
chart.Series[0].SerieFormat.MarkerSize = 8;
chart.Series[0].SerieFormat.MarkerBackgroundColor = Syncfusion.Drawing.Color.Red;
chart.Series[0].SerieFormat.MarkerForegroundColor = Syncfusion.Drawing.Color.Black;
//Set the marker style of the first series in the chart.
chart.Series[0].SerieFormat.MarkerStyle = OfficeChartMarkerType.Star;

//Customize the marker style.
chart.Series[0].SerieFormat.MarkerSize = 8;
chart.Series[0].SerieFormat.MarkerBackgroundColor = Color.Red;
chart.Series[0].SerieFormat.MarkerForegroundColor = Color.Black;
' Set the marker style of the first series in the chart.
chart.Series(0).SerieFormat.MarkerStyle = OfficeChartMarkerType.Star

' Customize the marker style.
chart.Series(0).SerieFormat.MarkerSize = 8
chart.Series(0).SerieFormat.MarkerBackgroundColor = Color.Red
chart.Series(0).SerieFormat.MarkerForegroundColor = Color.Black

Explode a Pie Chart

The following code snippet illustrates how to explode a pie chart.

//Exploding the pie chart to 10%.
chart.Series[0].SerieFormat.Percent = 10;
//Exploding the pie chart to 10%.
chart.Series[0].SerieFormat.Percent = 10;
' Exploding the pie chart to 10%.
chart.Series(0).SerieFormat.Percent = 10

You can download a complete working sample from GitHub.

See Also