TAChart: Improved alignment of legend text when single- and multi-line legend items are mixed.

This commit is contained in:
wp_xyz 2023-12-15 15:44:40 +01:00
parent 33801729a2
commit 0933dadcaf

View File

@ -409,17 +409,19 @@ end;
procedure TLegendItem.Draw(ADrawer: IChartDrawer; const ARect: TRect); procedure TLegendItem.Draw(ADrawer: IChartDrawer; const ARect: TRect);
var var
symTextSpc: Integer; symTextSpc: Integer;
P: TPoint;
begin begin
symTextSpc := ADrawer.Scale(SYMBOL_TEXT_SPACING); symTextSpc := ADrawer.Scale(SYMBOL_TEXT_SPACING);
P := ADrawer.TextExtent(FText, FTextFormat);
if ADrawer.GetRightToLeft then if ADrawer.GetRightToLeft then
ADrawer.TextOut. ADrawer.TextOut.
TextFormat(FTextFormat). TextFormat(FTextFormat).
Pos(ARect.Left - symTextSpc - ADrawer.TextExtent(FText, FTextFormat).X, ARect.Top). Pos(ARect.Left - symTextSpc - P.X, (ARect.Top + ARect.Bottom - P.Y) div 2).
Text(FText).Done Text(FText).Done
else else
ADrawer.TextOut. ADrawer.TextOut.
TextFormat(FTextFormat). TextFormat(FTextFormat).
Pos(ARect.Right + symTextSpc, ARect.Top). Pos(ARect.Right + symTextSpc, (ARect.Top + ARect.Bottom - P.Y) div 2).
Text(FText).Done; Text(FText).Done;
end; end;