TAChart: Set default values correctly in db-aware chart source

git-svn-id: trunk@20220 -
This commit is contained in:
ask 2009-05-26 02:54:49 +00:00
parent 62cc5113b7
commit 7ee8494e64
2 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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;