Reassigning series valuesources
Posted: Thu Mar 24, 2005 9:27 pm
My Delphi 2005 application (using TeeChart v7.04 reg) allows users to populate a clientdataset with either of two different sets of fields then displayed in a DBChart. After having specified the new dataset, when I reopen the clientdataset there will be an EDatabase Error:
'clientdataset1: Field 'Brix' not found'.
(Brix is the YValue.ValueSource for Series1 set at design-time)
unless I do the following beforehand:
with DBChart1 do begin
for i := 0 to 5 do Series[ i ].DataSource := nil;
for i := 0 to 5 do Series[ i ].YValues.ValueSource := '';
end;
After reopening the clientdataset I try to reassign the YValues.ValueSources with this code:
for i := 0 to 5 do
with DBChart1.Series[ i ] do begin
Datasource := DM1.cdsRPT0;
YValues.ValueSource := lfFieldList[ i+3 ]; // from a string array
Title := lfCaptionList[ i+3 ];
CheckDatasource;
end;
However the same error message occurs upon executing:
YValues.ValueSource := lfFieldList[ i+3 ];
It still seems to be looking for a previous field that no longer exists in the clientdataset based on the YValueSource design-time setting.
Can it be done this way or do I have to FreeAllSeries and rebuild from scratch?
Thanks in advance,
Barry
'clientdataset1: Field 'Brix' not found'.
(Brix is the YValue.ValueSource for Series1 set at design-time)
unless I do the following beforehand:
with DBChart1 do begin
for i := 0 to 5 do Series[ i ].DataSource := nil;
for i := 0 to 5 do Series[ i ].YValues.ValueSource := '';
end;
After reopening the clientdataset I try to reassign the YValues.ValueSources with this code:
for i := 0 to 5 do
with DBChart1.Series[ i ] do begin
Datasource := DM1.cdsRPT0;
YValues.ValueSource := lfFieldList[ i+3 ]; // from a string array
Title := lfCaptionList[ i+3 ];
CheckDatasource;
end;
However the same error message occurs upon executing:
YValues.ValueSource := lfFieldList[ i+3 ];
It still seems to be looking for a previous field that no longer exists in the clientdataset based on the YValueSource design-time setting.
Can it be done this way or do I have to FreeAllSeries and rebuild from scratch?
Thanks in advance,
Barry