From 6ddc63cdb618a14b95cf44d19bf3aed6484ad34d Mon Sep 17 00:00:00 2001 From: J Copperfield Date: Mon, 22 Jan 2018 16:38:19 +0100 Subject: [PATCH 1/2] Bug: Avoid updating Chart when `responsive: true` and Chart is hidden. --- src/core/core.controller.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index e29a5b0769c..8c7214374fb 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -192,6 +192,10 @@ module.exports = function(Chart) { helpers.retinaScale(me, options.devicePixelRatio); + if (newWidth === 0 || newHeight === 0) { + return; + } + if (!silent) { // Notify any plugins about the resize var newSize = {width: newWidth, height: newHeight}; From e69e2800be15a042c3ccaea971403737d7dbb789 Mon Sep 17 00:00:00 2001 From: J Copperfield Date: Mon, 19 Feb 2018 10:30:28 +0100 Subject: [PATCH 2/2] Prevent `drawing` when width/height is invalid. --- src/core/core.controller.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 8c7214374fb..9666b2bb446 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -177,7 +177,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))); @@ -192,10 +192,6 @@ module.exports = function(Chart) { helpers.retinaScale(me, options.devicePixelRatio); - if (newWidth === 0 || newHeight === 0) { - return; - } - if (!silent) { // Notify any plugins about the resize var newSize = {width: newWidth, height: newHeight}; @@ -561,6 +557,10 @@ module.exports = function(Chart) { me.transition(easingValue); + if (me.width <= 0 || me.height <= 0) { + return; + } + if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) { return; }