mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-02 18:37:38 +01:00
TAChart: Extract TGenericChartMarks.IsLabelHiddenDueToOverlap function
git-svn-id: trunk@25030 -
This commit is contained in:
parent
c2e7239df1
commit
2255790333
@ -571,7 +571,6 @@ procedure TBasicPointSeries.DrawLabels(ACanvas: TCanvas);
|
||||
var
|
||||
labelRect: TRect;
|
||||
center: TPoint;
|
||||
dummy: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
||||
sz: TSize;
|
||||
begin
|
||||
if AText = '' then exit;
|
||||
@ -582,13 +581,7 @@ procedure TBasicPointSeries.DrawLabels(ACanvas: TCanvas);
|
||||
center.Y += OFFSETS[ADir].Y * (Marks.Distance + sz.cy div 2);
|
||||
with center do
|
||||
labelRect := BoundsSize(X - sz.cx div 2, Y - sz.cy div 2, sz);
|
||||
if
|
||||
(Marks.OverlapPolicy = opHideNeighbour) and
|
||||
not IsRectEmpty(FPrevLabelRect) and
|
||||
IntersectRect(dummy, labelRect, FPrevLabelRect)
|
||||
then
|
||||
exit;
|
||||
FPrevLabelRect := labelRect;
|
||||
if Marks.IsLabelHiddenDueToOverlap(FPrevLabelRect, labelRect) then exit;
|
||||
|
||||
// Link between the label and the bar.
|
||||
ACanvas.Pen.Assign(Marks.LinkPen);
|
||||
|
||||
@ -142,6 +142,8 @@ type
|
||||
procedure DrawLabel(
|
||||
ACanvas: TCanvas; const ALabelRect: TRect; const AText: String);
|
||||
function IsMarkLabelsVisible: Boolean;
|
||||
function IsLabelHiddenDueToOverlap(
|
||||
var APrevLabelRect: TRect; const ALabelRect: TRect): Boolean;
|
||||
function MeasureLabel(ACanvas: TCanvas; const AText: String): TSize;
|
||||
|
||||
public
|
||||
@ -464,6 +466,19 @@ begin
|
||||
ACanvas.Clipping := true;
|
||||
end;
|
||||
|
||||
function TGenericChartMarks.IsLabelHiddenDueToOverlap(
|
||||
var APrevLabelRect: TRect; const ALabelRect: TRect): Boolean;
|
||||
var
|
||||
dummy: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
||||
begin
|
||||
Result :=
|
||||
(OverlapPolicy = opHideNeighbour) and
|
||||
not IsRectEmpty(APrevLabelRect) and
|
||||
IntersectRect(dummy, ALabelRect, APrevLabelRect);
|
||||
if not Result then
|
||||
APrevLabelRect := ALabelRect;
|
||||
end;
|
||||
|
||||
function TGenericChartMarks.IsMarginRequired: Boolean;
|
||||
begin
|
||||
Result :=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user