Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Charts Shrinking on Page Load

Open MichaelCropper opened this issue 2 years ago • 8 comments

Expected behavior

Normality

Current behavior

I know I've not changed anything on my end. All of a sudden various different chart types have been shrinking on page load for no apparent reason.

I'm pulling the JS from

I can't be the only one experiencing this, surely?

The setup I'm working with is basic out of the box ChartJS stuff that has been working fine for years.

Reproducible sample

Optional extra steps/info to reproduce

Possible solution

Context

chart.js version

v4.0.1

Browser name and version

No response

Link to your project

No response

MichaelCropper avatar Dec 01 '22 22:12 MichaelCropper

As per the issue template a reproducable sample is mandatory, please add one.

LeeLenaleee avatar Dec 02 '22 09:12 LeeLenaleee

I am having the same issue. I was able to resolve one chart (bar chart) by adding min-height & min-width values in a style tag for the canvas element. But did not get the same result with a pie chart. I am pulling in data from a local dev database but I will attempt to get recreate on codepen and if I can reproduce the issue there I will post a link in this comment. I am happy to provide a copy of my code - but I am not sure if it would be of value since it references several local resources and is not in production

jonellwood avatar Dec 02 '22 17:12 jonellwood

@MichaelCropper By using in the head I was able to stop the issue. Not a fix, but its something.

jonellwood avatar Dec 02 '22 18:12 jonellwood

Good shout @jonellwood That's solved the issue, just use an older version. Really surprised that this bug hasn't been resolved in hours. I think I first spotted this a couple of weeks ago.

MichaelCropper avatar Dec 02 '22 19:12 MichaelCropper

@MichaelCropper you are welcome to put in a PR if you can resolve the issue that quick

LeeLenaleee avatar Dec 02 '22 19:12 LeeLenaleee

@MichaelCropper Also, we would very much appreciate it if you provide a sandbox with issue reproduction

dangreen avatar Dec 02 '22 19:12 dangreen

@dangreen I tried to get a pen that recreated the issue but alas it worked as expected and I could not recreate it. I will try again later tonight after work to see if I can get you a reproduction of the issue.

jonellwood avatar Dec 02 '22 20:12 jonellwood

I've been having a play to see what is causing this as it is odd. The behaviour that I'm seeing is that the element is shrinking by 1 on a loop when hovering over the chart.

image

Took a lot of playing around and trying things, but found what is causing the issue.

To reproduce;

  1. Open Chrome
  2. CTRL + Scroll Down to get to 90% Zoom
  3. Load page with a chart on (

#2 and #3 doesn't really matter which order you do this in, same issue in both orders

What is really odd that it seems that this issue is only 90% Zoom. Doesn't seem to be impacted on the other zoom levels.

I've also tried on different screen sizes (laptop + second monitor) and doesn't seem to be related to that.

MichaelCropper avatar Dec 02 '22 21:12 MichaelCropper

Should be fixed in v4.1.1

gbaron avatar Dec 17 '22 18:12 gbaron

Good job chaps, I've just tested on v4.1.1 and this look to be fixed now.

MichaelCropper avatar Dec 17 '22 21:12 MichaelCropper

We're still experiencing the issue on 4.4.1. Any way to debug?

simPod avatar Dec 19 '22 16:12 simPod

@simPod could you please post a reproducible sample?

gbaron avatar Dec 19 '22 19:12 gbaron

We're still experiencing the issue on 4.4.1. Any way to debug?

Chart.js need to have a container around the canvas, with nothing else in it. Maybe in your case it does not? <div><chavas id="myChart"></canvas></div>

kurkle avatar Dec 19 '22 19:12 kurkle

@simPod 4.4.1? Time travelling? Sure that is a typo, but if you could confirm what version you are running. Latest version is 4.1.1.

Also, what Web Browser? And what Zoom %?

The basic setup is working for me now in 4.1.1 since the fix with;

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

and

<canvas id="myChart"></canvas>

With the relevant stuff in the script tag for all the chart settings etc. (not shown for ease, copy from the docs)

MichaelCropper avatar Dec 19 '22 20:12 MichaelCropper

Thats great news!

On Sat, Dec 17, 2022 at 4:58 PM MichaelCropper @.***> wrote:

Good job chaps, I've just tested on v4.1.1 and this look to be fixed now.

— Reply to this email directly, view it on GitHub https://github.com/chartjs/Chart.js/issues/10932#issuecomment-1356479824, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO4TKLU7CYNCZ3KMKF2NHTTWNYZPBANCNFSM6AAAAAASRJSNQI . You are receiving this because you were mentioned.Message ID: @.***>

--

Jon Ellwood

jonellwood avatar Dec 22 '22 23:12 jonellwood

Someone help the chartjs is shrinking only in chrome

pitamcclav avatar Jul 13 '24 17:07 pitamcclav

This issue is still not resolved. I am using this link to chartjs:

My chart builds OK on localhost, no weirdness. But when I upload to the server on chrome and have zoom NOT at 100% it shrinks comically over and over. There are no issues on my localhost (browsersync) but the server is MS IIS. I'm seeing it in Chrome today 7/18/2024. Frustrating as I have no control over users browser zoom settings. This is built on Bootstrap5 which has shown no issues aside from this on the same platform.

simonwickes avatar Jul 18 '24 20:07 simonwickes

options: { #maintainAspectRatio: false, responsive: true

when i added the maintainAspectRatio line it stopped though the graphs no longer look at good

pitamcclav avatar Jul 19 '24 08:07 pitamcclav