Back to Devexpress

ChartTrendLine Class

dashboard-devexpress-dot-dashboardcommon-9623c14e.md

latest6.3 KB
Original Source

ChartTrendLine Class

A trend line in a chart dashboard item that shows trends in the series data.

Namespace : DevExpress.DashboardCommon

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

NuGet Package : DevExpress.Dashboard.Core

Declaration

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

Remarks

The ChartTrendLine 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 trend line at runtime:

Create a ChartTrendLine 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;
            ChartTrendLine trendline = new ChartTrendLine();
            SimpleSeries simpleSeries = chartItem.Panes[0].Series[0] as SimpleSeries;
            if (simpleSeries != null) {
                trendLine.Value = simpleSeries.Value.UniqueId;
            }
            trendline.Name = "Trend Indicator";
            trendline.ValueLevel = DevExpress.XtraCharts.ValueLevel.Value;
            trendline.LegendText = "Sales Trend";
            trendline.ShowInLegend = true;
            trendline.Color = Color.DarkGreen;

            chartItem.Indicators.Add(trendline);
            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 trendline As New ChartTrendLine()
            Dim simpleSeries As SimpleSeries = TryCast(chartItem.Panes(0).Series(0), SimpleSeries)
            If simpleSeries IsNot Nothing Then
                trendLine.Value = simpleSeries.Value.UniqueId
            End If
            trendline.Name = "Trend Indicator"
            trendline.ValueLevel = DevExpress.XtraCharts.ValueLevel.Value
            trendline.LegendText = "Sales Trend"
            trendline.ShowInLegend = True
            trendline.Color = Color.DarkGreen

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

Inheritance

Object ChartIndicatorBase ChartTrendLine

See Also

ChartTrendLine Members

ChartRegressionLine

ChartCustomIndicator

DevExpress.DashboardCommon Namespace