mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-12 03:06:54 +01:00
Refactoring to put browser specific code in a new class (#3718)
Refactoring to put browser specific code in a new class, BrowserPlatform. BrowserPlatform implements IPlatform. Chart.Platform is the constructor for the platform object that is attached to the chart instance. Plugins are notified about the event using the `onEvent` call. The legend plugin was converted to use onEvent instead of the older private `handleEvent` method. Wrote test to check that plugins are notified about events
This commit is contained in:
@@ -410,6 +410,7 @@ Plugins will be called at the following times
|
||||
* After datasets draw
|
||||
* Resize
|
||||
* Before an animation is started
|
||||
* When an event occurs on the canvas (mousemove, click, etc). This requires the `options.events` property handled
|
||||
|
||||
Plugins should derive from Chart.PluginBase and implement the following interface
|
||||
```javascript
|
||||
@@ -437,6 +438,13 @@ Plugins should derive from Chart.PluginBase and implement the following interfac
|
||||
afterDatasetsDraw: function(chartInstance, easing) { },
|
||||
|
||||
destroy: function(chartInstance) { }
|
||||
|
||||
/**
|
||||
* Called when an event occurs on the chart
|
||||
* @param e {Core.Event} the Chart.js wrapper around the native event. e.native is the original event
|
||||
* @return {Boolean} true if the chart is changed and needs to re-render
|
||||
*/
|
||||
onEvent: function(chartInstance, e) {}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user