TAChart: Add function TChartAxis.MeasureLabelSize based on code by forum user piola (https://forum.lazarus.freepascal.org/index.php/topic,46243.0.html).

git-svn-id: trunk@61690 -
This commit is contained in:
wp 2019-08-13 21:35:46 +00:00
parent 90a7301300
commit 57dd9caaa1

View File

@ -160,6 +160,7 @@ type
function IsVertical: Boolean; inline;
procedure Measure(
const AExtent: TDoubleRect; var AMeasureData: TChartAxisGroup);
function MeasureLabelSize(ADrawer: IChartDrawer): Integer;
function PositionToCoord(const ARect: TRect): Integer;
procedure PrepareHelper(
ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
@ -875,6 +876,19 @@ begin
end;
end;
function TChartAxis.MeasureLabelSize(ADrawer: IChartDrawer): Integer;
var
sz: Integer;
mv: TChartValueTextArray = nil;
i: Integer;
begin
SetLength(mv, ValueCount);
for i := 0 to ValueCount - 1 do
mv[i] := Value[i];
sz := Marks.Measure(ADrawer, not IsVertical, TickLength, mv);
Result := round(sz);
end;
function TChartAxis.PositionIsStored: Boolean;
begin
Result := not SameValue(Position, 0.0);