From c97a2a7c7602d83196ec28042ef34264cc03bb07 Mon Sep 17 00:00:00 2001 From: wp Date: Sat, 23 May 2020 21:56:28 +0000 Subject: [PATCH] TAChart: Fix AreaSeries crashing when y of first or last data point is NaN. git-svn-id: trunk@63215 - --- components/tachart/taseries.pas | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/components/tachart/taseries.pas b/components/tachart/taseries.pas index b90c32d412..9b28f3fbdb 100644 --- a/components/tachart/taseries.pas +++ b/components/tachart/taseries.pas @@ -1938,6 +1938,16 @@ var zero: Double; ext, ext2: TDoubleRect; + { Replaces y=NaN at first level by zero if StackedNaN is ReplaceByZero } + procedure FixNaN; + var + i: Integer; + begin + if FStackedNaN = snReplaceByZero then + for i := 0 to High(FGraphPoints) do + if IsNaN(FGraphPoints[i].Y) then FGraphPoints[i].Y := 0.0; + end; + procedure CollectMissingItem(AIndex: Integer); begin missing[numMissing] := AIndex; @@ -1957,15 +1967,12 @@ var if IsNaN(item^.X) then CollectMissingItem(i) else - if FBanded and IsNaN(item^.Y) then + if IsNaN(item^.Y) and ((FStackedNaN = snDoNotDraw) or FBanded) then CollectMissingItem(i) else if FStacked and (FStackedNaN = snDoNotDraw) then - if IsNaN(item^.Y) then - CollectMissingItem(i) - else - for j := 0 to Source.YCount-2 do - if IsNaN(item^.YList[j]) then CollectMissingItem(i); + for j := 0 to Source.YCount - 2 do + if IsNaN(item^.YList[j]) then CollectMissingItem(i); end; SetLength(missing, numMissing); end; @@ -2218,6 +2225,7 @@ begin PrepareGraphPoints(ext, true); if Length(FGraphPoints) = 0 then exit; + FixNaN; if UseZeroLevel then zero := AxisToGraphY(ZeroLevel)