]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Initial plugin calls
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 16:02:42 +0000 (12:02 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 16:02:42 +0000 (12:02 -0400)
src/core/core.controller.js

index 64af936deab39c1bdaaed869b10e7fd3e11c6eb1..b6dad13b9888647e423752e5312ef28ff1bb6dda 100644 (file)
@@ -43,9 +43,8 @@ module.exports = function(Chart) {
        helpers.extend(Chart.Controller.prototype, {
 
                initialize: function initialize() {
-
-                       // TODO
-                       // If BeforeInit(this) doesn't return false, proceed
+                       // Before init plugin notification
+                       Chart.pluginService.notifyPlugins('beforeInit', this);
 
                        this.bindEvents();
 
@@ -60,8 +59,8 @@ module.exports = function(Chart) {
                        this.initToolTip();
                        this.update();
 
-                       // TODO
-                       // If AfterInit(this) doesn't return false, proceed
+                       // After init plugin notification
+                       Chart.pluginService.notifyPlugins('afterInit', this);
 
                        return this;
                },
@@ -243,6 +242,8 @@ module.exports = function(Chart) {
                },
 
                update: function update(animationDuration, lazy) {
+                       Chart.pluginService.notifyPlugins('beforeUpdate', this);
+
                        // In case the entire data object changed
                        this.tooltip._data = this.data;
 
@@ -266,6 +267,8 @@ module.exports = function(Chart) {
                                dataset.controller.update();
                        });
                        this.render(animationDuration, lazy);
+
+                       Chart.pluginService.notifyPlugins('afterUpdate', this);
                },
 
                render: function render(duration, lazy) {
@@ -302,6 +305,8 @@ module.exports = function(Chart) {
                        var easingDecimal = ease || 1;
                        this.clear();
 
+                       Chart.pluginService.notifyPlugins('beforeDraw', this);
+
                        // Draw all the scales
                        helpers.each(this.boxes, function(box) {
                                box.draw(this.chartArea);
@@ -328,6 +333,8 @@ module.exports = function(Chart) {
 
                        // Finally draw the tooltip
                        this.tooltip.transition(easingDecimal).draw();
+
+                       Chart.pluginService.notifyPlugins('afterDraw', this);
                },
 
                // Get the single element that was clicked on