We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback


Trusted by the world’s leading companies

Overview

A chart communicates data graphically on a slide. The Syncfusion .NET PowerPoint Library allows you to create, remove, and customize 80+ types of charts in PowerPoint presentations using C#, without Microsoft PowerPoint or interop dependencies.


How to create a chart in a PowerPoint presentation using C#

  1. Install NuGet package: Install the Syncfusion.Presentation.Net.Core NuGet package in your project.
  2. Create presentation: Create an instance of IPresentation to represent the presentation document.
  3. Add slide and chart: Add a blank slide as an ISlide and add a chart to the blank slide as an IPresentationChart.
  4. Set chart type: Set the chart type using the ChartType property.
  5. Set chart data range: Set the chart data range using the DataRange property and the data range values using the SetValue method.
  6. Save the presentation: Save the IPresentation object to the FileStream object.

Here is an example of how to create a pie chart in a PowerPoint presentation in C# using the Syncfusion .NET PowerPoint Library.

//Create an instance of presentation.
using IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a chart to the slide with position and size.
IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
//Select the chart type.
chart.ChartType = OfficeChartType.Pie;

//Assign data range.
chart.DataRange = chart.ChartData[1, 1, 6, 2];
chart.IsSeriesInRows = false;

//Set the values for the chart data.
chart.ChartData.SetValue(1, 1, "Food");
chart.ChartData.SetValue(2, 1, "Fruits");
chart.ChartData.SetValue(3, 1, "Vegetables");
chart.ChartData.SetValue(4, 1, "Dairy");
chart.ChartData.SetValue(5, 1, "Protein");
chart.ChartData.SetValue(6, 1, "Grains");
chart.ChartData.SetValue(1, 2, "Percentage");
chart.ChartData.SetValue(2, 2, 36);
chart.ChartData.SetValue(3, 2, 14);
chart.ChartData.SetValue(4, 2, 13);
chart.ChartData.SetValue(5, 2, 28);
chart.ChartData.SetValue(6, 2, 9);

//Set data labels.
chart.Series[0].DataPoints.DefaultDataPoint.DataLabels.IsValue = true;

//Save the presentation.
using FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);

Customize PowerPoint charts

A chart consists of various elements, such as title, area, plot area, series, legends, data labels, and axes. The .NET PowerPoint Library allows you to format each element, enhancing the visual appeal of the charts in a PowerPoint.

Chart title

Modify the chart title by changing its name, appearance, resizing the title area, and more.

Chart area and plot area

Enhance the chart area and plot area by adjusting borders, colors, transparency, adding images, changing positions, and more.

Series

Customize the chart series by adjusting the series name, type, color, borders, adding space between bars, formatting markers, and more.

Legend

Customize the chart legend by modifying the position, border, and legend entries.

Data labels

Adjust the chart data labels by changing their positions, sizes, and more.

Horizontal and vertical axes

Customize the horizontal and vertical axes of a chart by modifying the title, border, font, rotation angle, and more.





Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.

Scroll up icon