ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  TrendLayer and getDataSet return data
Posted by Bryan on Jul-15-2020 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 trend-line 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 Jul-15-2020 21:30
I forgot to mention I am using Python

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

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

  Re: TrendLayer and getDataSet return data
Posted by Peter Kwan on Jul-16-2020 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 x-value, you can then computer the y-value 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 y-axis?

The trend line may or may not intercept with the y-axis. For example, if the trend line is nearly vertical, it may intercept with the top and bottom borders of the plot area (the x-axis) instead of the y-axis.

The y-axis can be put on the left side or right side of the chart or other positions. There is no mathematical reason why the y-axis has to be put in any particular place. It is just a charting "style". So the trend line can intercept with the y-axis at any point (or not intercept at all) depending on the "style" where you position the y-axis. You just need to find out the x-position of the y-axis and use the formula above to calculate the corresponding y-value.

Regards
Peter Kwan

  Re: TrendLayer and getDataSet return data
Posted by Bryan on Jul-16-2020 01:33
Just ignore this thread as this link has helped me find my answer:
https://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1594793680#N1594793680
Thanks either way