Chart.js
Chart.js copied to clipboard
Wrong legend hitbox area when using textAlign right/center
Expected behavior
The entire legend item text should be clickable when centering or right-aligning the text.
For example:
Current behavior
The clickable area of the legend item is smaller than it should be, as if the text were always left-aligned.
Also occurs in RTL mode:
Reproducible sample
https://codepen.io/adrianbrs/pen/KwwzRja
Optional extra steps/info to reproduce
No response
Possible solution
No response
Context
No response
chart.js version
v4.4.9
Browser name and version
Google Chrome 135.0.7049.95 (64 bits)
Link to your project
No response
hi @adrianbrs
just change this
` legend.legendHitBoxes.forEach((box) => {
ctx.strokeRect(box.left, box.top, 100, box.height);//change the box.width to 100
});`