]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Use apply instead of call so that the animation easing can be passed to the draw...
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 16:25:47 +0000 (12:25 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 16:25:47 +0000 (12:25 -0400)
src/core/core.controller.js
src/core/core.plugin.js
test/core.plugin.tests.js

index b6dad13b9888647e423752e5312ef28ff1bb6dda..dfb62a3313f6e14093bfed8c5623a941d00ab782 100644 (file)
@@ -44,7 +44,7 @@ module.exports = function(Chart) {
 
                initialize: function initialize() {
                        // Before init plugin notification
-                       Chart.pluginService.notifyPlugins('beforeInit', this);
+                       Chart.pluginService.notifyPlugins('beforeInit', [this]);
 
                        this.bindEvents();
 
@@ -60,7 +60,7 @@ module.exports = function(Chart) {
                        this.update();
 
                        // After init plugin notification
-                       Chart.pluginService.notifyPlugins('afterInit', this);
+                       Chart.pluginService.notifyPlugins('afterInit', [this]);
 
                        return this;
                },
@@ -242,7 +242,7 @@ module.exports = function(Chart) {
                },
 
                update: function update(animationDuration, lazy) {
-                       Chart.pluginService.notifyPlugins('beforeUpdate', this);
+                       Chart.pluginService.notifyPlugins('beforeUpdate', [this]);
 
                        // In case the entire data object changed
                        this.tooltip._data = this.data;
@@ -268,7 +268,7 @@ module.exports = function(Chart) {
                        });
                        this.render(animationDuration, lazy);
 
-                       Chart.pluginService.notifyPlugins('afterUpdate', this);
+                       Chart.pluginService.notifyPlugins('afterUpdate', [this]);
                },
 
                render: function render(duration, lazy) {
@@ -305,7 +305,7 @@ module.exports = function(Chart) {
                        var easingDecimal = ease || 1;
                        this.clear();
 
-                       Chart.pluginService.notifyPlugins('beforeDraw', this);
+                       Chart.pluginService.notifyPlugins('beforeDraw', [this, easingDecimal]);
 
                        // Draw all the scales
                        helpers.each(this.boxes, function(box) {
@@ -334,7 +334,7 @@ module.exports = function(Chart) {
                        // Finally draw the tooltip
                        this.tooltip.transition(easingDecimal).draw();
 
-                       Chart.pluginService.notifyPlugins('afterDraw', this);
+                       Chart.pluginService.notifyPlugins('afterDraw', [this, easingDecimal]);
                },
 
                // Get the single element that was clicked on
index c98cef15a51bd9ec981f8a8492c237b81f5e1f14..78f5fe9886a6f1fac9293f66023747f3e5327e43 100644 (file)
@@ -22,10 +22,10 @@ module.exports = function(Chart) {
                },
 
                // Iterate over all plugins
-               notifyPlugins: function(method, chartInstance, scope) {
+               notifyPlugins: function(method, args, scope) {
                        helpers.each(Chart.plugins, function(plugin) {
                                if (plugin[method] && typeof plugin[method] === 'function') {
-                                       plugin[method].call(scope, chartInstance);
+                                       plugin[method].apply(scope, args);
                                }
                        }, scope);
                }
index 4f59c63cd81be37abd011fe93333891485d90c71..5a6891071ef452e48cc19e58c7a5262de9510ccb 100644 (file)
@@ -36,7 +36,7 @@ describe('Test the plugin system', function() {
                };
                Chart.pluginService.register(myplugin);
                
-               Chart.pluginService.notifyPlugins('trigger', { count: 10 });
+               Chart.pluginService.notifyPlugins('trigger', [{ count: 10 }]);
 
                expect(myplugin.count).toBe(10);
        });