diff --git a/components/tachart/tadbsource.pas b/components/tachart/tadbsource.pas index 8d991dd597..a91c44a40b 100644 --- a/components/tachart/tadbsource.pas +++ b/components/tachart/tadbsource.pas @@ -163,8 +163,10 @@ var ds: TDataSet; begin Result := @FCurItem; - Inc(AIndex); // RecNo is counted from 1 + SetDataItemDefaults(FCurItem); if not FDataLink.Active then exit; + + Inc(AIndex); // RecNo is counted from 1 ds := FDataLink.DataSet; if ds.IsUniDirectional then begin if ds.RecNo < AIndex then diff --git a/components/tachart/tasources.pas b/components/tachart/tasources.pas index 7b33ab63d8..4de66744fa 100644 --- a/components/tachart/tasources.pas +++ b/components/tachart/tasources.pas @@ -193,6 +193,7 @@ type function DoublePoint(const ACoord: TChartDataItem): TDoublePoint; inline; overload; procedure Register; +procedure SetDataItemDefaults(var AItem: TChartDataItem); implementation @@ -230,6 +231,14 @@ begin [TListChartSource, TRandomChartSource, TUserDefinedChartSource]); end; +procedure SetDataItemDefaults(var AItem: TChartDataItem); +begin + AItem.X := 0; + AItem.Y := 0; + AItem.Color := clTAColor; + AItem.Text := ''; +end; + { TCustomChartSource } procedure TCustomChartSource.AfterDraw; @@ -766,9 +775,7 @@ end; function TUserDefinedChartSource.GetItem(AIndex: Integer): PChartDataItem; begin - FItem.X := 0; - FItem.Y := 0; - FItem.Color := clTAColor; + SetDataItemDefaults(FItem); if Assigned(FOnGetChartDataItem) then FOnGetChartDataItem(Self, AIndex, FItem); Result := @FItem;