-
Notifications
You must be signed in to change notification settings - Fork 12k
Plugins Enhancement #2752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugins Enhancement #2752
Conversation
Rename `Chart.pluginService` to `Chart.plugins` (so move the old Chart.plugins array as a private member of the service), and rename `notifyPlugins` to `notify` for consistency with other service methods.
Change the plugin notification behavior: this method now returns false as soon as a plugin *explicitly* returns false, else returns true. Also, plugins are now called in their own scope (so remove the never used `scope` parameter).
0484180 to
b662d0c
Compare
The plugins service now accepts an array of plugin instances to register or unregister (for consistency, renamed `Chart.plugins.remove` to `unregister`). Also added a few methods to manipulate registered plugins, such as `count`, `getAll` and `clear` (mainly used by our unit tests).
Add `beforeDatasetsUpdate` and `afterDatasetsUpdate` plugin notifications during the chart update. Plugins are able to cancel the datasets update by explicitly returning false to `beforeDatasetsUpdate`. For consistency, rename `(before|after)DatasetDraw` to `(before|after)DatasetsDraw`.
b662d0c to
53eb766
Compare
| * Unregisters the given plugin(s) only if registered. | ||
| * @param {Array|Object} plugins plugin instance(s). | ||
| */ | ||
| unregister: function(plugins) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for completeness we should implement remove to alias to unregister
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same first but then realized that this method has never been used in code or plugins (correct me if I'm wrong), and I can't see any case where it should be used (except in unit tests). So was thinking that we may not keep compatibility and save a few bits. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I don't think anyone has used it.
|
Other than my 1 comment this is good to go Edit: did not mean to close, sorry |
Mostly explained in commit messages, but on the menu:
Chart.pluginServicetoChart.plugins,Chart.pluginService.removetoChart.plugins.unregister,Chart.pluginService.notifyPluginstoChart.plugins.notify,falseas soon as a plugin explicitly returnsfalse(can be used, for example, to cancel an action),beforeDatasetsUpdate(cancellable) andafterDatasetsUpdate,before/afterDatasetDrawtobefore/afterDatasetsDraw(with s to Datasets),Note: I need these changes to implement a plugin to address #2745