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