We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add custom trend line in Chart?

Platform: WinForms |
Control: Chart


TrendLines is used to draw lines in the ChartArea. The Trend Line can be added into the chart by using TrendLineAdder class. Using Mouse Events we can draw trend lines. We use utility class to listen to mouse events and convert them into trend lines. We can draw any number of trend lines and we can set the different colors to differentiate.


// Creating CustomPoints

ChartPoint ptStart = this.chart.ChartArea.GetValueByPoint(start);

ChartPoint ptEnd = this.chart.ChartArea.GetValueByPoint(end);

ChartSeries tseries = this.chart.Model.NewSeries("TrendLine", ChartSeriesType.Line);




tseries.LegendItem.Visible = false;

// Specify the color for the lines

tseries.Style.Interior = new Syncfusion.Drawing.BrushInfo(ptStart.YValues[0] < ptEnd.YValues[0] ? Color.DarkGreen : Color.Red);


' Creating CustomPoints

Dim tlineAdder As TrendLineAdder

Dim ptStart As ChartPoint = Me.chart.ChartArea.GetValueByPoint(start)

Dim ptEnd As ChartPoint = Me.chart.ChartArea.GetValueByPoint(end_Renamed)

Dim tseries As ChartSeries = Me.chart.Model.NewSeries("TrendLine", ChartSeriesType.Line)




tseries.LegendItem.Visible = False

' Specify the color for the lines

If ptStart.YValues(0) < ptEnd.YValues(0) Then

tseries.Style.Interior = New Syncfusion.Drawing.BrushInfo(Color.DarkGreen)


tseries.Style.Interior = New Syncfusion.Drawing.BrushInfo(Color.Red)

End If

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile