Page 1 of 1

TAverageTeeFunction LineSeries

Posted: Wed Nov 08, 2006 7:34 pm
by 9242699
I' having a problem of porting a procedure to TeeChart 7 pro (delphi2006) from a functioning enviornmet (Delphi2005, TeeChart Standard).

The following procedure will add an average TLineSeries to a chart with TLineSeries in it. If it works perfectly with Delphi2005 andTeeChart Standard, I now get the Errormessage: "No Valid DataSource: TLineSeries"

Code: Select all

  vCSeries := TLineSeries.Create(Self); //-------------------------------------- Average
  with vCSeries do
  begin
    ParentChart:=DBChart1;
    SetFunction(TAverageTeeFunction.Create(Self));
    Title:='Average';
    LinePen.Width:=2;
    Stairs:=True;
    Active:=true;
    for i := 0 to DBChart1.SeriesCount-1 do DataSources.Add(DBChart1.Series[i]);
    CheckDatasource;
  end;
The offending line being
for i := 0 to DBChart1.SeriesCount-1 do DataSources.Add(DBChart1.Series);

Can someone explain to me what is wrong with that ?

Posted: Thu Nov 09, 2006 9:03 am
by narcis
Hi dr.vodca,

This is because you need to change the ofending line to this:

Code: Select all

    for i := 0 to DBChart1.SeriesCount-2 do DataSources.Add(DBChart1.Series[i]);
Otherwise you assign the function series as a datasource for itself as it is already added in the chart and TChart series range from 0 to SeriesCount-1.

Another option would be adding the function series to the chart after this for loop:

Code: Select all

  vCSeries := TLineSeries.Create(Self); //-------------------------------------- Average
  with vCSeries do
  begin
    SetFunction(TAverageTeeFunction.Create(Self));
    Title:='Average';
    LinePen.Width:=2;
    Stairs:=True;
    Active:=true;
    for i := 0 to DBChart1.SeriesCount-1 do DataSources.Add(DBChart1.Series[i]);
    CheckDatasource;
    ParentChart:=DBChart1;
  end;

Posted: Thu Nov 09, 2006 7:57 pm
by 9242699
Dear NarcĂ­s

Thank you kindly for your support, I opted for your third suggestion and it works perfectly.
And I'm not going to ask why the heck it worked before ;-)

cheers
dr.vodca