Skip to main content
All docs
V25.1
  • 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.1.Core.dll

    NuGet Package: DevExpress.Dashboard.Core

    Declaration

    public sealed class ChartRegressionLine :
        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:

    Regression Line indicator

    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:

    Value
    Specifies 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:

    Name
    Specifies the name of the trend indicator within the indicators collection.
    ValueLevel
    Gets or sets the value that specifies which series point value should be used to calculate the indicator.
    ShowInLegend
    Specifies whether to display the trend indicator in the legend.
    LegendText
    Specifies the text that identifies the trend indicator within the legend.
    Thickness
    Specifies the thickness of the indicator line.
    Color
    Specifies the trend indicator’s color.
    DashStyle
    Specifies the dash style used to paint the line.
    Visible
    Specifies 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:

    Configure Regression Line in the UI

    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();
            }
        }   
    } 
    

    Inheritance

    Object
    ChartIndicatorBase
    ChartRegressionLine
    See Also