Skip to content

fix(legend): respect horizontal padding for legend title#12187

Open
jonathan-fulton wants to merge 1 commit intochartjs:masterfrom
jonathan-fulton:fix/12066-legend-title-padding
Open

fix(legend): respect horizontal padding for legend title#12187
jonathan-fulton wants to merge 1 commit intochartjs:masterfrom
jonathan-fulton:fix/12066-legend-title-padding

Conversation

@jonathan-fulton
Copy link

Summary

Fixes #12066

The legend title was not respecting the horizontal padding (left and right) specified in titlePadding. The title would be positioned without accounting for these padding values, causing visual misalignment.

Changes

  • Updated the x-coordinate calculation in plugin.legend.js to account for titlePadding.left and titlePadding.right when computing the title alignment position

Before

const x = _alignStartEnd(position, left, left + maxWidth);

After

const x = _alignStartEnd(position, left + titlePadding.left, left + maxWidth - titlePadding.right);

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 chartjs#12066
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legend title horizontal paddings doesn't work

1 participant