From 23ce9e129fbcb712aba13e1470ae888f29845cf4 Mon Sep 17 00:00:00 2001 From: Jonathan Fulton Date: Sat, 31 Jan 2026 18:55:50 -0500 Subject: [PATCH] fix(legend): respect horizontal padding for legend title The legend title's horizontal paddings (left/right) were being ignored when calculating the x position. Only vertical padding was used. This fix accounts for titlePadding.left and titlePadding.right when calculating the title x position using _alignStartEnd. Fixes #12066 --- src/plugins/plugin.legend.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 6ed99413536..4c4d943521f 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -474,8 +474,8 @@ export class Legend extends Element { } // Now that we know the left edge of the inner legend box, compute the correct - // X coordinate from the title alignment - const x = _alignStartEnd(position, left, left + maxWidth); + // X coordinate from the title alignment, accounting for horizontal padding + const x = _alignStartEnd(position, left + titlePadding.left, left + maxWidth - titlePadding.right); // Canvas setup ctx.textAlign = rtlHelper.textAlign(_toLeftRightCenter(position));