From aabe4314d5116950b45b3d7e48afe482b6d4e4a7 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Tue, 11 Jan 2022 12:07:20 +0100 Subject: [PATCH] TAChart: Fix missing minor ticks when an axis is inverted by means of a linear axis transform. Issue #39546. (cherry picked from commit b8f2e92f039f04ed5f614c7b95ec971803498089) --- components/tachart/tachartaxis.pas | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/tachart/tachartaxis.pas b/components/tachart/tachartaxis.pas index 92ba8b682c..30211e613a 100644 --- a/components/tachart/tachartaxis.pas +++ b/components/tachart/tachartaxis.pas @@ -574,6 +574,8 @@ procedure TChartAxis.Draw; j: Integer; minorMarks: TChartValueTextArray; m: TChartValueText; + isFlipped: Boolean; + trMin, trMax: Double; begin if IsNan(AMin) or (AMin = AMax) then exit; for j := 0 to Minors.Count - 1 do begin @@ -582,10 +584,15 @@ procedure TChartAxis.Draw; with FHelper.Clone do try FAxis := Minors[j]; + trMin := FAxisTransf(AMin); + trMax := FAxisTransf(AMax); // Only draw minor marks strictly inside the major mark interval. - FValueMin := Max(FAxisTransf(AMin), FValueMin); - FValueMax := Min(FAxisTransf(AMax), FValueMax); - if FValueMax <= FValueMin then + isFlipped := (AMin < AMax) and (trMin > trMax); + FValueMin := Max(trMin, FValueMin); + FValueMax := Min(trMax, FValueMax); + if (not isFlipped and (FValueMax <= FValueMin)) or + (isFlipped and (FValueMax >= FValueMin)) + then continue; ExpandRange(FValueMin, FValueMax, -EPS); FClipRangeDelta := 1;