# Regression Analysis - Trend Line

1. ##### Rene
65 posts
Member since:
Nov 2010

Posted 17 Apr 2015 Link to this post

Hi,

I have a series that is based on the following:

x (horizontal) axis:  12 months for current year.

y (vertical) axis:  inches of rain that fell in that month (units is inch)

Now, I have my series data and all charts well.

The one thing I also have is the starting point (pt A) and end point (pt B) for a simple linear regression line that I need to draw a straight line from pt A to pt B to show the trend over time.  Point A will reside in the first column (January) and point B will reside in the last column (December).  ( I am using canvas for the charting).

I would prefer to do this with the 2 end points I already have as opposed to determining each point for each month to create a different chart series based on these points where due to rounding et al - which could result in this new curve not being perfectly perfectly straight.

So I guess in short, is it possible to draw a straight line from month 1 to month 12 on a chart knowing only 2 points where the line would be inserted via svg et al at dynamically?

Thanks,

Rene.

2. ##### Daniel
2145 posts

Posted 21 Apr 2015 Link to this post

Hello Rene,

It is possible to draw a line(or any shape) on the chart by the drawing API and the approach demonstrated in the example from this documentation topic.

Regards,
Daniel
Telerik

See What's Next in App Development. Register for TelerikNEXT.

3. ##### Rene
65 posts
Member since:
Nov 2010

Posted 23 Apr 2015 in reply to Daniel Link to this post

Thanks Daniel.  I ended up obtaining all points for the trend line using the linear function - and it works great.

From what you mention, this does address another target I have - the ability of adding some lines of text below the legend (when below the x axis).  Is there a sample that would address this requirement?

Thank You.

4. ##### Daniel
2145 posts

Posted 27 Apr 2015 Link to this post

Hello again Rene,

I created an example that demonstrates drawing text below the legend.

Regards,
Daniel
Telerik

See What's Next in App Development. Register for TelerikNEXT.