From 727a37b89d3626563c51d2af6f660f6259087ab5 Mon Sep 17 00:00:00 2001 From: Peter-Van-Drunen Date: Thu, 22 Jun 2017 09:13:30 -0400 Subject: [PATCH 1/4] Fixed collapsed elements resize Elements were resizing incorrectly if they were regenerated while collapsed. Added a check to avoid this issue. --- src/core/core.controller.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 93546f56974..f896fab3499 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -169,8 +169,18 @@ 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. - var newWidth = Math.floor(helpers.getMaximumWidth(canvas)); - var newHeight = Math.floor(aspectRatio? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); + + //Default values. Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased + var newWidth = 0; + var newHeight = 0; + + //Avoid issues with the canvas having negative maximum width and/or height due to element being collapsed + if (Math.floor(helpers.getMaximumWidth(canvas)) >= 0) { + newWidth = Math.floor(helpers.getMaximumWidth(canvas)); + } + if (helpers.getMaximumHeight(canvas) >= 0) { + newHeight = Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); + } if (me.width === newWidth && me.height === newHeight) { return; From 9622efd8607b58c63faacaf024a7a8c1299c509f Mon Sep 17 00:00:00 2001 From: Peter-Van-Drunen Date: Thu, 22 Jun 2017 09:52:04 -0400 Subject: [PATCH 2/4] Update core.controller.js --- src/core/core.controller.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index f896fab3499..d06f7f1a0d6 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -170,17 +170,17 @@ 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. - //Default values. Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased - var newWidth = 0; - var newHeight = 0; - - //Avoid issues with the canvas having negative maximum width and/or height due to element being collapsed - if (Math.floor(helpers.getMaximumWidth(canvas)) >= 0) { - newWidth = Math.floor(helpers.getMaximumWidth(canvas)); - } - if (helpers.getMaximumHeight(canvas) >= 0) { - newHeight = Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); - } + // Default values. Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased + var newWidth = 0; + var newHeight = 0; + + // Avoid issues with the canvas having negative maximum width and/or height due to element being collapsed + if (Math.floor(helpers.getMaximumWidth(canvas)) >= 0) { + newWidth = Math.floor(helpers.getMaximumWidth(canvas)); + } + if (helpers.getMaximumHeight(canvas) >= 0) { + newHeight = Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); + } if (me.width === newWidth && me.height === newHeight) { return; From 0fe03cf38cc24522ea8934d38515f85370b4b013 Mon Sep 17 00:00:00 2001 From: Peter-Van-Drunen Date: Thu, 22 Jun 2017 09:55:17 -0400 Subject: [PATCH 3/4] Update core.controller.js --- src/core/core.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index d06f7f1a0d6..5868c2c60aa 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -169,7 +169,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. - + // Default values. Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased var newWidth = 0; var newHeight = 0; From b45337ce4726319fe416292dc4a4db76feb290aa Mon Sep 17 00:00:00 2001 From: Peter-Van-Drunen Date: Thu, 22 Jun 2017 21:30:24 -0400 Subject: [PATCH 4/4] Update core.controller.js --- src/core/core.controller.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 5868c2c60aa..0d21fc5f400 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -170,17 +170,9 @@ 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. - // Default values. Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased - var newWidth = 0; - var newHeight = 0; - - // Avoid issues with the canvas having negative maximum width and/or height due to element being collapsed - if (Math.floor(helpers.getMaximumWidth(canvas)) >= 0) { - newWidth = Math.floor(helpers.getMaximumWidth(canvas)); - } - if (helpers.getMaximumHeight(canvas) >= 0) { - newHeight = Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); - } + // Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased + var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas))); + var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas))); if (me.width === newWidth && me.height === newHeight) { return;