From febc06ca63935fb0e3a4dc1a84bc77e4ffd7ccaa Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Tue, 29 Aug 2023 17:39:18 +0200 Subject: [PATCH] TAChart: Fix painting error in 3d-pie series (https://forum.lazarus.freepascal.org/index.php/topic,64437.msg489868.html) --- components/tachart/taradialseries.pas | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/components/tachart/taradialseries.pas b/components/tachart/taradialseries.pas index cb773d7e5a..46c31f21bd 100644 --- a/components/tachart/taradialseries.pas +++ b/components/tachart/taradialseries.pas @@ -47,7 +47,7 @@ type TPieSlice = object FBase: TPoint; - FFlags: Integer; // 1: 1st part, 2: 2nd part of diviced slice + FFlags: Integer; // 1: 1st part, 2: 2nd part of divided slice FLabel: TLabelParams; FOrigIndex: Integer; FPrevAngle, FNextAngle: Double; // in CCW direction @@ -224,13 +224,13 @@ uses TAChartStrConsts, TATypes, TACustomSource, TAGeometry, TAGraph; const - TWO_PI = 2 * pi; - PI_1_2 = pi / 2; - PI_3_2 = (3 / 2) * pi; - PI_1_4 = pi / 4; - PI_3_4 = (3 / 4) * pi; - PI_5_4 = (5 / 4) * pi; - PI_7_4 = (7 / 4) * pi; + TWO_PI = Double(pi) * Double(2.0); // Avoid double/extended issues + PI_1_2 = Double(pi) * Double(0.5); + PI_3_2 = Double(pi) * Double(1.5); + PI_1_4 = Double(pi) * Double(0.25); + PI_3_4 = Double(pi) * Double(0.75); + PI_5_4 = Double(pi) * Double(1.25); + PI_7_4 = Double(pi) * Double(1.75); { TPieSlice } @@ -1037,10 +1037,12 @@ var i, j: Integer; compareFunc: TAngleFunc; begin - SetLength(ASlices{%H-}, Length(FSlices) + 1); + ASlices := nil; + SetLength(ASlices, Length(FSlices) + 1); j := 0; for i:=0 to High(FSlices) do begin - if FSlices[i].Angle >= pi then begin + if FSlices[i].Angle > pi then + begin ASlices[j] := FSlices[i]; ASlices[j].FNextAngle := FSlices[i].CenterAngle; ASlices[j].FFlags := 1; // 1st piece of divided slice