From 5cb240ac360f92c580f0cbd81e11ec0ece3538a3 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Wed, 22 Nov 2023 18:38:16 +0100 Subject: [PATCH] TAChart: Make sure that TAreasSeries is clipped at the plotarea boundaries. --- components/tachart/taseries.pas | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/components/tachart/taseries.pas b/components/tachart/taseries.pas index dd644dd417..3f53ed2dc6 100644 --- a/components/tachart/taseries.pas +++ b/components/tachart/taseries.pas @@ -2308,28 +2308,33 @@ begin scaled_depth := ADrawer.Scale(Depth); SetLength(pts, Length(FGraphPoints) * 4 + 4); - CollectMissing; - if Length(missing) = 0 then - DrawSegment(0, High(FGraphPoints)) - else begin - j := 0; - k := 0; - while j < Length(missing) do begin - while (missing[j] = k) do begin - inc(k); + ADrawer.ClippingStart(ParentChart.ClipRect); + try + CollectMissing; + if Length(missing) = 0 then + DrawSegment(0, High(FGraphPoints)) + else begin + j := 0; + k := 0; + while j < Length(missing) do begin + while (missing[j] = k) do begin + inc(k); + inc(j); + if j = Length(missing) then + break; + end; + if j <= High(missing) then begin + DrawSegment(k, missing[j]-1); + k := missing[j]+1; + end else + DrawSegment(k, High(FGraphPoints)); inc(j); - if j = Length(missing) then - break; end; - if j <= High(missing) then begin - DrawSegment(k, missing[j]-1); - k := missing[j]+1; - end else + if k <= High(FGraphPoints) then DrawSegment(k, High(FGraphPoints)); - inc(j); end; - if k <= High(FGraphPoints) then - DrawSegment(k, High(FGraphPoints)); + finally + ADrawer.ClippingStop; end; DrawLabels(ADrawer);