
Value at intersection of X and Y axis using Trendline 
Posted by Chuck on Aug302021 01:56 

Peter,
What is the simplest way to obtain the Y Value at the intersection of the X axis and a Trendline (using WinForms VB.Net)?
Thank you,
Chuck 
Re: Value at intersection of X and Y axis using Trendline 
Posted by Peter Kwan on Aug302021 15:00 

Hi Chuck,
By "Trendline", I assume you are referring to a line added using the addTrendLine or addTrendLine2. If the trend layer is configured to use linear regression (the default), the line is:
y = mx + c
So the x coordinate must be x = (y  c) / m. The "m" and "c" can be obtained using TrendLineLayer.getSlope and TrendLineLayer.getIntercept.
https://www.advsofteng.com/doc/cdnet.htm#TrendLayer.getSlope.htm
https://www.advsofteng.com/doc/cdnet.htm#TrendLayer.getIntercept.htm
In the most common chart configuration, the xaxis is at y = min_y_axis_value (the bottom of the yaxis). ChartDirector can only know what is the final yaxis scale after your code has completed the chart. ChartDirector assumes your code has completed the chart if your code displays the chart, or if it tells ChartDirector to layout the chart (using BaseChart.layout) or at least layout the axis (BaseChart.layoutAxes). At that stage, the bottom yaxis value can be obtained as:
Dim yBottom As Double = myXYChart.yAxis().getMinValue()
The xintercept is then:
Dim xIntercept As Double = (yBottom  myTrendLayer.getIntercept()) / myTrendLayer.getSlope()
Regards
Peter Kwan 
Re: Value at intersection of X and Y axis using Trendline 
Posted by Chuck on Aug302021 17:09 

Thank you Peter, this is very helpful!
Chuck 
