TAChart: Fix of TChart.IsPointInViewPort and axis labels if all data values are < 1E-12.

git-svn-id: trunk@60276 -
This commit is contained in:
wp 2019-02-02 11:03:36 +00:00
parent 759d2cc725
commit a67d32bace
3 changed files with 11 additions and 5 deletions

View File

@ -34,6 +34,7 @@ const
clTAColor = $20000000; // = clDefault, but avoiding dependency on Graphics
DEFAULT_FONT_SIZE = 10;
DEFAULT_EPSILON = 1e-6;
RANGE_EPSILON = 1e-12;
// Replacement for +INF, Canvas does not work correctly when MaxInt is used.
// Any screen coordinates are clipped to range -MAX_COORD ... MAX_COORD.

View File

@ -381,7 +381,7 @@ const
// Arbitrary limit to prevent hangup/OOM in case of bug in CalculateIntervals.
MAX_COUNT = 10000;
var
start, step, m: Double;
start, step, m, eps: Double;
i: Integer;
begin
if AParams.FMin >= AParams.FMax then exit;
@ -394,10 +394,11 @@ begin
EnsureOrder(AParams.FMin, AParams.FMax);
CalculateIntervals(AParams, start, step);
if step <= 0 then exit;
eps := (AParams.FMax - AParams.FMin) * RANGE_EPSILON;
m := start;
SetLength(AValues, Trunc(Min((AParams.FMax - m) / step + 2, MAX_COUNT)));
for i := 0 to High(AValues) do begin
if IsZero(m) then
if IsZero(m, eps) then
m := 0;
AValues[i].FValue := m;
if m > AParams.FMax then begin

View File

@ -28,7 +28,8 @@ function InRangeUlps(AX, ALo, AHi: Double; AMaxUlps: Word): Boolean;
function SafeInfinity: Double; inline;
function SafeInRange(AValue, ABound1, ABound2: Double): Boolean;
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double): Boolean;
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double;
AEpsilon: Double = 0.0): Boolean;
function SafeMin(A, B: Double): Double;
function SafeNan: Double; inline;
function SafeEqual(A, B: Double): Boolean;
@ -160,11 +161,14 @@ begin
Result := InRange(AValue, ABound1, ABound2);
end;
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double): Boolean;
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double;
AEpsilon: Double = 0.0): Boolean;
begin
EnsureOrder(ABound1, ABound2);
if AEpsilon = 0.0 then
AEpsilon := RANGE_EPSILON * (ABound2 - ABound1);
Result := InRange(AValue, ABound1, ABound2) or
SameValue(AValue, ABound1) or SameValue(AValue, ABound2);
SameValue(AValue, ABound1, AEpsilon) or SameValue(AValue, ABound2, AEpsilon);
end;
function SafeMin(A, B: Double): Double;