From: Evert Timberg Date: Sun, 17 Apr 2016 22:55:20 +0000 (-0400) Subject: Plugin event in destroy X-Git-Tag: 2.1.0~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9abc63b11eea0a1fdd4874a12a208715b9f77986;p=thirdparty%2FChart.js.git Plugin event in destroy --- diff --git a/docs/07-Advanced.md b/docs/07-Advanced.md index ffa9fc5c3..706f54b2d 100644 --- a/docs/07-Advanced.md +++ b/docs/07-Advanced.md @@ -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) { } } ``` diff --git a/src/core/core.controller.js b/src/core/core.controller.js index dfb62a331..19ca88fcf 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -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]; }, diff --git a/src/core/core.plugin.js b/src/core/core.plugin.js index 78f5fe988..8a82e4e94 100644 --- a/src/core/core.plugin.js +++ b/src/core/core.plugin.js @@ -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