Page 1 of 1

TTrendFunction Calculation Error

Posted: Tue Jul 06, 2004 9:18 am
by 9231415
TeeChart Version 7 & Delphi 7:

You have an issue with the TTrendFucntion when one of the point is zero.
I am using a TPointSeries and TLineSeries to draw a calibration line.
1st point: 0 , 1.06207
2nd point:1 , 672.42340

and this is the section of code that calls the TTrendFunction

with MyLineSeries do begin
DataSources.Clear;
DataSources.Add( MyPointSeries );
SetFunction( TTrendFunction.Create(Self) );
{display trend line}
CheckDataSource;
X1 := XValue[0];
X2 := XValue[1];
Y1 := YValue[0];
Y2 := YValue[1];
end;

Now what you will notice that the value of YValue[0] changes somehow to double the value of 1.06207. The error is less notisable when you have more than 2 points and it only happens when you have a zero as one of the points.

X1, X2, Y1, Y2 are used to calculate the slope and the Y intercept

Slope:= (Y2 - Y1)/(X2 - X1);
YIntercept := Y1 - X1 * (Y2 - Y1) / (X2 - X1) ;

Using the values above after the line has been ploted the YIntercept was calculated to be 2.124 where it should have been = to 1.06207.

I have checked TeeChart Version 4 & Delphi 5 and the calculations are correct.

Any ideas?

Regards,

Slim

Posted: Thu Jul 15, 2004 9:20 am
by Pep
Hi Slim,

see my other post.

Posted: Thu Jul 15, 2004 1:08 pm
by 9231415
Hi Pep,

Deleting the 0 point is not a solution, because the calculated intercept will be deferent.

Will this be sorted out in the next update? and as I said this worked fine in older versions

Slim

Posted: Wed Jul 21, 2004 12:15 am
by Pep
Hi Slim,

yes, you're correct, it seems to be a bug. We'll try to fix it for the next maintenance release v7.02.