
TrendLayer and getDataSet return data 
Posted by Bryan on Jul152020 14:14 

Hi there
I am looking for any example source code for using return data with getDataSet(). I am able to generate a successful trendline with addTrendLayer(). I have an example here which works for a chart:
c1.addTrendLayer2(timeStamps, closeData, 0x008000, "Trend Line").setLineWidth(2)
How do I find the data points of the trendline on Y axis? Can you provide an example on how to use getDataSet()?
Thanks 
Re: TrendLayer and getDataSet return data 
Posted by Bryan on Jul152020 21:30 

I forgot to mention I am using Python 
Re: TrendLayer and getDataSet return data 
Posted by Bryan on Jul152020 21:31 

I forgot to mention I am using Python 
Re: TrendLayer and getDataSet return data 
Posted by Bryan on Jul152020 21:31 

I forgot to mention I am using Python 
Re: TrendLayer and getDataSet return data 
Posted by Peter Kwan on Jul162020 01:26 

Hi Bryan,
I am not too sure exactly what you mean by "find the data points of the trendline on Y axis".
The "data points" are provided by your code to ChartDirector. So you already have all the data points.
The addTrendLayer draws the best line that fit your data points. The line itself does not have any data point. It is just line. ChartDirector can provide the slope and the intercept of the line to you. In this way, you can compute the y coordinate given the x coordinate. For example:
slope = myTrendLayer.getSlope()
intercept = myTrendLayer.getIntercept()
# give an xvalue, you can then computer the yvalue using y = slope * x + intercept
......
Is the above what you mean by "on y axis", or do you mean the intersection of the trend line with the yaxis?
The trend line may or may not intercept with the yaxis. For example, if the trend line is nearly vertical, it may intercept with the top and bottom borders of the plot area (the xaxis) instead of the yaxis.
The yaxis can be put on the left side or right side of the chart or other positions. There is no mathematical reason why the yaxis has to be put in any particular place. It is just a charting "style". So the trend line can intercept with the yaxis at any point (or not intercept at all) depending on the "style" where you position the yaxis. You just need to find out the xposition of the yaxis and use the formula above to calculate the corresponding yvalue.
Regards
Peter Kwan 
