This topic explains, with code examples, how to configure the trend line of UltraSparkline™ for custom appearance and color.
The following table lists the topics required as a prerequisite to understanding this topic.
By default, the trend line is not displayed in the Sparkline chart. The minimum setting for displaying the trend line is enabling it by setting the TrendLineVisibilty property to Visible.
A Trend Line configured with the minimum settings a line (based on selected trend line type) is a gray horizontal directional line with line thickness of 1 pixel.
The Trend Line can be customized in the following aspects:
Type – numerous trend line types are supported. For details, refer to the Supported trendline types text block of the UltraSparkline Features topic.
Line color
Line thickness
Line period – used for calculating the moving average of the trend line. Applicable to trend lines of Average types only (not for Fit types). For example, you can set the line period for Simple Average or Exponential Average trend lines, but not for Linear Fit or [other] type of Fit trend lines.
Each of these aspects is managed through a dedicated property. See the Property settings text block for details.
The following table maps the configuration tasks to the corresponding Trend Line property settings.
The code below demonstrates how to configure a red trend line of Simple Average type that is 3 pixels thick and have a period of 2.
In C#:
this.UltraSparkline1.TrendLineType = SparklineTrendType.SimpleAverage;
this.UltraSparkline1.TrendLineBrush = new SolidColorBrush(Color.Red);
this.UltraSparkline1.TrendLinePeriod = 2;
this.UltraSparkline1.TrendLineThickness = 3;
In Visual Basic:
Me.UltraSparkline1.TrendLineType = SparklineTrendType.SimpleAverage
Me.UltraSparkline1.TrendLineBrush = New SolidColorBrush(Color.Red)
Me.UltraSparkline1.TrendLinePeriod = 2
Me.UltraSparkline1.TrendLineThickness = 3
The following topic provide additional information related to this topic.