Chart.js: 1.0.2 - devicePixelRatio causes `responsive:true` to result in the wrong size (growing chart)

Created on 17 Jul 2015  ·  12Comments  ·  Source: chartjs/Chart.js

When the browser has a devicePixelRatio, a CSS height and width are defined on the canvas. The physical height of the element (clientHeight) is determined by this height. When the resize method runs, it updates the canvas.height property to resize the element. If the device's devicePixelRatio is greater than 1, what that means is that the height is set to a value greater than it should be set.

The net result is that resizing the element causes it to grow on each resize event.

blocker won't fix bug

Most helpful comment

I experience this issue in version 2.5.0

All 12 comments

:+1: I am being plagued by the same problem.

Hello, today I am closing all issues that are only affecting version 1 of Chart.js as WONTFIX.

If this issue does affect version 2 as well, I apologize for the error. Please create a test case against Chart.js 2 using on of the below websites and we will be happy to reopen the issue and update its classification:

I experience this issue in version 2.5.0

still exists in 2.7.3

@tiwari-abhishek are you able to share a codepen/jsfiddle that reproduces this issue in 2.7.3?

I'm having a similar issue where my chart grows out of control on page load.
It seems to be related to the generateLegend() function.

https://jsfiddle.net/up9beo1v/58/

I have the same issue @fulldecent chart growing

Same issue, triggered by floating component sibling to the div wrapping the canvas.

FWIW: In my case it I could set "maintainAspectRatio":true to stop the height growing.

For me wrapping with a div classed "relative" helped.

For me wrapping with a div classed "relative" helped.

chartJs has any css class with the relative that is used? I just want to understand why this works.

@TheoOliveira It's part of their documentation: https://www.chartjs.org/docs/latest/general/responsive.html#important-note

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joebirkin picture joebirkin  ·  3Comments

JAIOMP picture JAIOMP  ·  3Comments

lbowers picture lbowers  ·  3Comments

SylarRuby picture SylarRuby  ·  3Comments

lizbanach picture lizbanach  ·  3Comments