Share via


ChTrendlines Collection

ChSeries
ChTrendlines
Multiple objects

The collection of ChTrendline objects for a series.

Using the ChTrendlines collection

The Trendlines property of the ChSeries object returns a ChTrendlines collection.

Use the Add method of the ChTrendline object to add a trendline to your chart.

The following example adds a trendline to the first series in the first chart in Chartspace1 and then formats the trendline.

Sub AddPolyTrendline()

    Dim serSeries1
    Dim chConstants
    Dim tlSeries1Trend

    Set chConstants = ChartSpace1.Constants

    ' Set a variable to the first series of the first chart
    ' in Chartspace1.
    Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

    ' Add a trendline to the first series and return
    ' a Trendline object.
    Set tlSeries1Trend = serSeries1.Trendlines.Add

    ' Display the equation used to calculate the trendline.
    tlSeries1Trend.IsDisplayingEquation = True

    ' Set the trendline to be a polynomial trendline.
    tlSeries1Trend.Type = chConstants.chTrendlineTypePolynomial

End Sub

Properties | Count Property | Item Property | Parent Property

Methods | Add Method | Delete Method

Parent Objects | ChSeries Object

Child Objects | ChSeries Object | ChTrendline Object