mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Use apply instead of call so that the animation easing can be passed to the draw callbacks
This commit is contained in:
parent
7fa4c4c1b8
commit
d131e7d07a
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user