Skip to content

Fix width calculation for multiline vertical legend labels - #12339

Open
Aurantium-47 wants to merge 1 commit into
chartjs:masterfrom
Aurantium-47:fix/multiline-legend-width
Open

Aurantium-47 wants to merge 1 commit into
chartjs:masterfrom
Aurantium-47:fix/multiline-legend-width

Conversation

@Aurantium-47

Copy link
Copy Markdown

A multiline label in a left or right legend can be clipped when its widest line has fewer characters than another line. For example, ['WWW', 'iiiiiiii'] currently reserves less width than 'WWW' alone in a proportional font.

Measure each line and use the largest pixel width for the legend layout and hitbox. The regression tests cover both legend positions and compare against the same chart updated to its widest single line, without hard-coded pixel sizes.

Validation on Windows with Node 24:

  • Both new regression tests fail on the original code; all 79 legend tests pass with the fix.
  • The complete browser suite passes all 1,705 tests in headless Microsoft Edge, including image fixtures.
  • JavaScript/Markdown lint, Rollup builds, declaration generation, TypeScript checks, and all five integration projects pass.

Implemented and validated using OpenAI Codex.

Assisted-by: OpenAI GPT-6 <noreply@openai.com>
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.

1 participant