Add new hooks for plugins (#8103)

* Notify beforeUpdate on disabled plugins

cc?

cc2

cc3

typo

* init, unInit, enabled, disabled

self review :)

update the new hook signatures to unified

merge error

* Review update

* start/stop, cc

* types, jsdoc

* stop between destroy and uninstall
This commit is contained in:
Jukka Kurkela
2020-11-28 22:57:45 +02:00
committed by GitHub
parent d6b4fe2629
commit 78dbeea1f0
8 changed files with 243 additions and 68 deletions

View File

@@ -653,12 +653,14 @@ export default {
*/
_element: Legend,
beforeInit(chart) {
start(chart) {
const legendOpts = resolveOptions(chart.options.plugins.legend);
createNewLegendAndAttach(chart, legendOpts);
},
if (legendOpts) {
createNewLegendAndAttach(chart, legendOpts);
}
stop(chart) {
layouts.removeBox(chart, chart.legend);
delete chart.legend;
},
// During the beforeUpdate step, the layout configuration needs to run

View File

@@ -184,11 +184,17 @@ export default {
*/
_element: Title,
beforeInit(chart, options) {
start(chart, _args, options) {
createTitle(chart, options);
},
beforeUpdate(chart, args, options) {
stop(chart) {
const titleBlock = chart.titleBlock;
layouts.removeBox(chart, titleBlock);
delete chart.titleBlock;
},
beforeUpdate(chart, _args, options) {
if (options === false) {
removeTitle(chart);
} else {