Add Trend Lines to Presentation Charts in С++
Add a Trend Line
Aspose.Slides for C++ provides a simple API for managing different chart Trend Lines:
- Create an instance of the Presentation class.
- Obtain a slide’s reference by its index.
- Add a chart with default data along with the any of desired type (this example uses ChartType.ClusteredColumn).
- Adding the exponential trend line for chart series 1.
- Adding a linear trend line for chart series 1.
- Adding a logarithmic trend line for chart series 2.
- Adding moving average trend line for chart series 2.
- Adding a polynomial trend line for chart series 3.
- Adding a power trend line for chart series 3.
- Write the modified presentation to a PPTX file.
The following code is used to create a chart with Trend Lines.
Add a Custom Line
Aspose.Slides for C++ provides a simple API to add custom lines in a chart. To add a simple plain line to a selected slide of the presentation, please follow the steps below:
- Create an instance of Presentation class
- Obtain the reference of a slide by using its Index
- Create a new chart using AddChart method exposed by Shapes object
- Add an AutoShape of Line type using AddAutoShape method exposed by Shapes object
- Set the Color of the shape lines.
- Write the modified presentation as a PPTX file
The following code is used to create a chart with Custom Lines.
FAQ
What do ‘forward’ and ‘backward’ mean for a trendline?
They are the lengths of the trendline projected forward/backward: for scatter (XY) charts — in axis units; for non-scatter charts — in number of categories. Only non-negative values are allowed.
Will the trendline be preserved when exporting the presentation to PDF or SVG, or when rendering a slide to an image?
Yes. Aspose.Slides converts presentations to PDF/SVG and renders charts to images; trendlines, as part of the chart, are preserved during these operations. A method is also available to export an image of the chart itself.