mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 00:59:25 +02:00
TAChart: Fix TAChartExtentLink ignoring the size of the axis title.
git-svn-id: trunk@64909 -
This commit is contained in:
parent
8c91f78ac6
commit
b2fec33aad
@ -167,6 +167,7 @@ type
|
|||||||
procedure Measure(const AExtent: TDoubleRect; const AClipRect: TRect;
|
procedure Measure(const AExtent: TDoubleRect; const AClipRect: TRect;
|
||||||
var AMeasureData: TChartAxisGroup);
|
var AMeasureData: TChartAxisGroup);
|
||||||
function MeasureLabelSize(ADrawer: IChartDrawer): Integer;
|
function MeasureLabelSize(ADrawer: IChartDrawer): Integer;
|
||||||
|
function MeasureTitleSize(ADrawer: IChartDrawer): Integer;
|
||||||
function PositionToCoord(const ARect: TRect): Integer;
|
function PositionToCoord(const ARect: TRect): Integer;
|
||||||
procedure PrepareHelper(
|
procedure PrepareHelper(
|
||||||
ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
|
ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
|
||||||
@ -924,6 +925,14 @@ begin
|
|||||||
Result := round(sz / ADrawer.Scale(1));
|
Result := round(sz / ADrawer.Scale(1));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TChartAxis.MeasureTitleSize(ADrawer: IChartDrawer): Integer;
|
||||||
|
var
|
||||||
|
sz: TSize;
|
||||||
|
begin
|
||||||
|
sz := Title.MeasureLabel(ADrawer, GetRealTitle);
|
||||||
|
Result := IfThen(IsVertical, sz.CX, sz.CY);
|
||||||
|
end;
|
||||||
|
|
||||||
function TChartAxis.PositionIsStored: Boolean;
|
function TChartAxis.PositionIsStored: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := not SameValue(Position, 0.0);
|
Result := not SameValue(Position, 0.0);
|
||||||
|
@ -63,7 +63,8 @@ procedure Register;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Math, TAGeometry, TAChartAxis;
|
SysUtils, Math, Types,
|
||||||
|
TAGeometry, TAChartAxis;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
@ -155,13 +156,15 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Note: ignores several axes on the same chart side
|
// Note: ignores multiple axes on the same chart side
|
||||||
procedure TChartExtentLink.DoAlignSides;
|
procedure TChartExtentLink.DoAlignSides;
|
||||||
var
|
var
|
||||||
c: TCollectionItem;
|
c: TCollectionItem;
|
||||||
ch: TChart;
|
ch: TChart;
|
||||||
labelSize: array[TChartAxisAlignment] of Integer = (0, 0, 0, 0);
|
|
||||||
sideUsed: array[TChartAxisAlignment] of boolean = (false, false, false, false);
|
sideUsed: array[TChartAxisAlignment] of boolean = (false, false, false, false);
|
||||||
|
maxLabelSize: array[TChartAxisAlignment] of Integer = (0, 0, 0, 0);
|
||||||
|
maxTitleSize: array[TChartAxisAlignment] of Integer = (0, 0, 0, 0);
|
||||||
|
titleSize: Integer;
|
||||||
al: TChartAxisAlignment;
|
al: TChartAxisAlignment;
|
||||||
axis: TChartAxis;
|
axis: TChartAxis;
|
||||||
begin
|
begin
|
||||||
@ -170,10 +173,13 @@ begin
|
|||||||
FillChar(sideUsed, SizeOf(sideUsed), 0);
|
FillChar(sideUsed, SizeOf(sideUsed), 0);
|
||||||
for al in TChartAxisAlignment do
|
for al in TChartAxisAlignment do
|
||||||
if (al in FAlignsides) and not sideUsed[al] then begin
|
if (al in FAlignsides) and not sideUsed[al] then begin
|
||||||
sideUsed[al] := true;
|
sideUsed[al] := true; // avoid using another axis on the same side
|
||||||
axis := ch.AxisList.GetAxisByAlign(al);
|
axis := ch.AxisList.GetAxisByAlign(al);
|
||||||
if axis <> nil then
|
if axis <> nil then
|
||||||
labelsize[al] := Max(labelsize[al], axis.MeasureLabelSize(ch.Drawer));
|
begin
|
||||||
|
maxTitleSize[al] := axis.MeasureTitleSize(ch.Drawer);
|
||||||
|
maxLabelSize[al] := Max(maxLabelSize[al], axis.MeasureLabelSize(ch.Drawer));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -186,8 +192,10 @@ begin
|
|||||||
if (al in FAlignSides) and not sideUsed[al] then
|
if (al in FAlignSides) and not sideUsed[al] then
|
||||||
sideUsed[al] := true;
|
sideUsed[al] := true;
|
||||||
if sideUsed[al] then
|
if sideUsed[al] then
|
||||||
axis.labelSize := labelSize[al]
|
begin
|
||||||
else
|
titleSize := axis.MeasureTitleSize(ch.Drawer);
|
||||||
|
axis.LabelSize := maxTitleSize[al] + maxLabelSize[al] - titleSize;
|
||||||
|
end else
|
||||||
axis.LabelSize := 0;
|
axis.LabelSize := 0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user