]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Plugin event in destroy
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 22:55:20 +0000 (18:55 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 17 Apr 2016 22:55:20 +0000 (18:55 -0400)
docs/07-Advanced.md
src/core/core.controller.js
src/core/core.plugin.js

index ffa9fc5c3b7e592f2dc747ad47ed4a046bee229a..706f54b2d4150d598d0209a8ebb03e9a3bba12c1 100644 (file)
@@ -233,23 +233,27 @@ To work with Chart.js, custom scale types must implement the following interface
        determineDataLimits: function() {},
 
        // Generate tick marks. this.chart is the chart instance. The data object can be accessed as this.chart.data
-       // buildTicks() should create a ticks array on the scale instance, if you intend to use any of the implementations from the base class
+       // buildTicks() should create a ticks array on the axis instance, if you intend to use any of the implementations from the base class
        buildTicks: function() {},
 
        // Get the value to show for the data at the given index of the the given dataset, ie this.chart.data.datasets[datasetIndex].data[index]
        getLabelForIndex: function(index, datasetIndex) {},
 
-       // Get the pixel (x coordinate for horizontal scale, y coordinate for vertical scales) for a given value
+       // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
        // @param index: index into the ticks array
        // @param includeOffset: if true, get the pixel halway between the given tick and the next
        getPixelForTick: function(index, includeOffset) {},
 
-       // Get the pixel (x coordinate for horizontal scale, y coordinate for vertical scales) for a given value
+       // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
        // @param value : the value to get the pixel for
        // @param index : index into the data array of the value
        // @param datasetIndex : index of the dataset the value comes from
        // @param includeOffset : if true, get the pixel halway between the given tick and the next
        getPixelForValue: function(value, index, datasetIndex, includeOffset) {}
+
+       // Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis)
+       // @param pixel : pixel value
+       getValueForPixel: function(pixel) {}
 }
 ```
 
@@ -389,6 +393,8 @@ Plugins should derive from Chart.PluginBase and implement the following interfac
        // Easing is for animation
        beforeDraw: function(chartInstance, easing) { },
        afterDraw: function(chartInstance, easing) { }
+
+       destroy: function(chartInstance) { }
 }
 ```
 
index dfb62a3313f6e14093bfed8c5623a941d00ab782..19ca88fcf40058fed43403f868c9db2fc5aa7c8f 100644 (file)
@@ -422,6 +422,8 @@ module.exports = function(Chart) {
                        canvas.style.width = this.chart.originalCanvasStyleWidth;
                        canvas.style.height = this.chart.originalCanvasStyleHeight;
 
+                       Chart.pluginService.notifyPlugins('destory', [this, easingDecimal]);
+
                        delete Chart.instances[this.id];
                },
 
index 78f5fe9886a6f1fac9293f66023747f3e5327e43..8a82e4e944a8e8a4f7cb49170230a2af4b81c964 100644 (file)
@@ -51,5 +51,8 @@ module.exports = function(Chart) {
 
                // Called at end of draw
                afterDraw: helpers.noop,
+
+               // Called during destroy
+               destory: helpers.noop,
        });
 };
\ No newline at end of file