smoothing function

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jennifer
Newbie
Newbie
Posts: 20
Joined: Tue Dec 07, 2004 5:00 am

smoothing function

Post by Jennifer » Thu Jan 27, 2005 5:30 am

we made up a very simple program to use the smoothing function
which has a method called draw. when we "draw", we get a memory
access error at the setfunction line. The two series[Series1,2] are added in the chart editor. code is below: It compiles fine
***************************************************
Procedure Tform1.draw;
var
Tfunctiona:TsmoothingFunction;
Begin
series1.addXY(1,0,'',clTeeColor);
series1.addXY(2,2.5,'',clTeeColor);
series1.addXY(3,-1.6,'',clTeeColor);
series1.addXY(4,-0.5,'',clTeeColor);
series1.addXY(5,1.3,'',clTeeColor);
series1.addXY(6,1.5,'',clTeeColor);
series1.addXY(7,1.4,'',clTeeColor);
series1.addXY(8,-1.75,'',clTeeColor);
series1.addXY(9,-1.25,'',clTeeColor);
series1.addXY(10,1.3,'',clTeeColor);
series2.setfunction(Tfunctiona.create(self));
Tfunctiona.Interpolate:=true;
Tfunctiona.Factor:=4;
series2.datasources.clear;
series2.datasources.add(series1);
end;
************************************************************
Thanks,

Natalie

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

Post by Marjan » Thu Jan 27, 2005 6:54 am

Hi, Jennifer.

The problem is the Tfunctiona.create(self); which has to be coded differently. The way you're using it you'll get AV error (because you're not actually calling the class construction). Here is corrected code which doesn't generate AV error:

Code: Select all

var
  fFunctiona:TSmoothingFunction;
begin
  series1.addXY(1,0,'',clTeeColor);
  series1.addXY(2,2.5,'',clTeeColor);
  series1.addXY(3,-1.6,'',clTeeColor);
  series1.addXY(4,-0.5,'',clTeeColor);
  series1.addXY(5,1.3,'',clTeeColor);
  series1.addXY(6,1.5,'',clTeeColor);
  series1.addXY(7,1.4,'',clTeeColor);
  series1.addXY(8,-1.75,'',clTeeColor);
  series1.addXY(9,-1.25,'',clTeeColor);
  series1.addXY(10,1.3,'',clTeeColor);
  tFunctiona := TSmoothingFunction.Create(Self);
  series2.setfunction(tfunctiona);
  Tfunctiona.Interpolate:=true;
  Tfunctiona.Factor:=4;
  series2.datasources.clear;
  series2.datasources.add(series1);
end;
Marjan Slatinek,
http://www.steema.com

Jennifer
Newbie
Newbie
Posts: 20
Joined: Tue Dec 07, 2004 5:00 am

smoothing function

Post by Jennifer » Thu Jan 27, 2005 3:23 pm

Thanks-
We redid it as below and the strange thing is we have to clic k on draw
twice to get series 2 display. Click #1 shows source serties 1, while the second clicks causes both 1 and 2 to show.
**********************************************************
Procedure Tform1.draw;
var
Tfunctiona:TsmoothingFunction;
Begin
tfunctiona:=Tsmoothingfunction.create(self);
series2.setfunction(Tfunctiona);
Tfunctiona.Interpolate:=false;
Tfunctiona.Factor:=25;
series1.visible:=true;
series1.addXY(1,0,'',clTeeColor);
series1.addXY(2,2.5,'',clTeeColor);
series1.addXY(3,-1.6,'',clTeeColor);
series1.addXY(4,-0.5,'',clTeeColor);
series1.addXY(5,1.3,'',clTeeColor);
series1.addXY(6,1.5,'',clTeeColor);
series1.addXY(7,1.4,'',clTeeColor);
series1.addXY(8,-1.75,'',clTeeColor);
series1.addXY(9,-1.25,'',clTeeColor);
series1.addXY(10,1.3,'',clTeeColor);
series2.datasources.add(series1);
end;

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

Post by Marjan » Fri Jan 28, 2005 7:13 am

Try adding

Code: Select all

Series2.CheckDataSource;
to your code.
Marjan Slatinek,
http://www.steema.com

Post Reply