TTeeFunction question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
windmaomao
Newbie
Newbie
Posts: 27
Joined: Sat Dec 06, 2003 5:00 am
Location: baltimore

TTeeFunction question

Post by windmaomao » Sun Oct 10, 2004 3:46 pm

Hi,
I read the article "Introduction to function". Before I start to use it, I want to ask a question, how to use AddPoint() to control the number of points added to the function series, ex. every two points of the original series.

Thanks.

Best regards
Fang

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Oct 11, 2004 3:16 pm

Hi.

In the AddPoints method you could use it's SourceSeries parameter to retrieve source series xvalues, yvalues, count, etc.. Here is an example of copying every second point from source to targer series (pseudo code)

Code: Select all

procedure TYourFunction.AddPoints(Source: TChartSeries);
var N,i: Integer;
begin
  N := Source.Count;
  if N > 0 then
  for i := 0 to N-1 do
    if (i MOD 2 = 0) then ParentSeries.AddXY(Source.Xvalues[i],Source.YValues[i]);
end;

There are several good examples of AddPoints implementation available in TeeChart sources. Check the StatChar.pas, the TMACDFunction.AddPoints implementation.
BTw, in many cases when function is not a very complicated one it's a lot easier and simpler to override the Calculate and (optionally) CalculateMany methods.
Marjan Slatinek,
http://www.steema.com

windmaomao
Newbie
Newbie
Posts: 27
Joined: Sat Dec 06, 2003 5:00 am
Location: baltimore

Post by windmaomao » Mon Oct 11, 2004 5:54 pm

Thanks.

Here's another question.
I tried the teeFunction, but it gives me an exception whenever I close my application.

I am using v6pro, and I read in the v7 feature website, it says series.datasources had a bug which will cause access violation. I am not sure if it's exactly what happened to my case.

Because if I put the teeFunction example into a seperate program, it works fine. So I am not positive what's going on.

fang

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

Post by Pep » Fri Oct 22, 2004 8:41 am

Hi,
I am using v6pro, and I read in the v7 feature website, it says series.datasources had a bug which will cause access violation. I am not sure if it's exactly what happened to my case.
Yes, I think it could be related with the same bug, it happens when you close the app.
A solution is to place the RemoveAllSeries and FreeAllSeries methods in the OnFormClose event.

Post Reply