ChartTrendLine Class
A trend line in a chart dashboard item that shows trends in the series data.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.2.Core.dll
Declaration
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:
- 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:
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();
}
}
}