mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Allow single parameter to Defaults.set (#8050)
* Allow single parameter to Defaults.set * Review update * Record
This commit is contained in:
parent
6928b23a50
commit
f96fa2b96d
@ -59,14 +59,21 @@ export class Defaults {
|
||||
this.scales = {};
|
||||
this.controllers = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} scope
|
||||
* @param {*} values
|
||||
* @param {string|object} scope
|
||||
* @param {object} [values]
|
||||
*/
|
||||
set(scope, values) {
|
||||
return merge(getScope(this, scope), values);
|
||||
if (typeof scope === 'string') {
|
||||
return merge(getScope(this, scope), values);
|
||||
}
|
||||
return merge(getScope(this, ''), scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} scope
|
||||
*/
|
||||
get(scope) {
|
||||
return getScope(this, scope);
|
||||
}
|
||||
|
6
types/core/index.d.ts
vendored
6
types/core/index.d.ts
vendored
@ -333,6 +333,7 @@ export interface DatasetControllerChartComponent extends ChartComponent {
|
||||
};
|
||||
}
|
||||
|
||||
export type AnyObject = Record<string, unknown>;
|
||||
export interface Defaults extends CoreChartOptions, ElementChartOptions {
|
||||
controllers: {
|
||||
[key in ChartType]: DeepPartial<
|
||||
@ -352,8 +353,9 @@ export interface Defaults extends CoreChartOptions, ElementChartOptions {
|
||||
|
||||
plugins: PluginOptions;
|
||||
|
||||
set(scope: string, values: any): any;
|
||||
get(scope: string): any;
|
||||
set(values: AnyObject): AnyObject;
|
||||
set(scope: string, values: AnyObject): AnyObject;
|
||||
get(scope: string): AnyObject;
|
||||
|
||||
/**
|
||||
* Routes the named defaults to fallback to another scope/name.
|
||||
|
Loading…
Reference in New Issue
Block a user