From 2edd07d724f9a2eefe55261b42c31eb8d48e6826 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Wed, 24 Feb 2021 23:34:29 +0200 Subject: [PATCH] Config is no longer updated by options setter (#8516) --- src/core/core.config.js | 18 +++++++++--------- src/core/core.controller.js | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/core.config.js b/src/core/core.config.js index ef703865c..f93a8ba9e 100644 --- a/src/core/core.config.js +++ b/src/core/core.config.js @@ -80,25 +80,21 @@ function mergeScaleConfig(config, options) { return scales; } -function initOptions(config, options) { - options = options || {}; +function initOptions(config) { + const options = config.options || (config.options = {}); options.plugins = valueOrDefault(options.plugins, {}); options.scales = mergeScaleConfig(config, options); - - return options; } function initConfig(config) { config = config || {}; - // Do NOT use mergeConfig for the data object because this method merges arrays - // and so would change references to labels and datasets, preventing data updates. const data = config.data = config.data || {datasets: [], labels: []}; data.datasets = data.datasets || []; data.labels = data.labels || []; - config.options = initOptions(config, config.options); + initOptions(config); return config; } @@ -150,14 +146,18 @@ export default class Config { return this._config.options; } + set options(options) { + this._config.options = options; + } + get plugins() { return this._config.plugins; } - update(options) { + update() { const config = this._config; this.clearCache(); - config.options = initOptions(config, options); + initOptions(config); } clearCache() { diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 7450587df..7997acbda 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -159,7 +159,7 @@ class Chart { } set options(options) { - this.config.update(options); + this.config.options = options; } /** @@ -444,7 +444,7 @@ class Chart { const me = this; const config = me.config; - config.update(config.options); + config.update(); me._options = config.createResolver(config.chartOptionScopes(), me.getContext()); each(me.scales, (scale) => { -- 2.47.3