This is a migrated thread and some comments may be shown as answers.

Regression Analysis - Trend Line

3 Answers 160 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 17 Apr 2015, 04:38 PM

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.

 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Apr 2015, 01:25 PM
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.

 
0
Rene
Top achievements
Rank 1
answered on 23 Apr 2015, 11:47 AM

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.

0
Daniel
Telerik team
answered on 27 Apr 2015, 10:24 AM
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.

 
Tags
Chart
Asked by
Rene
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Rene
Top achievements
Rank 1
Share this question
or