
Description
Expected behavior
I expect the chart canvas to remain an appropriate size when changing the zoom in the browser (Ctrl + Mousewheel).
Current behavior
The chart initially renders correctly, but then slowly shrinks toward its top-left corner until it disappears, then re-renders at its initial size. This loop repeats indefinitely.
Reproducible sample
https://codepen.io/leelenaleee/pen/WNyJXEe
Optional extra steps/info to reproduce
To reproduce, change the browser zoom to 90% (Ctrl + Mousewheel down).
The chart behavior is different at various zoom levels. At 110% zoom, for example, it only shrinks to a certain point and then stops.
Note that this bug is also active on the chart.js documentation site on every chart example.
This bug does not happen in Firefox 109.0 (64-bit), but it does happen in Google Chrome Version 109.0.5414.75 (Official Build) (64-bit).
Possible solution
No response
Context
No response
chart.js version
v4.2.0
Browser name and version
Google Chrome Version 109.0.5414.75 (Official Build) (64-bit)
Link to your project
No response
Activity
LeeLenaleee commentedon Jan 25, 2023
Souds like a duplicate of #10932 which was already fixed and should not happen in this version, I also don't see the behaviour you specified in this version.
Are you sure you are using v4.2.0?
ghost commentedon Jan 25, 2023
This gif shows the issue I mentioned. It is on the chart.js documentation site. I am assuming the site would be using the latest version of chart.js, and the documentation indicates it is v4.2.0 (visible in the gif). The site is opened using Google Chrome, at 90% zoom.
I reviewed #10932 and it looks like it is exactly this problem.
From what I've gathered, it may be an issue isolated to the combination of a Windows OS and Google Chrome browser. In particular, someone else running Linux does not have the same issue on their Chrome browser, but it does happen on other Windows machines. As I mentioned earlier as well, the behavior does not happen when I try to reproduce it on Firefox.
To be thorough, I double-checked the chart.js version in my project. It was at v4.1.2, which has now been upgraded to v4.2.0, but the issue remains. Considering the example I shared in the gif, however, I don't think my project setup is relevant to the issue.
fly74 commentedon Jan 26, 2023
Same for me in 4.2.0 with browser zoom is set to 116%. It zooms to zero and again when the mouse lay over the chart. I'm using the umd variant.
dangreen commentedon Jan 27, 2023
@TrevorThiessen57 @fly74 Hi. Could you please share OS and browser versions?
fly74 commentedon Jan 27, 2023
@TrevorThiessen57 Sure, Windows 11 latest updates and Edge Version 109.0.1518.69.
ghost commentedon Jan 27, 2023
@dangreen Windows 10 Pro 64-bit Version 21H2 OS build 19044.1645, and Google Chrome Version 109.0.5414.120 (Official Build) (64-bit)
dangreen commentedon Jan 27, 2023
@fly74 @TrevorThiessen57 Could you also share screen resolution?
ghost commentedon Jan 27, 2023
@dangreen 3840 x 2160
fly74 commentedon Jan 27, 2023
3840x2160 (4K)
gbaron commentedon Jan 28, 2023
I don't have access to a screen with that resolution. Anyone knows of a trick to simulate that?
fly74 commentedon Jan 28, 2023
You can use Remote Desktop to another machine and set the resolution via cli. You have then scrollbars in the rdp window.
dangreen commentedon Jan 28, 2023
@gbaron You can use browserstack.com, but I'm already tried and can't reproduce this bug.
fly74 commentedon Jan 28, 2023
It is strange, it only happens when zoom is 116% in my case, 110/125 % works. :/
Maybe a function with round problem ?!?
gbaron commentedon Jan 28, 2023
40 remaining items
violuke commentedon Dec 5, 2023
I really hope so 🙏
fly74 commentedon Jan 3, 2024
Sorry can't wait any longer. Move on to Grafana. :/
But I'm not angry, I used it for a long time.
abdelouahabb commentedon Jan 14, 2024
The fix is still being reviewed ?
#11132
Marian-Kechlibar commentedon Jan 17, 2024
I am experiencing the problem with the latest version of Chart as well.
mnadalin commentedon Feb 9, 2024
Version 4.4.1 and the problem is still there.
Disabling
maintainAspectRatio
it actually works. However, loading the page at 25% and zooming to 100% produces a way-too-blurry Chart. Not an option to me.v6ak commentedon Feb 9, 2024
If you want a workaround, look at #11224 (comment)
jtomaszewski commentedon Mar 15, 2024
To me a workaround was to force the pixel ratio for charts to
1
, by setting thedevicePixelRatio: 1
option ( https://www.chartjs.org/docs/latest/configuration/device-pixel-ratio.html ).Pikamander2 commentedon Sep 20, 2024
We were having a similar issue where opening or closing Chrome's dev console was causing the graph to visually break.
We were able to resolve it by removing this line from
options
:Related threads for convenience:
Pikamander2 commentedon Sep 20, 2024
Calling
mychart.resize()
also reproduces the bad scaling issue.linusrush commentedon Apr 9, 2025
Any updates on this? I have some users running into this issue but cant reproduce it myself. Is the fix mentioned planned to be merged any time soon?
v6ak commentedon Apr 9, 2025
@linusrush For reproducing: Try various zooms on various devices.
For workaround: #11224 (comment)