PNG JPG BMP TIFF PPTX
Aspose.Slides  for .NET
PPTX

Create PPTX Charts in C#

Build .NET applications that create charts in presentation files using server-side Aspose.Slides APIs.

Create PPTX Charts Using C#

Use Aspose.Slides for .NET to create charts in PPTX presentations. Install the package from NuGet or use the following Package Manager Console command.

Command

PM> Install-Package Aspose.Slides.NET

How to Create Charts in PPTX Files Using C#

Create a chart in a PPTX presentation with Aspose.Slides for .NET in a few lines of code.

  1. Create a Presentation object.

  2. Select an ISlide object from the presentation.

  3. Call the AddChart method to add a chart to the slide.

  4. Add chart series and data points with IChartDataWorkbook.

  5. Save the presentation as a PPTX file.

System Requirements

Aspose.Slides for .NET supports major platforms and operating systems. Make sure that your environment includes the following prerequisites.

  • Microsoft Windows or a compatible operating system with .NET Framework, .NET Core, Windows Azure, Mono, or Xamarin.
  • A development environment such as Microsoft Visual Studio.
  • Aspose.Slides for .NET referenced in your project. Install it from NuGet or download it by using the Download button above.
 

Create PPTX Files Chart - C#

using var presentation = new Presentation();

var slide = presentation.Slides[0];
var chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);
var defaultWorksheetIndex = 0;
var chartDataWorkbook = chart.ChartData.ChartDataWorkbook;

chart.ChartData.Series.Clear();
chart.ChartData.Series.Add(chartDataWorkbook.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);
chart.ChartData.Series.Add(chartDataWorkbook.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type);

var firstSeries = chart.ChartData.Series[0];
firstSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 1, 1),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 2, 3));
firstSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 1, 2),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 2, 10));
firstSeries.Type = ChartType.ScatterWithStraightLinesAndMarkers;
firstSeries.Marker.Size = 10;
firstSeries.Marker.Symbol = MarkerStyleType.Star;

var secondSeries = chart.ChartData.Series[1];
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 3, 5),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 4, 2));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 3, 3),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 4, 1));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 4, 3, 2),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 4, 4, 2));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 5, 3, 5),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 5, 4, 1));
secondSeries.Marker.Size = 10;
secondSeries.Marker.Symbol = MarkerStyleType.Circle;

presentation.Save("AsposeScatterChart.pptx", SaveFormat.Pptx);
 
  • About Aspose.Slides for .NET API

    Aspose.Slides for .NET can read, write, manipulate, and convert presentation documents to formats such as PDF, XPS, HTML, TIFF, and ODP. You can create charts and diagrams in presentation files or generate them from data.

    Online PPTX Chart Creation Live Demos

    Generate charts in PPTX documents by visiting the Live Demos website . The live demo has the following benefits.

      No need to download Aspose API.
      No need to write any code.
      Upload your PPTX files.
      Charts are created instantly.

    PPTX What is PPTX File Format?

    Files with the PPTX extension use the Office Open XML presentation format. A PPTX file can contain slides with text, charts, images, formatting, animations, and other presentation content.

    Read More

    Other Supported Charting Formats

    Using C#, you can also create charts in other formats.

    PPT (Microsoft PowerPoint 97-2003)