-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Labels
Description
Expected behavior
Even with a non-standard font, the legend should be centered properly, and clicking on a label should disable the correct dataset.
Current behavior
The legend seems to be positioned based on the wrong font width. Clicking on the right half of the second last label hides the last dataset instead of the second last. After that, the legend is re-centered, now correctly, and the click regions are correct.
Reproducible sample
https://www.borislau.de/chartjs_bug.html
Optional extra steps/info to reproduce
- use a font that's wider than the regular by using
Chart.defaults.font.family = 'Permanent Marker'; - use 100% width/height
- make many and wide labels, so that the error gets obvious
Possible solution
Didn't find a workaround.
Even waiting for document.fonts.ready doesn't help:
window.onload = function() {
document.fonts.ready.then(function() {
var ctx = document.getElementById('chartcanvas').getContext('2d');
window.chart = new Chart(ctx, config);
});
};
Context
I want to make a beautiful chart with the Bitstream Vera font, and I want to be able to hide and show datasets by clicking on the entries in the legend.
chart.js version
v4.3.0
Browser name and version
Firefox, Chrome, Safari