From f6f8fe59592a503644102b30cda03255e637fec7 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 22 Apr 2016 21:04:55 -0400 Subject: [PATCH] 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 --- docs/07-Advanced.md | 4 ++++ src/core/core.controller.js | 1 + 2 files changed, 5 insertions(+) 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(); -- 2.47.3