A chart communicates data graphically on a slide. The Syncfusion .NET PowerPoint Library allows you to create, remove, and customize 75+ types of charts in PowerPoint presentations using C#, without Microsoft PowerPoint or interop dependencies.
This example code shows how to create a chart in a presentation using the Syncfusion .NET PowerPoint Library with just a few lines of code in C#.
using Syncfusion.OfficeChart;
using Syncfusion.Presentation;
//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("Result.pptx", FileMode.Create, FileAccess.ReadWrite);
presentation.Save(outputStream);
Modify the chart title by changing its text, appearance, size, and more.
Enhance the chart area and plot area by adjusting borders, colors, transparency; adding images; changing positions; and more.
Customize a chart series by adjusting its name, type, color, borders; adding space between bars; and formatting markers.
Adjust the chart’s data labels by changing their positions, sizes, and more.
Customize the chart legend by modifying its position, border, and legend entries.
Customize the horizontal and vertical axes of a chart by modifying their titles, borders, fonts, rotation angles, and more.
Discover valuable resources from our knowledge base to enhance your use of charts in the PowerPoint Library:
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Product Updates
Technical Support
Yes, apart from creating a chart from scratch, you can also create one from Excel data using the .NET PowerPoint Library, without needing Microsoft Office.
Yes, you can export specific charts within a PowerPoint presentation as individual images programmatically using the .NET PowerPoint Library in C#.
Yes, you can import data from various external sources into a chart programmatically using the .NET PowerPoint Library.
Yes, the .NET PowerPoint Library allows you to customize various chart elements such as the title, plot area, series, legends, data labels, and axes.
Yes, the .NET PowerPoint Library supports creating advanced charts such as funnel, box and whisker, waterfall, histogram, and Pareto charts programmatically using C#.
You can access this feature through the Syncfusion.Presentation.Net.Core NuGet package. Detailed code samples and a video tutorial are available in the documentation.
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.