Skip to end of metadata
Go to start of metadata
Contents Summary
  

Adding Charts

Aspose.Slides for C++ lets developers add custom charts into slides from scratch. This topic, explains how to create normal and scatter charts with multiple series from scratch using Aspose.Slides for C++. Aspose.Slides for C++ is works independently of Aspose.Cells for C++ for chart creation. This article explains how to create different types of charts:

  • Creating normal charts.
  • Creating scatter chart with multiple series and different series markers.

Creating Normal Chart

Aspose.Slides for C++ has provided the simplest API for creating charts in an easy way. To create a chart in a slide, please follow the steps below:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of a slide by index.
  3. Add chart with default data along with desired type.
  4. Add a chart title.
  5. Access the chart data worksheet.
  6. Clear all the default series and categories.
  7. Add new series and categories.
  8. Add new chart data for chart series.
  9. Add fill color for chart series.
  10. Adding chart series labels.
  11. Write the modified presentation as a PPTX file.

The following example shows how to create normal Chart.

 

Creating Scattered Chart

The following code is used to create a scatter chart with different series markers.

 

Creating Pie Chart

Aspose.Slides for C++ provides a simple API for creating and filling pie charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.Pie).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Add new chart data for the chart series.
  8. Add new points for charts and add custom colors for the pie chart's sectors.
  9. Set labels for series.
  10. Set leader lines for series labels.
  11. Set the rotation angle for pie chart slides.
  12. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Tree Map Chart

Aspose.Slides for C++ provides a simple API for creating Tree Map charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.TreeMap).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Add new chart data for the chart series.
  8. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Stock Chart

Aspose.Slides for C++ provides a simple API for creating Stock charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.OpenHighLowClose).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Add new chart data for the chart series.
  8. specifies HiLowLines format.
  9. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Box and Whisker Chart

Aspose.Slides for C++ provides a simple API for creating Box and Whisker charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.BoxAndWhisker).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Add new chart data for the chart series.
  8. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Funnel Chart

Aspose.Slides for C++ provides a simple API for creating Funnel charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.Funnel).
  4. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Sunburst Chart

Aspose.Slides for C++ provides a simple API for creating Sunburst charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.sunburst).
  4. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Histogram Chart

Aspose.Slides for C++ provides a simple API for creating Histogram charts in an easy way. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.Histogram).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Write the modified presentation to a PPTX file

The following code is used to create a chart.

 

Creating Multi Category Chart

Aspose.Slides for C++ provides a simple API for creating multi category chart. To create a chart on a slide:

  1. Create an instance of the Presentation class.
  2. Obtain a slide's reference by its index.
  3. Add a chart with default data along with the desired type (ChartType.ClusteredColumn).
  4. Access the chart data IChartDataWorkbook.
  5. Clear the default series and categories.
  6. Add new series and categories.
  7. Add new chart data for the chart series.
  8. Write the modified presentation to a PPTX file.

The following code is used to create a chart.

 

Updating an Existing Chart

Aspose.Slides for C++ has provided the simplest API to update charts in an easiest way. To update a chart in a slide:

  • Open an instance of Presentation class containing chart.
  • Obtain the reference of a slide by using its Index.
  • Traverse through all shapes to find desired chart.
  • Access the chart data worksheet.
  • Modify the chart data series data by changing series values.
  • Adding a new series and populating data inside it.
  • Write the modified presentation as a PPTX file.

The code examples that follow how to update a chart.

 

Setting Data Range for Chart

Aspose.Slides for C++ has provided the simplest API to set the data range for chart in an easiest way. To set the data range for chart:

  • Open an instance of Presentation class containing chart.
  • Obtain the reference of a slide by using its Index.
  • Traverse through all shapes to find desired chart.
  • Access the chart data and set the range.
  • Save the modified presentation as a PPTX file.

The code examples that follow how to update a chart.

 

Default Markers in Chart

Aspose.Slides for C++ provides a simple API to set the chart series marker automatically. In the following feature, every chart series will get different default marker symbol automatically.

Below code example shows how to set the chart series marker automatically.

 

Labels
  • No labels