From: Evert Timberg Date: Sat, 23 Apr 2016 01:04:55 +0000 (-0400) Subject: Add in a beforeRender plugin event. Makes it easier to handle things that need to... X-Git-Tag: 2.1.0~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6f8fe59592a503644102b30cda03255e637fec7;p=thirdparty%2FChart.js.git Add in a beforeRender plugin event. Makes it easier to handle things that need to happen once at the start of animation but not on every frame --- diff --git a/docs/07-Advanced.md b/docs/07-Advanced.md index b222561db..4bedca3e0 100644 --- a/docs/07-Advanced.md +++ b/docs/07-Advanced.md @@ -390,6 +390,10 @@ Plugins should derive from Chart.PluginBase and implement the following interfac beforeUpdate: function(chartInstance) { }, afterUpdate: function(chartInstance) { }, + // This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw + // to do something on each animation frame + beforeRender: function(chartInstance) { }, + // Easing is for animation beforeDraw: function(chartInstance, easing) { }, afterDraw: function(chartInstance, easing) { } diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 074cf591d..9e7b52253 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -272,6 +272,7 @@ module.exports = function(Chart) { }, render: function render(duration, lazy) { + Chart.pluginService.notifyPlugins('beforeRender', [this]); if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && this.options.animation.duration !== 0))) { var animation = new Chart.Animation();