TAChart: Use NumberOr function instead of checking for NaN explicitly

git-svn-id: trunk@38713 -
This commit is contained in:
ask 2012-09-17 11:24:26 +00:00
parent 460cd6ced3
commit 085082ce94

View File

@ -655,6 +655,9 @@ begin
UpdateMinMax(YList[j], Result.a.Y, Result.b.Y);
end;
// ALB -> leftmost item where X >= AXMin, or Count if no such item
// ALB -> rightmost item where X <= AXMax, or -1 if no such item
// If the source is sorted, performs binary search. Otherwise, skips NaNs.
procedure TCustomChartSource.FindBounds(
AXMin, AXMax: Double; out ALB, AUB: Integer);
@ -690,10 +693,10 @@ begin
end
else begin
ALB := 0;
while (ALB < Count) and (IsNan(Item[ALB]^.X) or (Item[ALB]^.X < AXMin)) do
while (ALB < Count) and (NumberOr(Item[ALB]^.X, AXMin - 1) < AXMin) do
Inc(ALB);
AUB := Count - 1;
while (AUB >= 0) and (IsNan(Item[AUB]^.X) or (Item[AUB]^.X > AXMax)) do
while (AUB >= 0) and (NumberOr(Item[AUB]^.X, AXMax + 1) > AXMax) do
Dec(AUB);
end;
end;
@ -904,8 +907,7 @@ begin
FValuesTotal := 0;
for i := 0 to Count - 1 do
with Item[i]^ do
if not IsNan(Y) then
FValuesTotal += Y;
FValuesTotal += NumberOr(Y);
FValuesTotalIsValid := true;
Result := FValuesTotal;
end;