TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
dr.vodca
- Newbie
- Posts: 8
- Joined: Fri Oct 13, 2006 12:00 am
Post
by dr.vodca » Wed Nov 08, 2006 7:34 pm
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 ?
-
Narcís
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Thu Nov 09, 2006 9:03 am
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;
-
dr.vodca
- Newbie
- Posts: 8
- Joined: Fri Oct 13, 2006 12:00 am
Post
by dr.vodca » Thu Nov 09, 2006 7:57 pm
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