Creating TrendLines at Design Time
TrendLines can be created at design time using the TrendLine Collection Editor. Using the collection editor, you may add, modify and remove trend lines. For more information on the TrendLine Collection Editor, see TrendLine Collection Editor.
Creating TrendLines Programmatically
To create a TrendLine programmatically, create instance of TrendLine object and set its properties. The TrendLine can be created using its constructor or AddNewTrendLine.TrendLinesCollection() method of TrendLinesCollection.
The following code adds a red TrendLine to ChartGroup(0) of the Chart:
' create trend line
Dim tl As C1.Win.C1Chart.TrendLine = New C1.Win.C1Chart.TrendLine()
' first data series
tl.SeriesIndex = 0
' set line color and thickness
tl.LineStyle.Color = Color.Red
tl.LineStyle.Thickness = 2
' show formula in legend
tl.Text = "{#FORMULA}"
' add trend to the chart
c1Chart1.ChartGroups(0).ChartData.TrendsList.Add(tl)
· C#
// create trend line
C1.Win.C1Chart.TrendLine tl = new C1.Win.C1Chart.TrendLine();
// first data series
tl.SeriesIndex = 0;
// set line color and thickness
tl.LineStyle.Color = Color.Red;
tl.LineStyle.Thickness = 2;
// show formula in legend
tl.Text = "{#FORMULA}";
// add trend to the chart
c1Chart1.ChartGroups[0].ChartData.TrendsList.Add( tl);
· Delphi
var
tl: C1.Win.C1Chart.TrendLine;
begin
// create trend line
tl := C1.Win.C1Chart.TrendLine.Create;
// first data series
tl.SeriesIndex := 0;
// set line color and thickness
tl.LineStyle.Color := Color.Red;
tl.LineStyle.Thickness := 2;
// show formula in legend
tl.Text := '{#FORMULA}';
// add trend to the chart
c1Chart1.ChartGroups[0].ChartData.TrendsList.Add(tl);
end;
This topic illustrates the following:
The red trend line connects the first and last data points.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |