MCPcopy
hub / github.com/chartjs/Chart.js / getOptionScopes

Method getOptionScopes

src/core/core.config.js:296–325  ·  view source on GitHub ↗

* Resolves the objects from options and defaults for option value resolution. * @param {object} mainScope - The main scope object for options * @param {string[][]} keyLists - The arrays of keys in resolution order * @param {boolean} [resetCache] - reset the cache for this mainScope

(mainScope, keyLists, resetCache)

Source from the content-addressed store, hash-verified

294 * @param {boolean} [resetCache] - reset the cache for this mainScope
295 */
296 getOptionScopes(mainScope, keyLists, resetCache) {
297 const {options, type} = this;
298 const cache = this._cachedScopes(mainScope, resetCache);
299 const cached = cache.get(keyLists);
300 if (cached) {
301 return cached;
302 }
303
304 const scopes = new Set();
305
306 keyLists.forEach(keys => {
307 if (mainScope) {
308 scopes.add(mainScope);
309 keys.forEach(key => addIfFound(scopes, mainScope, key));
310 }
311 keys.forEach(key => addIfFound(scopes, options, key));
312 keys.forEach(key => addIfFound(scopes, overrides[type] || {}, key));
313 keys.forEach(key => addIfFound(scopes, defaults, key));
314 keys.forEach(key => addIfFound(scopes, descriptors, key));
315 });
316
317 const array = Array.from(scopes);
318 if (array.length === 0) {
319 array.push(Object.create(null));
320 }
321 if (keysCached.has(keyLists)) {
322 cache.set(keyLists, array);
323 }
324 return array;
325 }
326
327 /**
328 * Returns the option scopes for resolving chart options

Callers 4

pluginOptsFunction · 0.80
configureMethod · 0.80
_resolveAnimationsMethod · 0.80

Calls 6

_cachedScopesMethod · 0.95
addIfFoundFunction · 0.85
hasMethod · 0.80
getMethod · 0.65
addMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected