TAChart: Extract UpdateMinMax procedure.

git-svn-id: trunk@19922 -
This commit is contained in:
ask 2009-05-11 08:54:27 +00:00
parent e9e7756aa5
commit 5f1f1c8897
2 changed files with 15 additions and 10 deletions

View File

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

View File

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