mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:16:05 +02:00
TAChart: Fix TListChartSource.CopyFrom not copying additional x and y values.
This commit is contained in:
parent
b16ec6790f
commit
dddd7c85cd
@ -86,6 +86,7 @@ type
|
||||
|
||||
TChartValueTextArray = array of TChartValueText;
|
||||
|
||||
PChartDataItem = ^TChartDataItem;
|
||||
TChartDataItem = packed record
|
||||
public
|
||||
X, Y: Double;
|
||||
@ -93,6 +94,7 @@ type
|
||||
Text: String;
|
||||
XList: TDoubleDynArray;
|
||||
YList: TDoubleDynArray;
|
||||
procedure CopyFrom(AItem: PChartDataItem);
|
||||
function GetX(AIndex: Integer): Double;
|
||||
function GetY(AIndex: Integer): Double;
|
||||
procedure SetX(AIndex: Integer; const AValue: Double);
|
||||
@ -103,7 +105,6 @@ type
|
||||
function Point: TDoublePoint; inline;
|
||||
procedure MakeUnique;
|
||||
end;
|
||||
PChartDataItem = ^TChartDataItem;
|
||||
|
||||
TGraphToImageFunc = function (AX: Double): Integer of object;
|
||||
TIntegerTransformFunc = function (AX: Integer): Integer of object;
|
||||
@ -536,6 +537,18 @@ end;
|
||||
|
||||
{ TChartDataItem }
|
||||
|
||||
procedure TChartDataItem.CopyFrom(AItem: PChartDataItem);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
X := AItem^.X;
|
||||
Y := AItem^.Y;
|
||||
SetLength(XList, Length(AItem^.XList));
|
||||
for i := 0 to High(AItem^.XList) do XList[i] := AItem^.XList[i];
|
||||
SetLength(YList, Length(AItem^.YList));
|
||||
for i := 0 to High(AItem^.YList) do YList[i] := AItem^.YList[i];
|
||||
end;
|
||||
|
||||
function TChartDataItem.GetX(AIndex: Integer): Double;
|
||||
begin
|
||||
AIndex := EnsureRange(AIndex, 0, Length(XList));
|
||||
|
@ -717,7 +717,7 @@ begin
|
||||
try // optimization: don't execute try..except..end in a loop
|
||||
for i := 0 to ASource.Count - 1 do begin
|
||||
pcd := NewItem;
|
||||
pcd^ := ASource[i]^;
|
||||
pcd^.CopyFrom(ASource[i]);
|
||||
FData.Add(pcd); // don't use ItemAdd() here
|
||||
pcd := nil;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user