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
set(scope, values) { return set(this, scope, values); }
@param {string|object} scope @param {object} [values]
set
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
describe(scope, values) { return set(descriptors, scope, values); }
@param {string|object} scope @param {object} [values]
describe
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
override(scope, values) { return set(overrides, scope, values); }
@param {string|object} scope @param {object} [values]
override
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
route(scope, name, targetScope, targetName) { const scopeObject = getScope(this, scope); const targetScopeObject = getScope(this, targetScope); const privateName = '_' + name; Object.defineProperties(scopeObject, { // A private property is defined to hold the actual value, when this property is s...
Routes the named defaults to fallback to another scope/name. This routing is useful when those target values, like defaults.color, are changed runtime. If the values would be copied, the runtime change would not take effect. By routing, the fallback is evaluated at each access, so its always up to date. Example: def...
route
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
get() { const local = this[privateName]; const target = targetScopeObject[targetName]; if (isObject(local)) { return Object.assign({}, target, local); } return valueOrDefault(local, target); }
Routes the named defaults to fallback to another scope/name. This routing is useful when those target values, like defaults.color, are changed runtime. If the values would be copied, the runtime change would not take effect. By routing, the fallback is evaluated at each access, so its always up to date. Example: def...
get
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
set(value) { this[privateName] = value; }
Routes the named defaults to fallback to another scope/name. This routing is useful when those target values, like defaults.color, are changed runtime. If the values would be copied, the runtime change would not take effect. By routing, the fallback is evaluated at each access, so its always up to date. Example: def...
set
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
apply(appliers) { appliers.forEach((apply) => apply(this)); }
Routes the named defaults to fallback to another scope/name. This routing is useful when those target values, like defaults.color, are changed runtime. If the values would be copied, the runtime change would not take effect. By routing, the fallback is evaluated at each access, so its always up to date. Example: def...
apply
javascript
chartjs/Chart.js
src/core/core.defaults.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.defaults.js
MIT
function binarySearch(metaset, axis, value, intersect) { const {controller, data, _sorted} = metaset; const iScale = controller._cachedMeta.iScale; const spanGaps = metaset.dataset ? metaset.dataset.options ? metaset.dataset.options.spanGaps : null : null; if (iScale && axis === iScale.axis && axis !== 'r' && ...
Helper function to do binary search when possible @param {object} metaset - the dataset meta @param {string} axis - the axis mode. x|y|xy|r @param {number} value - the value to find @param {boolean} [intersect] - should the element intersect @returns {{lo:number, hi:number}} indices to search data array between
binarySearch
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function evaluateInteractionItems(chart, axis, position, handler, intersect) { const metasets = chart.getSortedVisibleDatasetMetas(); const value = position[axis]; for (let i = 0, ilen = metasets.length; i < ilen; ++i) { const {index, data} = metasets[i]; const {lo, hi} = binarySearch(metasets[i], axis, v...
Helper function to select candidate elements for interaction @param {Chart} chart - the chart @param {string} axis - the axis mode. x|y|xy|r @param {Point} position - the point to be nearest to, in relative coordinates @param {function} handler - the callback to execute for each visible item @param {boolean} [intersect...
evaluateInteractionItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getDistanceMetricForAxis(axis) { const useX = axis.indexOf('x') !== -1; const useY = axis.indexOf('y') !== -1; return function(pt1, pt2) { const deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0; const deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0; return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(del...
Get a distance metric function for two points based on the axis mode setting @param {string} axis - the axis mode. x|y|xy|r
getDistanceMetricForAxis
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) { const items = []; if (!includeInvisible && !chart.isPointInArea(position)) { return items; } const evaluationFunc = function(element, datasetIndex, index) { if (!includeInvisible && !_isPointInArea(element, chart.c...
Helper function to get the items that intersect the event position @param {Chart} chart - the chart @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axis mode. x|y|xy|r @param {boolean} [useFinalPosition] - use the element's animation target instead of current pos...
getIntersectItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
evaluationFunc = function(element, datasetIndex, index) { if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) { return; } if (element.inRange(position.x, position.y, useFinalPosition)) { items.push({element, datasetIndex, index}); } }
Helper function to get the items that intersect the event position @param {Chart} chart - the chart @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axis mode. x|y|xy|r @param {boolean} [useFinalPosition] - use the element's animation target instead of current pos...
evaluationFunc
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
evaluationFunc = function(element, datasetIndex, index) { if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) { return; } if (element.inRange(position.x, position.y, useFinalPosition)) { items.push({element, datasetIndex, index}); } }
Helper function to get the items that intersect the event position @param {Chart} chart - the chart @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axis mode. x|y|xy|r @param {boolean} [useFinalPosition] - use the element's animation target instead of current pos...
evaluationFunc
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getNearestRadialItems(chart, position, axis, useFinalPosition) { let items = []; function evaluationFunc(element, datasetIndex, index) { const {startAngle, endAngle} = element.getProps(['startAngle', 'endAngle'], useFinalPosition); const {angle} = getAngleFromPoint(element, {x: position.x, y: posi...
Helper function to get the items nearest to the event position for a radial chart @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axes along which to measure distance @param {boolean} [useFinalPosition] - ...
getNearestRadialItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function evaluationFunc(element, datasetIndex, index) { const {startAngle, endAngle} = element.getProps(['startAngle', 'endAngle'], useFinalPosition); const {angle} = getAngleFromPoint(element, {x: position.x, y: position.y}); if (_angleBetween(angle, startAngle, endAngle)) { items.push({element, dat...
Helper function to get the items nearest to the event position for a radial chart @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axes along which to measure distance @param {boolean} [useFinalPosition] - ...
evaluationFunc
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) { let items = []; const distanceMetric = getDistanceMetricForAxis(axis); let minDistance = Number.POSITIVE_INFINITY; function evaluationFunc(element, datasetIndex, index) { const inRange = element.inRang...
Helper function to get the items nearest to the event position for a cartesian chart @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axes along which to measure distance @param {boolean} [intersect] - if t...
getNearestCartesianItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function evaluationFunc(element, datasetIndex, index) { const inRange = element.inRange(position.x, position.y, useFinalPosition); if (intersect && !inRange) { return; } const center = element.getCenterPoint(useFinalPosition); const pointInArea = !!includeInvisible || chart.isPointInArea(cent...
Helper function to get the items nearest to the event position for a cartesian chart @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axes along which to measure distance @param {boolean} [intersect] - if t...
evaluationFunc
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) { if (!includeInvisible && !chart.isPointInArea(position)) { return []; } return axis === 'r' && !intersect ? getNearestRadialItems(chart, position, axis, useFinalPosition) : getNearestCartesianItems(chart,...
Helper function to get the items nearest to the event position considering all visible items in the chart @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axes along which to measure distance @param {boolea...
getNearestItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function getAxisItems(chart, position, axis, intersect, useFinalPosition) { const items = []; const rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange'; let intersectsItem = false; evaluateInteractionItems(chart, axis, position, (element, datasetIndex, index) => { if (element[rangeMethod] && element[range...
Helper function to get the items matching along the given X or Y axis @param {Chart} chart - the chart to look at elements from @param {Point} position - the point to be nearest to, in relative coordinates @param {string} axis - the axis to match @param {boolean} [intersect] - if true, only consider items that intersec...
getAxisItems
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
index(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); // Default axis for index mode is 'x' to match old behaviour const axis = options.axis || 'x'; const includeInvisible = options.includeInvisible || false; const items = options.intersect ? ...
Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item @function Chart.Interaction.modes.index @since v2.4.0 @param {Chart} chart - th...
index
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
dataset(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); const axis = options.axis || 'xy'; const includeInvisible = options.includeInvisible || false; let items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, include...
Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something If the options.intersect is false, we find the nearest item and return the items in that dataset @function Chart.Interaction.modes.dataset @param {Chart} chart - the chart we are returning items...
dataset
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
point(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); const axis = options.axis || 'xy'; const includeInvisible = options.includeInvisible || false; return getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible); }
Point mode returns all elements that hit test based on the event position of the event @function Chart.Interaction.modes.intersect @param {Chart} chart - the chart we are returning items from @param {Event} e - the event we are find things at @param {InteractionOptions} options - options to use @param {boolean} [useFin...
point
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
nearest(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); const axis = options.axis || 'xy'; const includeInvisible = options.includeInvisible || false; return getNearestItems(chart, position, axis, options.intersect, useFinalPosition, includeInvisible); ...
nearest mode returns the element closest to the point @function Chart.Interaction.modes.intersect @param {Chart} chart - the chart we are returning items from @param {Event} e - the event we are find things at @param {InteractionOptions} options - options to use @param {boolean} [useFinalPosition] - use final element p...
nearest
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
x(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); return getAxisItems(chart, position, 'x', options.intersect, useFinalPosition); }
x mode returns the elements that hit-test at the current x coordinate @function Chart.Interaction.modes.x @param {Chart} chart - the chart we are returning items from @param {Event} e - the event we are find things at @param {InteractionOptions} options - options to use @param {boolean} [useFinalPosition] - use final e...
x
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
y(chart, e, options, useFinalPosition) { const position = getRelativePosition(e, chart); return getAxisItems(chart, position, 'y', options.intersect, useFinalPosition); }
y mode returns the elements that hit-test at the current y coordinate @function Chart.Interaction.modes.y @param {Chart} chart - the chart we are returning items from @param {Event} e - the event we are find things at @param {InteractionOptions} options - options to use @param {boolean} [useFinalPosition] - use final e...
y
javascript
chartjs/Chart.js
src/core/core.interaction.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.interaction.js
MIT
function filterByPosition(array, position) { return array.filter(v => v.pos === position); }
@typedef { import('./core.controller.js').default } Chart
filterByPosition
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function filterDynamicPositionByAxis(array, axis) { return array.filter(v => STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis); }
@typedef { import('./core.controller.js').default } Chart
filterDynamicPositionByAxis
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function sortByWeight(array, reverse) { return array.sort((a, b) => { const v0 = reverse ? b : a; const v1 = reverse ? a : b; return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight; }); }
@typedef { import('./core.controller.js').default } Chart
sortByWeight
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function wrapBoxes(boxes) { const layoutBoxes = []; let i, ilen, box, pos, stack, stackWeight; for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) { box = boxes[i]; ({position: pos, options: {stack, stackWeight = 1}} = box); layoutBoxes.push({ index: i, box, pos, horizonta...
@typedef { import('./core.controller.js').default } Chart
wrapBoxes
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function buildStacks(layouts) { const stacks = {}; for (const wrap of layouts) { const {stack, pos, stackWeight} = wrap; if (!stack || !STATIC_POSITIONS.includes(pos)) { continue; } const _stack = stacks[stack] || (stacks[stack] = {count: 0, placed: 0, weight: 0, size: 0}); _stack.count++;...
@typedef { import('./core.controller.js').default } Chart
buildStacks
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function setLayoutDims(layouts, params) { const stacks = buildStacks(layouts); const {vBoxMaxWidth, hBoxMaxHeight} = params; let i, ilen, layout; for (i = 0, ilen = layouts.length; i < ilen; ++i) { layout = layouts[i]; const {fullSize} = layout.box; const stack = stacks[layout.stack]; const fact...
store dimensions used instead of available chartArea in fitBoxes
setLayoutDims
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function buildLayoutBoxes(boxes) { const layoutBoxes = wrapBoxes(boxes); const fullSize = sortByWeight(layoutBoxes.filter(wrap => wrap.box.fullSize), true); const left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true); const right = sortByWeight(filterByPosition(layoutBoxes, 'right')); const top = s...
store dimensions used instead of available chartArea in fitBoxes
buildLayoutBoxes
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function getCombinedMax(maxPadding, chartArea, a, b) { return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]); }
store dimensions used instead of available chartArea in fitBoxes
getCombinedMax
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function updateMaxPadding(maxPadding, boxPadding) { maxPadding.top = Math.max(maxPadding.top, boxPadding.top); maxPadding.left = Math.max(maxPadding.left, boxPadding.left); maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom); maxPadding.right = Math.max(maxPadding.right, boxPadding.right); }
store dimensions used instead of available chartArea in fitBoxes
updateMaxPadding
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function updateDims(chartArea, params, layout, stacks) { const {pos, box} = layout; const maxPadding = chartArea.maxPadding; // dynamically placed boxes size is not considered if (!isObject(pos)) { if (layout.size) { // this layout was already counted for, lets first reduce old size chartArea[p...
store dimensions used instead of available chartArea in fitBoxes
updateDims
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function handleMaxPadding(chartArea) { const maxPadding = chartArea.maxPadding; function updatePos(pos) { const change = Math.max(maxPadding[pos] - chartArea[pos], 0); chartArea[pos] += change; return change; } chartArea.y += updatePos('top'); chartArea.x += updatePos('left'); updatePos('right'...
store dimensions used instead of available chartArea in fitBoxes
handleMaxPadding
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function updatePos(pos) { const change = Math.max(maxPadding[pos] - chartArea[pos], 0); chartArea[pos] += change; return change; }
store dimensions used instead of available chartArea in fitBoxes
updatePos
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function getMargins(horizontal, chartArea) { const maxPadding = chartArea.maxPadding; function marginForPositions(positions) { const margin = {left: 0, top: 0, right: 0, bottom: 0}; positions.forEach((pos) => { margin[pos] = Math.max(chartArea[pos], maxPadding[pos]); }); return margin; } ...
store dimensions used instead of available chartArea in fitBoxes
getMargins
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function marginForPositions(positions) { const margin = {left: 0, top: 0, right: 0, bottom: 0}; positions.forEach((pos) => { margin[pos] = Math.max(chartArea[pos], maxPadding[pos]); }); return margin; }
store dimensions used instead of available chartArea in fitBoxes
marginForPositions
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function fitBoxes(boxes, chartArea, params, stacks) { const refitBoxes = []; let i, ilen, layout, box, refit, changed; for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) { layout = boxes[i]; box = layout.box; box.update( layout.width || chartArea.w, layout.height || chartArea.h, ...
store dimensions used instead of available chartArea in fitBoxes
fitBoxes
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function setBoxDims(box, left, top, width, height) { box.top = top; box.left = left; box.right = left + width; box.bottom = top + height; box.width = width; box.height = height; }
store dimensions used instead of available chartArea in fitBoxes
setBoxDims
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
function placeBoxes(boxes, chartArea, params, stacks) { const userPadding = params.padding; let {x, y} = chartArea; for (const layout of boxes) { const box = layout.box; const stack = stacks[layout.stack] || {count: 1, placed: 0, weight: 1}; const weight = (layout.stackWeight / stack.weight) || 1; ...
store dimensions used instead of available chartArea in fitBoxes
placeBoxes
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
addBox(chart, item) { if (!chart.boxes) { chart.boxes = []; } // initialize item with default values item.fullSize = item.fullSize || false; item.position = item.position || 'top'; item.weight = item.weight || 0; // @ts-ignore item._layers = item._layers || function() { retu...
Register a box to a chart. A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title. @param {Chart} chart - the chart to use @param {LayoutItem} item - the item to add to be laid out
addBox
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
removeBox(chart, layoutItem) { const index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; if (index !== -1) { chart.boxes.splice(index, 1); } }
Remove a layoutItem from a chart @param {Chart} chart - the chart to remove the box from @param {LayoutItem} layoutItem - the item to remove from the layout
removeBox
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
configure(chart, item, options) { item.fullSize = options.fullSize; item.position = options.position; item.weight = options.weight; }
Sets (or updates) options on the given `item`. @param {Chart} chart - the chart in which the item lives (or will be added to) @param {LayoutItem} item - the item to configure with the given options @param {object} options - the new item options.
configure
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
update(chart, width, height, minPadding) { if (!chart) { return; } const padding = toPadding(chart.options.layout.padding); const availableWidth = Math.max(width - padding.width, 0); const availableHeight = Math.max(height - padding.height, 0); const boxes = buildLayoutBoxes(chart.boxes);...
Fits boxes of the given chart into the given size by having each box measure itself then running a fitting algorithm @param {Chart} chart - the chart @param {number} width - the width to fit into @param {number} height - the height to fit into @param {number} minPadding - minimum padding required for each side of chart...
update
javascript
chartjs/Chart.js
src/core/core.layouts.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.layouts.js
MIT
constructor() { this._init = []; }
@callback filterCallback @param {{plugin: object, options: object}} value @param {number} [index] @param {array} [array] @param {object} [thisArg] @return {boolean}
constructor
javascript
chartjs/Chart.js
src/core/core.plugins.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.plugins.js
MIT
function allPlugins(config) { const localIds = {}; const plugins = []; const keys = Object.keys(registry.plugins.items); for (let i = 0; i < keys.length; i++) { plugins.push(registry.getPlugin(keys[i])); } const local = config.plugins || []; for (let i = 0; i < local.length; i++) { const plugin =...
@param {import('./core.config.js').default} config
allPlugins
javascript
chartjs/Chart.js
src/core/core.plugins.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.plugins.js
MIT
function getOpts(options, all) { if (!all && options === false) { return null; } if (options === true) { return {}; } return options; }
@param {import('./core.config.js').default} config
getOpts
javascript
chartjs/Chart.js
src/core/core.plugins.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.plugins.js
MIT
function createDescriptors(chart, {plugins, localIds}, options, all) { const result = []; const context = chart.getContext(); for (const plugin of plugins) { const id = plugin.id; const opts = getOpts(options[id], all); if (opts === null) { continue; } result.push({ plugin, ...
@param {import('./core.config.js').default} config
createDescriptors
javascript
chartjs/Chart.js
src/core/core.plugins.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.plugins.js
MIT
function pluginOpts(config, {plugin, local}, opts, context) { const keys = config.pluginScopeKeys(plugin); const scopes = config.getOptionScopes(opts, keys); if (local && plugin.defaults) { // make sure plugin defaults are in scopes for local (not registered) plugins scopes.push(plugin.defaults); } re...
@param {import('./core.config.js').default} config
pluginOpts
javascript
chartjs/Chart.js
src/core/core.plugins.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.plugins.js
MIT
constructor() { this.controllers = new TypedRegistry(DatasetController, 'datasets', true); this.elements = new TypedRegistry(Element, 'elements'); this.plugins = new TypedRegistry(Object, 'plugins'); this.scales = new TypedRegistry(Scale, 'scales'); // Order is important, Scale has Element in protot...
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.registry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.registry.js
MIT
getController(id) { return this._get(id, this.controllers, 'controller'); }
@param {string} id @returns {typeof DatasetController}
getController
javascript
chartjs/Chart.js
src/core/core.registry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.registry.js
MIT
getElement(id) { return this._get(id, this.elements, 'element'); }
@param {string} id @returns {typeof Element}
getElement
javascript
chartjs/Chart.js
src/core/core.registry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.registry.js
MIT
getScale(id) { return this._get(id, this.scales, 'scale'); }
@param {string} id @returns {typeof Scale}
getScale
javascript
chartjs/Chart.js
src/core/core.registry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.registry.js
MIT
function autoSkip(scale, ticks) { const tickOpts = scale.options.ticks; const determinedMaxTicks = determineMaxTicks(scale); const ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks); const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : []; const numMajorI...
Returns a subset of ticks to be plotted to avoid overlapping labels. @param {import('./core.scale.js').default} scale @param {Tick[]} ticks @return {Tick[]} @private
autoSkip
javascript
chartjs/Chart.js
src/core/core.scale.autoskip.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.autoskip.js
MIT
function determineMaxTicks(scale) { const offset = scale.options.offset; const tickLength = scale._tickSize(); const maxScale = scale._length / tickLength + (offset ? 0 : 1); const maxChart = scale._maxLength / tickLength; return Math.floor(Math.min(maxScale, maxChart)); }
Returns a subset of ticks to be plotted to avoid overlapping labels. @param {import('./core.scale.js').default} scale @param {Tick[]} ticks @return {Tick[]} @private
determineMaxTicks
javascript
chartjs/Chart.js
src/core/core.scale.autoskip.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.autoskip.js
MIT
function skipMajors(ticks, newTicks, majorIndices, spacing) { let count = 0; let next = majorIndices[0]; let i; spacing = Math.ceil(spacing); for (i = 0; i < ticks.length; i++) { if (i === next) { newTicks.push(ticks[i]); count++; next = majorIndices[count * spacing]; } } }
@param {Tick[]} ticks @param {Tick[]} newTicks @param {number[]} majorIndices @param {number} spacing
skipMajors
javascript
chartjs/Chart.js
src/core/core.scale.autoskip.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.autoskip.js
MIT
function skip(ticks, newTicks, spacing, majorStart, majorEnd) { const start = valueOrDefault(majorStart, 0); const end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length); let count = 0; let length, i, next; spacing = Math.ceil(spacing); if (majorEnd) { length = majorEnd - majorStart; ...
@param {Tick[]} ticks @param {Tick[]} newTicks @param {number} spacing @param {number} [majorStart] @param {number} [majorEnd]
skip
javascript
chartjs/Chart.js
src/core/core.scale.autoskip.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.autoskip.js
MIT
function getPixelForGridLine(scale, index, offsetGridLines) { const length = scale.ticks.length; const validIndex = Math.min(index, length - 1); const start = scale._startPixel; const end = scale._endPixel; const epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error. let lineValue = scale.getPix...
@param {Scale} scale @param {number} index @param {boolean} offsetGridLines
getPixelForGridLine
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
function garbageCollect(caches, length) { each(caches, (cache) => { const gc = cache.gc; const gcLen = gc.length / 2; let i; if (gcLen > length) { for (i = 0; i < gcLen; ++i) { delete cache.data[gc[i]]; } gc.splice(0, gcLen); } }); }
@param {object} caches @param {number} length
garbageCollect
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
parse(raw, index) { // eslint-disable-line no-unused-vars return raw; }
Parse a supported input value to internal representation. @param {*} raw @param {number} [index] @since 3.0
parse
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getUserBounds() { let {_userMin, _userMax, _suggestedMin, _suggestedMax} = this; _userMin = finiteOrDefault(_userMin, Number.POSITIVE_INFINITY); _userMax = finiteOrDefault(_userMax, Number.NEGATIVE_INFINITY); _suggestedMin = finiteOrDefault(_suggestedMin, Number.POSITIVE_INFINITY); _suggestedMax = f...
@return {{min: number, max: number, minDefined: boolean, maxDefined: boolean}} @protected @since 3.0
getUserBounds
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getMinMax(canStack) { let {min, max, minDefined, maxDefined} = this.getUserBounds(); let range; if (minDefined && maxDefined) { return {min, max}; } const metas = this.getMatchingVisibleMetas(); for (let i = 0, ilen = metas.length; i < ilen; ++i) { range = metas[i].controller.getMi...
@param {boolean} canStack @return {{min: number, max: number}} @protected @since 3.0
getMinMax
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getPadding() { return { left: this.paddingLeft || 0, top: this.paddingTop || 0, right: this.paddingRight || 0, bottom: this.paddingBottom || 0 }; }
Get the padding needed for the scale @return {{top: number, left: number, bottom: number, right: number}} the necessary padding @private
getPadding
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getTicks() { return this.ticks; }
Returns the scale tick objects @return {Tick[]} @since 2.7
getTicks
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
update(maxWidth, maxHeight, margins) { const {beginAtZero, grace, ticks: tickOpts} = this.options; const sampleSize = tickOpts.sampleSize; // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;) this.beforeUpdate(); // Absorb the master measurements this.maxWidth...
@param {number} maxWidth - the max width in pixels @param {number} maxHeight - the max height in pixels @param {{top: number, left: number, bottom: number, right: number}} margins - the space between the edge of the other scales and edge of the chart This space comes from two sources: - padding - space that's req...
update
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
generateTickLabels(ticks) { const tickOpts = this.options.ticks; let i, ilen, tick; for (i = 0, ilen = ticks.length; i < ilen; i++) { tick = ticks[i]; tick.label = call(tickOpts.callback, [tick.value, i, ticks], this); } }
Convert ticks to label strings @param {Tick[]} ticks
generateTickLabels
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
afterTickToLabelConversion() { call(this.options.afterTickToLabelConversion, [this]); }
Convert ticks to label strings @param {Tick[]} ticks
afterTickToLabelConversion
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
beforeCalculateLabelRotation() { call(this.options.beforeCalculateLabelRotation, [this]); }
Convert ticks to label strings @param {Tick[]} ticks
beforeCalculateLabelRotation
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
calculateLabelRotation() { const options = this.options; const tickOpts = options.ticks; const numTicks = getTicksLimit(this.ticks.length, options.ticks.maxTicksLimit); const minRotation = tickOpts.minRotation || 0; const maxRotation = tickOpts.maxRotation; let labelRotation = minRotation; l...
Convert ticks to label strings @param {Tick[]} ticks
calculateLabelRotation
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
afterCalculateLabelRotation() { call(this.options.afterCalculateLabelRotation, [this]); }
Convert ticks to label strings @param {Tick[]} ticks
afterCalculateLabelRotation
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
beforeFit() { call(this.options.beforeFit, [this]); }
Convert ticks to label strings @param {Tick[]} ticks
beforeFit
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
fit() { // Reset const minSize = { width: 0, height: 0 }; const {chart, options: {ticks: tickOpts, title: titleOpts, grid: gridOpts}} = this; const display = this._isVisible(); const isHorizontal = this.isHorizontal(); if (display) { const titleHeight = getTitleHeight(tit...
Convert ticks to label strings @param {Tick[]} ticks
fit
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
_calculatePadding(first, last, sin, cos) { const {ticks: {align, padding}, position} = this.options; const isRotated = this.labelRotation !== 0; const labelsBelowTicks = position !== 'top' && this.axis === 'x'; if (this.isHorizontal()) { const offsetLeft = this.getPixelForTick(0) - this.left; ...
Convert ticks to label strings @param {Tick[]} ticks
_calculatePadding
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
_handleMargins() { if (this._margins) { this._margins.left = Math.max(this.paddingLeft, this._margins.left); this._margins.top = Math.max(this.paddingTop, this._margins.top); this._margins.right = Math.max(this.paddingRight, this._margins.right); this._margins.bottom = Math.max(this.paddingB...
Handle margins and padding interactions @private
_handleMargins
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
afterFit() { call(this.options.afterFit, [this]); }
Handle margins and padding interactions @private
afterFit
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
_getLabelSizes() { let labelSizes = this._labelSizes; if (!labelSizes) { const sampleSize = this.options.ticks.sampleSize; let ticks = this.ticks; if (sampleSize < ticks.length) { ticks = sample(ticks, sampleSize); } this._labelSizes = labelSizes = this._computeLabelSizes...
@return {{ first: object, last: object, widest: object, highest: object, widths: Array, heights: array }} @private
_getLabelSizes
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
_computeLabelSizes(ticks, length, maxTicksLimit) { const {ctx, _longestTextCache: caches} = this; const widths = []; const heights = []; const increment = Math.floor(length / getTicksLimit(length, maxTicksLimit)); let widestLabelSize = 0; let highestLabelSize = 0; let i, j, jlen, label, tick...
Returns {width, height, offset} objects for the first, last, widest, highest tick labels where offset indicates the anchor point offset from the top in pixels. @return {{ first: object, last: object, widest: object, highest: object, widths: Array, heights: array }} @private
_computeLabelSizes
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getLabelForValue(value) { return value; }
Used to get the label to display in the tooltip for the given value @param {*} value @return {string}
getLabelForValue
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getPixelForValue(value, index) { // eslint-disable-line no-unused-vars return NaN; }
Returns the location of the given data point. Value can either be an index or a numerical value The coordinate (0, 0) is at the upper-left corner of the canvas @param {*} value @param {number} [index] @return {number}
getPixelForValue
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getPixelForTick(index) { const ticks = this.ticks; if (index < 0 || index > ticks.length - 1) { return null; } return this.getPixelForValue(ticks[index].value); }
Returns the location of the tick at the given index The coordinate (0, 0) is at the upper-left corner of the canvas @param {number} index @return {number}
getPixelForTick
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getPixelForDecimal(decimal) { if (this._reversePixels) { decimal = 1 - decimal; } const pixel = this._startPixel + decimal * this._length; return _int16Range(this._alignToPixels ? _alignPixel(this.chart, pixel, 0) : pixel); }
Utility for getting the pixel location of a percentage of scale The coordinate (0, 0) is at the upper-left corner of the canvas @param {number} decimal @return {number}
getPixelForDecimal
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getBasePixel() { return this.getPixelForValue(this.getBaseValue()); }
Returns the pixel for the minimum chart value The coordinate (0, 0) is at the upper-left corner of the canvas @return {number}
getBasePixel
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
getMatchingVisibleMetas(type) { const metas = this.chart.getSortedVisibleDatasetMetas(); const axisID = this.axis + 'AxisID'; const result = []; let i, ilen; for (i = 0, ilen = metas.length; i < ilen; ++i) { const meta = metas[i]; if (meta[axisID] === this.id && (!type || meta.type === ...
Returns visible dataset metas that are attached to this scale @param {string} [type] - if specified, also filter by dataset type @return {object[]}
getMatchingVisibleMetas
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
_resolveTickFontOptions(index) { const opts = this.options.ticks.setContext(this.getContext(index)); return toFont(opts.font); }
@param {number} index @return {object} @protected
_resolveTickFontOptions
javascript
chartjs/Chart.js
src/core/core.scale.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js
MIT
values(value) { return isArray(value) ? /** @type {string[]} */ (value) : '' + value; }
Formatter for value labels @method Chart.Ticks.formatters.values @param value the value to display @return {string|string[]} the label to display
values
javascript
chartjs/Chart.js
src/core/core.ticks.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.ticks.js
MIT
numeric(tickValue, index, ticks) { if (tickValue === 0) { return '0'; // never show decimal places for 0 } const locale = this.chart.options.locale; let notation; let delta = tickValue; // This is used when there are less than 2 ticks as the tick interval. if (ticks.length > 1) { /...
Formatter for numeric ticks @method Chart.Ticks.formatters.numeric @param tickValue {number} the value to be formatted @param index {number} the position of the tickValue parameter in the ticks array @param ticks {object[]} the list of ticks being converted @return {string} string representation of the tickValue parame...
numeric
javascript
chartjs/Chart.js
src/core/core.ticks.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.ticks.js
MIT
logarithmic(tickValue, index, ticks) { if (tickValue === 0) { return '0'; } const remain = ticks[index].significand || (tickValue / (Math.pow(10, Math.floor(log10(tickValue))))); if ([1, 2, 3, 5, 10, 15].includes(remain) || index > 0.8 * ticks.length) { return formatters.numeric.call(this, t...
Formatter for logarithmic ticks @method Chart.Ticks.formatters.logarithmic @param tickValue {number} the value to be formatted @param index {number} the position of the tickValue parameter in the ticks array @param ticks {object[]} the list of ticks being converted @return {string} string representation of the tickValu...
logarithmic
javascript
chartjs/Chart.js
src/core/core.ticks.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.ticks.js
MIT
function calculateDelta(tickValue, ticks) { // Figure out how many digits to show // The space between the first two ticks might be smaller than normal spacing let delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value; // If we have a number like 2.5 as the delta, figure ...
Formatter for logarithmic ticks @method Chart.Ticks.formatters.logarithmic @param tickValue {number} the value to be formatted @param index {number} the position of the tickValue parameter in the ticks array @param ticks {object[]} the list of ticks being converted @return {string} string representation of the tickValu...
calculateDelta
javascript
chartjs/Chart.js
src/core/core.ticks.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.ticks.js
MIT
constructor(type, scope, override) { this.type = type; this.scope = scope; this.override = override; this.items = Object.create(null); }
@typedef {{id: string, defaults: any, overrides?: any, defaultRoutes: any}} IChartComponent
constructor
javascript
chartjs/Chart.js
src/core/core.typedRegistry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.typedRegistry.js
MIT
isForType(type) { return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype); }
@typedef {{id: string, defaults: any, overrides?: any, defaultRoutes: any}} IChartComponent
isForType
javascript
chartjs/Chart.js
src/core/core.typedRegistry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.typedRegistry.js
MIT
register(item) { const proto = Object.getPrototypeOf(item); let parentScope; if (isIChartComponent(proto)) { // Make sure the parent is registered and note the scope where its defaults are. parentScope = this.register(proto); } const items = this.items; const id = item.id; cons...
@param {IChartComponent} item @returns {string} The scope where items defaults were registered to.
register
javascript
chartjs/Chart.js
src/core/core.typedRegistry.js
https://github.com/chartjs/Chart.js/blob/master/src/core/core.typedRegistry.js
MIT
function getBarBounds(bar, useFinalPosition) { const {x, y, base, width, height} = /** @type {BarProps} */ (bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition)); let left, right, top, bottom, half; if (bar.horizontal) { half = height / 2; left = Math.min(x, base); right = Math.max(...
Helper function to get the bounds of the bar regardless of the orientation @param {BarElement} bar the bar @param {boolean} [useFinalPosition] @return {object} bounds of the bar @private
getBarBounds
javascript
chartjs/Chart.js
src/elements/element.bar.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.bar.js
MIT
function addNormalRectPath(ctx, rect) { ctx.rect(rect.x, rect.y, rect.w, rect.h); }
Add a path of a rectangle to the current sub-path @param {CanvasRenderingContext2D} ctx Context @param {*} rect Bounding rect
addNormalRectPath
javascript
chartjs/Chart.js
src/elements/element.bar.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.bar.js
MIT
function inflateRect(rect, amount, refRect = {}) { const x = rect.x !== refRect.x ? -amount : 0; const y = rect.y !== refRect.y ? -amount : 0; const w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x; const h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y; return { x: rect.x ...
Add a path of a rectangle to the current sub-path @param {CanvasRenderingContext2D} ctx Context @param {*} rect Bounding rect
inflateRect
javascript
chartjs/Chart.js
src/elements/element.bar.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.bar.js
MIT
function setStyle(ctx, options, style = options) { ctx.lineCap = valueOrDefault(style.borderCapStyle, options.borderCapStyle); ctx.setLineDash(valueOrDefault(style.borderDash, options.borderDash)); ctx.lineDashOffset = valueOrDefault(style.borderDashOffset, options.borderDashOffset); ctx.lineJoin = valueOrDefau...
@typedef { import('./element.point.js').default } PointElement
setStyle
javascript
chartjs/Chart.js
src/elements/element.line.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.line.js
MIT
function lineTo(ctx, previous, target) { ctx.lineTo(target.x, target.y); }
@typedef { import('./element.point.js').default } PointElement
lineTo
javascript
chartjs/Chart.js
src/elements/element.line.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.line.js
MIT
function _getSegmentMethod(line) { const opts = line.options; const borderDash = opts.borderDash && opts.borderDash.length; const useFastPath = !line._decimated && !line._loop && !opts.tension && opts.cubicInterpolationMode !== 'monotone' && !opts.stepped && !borderDash; return useFastPath ? fastPathSegment : p...
@param {LineElement} line - the line @returns {function} @private
_getSegmentMethod
javascript
chartjs/Chart.js
src/elements/element.line.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.line.js
MIT
first() { const segments = this.segments; const points = this.points; return segments.length && points[segments[0].start]; }
First non-skipped point on this line @returns {PointElement|undefined}
first
javascript
chartjs/Chart.js
src/elements/element.line.js
https://github.com/chartjs/Chart.js/blob/master/src/elements/element.line.js
MIT