code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
constructor() { this._request = null; this._charts = new Map(); this._running = false; this._lastDate = undefined; }
Please use the module's default export which provides a singleton instance Note: class is export for typedoc
constructor
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
add(chart, items) { if (!items || !items.length) { return; } this._getAnims(chart).items.push(...items); }
Add animations @param {Chart} chart @param {Animation[]} items - animations
add
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
has(chart) { return this._getAnims(chart).items.length > 0; }
Counts number of active animations for the chart @param {Chart} chart
has
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
start(chart) { const anims = this._charts.get(chart); if (!anims) { return; } anims.running = true; anims.start = Date.now(); anims.duration = anims.items.reduce((acc, cur) => Math.max(acc, cur._duration), 0); this._refresh(); }
Start animating (all charts) @param {Chart} chart
start
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
running(chart) { if (!this._running) { return false; } const anims = this._charts.get(chart); if (!anims || !anims.running || !anims.items.length) { return false; } return true; }
Start animating (all charts) @param {Chart} chart
running
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
stop(chart) { const anims = this._charts.get(chart); if (!anims || !anims.items.length) { return; } const items = anims.items; let i = items.length - 1; for (; i >= 0; --i) { items[i].cancel(); } anims.items = []; this._notify(chart, anims, Date.now(), 'complete'); }
Stop all animations for the chart @param {Chart} chart
stop
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
remove(chart) { return this._charts.delete(chart); }
Remove chart from Animator @param {Chart} chart
remove
javascript
chartjs/Chart.js
src/core/core.animator.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.animator.js
MIT
datasetScopeKeys(datasetType) { return cachedKeys(datasetType, () => [[ `datasets.${datasetType}`, '' ]]); }
Returns the option scope keys for resolving dataset options. These keys do not include the dataset itself, because it is not under options. @param {string} datasetType @return {string[][]}
datasetScopeKeys
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
datasetAnimationScopeKeys(datasetType, transition) { return cachedKeys(`${datasetType}.transition.${transition}`, () => [ [ `datasets.${datasetType}.transitions.${transition}`, `transitions.${transition}`, ], // The following are used for looking up the `animations`...
Returns the option scope keys for resolving dataset animation options. These keys do not include the dataset itself, because it is not under options. @param {string} datasetType @param {string} transition @return {string[][]}
datasetAnimationScopeKeys
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
datasetElementScopeKeys(datasetType, elementType) { return cachedKeys(`${datasetType}-${elementType}`, () => [[ `datasets.${datasetType}.elements.${elementType}`, `datasets.${datasetType}`, `elements.${elementType}`, '' ]]); }
Returns the options scope keys for resolving element options that belong to an dataset. These keys do not include the dataset itself, because it is not under options. @param {string} datasetType @param {string} elementType @return {string[][]}
datasetElementScopeKeys
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
pluginScopeKeys(plugin) { const id = plugin.id; const type = this.type; return cachedKeys(`${type}-plugin-${id}`, () => [[ `plugins.${id}`, ...plugin.additionalOptionScopes || [], ]]); }
Returns the options scope keys for resolving plugin options. @param {{id: string, additionalOptionScopes?: string[]}} plugin @return {string[][]}
pluginScopeKeys
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
getOptionScopes(mainScope, keyLists, resetCache) { const {options, type} = this; const cache = this._cachedScopes(mainScope, resetCache); const cached = cache.get(keyLists); if (cached) { return cached; } const scopes = new Set(); keyLists.forEach(keys => { if (mainScope) { ...
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
getOptionScopes
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
chartOptionScopes() { const {options, type} = this; return [ options, overrides[type] || {}, defaults.datasets[type] || {}, // https://github.com/chartjs/Chart.js/issues/8531 {type}, defaults, descriptors ]; }
Returns the option scopes for resolving chart options @return {object[]}
chartOptionScopes
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
resolveNamedOptions(scopes, names, context, prefixes = ['']) { const result = {$shared: true}; const {resolver, subPrefixes} = getResolver(this._resolverCache, scopes, prefixes); let options = resolver; if (needContext(resolver, names)) { result.$shared = false; context = isFunction(context)...
@param {object[]} scopes @param {string[]} names @param {function|object} context @param {string[]} [prefixes] @return {object}
resolveNamedOptions
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
createResolver(scopes, context, prefixes = [''], descriptorDefaults) { const {resolver} = getResolver(this._resolverCache, scopes, prefixes); return isObject(context) ? _attachContext(resolver, context, undefined, descriptorDefaults) : resolver; }
@param {object[]} scopes @param {object} [context] @param {string[]} [prefixes] @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
createResolver
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
function getResolver(resolverCache, scopes, prefixes) { let cache = resolverCache.get(scopes); if (!cache) { cache = new Map(); resolverCache.set(scopes, cache); } const cacheKey = prefixes.join(); let cached = cache.get(cacheKey); if (!cached) { const resolver = _createResolver(scopes, prefixes...
@param {object[]} scopes @param {object} [context] @param {string[]} [prefixes] @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
getResolver
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
hasFunction = value => isObject(value) && Object.getOwnPropertyNames(value).some((key) => isFunction(value[key]))
@param {object[]} scopes @param {object} [context] @param {string[]} [prefixes] @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
hasFunction
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
hasFunction = value => isObject(value) && Object.getOwnPropertyNames(value).some((key) => isFunction(value[key]))
@param {object[]} scopes @param {object} [context] @param {string[]} [prefixes] @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
hasFunction
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
function needContext(proxy, names) { const {isScriptable, isIndexable} = _descriptors(proxy); for (const prop of names) { const scriptable = isScriptable(prop); const indexable = isIndexable(prop); const value = (indexable || scriptable) && proxy[prop]; if ((scriptable && (isFunction(value) || hasF...
@param {object[]} scopes @param {object} [context] @param {string[]} [prefixes] @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
needContext
javascript
chartjs/Chart.js
src/core/core.config.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.config.js
MIT
function positionIsHorizontal(position, axis) { return position === 'top' || position === 'bottom' || (KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x'); }
@typedef { import('../types/index.js').ChartEvent } ChartEvent @typedef { import('../types/index.js').Point } Point
positionIsHorizontal
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function compare2Level(l1, l2) { return function(a, b) { return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1]; }; }
@typedef { import('../types/index.js').ChartEvent } ChartEvent @typedef { import('../types/index.js').Point } Point
compare2Level
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function onAnimationsComplete(context) { const chart = context.chart; const animationOptions = chart.options.animation; chart.notifyPlugins('afterRender'); callCallback(animationOptions && animationOptions.onComplete, [context], chart); }
@typedef { import('../types/index.js').ChartEvent } ChartEvent @typedef { import('../types/index.js').Point } Point
onAnimationsComplete
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function onAnimationProgress(context) { const chart = context.chart; const animationOptions = chart.options.animation; callCallback(animationOptions && animationOptions.onProgress, [context], chart); }
@typedef { import('../types/index.js').ChartEvent } ChartEvent @typedef { import('../types/index.js').Point } Point
onAnimationProgress
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function getCanvas(item) { if (_isDomSupported() && typeof item === 'string') { item = document.getElementById(item); } else if (item && item.length) { // Support for array based queries (such as jQuery) item = item[0]; } if (item && item.canvas) { // Support for any object associated to a canv...
Chart.js can take a string id of a canvas element, a 2d context, or a canvas element itself. Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible).
getCanvas
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getChart = (key) => { const canvas = getCanvas(key); return Object.values(instances).filter((c) => c.canvas === canvas).pop(); }
Chart.js can take a string id of a canvas element, a 2d context, or a canvas element itself. Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible).
getChart
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getChart = (key) => { const canvas = getCanvas(key); return Object.values(instances).filter((c) => c.canvas === canvas).pop(); }
Chart.js can take a string id of a canvas element, a 2d context, or a canvas element itself. Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible).
getChart
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function moveNumericKeys(obj, start, move) { const keys = Object.keys(obj); for (const key of keys) { const intKey = +key; if (intKey >= start) { const value = obj[key]; delete obj[key]; if (move > 0 || intKey > start) { obj[intKey + move] = value; } } } }
Chart.js can take a string id of a canvas element, a 2d context, or a canvas element itself. Attempt to unwrap the item passed into the chart constructor so that it is a canvas element (if possible).
moveNumericKeys
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function determineLastEvent(e, lastEvent, inChartArea, isClick) { if (!inChartArea || e.type === 'mouseout') { return null; } if (isClick) { return lastEvent; } return e; }
@param {ChartEvent} e @param {ChartEvent|null} lastEvent @param {boolean} inChartArea @param {boolean} isClick @returns {ChartEvent|null}
determineLastEvent
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
static register(...items) { registry.add(...items); invalidatePlugins(); }
@param {ChartEvent} e @param {ChartEvent|null} lastEvent @param {boolean} inChartArea @param {boolean} isClick @returns {ChartEvent|null}
register
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
static unregister(...items) { registry.remove(...items); invalidatePlugins(); }
@param {ChartEvent} e @param {ChartEvent|null} lastEvent @param {boolean} inChartArea @param {boolean} isClick @returns {ChartEvent|null}
unregister
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
constructor(item, userConfig) { const config = this.config = new Config(userConfig); const initialCanvas = getCanvas(item); const existingChart = getChart(initialCanvas); if (existingChart) { throw new Error( 'Canvas is already in use. Chart with ID \'' + existingChart.id + '\'' + ' mu...
@param {ChartEvent} e @param {ChartEvent|null} lastEvent @param {boolean} inChartArea @param {boolean} isClick @returns {ChartEvent|null}
constructor
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
get aspectRatio() { const {options: {aspectRatio, maintainAspectRatio}, width, height, _aspectRatio} = this; if (!isNullOrUndef(aspectRatio)) { // If aspectRatio is defined in options, use that. return aspectRatio; } if (maintainAspectRatio && _aspectRatio) { // If maintainAspectRatio...
@type {?{attach?: function, detach?: function, resize?: function}}
aspectRatio
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
get data() { return this.config.data; }
@type {?{attach?: function, detach?: function, resize?: function}}
data
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
set data(data) { this.config.data = data; }
@type {?{attach?: function, detach?: function, resize?: function}}
data
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
get options() { return this._options; }
@type {?{attach?: function, detach?: function, resize?: function}}
options
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
set options(options) { this.config.options = options; }
@type {?{attach?: function, detach?: function, resize?: function}}
options
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
get registry() { return registry; }
@type {?{attach?: function, detach?: function, resize?: function}}
registry
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
resize(width, height) { if (!animator.running(this)) { this._resize(width, height); } else { this._resizeBeforeDraw = {width, height}; } }
Resize the chart to its container or to explicit dimensions. @param {number} [width] @param {number} [height]
resize
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_resize(width, height) { const options = this.options; const canvas = this.canvas; const aspectRatio = options.maintainAspectRatio && this.aspectRatio; const newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio); const newRatio = options.devicePixelRatio || this.platform.getDevi...
Resize the chart to its container or to explicit dimensions. @param {number} [width] @param {number} [height]
_resize
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
ensureScalesHaveIDs() { const options = this.options; const scalesOptions = options.scales || {}; each(scalesOptions, (axisOptions, axisID) => { axisOptions.id = axisID; }); }
Resize the chart to its container or to explicit dimensions. @param {number} [width] @param {number} [height]
ensureScalesHaveIDs
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
buildOrUpdateScales() { const options = this.options; const scaleOpts = options.scales; const scales = this.scales; const updated = Object.keys(scales).reduce((obj, id) => { obj[id] = false; return obj; }, {}); let items = []; if (scaleOpts) { items = items.concat( ...
Builds a map of scale ID to scale object for future lookup.
buildOrUpdateScales
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_resetElements() { each(this.data.datasets, (dataset, datasetIndex) => { this.getDatasetMeta(datasetIndex).controller.reset(); }, this); }
Reset the elements of all datasets @private
_resetElements
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
reset() { this._resetElements(); this.notifyPlugins('reset'); }
Resets the chart back to its state before the initial animation
reset
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
update(mode) { const config = this.config; config.update(); const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext()); const animsDisabled = this._animationsDisabled = !options.animation; this._updateScales(); this._checkEventBindings(); this._upd...
Resets the chart back to its state before the initial animation
update
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_updateLayout(minPadding) { if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) { return; } layouts.update(this, this.width, this.height, minPadding); const area = this.chartArea; const noArea = area.width <= 0 || area.height <= 0; this._layers = []; each(this.boxe...
Updates the chart layout unless a plugin returns `false` to the `beforeLayout` hook, in which case, plugins will not be called on `afterLayout`. @private
_updateLayout
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_updateDatasets(mode) { if (this.notifyPlugins('beforeDatasetsUpdate', {mode, cancelable: true}) === false) { return; } for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { this.getDatasetMeta(i).controller.configure(); } for (let i = 0, ilen = this.data.datasets.length; ...
Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate` hook, in which case, plugins will not be called on `afterDatasetsUpdate`. @private
_updateDatasets
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_updateDataset(index, mode) { const meta = this.getDatasetMeta(index); const args = {meta, index, mode, cancelable: true}; if (this.notifyPlugins('beforeDatasetUpdate', args) === false) { return; } meta.controller._update(mode); args.cancelable = false; this.notifyPlugins('afterData...
Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate` hook, in which case, plugins will not be called on `afterDatasetUpdate`. @private
_updateDataset
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
render() { if (this.notifyPlugins('beforeRender', {cancelable: true}) === false) { return; } if (animator.has(this)) { if (this.attached && !animator.running(this)) { animator.start(this); } } else { this.draw(); onAnimationsComplete({chart: this}); } }
Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate` hook, in which case, plugins will not be called on `afterDatasetUpdate`. @private
render
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
draw() { let i; if (this._resizeBeforeDraw) { const {width, height} = this._resizeBeforeDraw; // Unset pending resize request now to avoid possible recursion within _resize this._resizeBeforeDraw = null; this._resize(width, height); } this.clear(); if (this.width <= 0 || thi...
Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate` hook, in which case, plugins will not be called on `afterDatasetUpdate`. @private
draw
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getSortedVisibleDatasetMetas() { return this._getSortedDatasetMetas(true); }
Gets the visible dataset metas in drawing order @return {object[]}
getSortedVisibleDatasetMetas
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_drawDatasets() { if (this.notifyPlugins('beforeDatasetsDraw', {cancelable: true}) === false) { return; } const metasets = this.getSortedVisibleDatasetMetas(); for (let i = metasets.length - 1; i >= 0; --i) { this._drawDataset(metasets[i]); } this.notifyPlugins('afterDatasetsDraw')...
Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw` hook, in which case, plugins will not be called on `afterDatasetsDraw`. @private
_drawDatasets
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_drawDataset(meta) { const ctx = this.ctx; const args = { meta, index: meta.index, cancelable: true }; // @ts-expect-error const clip = getDatasetClipArea(this, meta); if (this.notifyPlugins('beforeDatasetDraw', args) === false) { return; } if (clip) { cli...
Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw` hook, in which case, plugins will not be called on `afterDatasetDraw`. @private
_drawDataset
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
isPointInArea(point) { return _isPointInArea(point, this.chartArea, this._minPadding); }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
isPointInArea
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getElementsAtEventForMode(e, mode, options, useFinalPosition) { const method = Interaction.modes[mode]; if (typeof method === 'function') { return method(this, e, options, useFinalPosition); } return []; }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
getElementsAtEventForMode
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getDatasetMeta(datasetIndex) { const dataset = this.data.datasets[datasetIndex]; const metasets = this._metasets; let meta = metasets.filter(x => x && x._dataset === dataset).pop(); if (!meta) { meta = { type: null, data: [], dataset: null, controller: null, ...
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
getDatasetMeta
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getContext() { return this.$context || (this.$context = createContext(null, {chart: this, type: 'chart'})); }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
getContext
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getVisibleDatasetCount() { return this.getSortedVisibleDatasetMetas().length; }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
getVisibleDatasetCount
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
isDatasetVisible(datasetIndex) { const dataset = this.data.datasets[datasetIndex]; if (!dataset) { return false; } const meta = this.getDatasetMeta(datasetIndex); // meta.hidden is a per chart dataset hidden flag override with 3 states: if true or false, // the dataset.hidden value is ig...
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
isDatasetVisible
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
setDatasetVisibility(datasetIndex, visible) { const meta = this.getDatasetMeta(datasetIndex); meta.hidden = !visible; }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
setDatasetVisibility
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
toggleDataVisibility(index) { this._hiddenIndices[index] = !this._hiddenIndices[index]; }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
toggleDataVisibility
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getDataVisibility(index) { return !this._hiddenIndices[index]; }
Checks whether the given point is in the chart area. @param {Point} point - in relative coordinates (see, e.g., getRelativePosition) @returns {boolean}
getDataVisibility
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
getActiveElements() { return this._active || []; }
Get active (hovered) elements @returns array
getActiveElements
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
setActiveElements(activeElements) { const lastActive = this._active || []; const active = activeElements.map(({datasetIndex, index}) => { const meta = this.getDatasetMeta(datasetIndex); if (!meta) { throw new Error('No dataset found at index ' + datasetIndex); } return { ...
Set active (hovered) elements @param {array} activeElements New active data points
setActiveElements
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
isPluginEnabled(pluginId) { return this._plugins._cache.filter(p => p.plugin.id === pluginId).length === 1; }
Check if a plugin with the specific ID is registered and enabled @param {string} pluginId - The ID of the plugin of which to check if it is enabled @returns {boolean}
isPluginEnabled
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_handleEvent(e, replay, inChartArea) { const {_active: lastActive = [], options} = this; // If the event is replayed from `update`, we should evaluate with the final positions. // // The `replay`: // It's the last event (excluding click) that has occurred before `update`. // So mouse has not mo...
Handle an event @param {ChartEvent} e the event to handle @param {boolean} [replay] - true if the event was replayed by `update` @param {boolean} [inChartArea] - true if the event is inside chartArea @return {boolean} true if the chart needs to re-render @private
_handleEvent
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
_getActiveElements(e, lastActive, inChartArea, useFinalPosition) { if (e.type === 'mouseout') { return []; } if (!inChartArea) { // Let user control the active elements outside chartArea. Eg. using Legend. return lastActive; } const hoverOptions = this.options.hover; return t...
@param {ChartEvent} e - The event @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements @param {boolean} inChartArea - Is the event inside chartArea @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions @returns...
_getActiveElements
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function invalidatePlugins() { return each(Chart.instances, (chart) => chart._plugins.invalidate()); }
@param {ChartEvent} e - The event @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements @param {boolean} inChartArea - Is the event inside chartArea @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions @returns...
invalidatePlugins
javascript
chartjs/Chart.js
src/core/core.controller.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js
MIT
function scaleClip(scale, allowedOverflow) { const opts = scale && scale.options || {}; const reverse = opts.reverse; const min = opts.min === undefined ? allowedOverflow : 0; const max = opts.max === undefined ? allowedOverflow : 0; return { start: reverse ? max : min, end: reverse ? min : max }; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
scaleClip
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function defaultClip(xScale, yScale, allowedOverflow) { if (allowedOverflow === false) { return false; } const x = scaleClip(xScale, allowedOverflow); const y = scaleClip(yScale, allowedOverflow); return { top: y.end, right: x.end, bottom: y.start, left: x.start }; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
defaultClip
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function toClip(value) { let t, r, b, l; if (isObject(value)) { t = value.top; r = value.right; b = value.bottom; l = value.left; } else { t = r = b = l = value; } return { top: t, right: r, bottom: b, left: l, disabled: value === false }; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
toClip
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getSortedDatasetIndices(chart, filterVisible) { const keys = []; const metasets = chart._getSortedDatasetMetas(filterVisible); let i, ilen; for (i = 0, ilen = metasets.length; i < ilen; ++i) { keys.push(metasets[i].index); } return keys; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getSortedDatasetIndices
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function applyStack(stack, value, dsIndex, options = {}) { const keys = stack.keys; const singleMode = options.mode === 'single'; let i, ilen, datasetIndex, otherValue; if (value === null) { return; } let found = false; for (i = 0, ilen = keys.length; i < ilen; ++i) { datasetIndex = +keys[i]; ...
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
applyStack
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function convertObjectDataToArray(data, meta) { const {iScale, vScale} = meta; const iAxisKey = iScale.axis === 'x' ? 'x' : 'y'; const vAxisKey = vScale.axis === 'x' ? 'x' : 'y'; const keys = Object.keys(data); const adata = new Array(keys.length); let i, ilen, key; for (i = 0, ilen = keys.length; i < ile...
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
convertObjectDataToArray
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function isStacked(scale, meta) { const stacked = scale && scale.options.stacked; return stacked || (stacked === undefined && meta.stack !== undefined); }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
isStacked
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getStackKey(indexScale, valueScale, meta) { return `${indexScale.id}.${valueScale.id}.${meta.stack || meta.type}`; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getStackKey
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getUserBounds(scale) { const {min, max, minDefined, maxDefined} = scale.getUserBounds(); return { min: minDefined ? min : Number.NEGATIVE_INFINITY, max: maxDefined ? max : Number.POSITIVE_INFINITY }; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getUserBounds
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getOrCreateStack(stacks, stackKey, indexValue) { const subStack = stacks[stackKey] || (stacks[stackKey] = {}); return subStack[indexValue] || (subStack[indexValue] = {}); }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getOrCreateStack
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getLastIndexInStack(stack, vScale, positive, type) { for (const meta of vScale.getMatchingVisibleMetas(type).reverse()) { const value = stack[meta.index]; if ((positive && value > 0) || (!positive && value < 0)) { return meta.index; } } return null; }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getLastIndexInStack
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function updateStacks(controller, parsed) { const {chart, _cachedMeta: meta} = controller; const stacks = chart._stacks || (chart._stacks = {}); // map structure is {stackKey: {datasetIndex: value}} const {iScale, vScale, index: datasetIndex} = meta; const iAxis = iScale.axis; const vAxis = vScale.axis; con...
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
updateStacks
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getFirstScaleId(chart, axis) { const scales = chart.scales; return Object.keys(scales).filter(key => scales[key].axis === axis).shift(); }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
getFirstScaleId
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function createDatasetContext(parent, index) { return createContext(parent, { active: false, dataset: undefined, datasetIndex: index, index, mode: 'default', type: 'dataset' } ); }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
createDatasetContext
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function createDataContext(parent, index, element) { return createContext(parent, { active: false, dataIndex: index, parsed: undefined, raw: undefined, element, index, mode: 'default', type: 'data' }); }
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
createDataContext
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function clearStacks(meta, items) { // Not using meta.index here, because it might be already updated if the dataset changed location const datasetIndex = meta.controller.index; const axis = meta.vScale && meta.vScale.axis; if (!axis) { return; } items = items || meta._parsed; for (const parsed of it...
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
clearStacks
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
createStack = (canStack, meta, chart) => canStack && !meta.hidden && meta._stacked && {keys: getSortedDatasetIndices(chart, true), values: null}
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
createStack
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
createStack = (canStack, meta, chart) => canStack && !meta.hidden && meta._stacked && {keys: getSortedDatasetIndices(chart, true), values: null}
@typedef { import('./core.controller.js').default } Chart @typedef { import('./core.scale.js').default } Scale
createStack
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
constructor(chart, datasetIndex) { this.chart = chart; this._ctx = chart.ctx; this.index = datasetIndex; this._cachedDataOpts = {}; this._cachedMeta = this.getMeta(); this._type = this._cachedMeta.type; this.options = undefined; /** @type {boolean | object} */ this._parsing = false; ...
@param {Chart} chart @param {number} datasetIndex
constructor
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
configure() { const config = this.chart.config; const scopeKeys = config.datasetScopeKeys(this._type); const scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true); this.options = config.createResolver(scopes, this.getContext()); this._parsing = this.options.parsing; this._cachedDat...
Merges user-supplied and default dataset-level options @private
configure
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
parse(start, count) { const {_cachedMeta: meta, _data: data} = this; const {iScale, _stacked} = meta; const iAxis = iScale.axis; let sorted = start === 0 && count === data.length ? true : meta._sorted; let prev = start > 0 && meta._parsed[start - 1]; let i, cur, parsed; if (this._parsing =...
@param {number} start @param {number} count
parse
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
parseArrayData(meta, data, start, count) { const {xScale, yScale} = meta; const parsed = new Array(count); let i, ilen, index, item; for (i = 0, ilen = count; i < ilen; ++i) { index = i + start; item = data[index]; parsed[i] = { x: xScale.parse(item[0], index), y: ySca...
Parse array of arrays @param {object} meta - dataset meta @param {array} data - data array. Example [[1,2],[3,4]] @param {number} start - start index @param {number} count - number of items to parse @returns {object} parsed item - item containing index and a parsed value for each scale id. Example: {x: 0, y: 1} @protec...
parseArrayData
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
parseObjectData(meta, data, start, count) { const {xScale, yScale} = meta; const {xAxisKey = 'x', yAxisKey = 'y'} = this._parsing; const parsed = new Array(count); let i, ilen, index, item; for (i = 0, ilen = count; i < ilen; ++i) { index = i + start; item = data[index]; parsed[i]...
Parse array of objects @param {object} meta - dataset meta @param {array} data - data array. Example [{x:1, y:5}, {x:2, y:10}] @param {number} start - start index @param {number} count - number of items to parse @returns {object} parsed item - item containing index and a parsed value for each scale id. _custom is optio...
parseObjectData
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
getStyle(index, active) { const mode = active ? 'active' : 'default'; return index === undefined && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(mode) : this.resolveDataElementOptions(index || 0, mode); }
Returns a set of predefined style properties that should be used to represent the dataset or the data if the index is specified @param {number} index - data index @param {boolean} [active] - true if hover @return {object} style object
getStyle
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
resolveDataElementOptions(index, mode) { return this._resolveElementOptions(this.dataElementType.id, mode, index); }
@param {number} index @param {string} [mode] @protected
resolveDataElementOptions
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
getSharedOptions(options) { if (!options.$shared) { return; } return this._sharedOptions || (this._sharedOptions = Object.assign({}, options)); }
Utility for getting the options object shared between elements @protected
getSharedOptions
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
includeOptions(mode, sharedOptions) { return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled; }
Utility for determining if `options` should be included in the updated properties @protected
includeOptions
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
_getSharedOptions(start, mode) { const firstOpts = this.resolveDataElementOptions(start, mode); const previouslySharedOptions = this._sharedOptions; const sharedOptions = this.getSharedOptions(firstOpts); const includeOptions = this.includeOptions(mode, sharedOptions) || (sharedOptions !== previouslySha...
@todo v4, rename to getSharedOptions and remove excess functions
_getSharedOptions
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
updateElement(element, index, properties, mode) { if (isDirectUpdateMode(mode)) { Object.assign(element, properties); } else { this._resolveAnimations(index, mode).update(element, properties); } }
Utility for updating an element with new properties, using animations when appropriate. @protected
updateElement
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
updateSharedOptions(sharedOptions, mode, newOptions) { if (sharedOptions && !isDirectUpdateMode(mode)) { this._resolveAnimations(undefined, mode).update(sharedOptions, newOptions); } }
Utility to animate the shared options, that are potentially affecting multiple elements. @protected
updateSharedOptions
javascript
chartjs/Chart.js
src/core/core.datasetController.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js
MIT
function getScope(node, key) { if (!key) { return node; } const keys = key.split('.'); for (let i = 0, n = keys.length; i < n; ++i) { const k = keys[i]; node = node[k] || (node[k] = Object.create(null)); } return node; }
@param {object} node @param {string} key @return {object}
getScope
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
function set(root, scope, values) { if (typeof scope === 'string') { return merge(getScope(root, scope), values); } return merge(getScope(root, ''), scope); }
@param {object} node @param {string} key @return {object}
set
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
constructor(_descriptors, _appliers) { this.animation = undefined; this.backgroundColor = 'rgba(0,0,0,0.1)'; this.borderColor = 'rgba(0,0,0,0.1)'; this.color = '#666'; this.datasets = {}; this.devicePixelRatio = (context) => context.chart.platform.getDevicePixelRatio(); this.elements = {}; ...
Please use the module's default export which provides a singleton instance Note: class is exported for typedoc
constructor
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT