]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Make `beforeDraw` cancellable and fix easing value
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Sun, 22 Jan 2017 20:01:46 +0000 (21:01 +0100)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 28 Jan 2017 00:32:35 +0000 (19:32 -0500)
src/core/core.controller.js

index e6c19659387192c1f33f288ccaf2e96c86ae5002..f67b29ff934829641f5faf33a7498de9c6ab70bc 100644 (file)
@@ -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]);
                },
 
                /**