Skip to content
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

Config is no longer updated by options setter #8516

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/core/core.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Chart {
}

set options(options) {
this.config.update(options);
this.config.options = options;
}

/**
Expand Down Expand Up @@ -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) => {
Expand Down