The problem is that the datasource property is always stored, causing an overwrite

Therefore the datasource property should be defined as
Code: Select all
property DataSource:TComponent read GetDataSource write SetDataSource stored StoreDatasource;
Code: Select all
function TChartSeries.StoreDatasource:boolean;
begin
Result:=DataSources.Count=1;
end;


Code: Select all
procedure TChartSeries.Notification( AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if Operation=opRemove then
{$ifdef HH_PATCH_TC_DATASOURCE}
begin
{$endif}
if AComponent=FTeeFunction then
FTeeFunction:=nil
else
{$ifdef HH_PATCH_TC_DATASOURCE}
// Update Datasources list
if assigned(Datasources) and (Datasources.IndexOf(AComponent)>=0) then
begin
DataSources.Remove(AComponent);
end;
{$else}
{ if "AComponent" is the same as series datasource,
then set datasource to nil }
if AComponent=DataSource then
InternalRemoveDataSource(AComponent); // 7.0
{$endif}
{$ifdef HH_PATCH_TC_DATASOURCE}
end;
{$endif}
end;
Code: Select all
Function TChartSeries.GetDataSource:TComponent;
VAR i:integer;
begin
Result:=nil;
if Assigned(FDataSources) and (FDataSources.Count>0) then
begin
for i:=0 to FDataSources.Count-1 do
begin
if TChartSeries(FDataSources[i]).Count>0 then
begin
Result:=TChartSeries(FDataSources[i]);
break; // found a series with data
end;
end;
if not assigned(Result) then
result:=FDataSources[0];
end;
end;