]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Bug: Avoid updating Chart when `responsive: true` and Chart is hidden. (#5172)
authorjcopperfield <33193571+jcopperfield@users.noreply.github.com>
Wed, 23 May 2018 01:11:28 +0000 (03:11 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Wed, 23 May 2018 01:11:28 +0000 (21:11 -0400)
* Bug: Avoid updating Chart when `responsive: true` and Chart is hidden.

* Prevent `drawing` when width/height is invalid.

src/core/core.controller.js

index d27967d39413922325c3a81eca4b2f7040d78c37..3445cb51801fe5d6781a28037e7215bf67c92178 100644 (file)
@@ -181,7 +181,7 @@ module.exports = function(Chart) {
                        // the canvas render width and height will be casted to integers so make sure that
                        // the canvas display style uses the same integer values to avoid blurring effect.
 
-                       // Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased
+                       // Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collapsed
                        var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas)));
                        var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)));
 
@@ -561,6 +561,10 @@ module.exports = function(Chart) {
 
                        me.transition(easingValue);
 
+                       if (me.width <= 0 || me.height <= 0) {
+                               return;
+                       }
+
                        if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) {
                                return;
                        }