Skip to content
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

Charts Shrinking on Page Load #10932

Closed
MichaelCropper opened this issue Dec 1, 2022 · 15 comments
Closed

Charts Shrinking on Page Load #10932

MichaelCropper opened this issue Dec 1, 2022 · 15 comments

Comments

@MichaelCropper
Copy link

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 <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

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

@LeeLenaleee
Copy link
Collaborator

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

@jonellwood
Copy link

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
Copy link

@MichaelCropper By using <script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1"></script> in the head I was able to stop the issue. Not a fix, but its something.

@MichaelCropper
Copy link
Author

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.

@LeeLenaleee
Copy link
Collaborator

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

@dangreen
Copy link
Collaborator

dangreen commented Dec 2, 2022

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

@jonellwood
Copy link

@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.

@MichaelCropper
Copy link
Author

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.

@gbaron
Copy link
Contributor

gbaron commented Dec 17, 2022

Should be fixed in v4.1.1

@MichaelCropper
Copy link
Author

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

@simPod
Copy link

simPod commented Dec 19, 2022

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

@gbaron
Copy link
Contributor

gbaron commented Dec 19, 2022

@simPod could you please post a reproducible sample?

@kurkle
Copy link
Member

kurkle commented Dec 19, 2022

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>

@MichaelCropper
Copy link
Author

@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/chart.js@4.1.1"></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)

@jonellwood
Copy link

jonellwood commented Dec 22, 2022 via email

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

No branches or pull requests

8 participants