Back to Devexpress

TrendLine.ExtrapolateToInfinity Property

corelibraries-devexpress-dot-xtracharts-dot-trendline.md

latest7.6 KB
Original Source

TrendLine.ExtrapolateToInfinity Property

Specifies whether the Trend Line is extrapolated to infinity.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public bool ExtrapolateToInfinity { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property ExtrapolateToInfinity As Boolean

Property Value

TypeDescription
Boolean

true if the Trend Line is extrapolated to infinity; otherwise, false.

|

Remarks

The following images demonstrate the use of the ExtrapolateToInfinity property.

ExtrapolateToInfinity = falseExtrapolateToInfinity = true

For more information, refer to Trend Lines.

Example

This example demonstrates how a Trend Line can be added to a series’ collection of indicators at runtime.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/winforms-chart-add-a-trend-line

csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
        private void Form1_Load (object sender, EventArgs e) {
            // Create an empty chart.
            ChartControl stockChart = new ChartControl();

            // Create a stock series, add it to the chart and set its properties.
            Series series1 = new Series("Series 1", ViewType.Stock);
            stockChart.Series.Add(series1);
            series1.ArgumentScaleType = ScaleType.DateTime;
            series1.ValueScaleType = ScaleType.Numerical;

            // Add points to the series.
            series1.Points.Add(new SeriesPoint(new DateTime(1994, 3, 1),
                new object[] { 4.00, 5.00, 5.00, 4.85 }));
            series1.Points.Add(new SeriesPoint(new DateTime(1994, 3, 2),
                new object[] { 6.05, 8.05, 6.05, 7.05 }));
            series1.Points.Add(new SeriesPoint(new DateTime(1994, 3, 3),
                new object[] { 6.25, 8.25, 6.75, 7.15 }));

            // Create and customize a trendline, 
            TrendLine trendline1 = new TrendLine("A Trend");
            trendline1.Point1.Argument = new DateTime(1994, 3, 1);
            trendline1.Point1.ValueLevel = ValueLevel.High;
            trendline1.Point2.Argument = new DateTime(1994, 3, 3);
            trendline1.Point2.ValueLevel = ValueLevel.High;
            trendline1.ExtrapolateToInfinity = false;
            trendline1.Color = Color.Red;
            trendline1.LineStyle.DashStyle = DashStyle.Dash;

            // Cast the view type of the series to the Stock view.
            StockSeriesView myView = ((StockSeriesView)series1.View);

            // Define the Y-axis range.
            myView.AxisY.WholeRange.AlwaysShowZeroLevel = false;

            // Add the trendline to the series collection of indicators.
            myView.Indicators.Add(trendline1);

            // Add the chart to the form.
            stockChart.Dock = DockStyle.Fill;
            this.Controls.Add(stockChart);
        }
vb
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            ' Create an empty chart.
            Dim stockChart As New ChartControl()

            ' Create a stock series, add it to the chart and set its properties.
            Dim series1 As New Series("Series 1", ViewType.Stock)
            stockChart.Series.Add(series1)
            series1.ArgumentScaleType = ScaleType.DateTime
            series1.ValueScaleType = ScaleType.Numerical

            ' Add points to the series.
            series1.Points.Add(New SeriesPoint(New DateTime(1994, 3, 1), New Object() { 4.00, 5.00, 5.00, 4.85 }))
            series1.Points.Add(New SeriesPoint(New DateTime(1994, 3, 2), New Object() { 6.05, 8.05, 6.05, 7.05 }))
            series1.Points.Add(New SeriesPoint(New DateTime(1994, 3, 3), New Object() { 6.25, 8.25, 6.75, 7.15 }))

            ' Create and customize a trendline, 
            Dim trendline1 As New TrendLine("A Trend")
            trendline1.Point1.Argument = New DateTime(1994, 3, 1)
            trendline1.Point1.ValueLevel = ValueLevel.High
            trendline1.Point2.Argument = New DateTime(1994, 3, 3)
            trendline1.Point2.ValueLevel = ValueLevel.High
            trendline1.ExtrapolateToInfinity = False
            trendline1.Color = Color.Red
            trendline1.LineStyle.DashStyle = DashStyle.Dash

            ' Cast the view type of the series to the Stock view.
            Dim myView As StockSeriesView = (CType(series1.View, StockSeriesView))

            ' Define the Y-axis range.
            myView.AxisY.WholeRange.AlwaysShowZeroLevel = False

            ' Add the trendline to the series collection of indicators.
            myView.Indicators.Add(trendline1)

            ' Add the chart to the form.
            stockChart.Dock = DockStyle.Fill
            Me.Controls.Add(stockChart)
        End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ExtrapolateToInfinity property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-chart-add-a-trend-line/CS/Form1.cs#L40

csharp
trendline1.Point2.ValueLevel = ValueLevel.High;
trendline1.ExtrapolateToInfinity = false;
trendline1.Color = Color.Red;

winforms-chart-add-a-trend-line/VB/Form1.vb#L37

vb
trendline1.Point2.ValueLevel = ValueLevel.High
trendline1.ExtrapolateToInfinity = False
trendline1.Color = Color.Red

See Also

Trend Lines

TrendLine Class

TrendLine Members

DevExpress.XtraCharts Namespace