mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 20:40:20 +02:00
TAChart: Extract UpdateMinMax procedure.
git-svn-id: trunk@19922 -
This commit is contained in:
parent
e9e7756aa5
commit
5f1f1c8897
@ -138,6 +138,8 @@ function PointDistY(const A, B: TPoint): Integer; inline;
|
||||
procedure Unused(const A1);
|
||||
procedure Unused(const A1, A2);
|
||||
|
||||
procedure UpdateMinMax(AValue: Double; var AMin, AMax: Double);
|
||||
|
||||
operator +(const A: TPoint; B: TSize): TPoint;
|
||||
|
||||
implementation
|
||||
@ -300,6 +302,14 @@ begin
|
||||
end;
|
||||
{$HINTS ON}
|
||||
|
||||
procedure UpdateMinMax(AValue: Double; var AMin, AMax: Double);
|
||||
begin
|
||||
if AValue < AMin then
|
||||
AMin := AValue
|
||||
else if AValue > AMax then
|
||||
AMax := AValue;
|
||||
end;
|
||||
|
||||
operator + (const A: TPoint; B: TSize): TPoint;
|
||||
begin
|
||||
Result.X := A.X + B.cx;
|
||||
|
@ -704,8 +704,7 @@ begin
|
||||
Result := inherited AddXY(X, Y, XLabel, Color);
|
||||
|
||||
// Update max
|
||||
if X > XGraphMax then XGraphMax := X;
|
||||
if X < XGraphMin then XGraphMin := X;
|
||||
UpdateMinMax(X, FXGraphMin, FXGraphMax);
|
||||
if Y > YGraphMax then begin
|
||||
YGraphMax := Y;
|
||||
XOfYGraphMax := X;
|
||||
@ -915,16 +914,14 @@ begin
|
||||
XGraphMin := MaxDouble;
|
||||
for i := 0 to Count - 1 do begin
|
||||
Val := PChartCoord(FCoordList.Items[i])^.x;
|
||||
if Val > XGraphMax then XGraphMax := Val;
|
||||
if Val < XGraphMin then XGraphMin := Val;
|
||||
UpdateMinMax(Val, FXGraphMin, FXGraphMax);
|
||||
end;
|
||||
|
||||
YGraphMax := MinDouble;
|
||||
YGraphMin := MaxDouble;
|
||||
for i:=0 to Count-1 do begin
|
||||
Val := PChartCoord(FCoordList.Items[i])^.y;
|
||||
if Val > YGraphMax then YGraphMax := Val;
|
||||
if Val < YGraphMin then YGraphMin := Val;
|
||||
UpdateMinMax(Val, FYGraphMin, FYGraphMax);
|
||||
end;
|
||||
|
||||
UpdateParentChart;
|
||||
@ -1437,10 +1434,8 @@ begin
|
||||
Result := inherited AddXY(X, Y, XLabel, Color);
|
||||
|
||||
// Update max
|
||||
if X > XGraphMax then XGraphMax := X;
|
||||
if X < XGraphMin then XGraphMin := X;
|
||||
if Y > YGraphMax then YGraphMax := Y;
|
||||
if Y < YGraphMin then YGraphMin := Y;
|
||||
UpdateMinMax(X, FXGraphMin, FXGraphMax);
|
||||
UpdateMinMax(Y, FYGraphMin, FYGraphMax);
|
||||
|
||||
UpdateParentChart;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user