]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add in a beforeRender plugin event. Makes it easier to handle things that need to...
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 23 Apr 2016 01:04:55 +0000 (21:04 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 23 Apr 2016 01:04:55 +0000 (21:04 -0400)
docs/07-Advanced.md
src/core/core.controller.js

index b222561dbb8478896cea39d641d690902e564445..4bedca3e03e422fb158f24983d58cce4c4735bf3 100644 (file)
@@ -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) { }
index 074cf591daf79affb61c318b463e2fd535fa3a5d..9e7b522539b5cb119890b052cee11dc4ee2be485 100644 (file)
@@ -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();