From 25e81e629654540f7a57be5a2599bc58d1922b6d Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 27 Jun 2023 21:04:18 +0000 Subject: [PATCH] NiceChart: Activate clipping at the chart box boundaries. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8862 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/nicechart/source/NiceChart.pas | 52 ++++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/components/nicechart/source/NiceChart.pas b/components/nicechart/source/NiceChart.pas index c1475410f..04a2648c6 100644 --- a/components/nicechart/source/NiceChart.pas +++ b/components/nicechart/source/NiceChart.pas @@ -1471,37 +1471,49 @@ begin AutoColors(ACanvas, Index, sr.FKind = skBar); with ACanvas do begin + ClipRect := RcChart; if (sr.FKind = skBar) then begin - Pen.Width := 1; - for x := 0 to Sr.Values.Count-1 do - begin - P := PXYInfo(Sr.Values[x]); - Rectangle(P^.Rc); - end; - end else - begin - if (sr.FKind = skLine) then - begin - Pen.Width := sr.LineWidth; + Clipping := true; + try + Pen.Width := 1; for x := 0 to Sr.Values.Count-1 do begin P := PXYInfo(Sr.Values[x]); - if (x = 0) - then MoveTo(P^.Px, P^.Py) - else LineTo(P^.Px, P^.Py); + Rectangle(P^.Rc); end; - end else - if (sr.FKind = skSmooth) then - begin - Pen.Width := sr.LineWidth; - sr.Spline.Draw(ACanvas); + finally + Clipping := false; + end; + end else + begin + Clipping := true; + try + if (sr.FKind = skLine) then + begin + Pen.Width := sr.LineWidth; + for x := 0 to Sr.Values.Count-1 do + begin + P := PXYInfo(Sr.Values[x]); + if (x = 0) + then MoveTo(P^.Px, P^.Py) + else LineTo(P^.Px, P^.Py); + end; + end else + if (sr.FKind = skSmooth) then + begin + Pen.Width := sr.LineWidth; + sr.Spline.Draw(ACanvas); + end; + finally + Clipping := false; end; Pen.Width := 1; for x := 0 to Sr.Values.Count-1 do begin P := PXYInfo(Sr.Values[x]); - Marker(ACanvas, P^.Px, P^.Py, MarkSize); + if PtInRect(RcChart, Point(P^.Px, P^.Py)) then + Marker(ACanvas, P^.Px, P^.Py, MarkSize); end; end; if FShowLegend then