Skip to content

docs: design the legend rework - #12482

Merged
kurkle merged 4 commits into
chartjs:masterfrom
kurkle:design/rework-legend
Nov 24, 2026
Merged

kurkle merged 4 commits into
chartjs:masterfrom
kurkle:design/rework-legend

Conversation

@kurkle

@kurkle kurkle commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

The legend works out its layout three times (when it is fitted, when its hit boxes are placed, and while it is drawn), and items go missing, overlap, crash or cannot be clicked wherever those disagree. This design makes the hit boxes the one layout that hit-testing and drawing read, lands the open legend fixes first, and fixes the click, hover, hide and typing problems around the legend.

Design only: openspec/changes/rework-legend/ (proposal, specs, design with the pieces table, tasks). No code.

Pieces, in order

Patch releases (4.6.x):

Piece Builds Completes
P1 #12346: drawing follows the hit boxes (supersedes #12205, its test moves in) #12345, #12196
P2 #12330: the title's width counts #11850
P3 #12187: the title's padding moves it #12066
P4 #12316: hit boxes cover aligned text, columns don't overlap #12067
P5 only arrays are multi-line labels #11594
P6 one press runs onClick once (legend and chart) #11538
P7 the legend callbacks don't infer the chart type #10442, #11666
P8 legend docs #12144, #11877, #10624, #10384
P19 refactor: the legend plugin in TypeScript (built after P8, before P9)
P9 refactor: drawing reads the hit boxes
P10 rows as tall as their tallest item #11824
P11 wrap within maxWidth / maxHeight #11805
P12 hidden data is not active #10882
P13 the pointer's active elements end outside the chart area (supersedes #11849) #11801

4.7.0:

Piece Builds Completes
P14 labels.boxYOffset (#12242 renamed) #11884
P15 LegendItem.textDecoration, labels.decorationWidth #11692, #11725
P16 legend padding #11740, #11280
P17 hidden state follows replaced labels #10120
P18 hidden bars leave the value axis

Parallel work and waits

Part of #12345, #12196, #11850, #12066, #11280, #12067, #11594, #11538, #10442, #11666, #12144, #11877, #10624, #10384, #11824, #11805, #10882, #11801, #11884, #11692, #11725, #11571, #11941, #11740, #10120 and #11949. design.md also accounts for every other open legend issue: fixed on master, fixed by an open PR (#11978 by #12331), possible today, or a non-goal.

@kurkle
kurkle marked this pull request as ready for review November 24, 2026 17:25
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 362 kB

ℹ️ View Unchanged
Filename Size
dist/chart.cjs 81.5 kB
dist/chart.js 81.7 kB
dist/chart.umd.js 72.1 kB
dist/chart.umd.min.js 72.1 kB
dist/chunks/helpers.dataset.cjs 25.7 kB
dist/chunks/helpers.dataset.js 25.5 kB
dist/helpers.cjs 1.52 kB
dist/helpers.js 1.33 kB

compressed-size-action

@netlify

netlify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for chartjs-docs canceled.

Name Link
🔨 Latest commit 997bc2d
🔍 Latest deploy log https://app.netlify.com/projects/chartjs-docs/deploys/6b05d488e3f07916e7c3ef68

@etimberg

Copy link
Copy Markdown
Member

@kurkle what do you think about converting the legend plugin to typescript before or after this work?

@kurkle

kurkle commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@kurkle what do you think about converting the legend plugin to typescript before or after this work?

Good question. Probably during. I'll add it to the plan.

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.

2 participants