TTrendFunction Calculation Error

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Slim
Newbie
Newbie
Posts: 6
Joined: Fri Mar 12, 2004 5:00 am

TTrendFunction Calculation Error

Post by Slim » Tue Jul 06, 2004 9:18 am

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
Last edited by Slim on Tue Jul 06, 2004 9:35 am, edited 1 time in total.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jul 15, 2004 9:20 am

Hi Slim,

see my other post.

Slim
Newbie
Newbie
Posts: 6
Joined: Fri Mar 12, 2004 5:00 am

Post by Slim » Thu Jul 15, 2004 1:08 pm

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

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jul 21, 2004 12:15 am

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.

Post Reply