Skip to content

Chart shrinking uncontrollably on browser zoom #11089

Open
@ghost

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

LeeLenaleee commented on Jan 25, 2023

@LeeLenaleee
Collaborator

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

ghost commented on Jan 25, 2023

@ghost

Bar Chart Border Radius _ Chart js - Google Chrome 2023-01-25 08-21-39

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

fly74 commented on Jan 26, 2023

@fly74

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

dangreen commented on Jan 27, 2023

@dangreen
Collaborator

@TrevorThiessen57 @fly74 Hi. Could you please share OS and browser versions?

fly74

fly74 commented on Jan 27, 2023

@fly74

@TrevorThiessen57 Sure, Windows 11 latest updates and Edge Version 109.0.1518.69.

ghost

ghost commented on Jan 27, 2023

@ghost

@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

dangreen commented on Jan 27, 2023

@dangreen
Collaborator

@fly74 @TrevorThiessen57 Could you also share screen resolution?

ghost

ghost commented on Jan 27, 2023

@ghost

@dangreen 3840 x 2160

fly74

fly74 commented on Jan 27, 2023

@fly74

@fly74 @TrevorThiessen57 Could you also share screen resolution?

3840x2160 (4K)

gbaron

gbaron commented on Jan 28, 2023

@gbaron
Contributor

I don't have access to a screen with that resolution. Anyone knows of a trick to simulate that?

fly74

fly74 commented on Jan 28, 2023

@fly74

You can use Remote Desktop to another machine and set the resolution via cli. You have then scrollbars in the rdp window.

dangreen

dangreen commented on Jan 28, 2023

@dangreen
Collaborator

@gbaron You can use browserstack.com, but I'm already tried and can't reproduce this bug.

fly74

fly74 commented on Jan 28, 2023

@fly74

It is strange, it only happens when zoom is 116% in my case, 110/125 % works. :/
Maybe a function with round problem ?!?

gbaron

gbaron commented on Jan 28, 2023

@gbaron
Contributor

40 remaining items

violuke

violuke commented on Dec 5, 2023

@violuke

I really hope so 🙏

fly74

fly74 commented on Jan 3, 2024

@fly74

Sorry can't wait any longer. Move on to Grafana. :/

But I'm not angry, I used it for a long time.

abdelouahabb

abdelouahabb commented on Jan 14, 2024

@abdelouahabb

The fix is still being reviewed ?
#11132

Marian-Kechlibar

Marian-Kechlibar commented on Jan 17, 2024

@Marian-Kechlibar

I am experiencing the problem with the latest version of Chart as well.

mnadalin

mnadalin commented on Feb 9, 2024

@mnadalin

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

v6ak commented on Feb 9, 2024

@v6ak

If you want a workaround, look at #11224 (comment)

jtomaszewski

jtomaszewski commented on Mar 15, 2024

@jtomaszewski

To me a workaround was to force the pixel ratio for charts to 1, by setting the devicePixelRatio: 1 option ( https://www.chartjs.org/docs/latest/configuration/device-pixel-ratio.html ).

Pikamander2

Pikamander2 commented on Sep 20, 2024

@Pikamander2
Contributor

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:

devicePixelRatio: 4,

Related threads for convenience:

Pikamander2

Pikamander2 commented on Sep 20, 2024

@Pikamander2
Contributor

Calling mychart.resize() also reproduces the bad scaling issue.

linusrush

linusrush commented on Apr 9, 2025

@linusrush

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

v6ak commented on Apr 9, 2025

@v6ak

@linusrush For reproducing: Try various zooms on various devices.
For workaround: #11224 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @v6ak@lincolnthree@lukos@dangreen@gbaron

      Issue actions

        Chart shrinking uncontrollably on browser zoom · Issue #11089 · chartjs/Chart.js