-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chart shrinking uncontrollably on browser zoom #11089
Comments
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? |
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. |
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. |
@TrevorThiessen57 @fly74 Hi. Could you please share OS and browser versions? |
@TrevorThiessen57 Sure, Windows 11 latest updates and Edge Version 109.0.1518.69. |
@dangreen Windows 10 Pro 64-bit Version 21H2 OS build 19044.1645, and Google Chrome Version 109.0.5414.120 (Official Build) (64-bit) |
@fly74 @TrevorThiessen57 Could you also share screen resolution? |
@dangreen 3840 x 2160 |
3840x2160 (4K) |
I don't have access to a screen with that resolution. Anyone knows of a trick to simulate that? |
You can use Remote Desktop to another machine and set the resolution via cli. You have then scrollbars in the rdp window. |
@gbaron You can use browserstack.com, but I'm already tried and can't reproduce this bug. |
It is strange, it only happens when zoom is 116% in my case, 110/125 % works. :/ |
Could you please share what is the value of Window.devicePixelRatio when
zoom is 116%?
…On Sat, Jan 28, 2023 at 13:30 fly74 ***@***.***> wrote:
It is strange, it only happens when zoom is 116% in my case, 110/125 %
works. :/
Maybe a function with round problem ?!?
—
Reply to this email directly, view it on GitHub
<#11089 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAICJ3E7EYWQR5TV2OOT4ELWUVQSPANCNFSM6AAAAAAUFGGMGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
How can I get the Window.devicePixelRatio? |
I can easily reproduce this on a mac with chart.js 4.1.0, but with 4.2.0 I can't. Played around with a lot of different display settings. But with mac it seems I can only get 1 or 2 as the "base" devicePixelRatio on screens, while in windows it can be something like 1.25 etc |
Open the Developer Tools, then choose the Console and type
On my MacBookPro, using an external display and Zoom %110 I'm asking because previously, the root cause was mishandling these non-integer values. I'm not sure if this is the case now. |
Thank you; I ran some tests but unfortunately, I couldn't reproduce the issue. How do you set the zoom level to 116%? I only see 110% and 125%... |
It seems 116% will only be offered when the resolution is 4k/200%dpi. But I found an edge extension with this I can reproduce the behavior at any resolution with 116% zoom.
|
Thank you. I'm now also able to reproduce the issue. The simplest way would be to set a It is probably a rounding issue. |
I am able to reproduce it on Chrome too using "non-standard" zoom levels (i.e 117%) Here is what I'm seeing:
Then, the code below will check if the container's height is large enough. If it isn't, it will set the height to the container height (the width is also updated). Chart.js/src/helpers/helpers.dom.ts Line 202 in 23e8f7d
After the chart size is updated the browser will fire the ResizeObserver again. However, the container height is slightly less than the chart height (when zoom is active). For example, when setting the chart height to be At the moment I can't think of an elegant fix. |
@gbaron Nice analysis, but what is the difference to v3.9.1 were it works? |
@gbaron Maybe just round values from resize observer ? |
@gbaron I don't really know if something is happen with this issue, but Chart.js v4.2.1 don't fix it. |
@gbaron Can you provide an umd dist file for some tests? |
I've tested the 4.3.0 it is not fixed. @gbaron |
This happens to me with 4.3.0. Settings that produce effect: It doesn't happen if I change the scaling in chrome or in the windows settings to something other than above... |
That's what I said. The fix ist not in the official release. |
Would love to see this included in the official release. Signing up for notifications. |
What are the blockers to releasing this fix? ( #11132 ) Also, what is the any workaround until it is released? |
Thank you for your reply. |
Is it fixed in 4.3.1? |
I am still experiencing this with 4.3 |
options={{ responsive: true, maintainAspectRatio: false }} <-- these options solved my issue |
@avisek-official But doesn't that mean the chart will no longer keep its aspect ratio if proportions go askew? |
@lincolnthree I can't say this a fix for the issue, but it worked for me. Try it once in your project too and test anything breaks in any resolution. In my case it didn't break anytime with any data. |
Still experiencing this in 4.3.3, any fixes expected anytime soon? |
Any new for this issue in the 4.4.1 release ? |
I really hope so 🙏 |
Sorry can't wait any longer. Move on to Grafana. :/ But I'm not angry, I used it for a long time. |
The fix is still being reviewed ? |
I am experiencing the problem with the latest version of Chart as well. |
Version 4.4.1 and the problem is still there. |
If you want a workaround, look at #11224 (comment) |
To me a workaround was to force the pixel ratio for charts to |
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
Related threads for convenience:
|
Calling |
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
The text was updated successfully, but these errors were encountered: