Add args.mode to before/after update plugin hooks (#7949)

This commit is contained in:
Jukka Kurkela
2020-10-24 18:36:31 +03:00
committed by GitHub
parent 93fabd1f26
commit 58d1911d05
5 changed files with 951 additions and 928 deletions

View File

@@ -587,6 +587,7 @@ class Chart {
update(mode) {
const me = this;
const args = {mode};
let i, ilen;
me._updating = true;
@@ -600,7 +601,7 @@ class Chart {
// https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167
me._plugins.invalidate();
if (me._plugins.notify(me, 'beforeUpdate') === false) {
if (me._plugins.notify(me, 'beforeUpdate', [args]) === false) {
return;
}
@@ -622,7 +623,7 @@ class Chart {
me._updateDatasets(mode);
// Do this before render so that any plugins that need final scale updates can use it
me._plugins.notify(me, 'afterUpdate');
me._plugins.notify(me, 'afterUpdate', [args]);
me._layers.sort(compare2Level('z', '_idx'));
@@ -675,8 +676,9 @@ class Chart {
_updateDatasets(mode) {
const me = this;
const isFunction = typeof mode === 'function';
const args = {mode};
if (me._plugins.notify(me, 'beforeDatasetsUpdate') === false) {
if (me._plugins.notify(me, 'beforeDatasetsUpdate', [args]) === false) {
return;
}
@@ -684,7 +686,7 @@ class Chart {
me._updateDataset(i, isFunction ? mode({datasetIndex: i}) : mode);
}
me._plugins.notify(me, 'afterDatasetsUpdate');
me._plugins.notify(me, 'afterDatasetsUpdate', [args]);
}
/**