From 1e9224d49c66507d9c7e8b745416a446a08401e2 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sun, 22 Jan 2017 21:01:46 +0100 Subject: [PATCH] Make `beforeDraw` cancellable and fix easing value --- src/core/core.controller.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index e6c196593..f67b29ff9 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -433,12 +433,18 @@ module.exports = function(Chart) { return me; }, - draw: function(ease) { + draw: function(easingValue) { var me = this; - var easingDecimal = ease || 1; + me.clear(); - plugins.notify(me, 'beforeDraw', [easingDecimal]); + if (easingValue === undefined || easingValue === null) { + easingValue = 1; + } + + if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) { + return; + } // Draw all the scales helpers.each(me.boxes, function(box) { @@ -449,12 +455,12 @@ module.exports = function(Chart) { me.scale.draw(); } - me.drawDatasets(easingDecimal); + me.drawDatasets(easingValue); // Finally draw the tooltip - me.tooltip.transition(easingDecimal).draw(); + me.tooltip.transition(easingValue).draw(); - plugins.notify(me, 'afterDraw', [easingDecimal]); + plugins.notify(me, 'afterDraw', [easingValue]); }, /** -- 2.47.3