Back to Devexpress

ChartRegressionLine Class

dashboard-devexpress-dot-dashboardcommon-585cf9ac.md

latest6.7 KB
Original Source

ChartRegressionLine Class

A regression line in a chart dashboard item that shows data using a mathematical formula that minimizes the distance between the line itself and associated data points.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public sealed class ChartRegressionLine :
    ChartIndicatorBase
vb
Public NotInheritable Class ChartRegressionLine
    Inherits ChartIndicatorBase

Remarks

The ChartRegressionLine object is contained in the ChartIndicatorCollection collection. The ChartDashboardItem.Indicators property gets a collection that contains all trend indicators in a chart dashboard item.

Example

The following example shows how to create a regression line at runtime:

Create a ChartRegressionLine object and specify its settings:

This property is required to display the indicator in the Chart dashboard item when you launch the application:

ValueSpecifies the measure data item that is used to calculate the trend indicator.

If you do not specify the following properties, their default values are used:

NameSpecifies the name of the trend indicator within the indicators collection.ValueLevelGets or sets the value that specifies which series point value should be used to calculate the indicator.ShowInLegendSpecifies whether to display the trend indicator in the legend.LegendTextSpecifies the text that identifies the trend indicator within the legend.ThicknessSpecifies the thickness of the indicator line.ColorSpecifies the trend indicator’s color.DashStyleSpecifies the dash style used to paint the line.VisibleSpecifies whether to display the trend indicator.

Add the object to the chart indicators collection to display the configured indicator in the UI.

You can edit the created indicator in the Trend Indicators dialog:

cs
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using DevExpress.DashboardCommon;

namespace WinForm {
    public partial class FormDesigner : Form {
        public FormDesigner() {
            InitializeComponent();
            var dashboard = new Dashboard1();
            ChartDashboardItem chartItem = dashboard.Items.First(x => x.ComponentName == "chartDashboardItem1") as ChartDashboardItem;
            ChartRegressionLine regressionline = new ChartRegressionLine();
            SimpleSeries simpleSeries = chartItem.Panes[0].Series[0] as SimpleSeries;
            if (simpleSeries != null) {
              regressionline.Value = simpleSeries.Value.UniqueId;
            }
            regressionline.Name = "Regression Indicator";
            regressionline.ValueLevel = DevExpress.XtraCharts.ValueLevel.Value;
            regressionline.LegendText = "Linear Regression";
            regressionline.ShowInLegend = true;
            regressionline.Color = Color.DarkGreen;

            chartItem.Indicators.Add(regressionline);
            dashboardDesigner.Dashboard = dashboard;
            dashboardDesigner.CreateRibbon();
            dashboardDesigner.CreateCustomItemBars();
        }
    }   
}
vb
Imports System.Drawing
Imports System.Linq
Imports System.Windows.Forms
Imports DevExpress.DashboardCommon

Namespace WinForm
    Partial Public Class FormDesigner
        Inherits Form

        Public Sub New()
            InitializeComponent()
            Dim dashboard = New Dashboard1()
            Dim chartItem As ChartDashboardItem = TryCast(dashboard.Items.First(Function(x) x.ComponentName = "chartDashboardItem1"), ChartDashboardItem)
            Dim regressionline As New ChartRegressionLine()
      Dim simpleSeries As SimpleSeries = TryCast(chartItem.Panes(0).Series(0), SimpleSeries)
            If simpleSeries IsNot Nothing Then
              regressionline.Value = simpleSeries.Value.UniqueId
            End If
            regressionline.Name = "Regression Indicator"
            regressionline.ValueLevel = DevExpress.XtraCharts.ValueLevel.Value
            regressionline.LegendText = "Linear Regression"
            regressionline.ShowInLegend = True
            regressionline.Color = Color.DarkGreen

            chartItem.Indicators.Add(regressionline)
            dashboardDesigner.Dashboard = dashboard
            dashboardDesigner.CreateRibbon()
            dashboardDesigner.CreateCustomItemBars()
        End Sub
    End Class
End Namespace

Inheritance

Object ChartIndicatorBase ChartRegressionLine

See Also

ChartRegressionLine Members

ChartTrendLine

ChartCustomIndicator

DevExpress.DashboardCommon Namespace