1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 10:19:24 +02:00
Daniel Neto 2023-06-30 08:55:17 -03:00
parent 746e163d01
commit 1c7ea28b46
808 changed files with 316395 additions and 381162 deletions

315
node_modules/chart.js/dist/chart.cjs generated vendored
View file

@ -1,5 +1,5 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
@ -1815,7 +1815,7 @@ class DoughnutController extends DatasetController {
};
static descriptors = {
_scriptable: (name)=>name !== 'spacing',
_indexable: (name)=>name !== 'spacing'
_indexable: (name)=>name !== 'spacing' && !name.startsWith('borderDash') && !name.startsWith('hoverBorderDash')
};
static overrides = {
aspectRatio: 1,
@ -2549,8 +2549,8 @@ BarController: BarController,
BubbleController: BubbleController,
DoughnutController: DoughnutController,
LineController: LineController,
PolarAreaController: PolarAreaController,
PieController: PieController,
PolarAreaController: PolarAreaController,
RadarController: RadarController,
ScatterController: ScatterController
});
@ -2580,6 +2580,7 @@ ScatterController: ScatterController
*/ static override(members) {
Object.assign(DateAdapterBase.prototype, members);
}
options;
constructor(options){
this.options = options || {};
}
@ -3045,18 +3046,18 @@ function placeBoxes(boxes, chartArea, params, stacks) {
stack.placed += width;
y = box.bottom;
} else {
const height1 = chartArea.h * weight;
const width1 = stack.size || box.width;
const height = chartArea.h * weight;
const width = stack.size || box.width;
if (helpers_segment.defined(stack.start)) {
x = stack.start;
}
if (box.fullSize) {
setBoxDims(box, x, userPadding.top, width1, params.outerHeight - userPadding.bottom - userPadding.top);
setBoxDims(box, x, userPadding.top, width, params.outerHeight - userPadding.bottom - userPadding.top);
} else {
setBoxDims(box, x, chartArea.top + stack.placed, width1, height1);
setBoxDims(box, x, chartArea.top + stack.placed, width, height);
}
stack.start = x;
stack.placed += height1;
stack.placed += height;
x = box.right;
}
}
@ -3457,7 +3458,11 @@ function _detectPlatform(canvas) {
class Element {
static defaults = {};
static defaultRoutes = undefined;
x;
y;
active = false;
options;
$animations;
tooltipPosition(useFinalPosition) {
const { x , y } = this.getProps([
'x',
@ -3669,7 +3674,7 @@ function createTickContext(parent, index, tick) {
});
}
function titleAlign(align, position, reverse) {
let ret = helpers_segment._toLeftRightCenter(align);
let ret = helpers_segment._toLeftRightCenter(align);
if (reverse && position !== 'right' || !reverse && position === 'right') {
ret = reverseAlign(ret);
}
@ -3696,9 +3701,9 @@ function titleArgs(scale, offset, position, align) {
maxWidth = right - left;
} else {
if (helpers_segment.isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
titleX = scales[positionAxisID1].getPixelForValue(value1) - width + offset;
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
titleX = scales[positionAxisID].getPixelForValue(value) - width + offset;
} else if (position === 'center') {
titleX = (chartArea.left + chartArea.right) / 2 - width + offset;
} else {
@ -4176,7 +4181,7 @@ class Scale extends Element {
height = lineHeight;
} else if (helpers_segment.isArray(label)) {
for(j = 0, jlen = label.length; j < jlen; ++j){
nestedLabel = label[j];
nestedLabel = label[j];
if (!helpers_segment.isNullOrUndef(nestedLabel) && !helpers_segment.isArray(nestedLabel)) {
width = helpers_segment._measureText(ctx, cache.data, cache.gc, width, nestedLabel);
height += lineHeight;
@ -4321,9 +4326,9 @@ class Scale extends Element {
if (position === 'center') {
borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
} else if (helpers_segment.isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
borderValue = alignBorderValue(this.chart.scales[positionAxisID1].getPixelForValue(value1));
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));
}
tx1 = borderValue - axisHalfWidth;
tx2 = tx1 - tl;
@ -4402,9 +4407,9 @@ class Scale extends Element {
textAlign = ret.textAlign;
x = ret.x;
} else if (position === 'right') {
const ret1 = this._getYAxisLabelAlignment(tl);
textAlign = ret1.textAlign;
x = ret1.x;
const ret = this._getYAxisLabelAlignment(tl);
textAlign = ret.textAlign;
x = ret.x;
} else if (axis === 'x') {
if (position === 'center') {
y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;
@ -4418,9 +4423,9 @@ class Scale extends Element {
if (position === 'center') {
x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;
} else if (helpers_segment.isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
x = this.chart.scales[positionAxisID1].getPixelForValue(value1);
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
x = this.chart.scales[positionAxisID].getPixelForValue(value);
}
textAlign = this._getYAxisLabelAlignment(tl).textAlign;
}
@ -5103,8 +5108,8 @@ class PluginService {
plugins.push(registry.getPlugin(keys[i]));
}
const local = config.plugins || [];
for(let i1 = 0; i1 < local.length; i1++){
const plugin = local[i1];
for(let i = 0; i < local.length; i++){
const plugin = local[i];
if (plugins.indexOf(plugin) === -1) {
plugins.push(plugin);
localIds[plugin.id] = true;
@ -5175,6 +5180,11 @@ function getAxisFromDefaultScaleID(id, indexAxis) {
function getDefaultScaleIDFromAxis(axis, indexAxis) {
return axis === indexAxis ? '_index_' : '_value_';
}
function idMatchesAxis(id) {
if (id === 'x' || id === 'y' || id === 'r') {
return id;
}
}
function axisFromPosition(position) {
if (position === 'top' || position === 'bottom') {
return 'x';
@ -5183,15 +5193,33 @@ function axisFromPosition(position) {
return 'y';
}
}
function determineAxis(id, scaleOptions) {
if (id === 'x' || id === 'y' || id === 'r') {
function determineAxis(id, ...scaleOptions) {
if (idMatchesAxis(id)) {
return id;
}
id = scaleOptions.axis || axisFromPosition(scaleOptions.position) || id.length > 1 && determineAxis(id[0].toLowerCase(), scaleOptions);
if (id) {
return id;
for (const opts of scaleOptions){
const axis = opts.axis || axisFromPosition(opts.position) || id.length > 1 && idMatchesAxis(id[0].toLowerCase());
if (axis) {
return axis;
}
}
throw new Error(`Cannot determine type of '${name}' axis. Please provide 'axis' or 'position' option.`);
throw new Error(`Cannot determine type of '${id}' axis. Please provide 'axis' or 'position' option.`);
}
function getAxisFromDataset(id, axis, dataset) {
if (dataset[axis + 'AxisID'] === id) {
return {
axis
};
}
}
function retrieveAxisFromDatasets(id, config) {
if (config.data && config.data.datasets) {
const boundDs = config.data.datasets.filter((d)=>d.xAxisID === id || d.yAxisID === id);
if (boundDs.length) {
return getAxisFromDataset(id, 'x', boundDs[0]) || getAxisFromDataset(id, 'y', boundDs[0]);
}
}
return {};
}
function mergeScaleConfig(config, options) {
const chartDefaults = helpers_segment.overrides[config.type] || {
@ -5208,7 +5236,7 @@ function mergeScaleConfig(config, options) {
if (scaleConf._proxy) {
return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
}
const axis = determineAxis(id, scaleConf);
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), helpers_segment.defaults.scales[scaleConf.type]);
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
const defaultScaleOptions = chartDefaults.scales || {};
scales[id] = helpers_segment.mergeIf(Object.create(null), [
@ -5467,7 +5495,7 @@ function needContext(proxy, names) {
return false;
}
var version = "4.2.1";
var version = "4.3.0";
const KNOWN_POSITIONS = [
'top',
@ -5950,9 +5978,9 @@ class Chart {
for(let i = 0, ilen = this.data.datasets.length; i < ilen; ++i){
this.getDatasetMeta(i).controller.configure();
}
for(let i1 = 0, ilen1 = this.data.datasets.length; i1 < ilen1; ++i1){
this._updateDataset(i1, helpers_segment.isFunction(mode) ? mode({
datasetIndex: i1
for(let i = 0, ilen = this.data.datasets.length; i < ilen; ++i){
this._updateDataset(i, helpers_segment.isFunction(mode) ? mode({
datasetIndex: i
}) : mode);
}
this.notifyPlugins('afterDatasetsUpdate', {
@ -6493,8 +6521,8 @@ function toRadiusCorners(value) {
ctx.lineTo(p4.x, p4.y);
// The corner segment from point 4 to point 5
if (innerEnd > 0) {
const pCenter1 = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
ctx.arc(pCenter1.x, pCenter1.y, innerEnd, endAngle + helpers_segment.HALF_PI, innerEndAdjustedAngle + Math.PI);
const pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, innerEnd, endAngle + helpers_segment.HALF_PI, innerEndAdjustedAngle + Math.PI);
}
// The inner arc from point 5 to point b to point 6
const innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;
@ -6502,16 +6530,16 @@ function toRadiusCorners(value) {
ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);
// The corner segment from point 6 to point 7
if (innerStart > 0) {
const pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
ctx.arc(pCenter2.x, pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - helpers_segment.HALF_PI);
const pCenter = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - helpers_segment.HALF_PI);
}
// The line from point 7 to point 8
const p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
ctx.lineTo(p8.x, p8.y);
// The corner segment from point 8 to point 1
if (outerStart > 0) {
const pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
ctx.arc(pCenter3.x, pCenter3.y, outerStart, startAngle - helpers_segment.HALF_PI, outerStartAdjustedAngle);
const pCenter = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, outerStart, startAngle - helpers_segment.HALF_PI, outerStartAdjustedAngle);
}
} else {
ctx.moveTo(x, y);
@ -6542,11 +6570,13 @@ function drawArc(ctx, element, offset, spacing, circular) {
}
function drawBorder(ctx, element, offset, spacing, circular) {
const { fullCircles , startAngle , circumference , options } = element;
const { borderWidth , borderJoinStyle } = options;
const { borderWidth , borderJoinStyle , borderDash , borderDashOffset } = options;
const inner = options.borderAlign === 'inner';
if (!borderWidth) {
return;
}
ctx.setLineDash(borderDash || []);
ctx.lineDashOffset = borderDashOffset;
if (inner) {
ctx.lineWidth = borderWidth * 2;
ctx.lineJoin = borderJoinStyle || 'round';
@ -6577,6 +6607,8 @@ class ArcElement extends Element {
static defaults = {
borderAlign: 'center',
borderColor: '#fff',
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: undefined,
borderRadius: 0,
borderWidth: 2,
@ -6588,6 +6620,17 @@ class ArcElement extends Element {
static defaultRoutes = {
backgroundColor: 'backgroundColor'
};
static descriptors = {
_scriptable: true,
_indexable: (name)=>name !== 'borderDash'
};
circumference;
endAngle;
fullCircles;
innerRadius;
outerRadius;
pixelMargin;
startAngle;
constructor(cfg){
super();
this.options = undefined;
@ -6618,7 +6661,7 @@ class ArcElement extends Element {
'outerRadius',
'circumference'
], useFinalPosition);
const rAdjust = this.options.spacing / 2;
const rAdjust = (this.options.spacing + this.options.borderWidth) / 2;
const _circumference = helpers_segment.valueOrDefault(circumference, endAngle - startAngle);
const betweenAngles = _circumference >= helpers_segment.TAU || helpers_segment._angleBetween(angle, startAngle, endAngle);
const withinRadius = helpers_segment._isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);
@ -6678,7 +6721,7 @@ function setStyle(ctx, options, style = options) {
function lineTo(ctx, previous, target) {
ctx.lineTo(target.x, target.y);
}
function getLineMethod(options) {
function getLineMethod(options) {
if (options.stepped) {
return helpers_segment._steppedLineTo;
}
@ -6962,6 +7005,9 @@ function inRange$1(el, pos, axis, useFinalPosition) {
}
class PointElement extends Element {
static id = 'point';
parsed;
skip;
stop;
/**
* @type {any}
*/ static defaults = {
@ -7223,9 +7269,9 @@ class BarElement extends Element {
var elements = /*#__PURE__*/Object.freeze({
__proto__: null,
ArcElement: ArcElement,
BarElement: BarElement,
LineElement: LineElement,
PointElement: PointElement,
BarElement: BarElement
PointElement: PointElement
});
const BORDER_COLORS = [
@ -8277,15 +8323,15 @@ class Legend extends Element {
} else {
let col = 0;
let top = helpers_segment._alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
for (const hitbox1 of hitboxes){
if (hitbox1.col !== col) {
col = hitbox1.col;
for (const hitbox of hitboxes){
if (hitbox.col !== col) {
col = hitbox.col;
top = helpers_segment._alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
}
hitbox1.top = top;
hitbox1.left += this.left + padding;
hitbox1.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox1.left), hitbox1.width);
top += hitbox1.height + padding;
hitbox.top = top;
hitbox.left += this.left + padding;
hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox.left), hitbox.width);
top += hitbox.height + padding;
}
}
}
@ -9384,9 +9430,9 @@ class Tooltip extends Element {
}
}
_drawColorBox(ctx, pt, i, rtlHelper, options) {
const labelColors = this.labelColors[i];
const labelColor = this.labelColors[i];
const labelPointStyle = this.labelPointStyles[i];
const { boxHeight , boxWidth , boxPadding } = options;
const { boxHeight , boxWidth } = options;
const bodyFont = helpers_segment.toFont(options.bodyFont);
const colorX = getAlignedX(this, 'left', options);
const rtlColorX = rtlHelper.x(colorX);
@ -9404,17 +9450,17 @@ class Tooltip extends Element {
ctx.strokeStyle = options.multiKeyBackground;
ctx.fillStyle = options.multiKeyBackground;
helpers_segment.drawPoint(ctx, drawOptions, centerX, centerY);
ctx.strokeStyle = labelColors.borderColor;
ctx.fillStyle = labelColors.backgroundColor;
ctx.strokeStyle = labelColor.borderColor;
ctx.fillStyle = labelColor.backgroundColor;
helpers_segment.drawPoint(ctx, drawOptions, centerX, centerY);
} else {
ctx.lineWidth = helpers_segment.isObject(labelColors.borderWidth) ? Math.max(...Object.values(labelColors.borderWidth)) : labelColors.borderWidth || 1;
ctx.strokeStyle = labelColors.borderColor;
ctx.setLineDash(labelColors.borderDash || []);
ctx.lineDashOffset = labelColors.borderDashOffset || 0;
const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth - boxPadding);
const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - boxPadding - 2);
const borderRadius = helpers_segment.toTRBLCorners(labelColors.borderRadius);
ctx.lineWidth = helpers_segment.isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : labelColor.borderWidth || 1;
ctx.strokeStyle = labelColor.borderColor;
ctx.setLineDash(labelColor.borderDash || []);
ctx.lineDashOffset = labelColor.borderDashOffset || 0;
const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);
const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);
const borderRadius = helpers_segment.toTRBLCorners(labelColor.borderRadius);
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
ctx.fillStyle = options.multiKeyBackground;
@ -9427,7 +9473,7 @@ class Tooltip extends Element {
});
ctx.fill();
ctx.stroke();
ctx.fillStyle = labelColors.backgroundColor;
ctx.fillStyle = labelColor.backgroundColor;
ctx.beginPath();
helpers_segment.addRoundedRectPath(ctx, {
x: innerX,
@ -9441,7 +9487,7 @@ class Tooltip extends Element {
ctx.fillStyle = options.multiKeyBackground;
ctx.fillRect(outerX, colorY, boxWidth, boxHeight);
ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);
ctx.fillStyle = labelColors.backgroundColor;
ctx.fillStyle = labelColor.backgroundColor;
ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);
}
}
@ -10006,8 +10052,12 @@ function generateTicks$1(generationOptions, dataRange) {
}
}
for(; j < numSpaces; ++j){
const tickValue = Math.round((niceMin + j * spacing) * factor) / factor;
if (maxDefined && tickValue > max) {
break;
}
ticks.push({
value: Math.round((niceMin + j * spacing) * factor) / factor
value: tickValue
});
}
if (maxDefined && includeBounds && niceMax !== max) {
@ -10429,29 +10479,66 @@ function updateLimits(limits, orig, angle, hLimits, vLimits) {
limits.b = Math.max(limits.b, orig.b + y);
}
}
function createPointLabelItem(scale, index, itemOpts) {
const outerDistance = scale.drawingArea;
const { extra , additionalAngle , padding , size } = itemOpts;
const pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle);
const angle = Math.round(helpers_segment.toDegrees(helpers_segment._normalizeAngle(pointLabelPosition.angle + helpers_segment.HALF_PI)));
const y = yForAngle(pointLabelPosition.y, size.h, angle);
const textAlign = getTextAlignForAngle(angle);
const left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
return {
visible: true,
x: pointLabelPosition.x,
y,
textAlign,
left,
top: y,
right: left + size.w,
bottom: y + size.h
};
}
function isNotOverlapped(item, area) {
if (!area) {
return true;
}
const { left , top , right , bottom } = item;
const apexesInArea = helpers_segment._isPointInArea({
x: left,
y: top
}, area) || helpers_segment._isPointInArea({
x: left,
y: bottom
}, area) || helpers_segment._isPointInArea({
x: right,
y: top
}, area) || helpers_segment._isPointInArea({
x: right,
y: bottom
}, area);
return !apexesInArea;
}
function buildPointLabelItems(scale, labelSizes, padding) {
const items = [];
const valueCount = scale._pointLabels.length;
const opts = scale.options;
const extra = getTickBackdropHeight(opts) / 2;
const outerDistance = scale.drawingArea;
const additionalAngle = opts.pointLabels.centerPointLabels ? helpers_segment.PI / valueCount : 0;
const { centerPointLabels , display } = opts.pointLabels;
const itemOpts = {
extra: getTickBackdropHeight(opts) / 2,
additionalAngle: centerPointLabels ? helpers_segment.PI / valueCount : 0
};
let area;
for(let i = 0; i < valueCount; i++){
const pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + padding[i], additionalAngle);
const angle = Math.round(helpers_segment.toDegrees(helpers_segment._normalizeAngle(pointLabelPosition.angle + helpers_segment.HALF_PI)));
const size = labelSizes[i];
const y = yForAngle(pointLabelPosition.y, size.h, angle);
const textAlign = getTextAlignForAngle(angle);
const left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
items.push({
x: pointLabelPosition.x,
y,
textAlign,
left,
top: y,
right: left + size.w,
bottom: y + size.h
});
itemOpts.padding = padding[i];
itemOpts.size = labelSizes[i];
const item = createPointLabelItem(scale, i, itemOpts);
items.push(item);
if (display === 'auto') {
item.visible = isNotOverlapped(item, area);
if (item.visible) {
area = item;
}
}
}
return items;
}
@ -10479,35 +10566,43 @@ function yForAngle(y, h, angle) {
}
return y;
}
function drawPointLabelBox(ctx, opts, item) {
const { left , top , right , bottom } = item;
const { backdropColor } = opts;
if (!helpers_segment.isNullOrUndef(backdropColor)) {
const borderRadius = helpers_segment.toTRBLCorners(opts.borderRadius);
const padding = helpers_segment.toPadding(opts.backdropPadding);
ctx.fillStyle = backdropColor;
const backdropLeft = left - padding.left;
const backdropTop = top - padding.top;
const backdropWidth = right - left + padding.width;
const backdropHeight = bottom - top + padding.height;
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
helpers_segment.addRoundedRectPath(ctx, {
x: backdropLeft,
y: backdropTop,
w: backdropWidth,
h: backdropHeight,
radius: borderRadius
});
ctx.fill();
} else {
ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
}
}
}
function drawPointLabels(scale, labelCount) {
const { ctx , options: { pointLabels } } = scale;
for(let i = labelCount - 1; i >= 0; i--){
const optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
const plFont = helpers_segment.toFont(optsAtIndex.font);
const { x , y , textAlign , left , top , right , bottom } = scale._pointLabelItems[i];
const { backdropColor } = optsAtIndex;
if (!helpers_segment.isNullOrUndef(backdropColor)) {
const borderRadius = helpers_segment.toTRBLCorners(optsAtIndex.borderRadius);
const padding = helpers_segment.toPadding(optsAtIndex.backdropPadding);
ctx.fillStyle = backdropColor;
const backdropLeft = left - padding.left;
const backdropTop = top - padding.top;
const backdropWidth = right - left + padding.width;
const backdropHeight = bottom - top + padding.height;
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
helpers_segment.addRoundedRectPath(ctx, {
x: backdropLeft,
y: backdropTop,
w: backdropWidth,
h: backdropHeight,
radius: borderRadius
});
ctx.fill();
} else {
ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
}
const item = scale._pointLabelItems[i];
if (!item.visible) {
continue;
}
const optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
drawPointLabelBox(ctx, optsAtIndex, item);
const plFont = helpers_segment.toFont(optsAtIndex.font);
const { x , y , textAlign } = item;
helpers_segment.renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {
color: optsAtIndex.color,
textAlign: textAlign,

File diff suppressed because one or more lines are too long

318
node_modules/chart.js/dist/chart.js generated vendored
View file

@ -1,11 +1,10 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
*/
import { r as requestAnimFrame, a as resolve, e as effects, c as color, i as isObject, d as defaults, b as isArray, v as valueOrDefault, u as unlistenArrayEvents, l as listenArrayEvents, f as resolveObjectKey, g as isNumberFinite, h as defined, s as sign, j as createContext, k as isNullOrUndef, _ as _arrayUnique, t as toRadians, m as toPercentage, n as toDimension, T as TAU, o as formatNumber, p as _angleBetween, H as HALF_PI, P as PI, q as _getStartAndCountOfVisiblePoints, w as _scaleRangesChanged, x as isNumber, y as _parseObjectDataRadialScale, z as getRelativePosition, A as _rlookupByKey, B as _lookupByKey, C as _isPointInArea, D as getAngleFromPoint, E as toPadding, F as each, G as getMaximumSize, I as _getParentNode, J as readUsedSize, K as supportsEventListenerOptions, L as throttled, M as _isDomSupported, N as _factorize, O as finiteOrDefault, Q as callback, R as _addGrace, S as _limitValue, U as toDegrees, V as _measureText, W as _int16Range, X as _alignPixel, Y as clipArea, Z as renderText, $ as unclipArea, a0 as toFont, a1 as _toLeftRightCenter, a2 as _alignStartEnd, a3 as overrides, a4 as merge, a5 as _capitalize, a6 as descriptors, a7 as isFunction, a8 as _attachContext, a9 as _createResolver, aa as _descriptors, ab as mergeIf, ac as uid, ad as debounce, ae as retinaScale, af as clearCanvas, ag as setsEqual, ah as _elementsEqual, ai as _isClickEvent, aj as _isBetween, ak as _readValueToProps, al as _updateBezierControlPoints, am as _computeSegments, an as _boundSegments, ao as _steppedInterpolation, ap as _bezierInterpolation, aq as _pointInLine, ar as _steppedLineTo, as as _bezierCurveTo, at as drawPoint, au as addRoundedRectPath, av as toTRBL, aw as toTRBLCorners, ax as _boundSegment, ay as _normalizeAngle, az as getRtlAdapter, aA as overrideTextDirection, aB as _textX, aC as restoreTextDirection, aD as drawPointLegend, aE as distanceBetweenPoints, aF as noop, aG as _setMinAndMaxByKey, aH as niceNum, aI as almostWhole, aJ as almostEquals, aK as _decimalPlaces, aL as Ticks, aM as log10, aN as _longestText, aO as _filterBetween, aP as _lookup } from './chunks/helpers.segment.js';
export { aL as Ticks, d as defaults } from './chunks/helpers.segment.js';
import '@kurkle/color';
class Animator {
@ -1814,7 +1813,7 @@ class DoughnutController extends DatasetController {
};
static descriptors = {
_scriptable: (name)=>name !== 'spacing',
_indexable: (name)=>name !== 'spacing'
_indexable: (name)=>name !== 'spacing' && !name.startsWith('borderDash') && !name.startsWith('hoverBorderDash')
};
static overrides = {
aspectRatio: 1,
@ -2548,8 +2547,8 @@ BarController: BarController,
BubbleController: BubbleController,
DoughnutController: DoughnutController,
LineController: LineController,
PolarAreaController: PolarAreaController,
PieController: PieController,
PolarAreaController: PolarAreaController,
RadarController: RadarController,
ScatterController: ScatterController
});
@ -2579,6 +2578,7 @@ ScatterController: ScatterController
*/ static override(members) {
Object.assign(DateAdapterBase.prototype, members);
}
options;
constructor(options){
this.options = options || {};
}
@ -3044,18 +3044,18 @@ function placeBoxes(boxes, chartArea, params, stacks) {
stack.placed += width;
y = box.bottom;
} else {
const height1 = chartArea.h * weight;
const width1 = stack.size || box.width;
const height = chartArea.h * weight;
const width = stack.size || box.width;
if (defined(stack.start)) {
x = stack.start;
}
if (box.fullSize) {
setBoxDims(box, x, userPadding.top, width1, params.outerHeight - userPadding.bottom - userPadding.top);
setBoxDims(box, x, userPadding.top, width, params.outerHeight - userPadding.bottom - userPadding.top);
} else {
setBoxDims(box, x, chartArea.top + stack.placed, width1, height1);
setBoxDims(box, x, chartArea.top + stack.placed, width, height);
}
stack.start = x;
stack.placed += height1;
stack.placed += height;
x = box.right;
}
}
@ -3456,7 +3456,11 @@ function _detectPlatform(canvas) {
class Element {
static defaults = {};
static defaultRoutes = undefined;
x;
y;
active = false;
options;
$animations;
tooltipPosition(useFinalPosition) {
const { x , y } = this.getProps([
'x',
@ -3668,7 +3672,7 @@ function createTickContext(parent, index, tick) {
});
}
function titleAlign(align, position, reverse) {
let ret = _toLeftRightCenter(align);
let ret = _toLeftRightCenter(align);
if (reverse && position !== 'right' || !reverse && position === 'right') {
ret = reverseAlign(ret);
}
@ -3695,9 +3699,9 @@ function titleArgs(scale, offset, position, align) {
maxWidth = right - left;
} else {
if (isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
titleX = scales[positionAxisID1].getPixelForValue(value1) - width + offset;
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
titleX = scales[positionAxisID].getPixelForValue(value) - width + offset;
} else if (position === 'center') {
titleX = (chartArea.left + chartArea.right) / 2 - width + offset;
} else {
@ -4175,7 +4179,7 @@ class Scale extends Element {
height = lineHeight;
} else if (isArray(label)) {
for(j = 0, jlen = label.length; j < jlen; ++j){
nestedLabel = label[j];
nestedLabel = label[j];
if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {
width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);
height += lineHeight;
@ -4320,9 +4324,9 @@ class Scale extends Element {
if (position === 'center') {
borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
} else if (isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
borderValue = alignBorderValue(this.chart.scales[positionAxisID1].getPixelForValue(value1));
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));
}
tx1 = borderValue - axisHalfWidth;
tx2 = tx1 - tl;
@ -4401,9 +4405,9 @@ class Scale extends Element {
textAlign = ret.textAlign;
x = ret.x;
} else if (position === 'right') {
const ret1 = this._getYAxisLabelAlignment(tl);
textAlign = ret1.textAlign;
x = ret1.x;
const ret = this._getYAxisLabelAlignment(tl);
textAlign = ret.textAlign;
x = ret.x;
} else if (axis === 'x') {
if (position === 'center') {
y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;
@ -4417,9 +4421,9 @@ class Scale extends Element {
if (position === 'center') {
x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;
} else if (isObject(position)) {
const positionAxisID1 = Object.keys(position)[0];
const value1 = position[positionAxisID1];
x = this.chart.scales[positionAxisID1].getPixelForValue(value1);
const positionAxisID = Object.keys(position)[0];
const value = position[positionAxisID];
x = this.chart.scales[positionAxisID].getPixelForValue(value);
}
textAlign = this._getYAxisLabelAlignment(tl).textAlign;
}
@ -5102,8 +5106,8 @@ class PluginService {
plugins.push(registry.getPlugin(keys[i]));
}
const local = config.plugins || [];
for(let i1 = 0; i1 < local.length; i1++){
const plugin = local[i1];
for(let i = 0; i < local.length; i++){
const plugin = local[i];
if (plugins.indexOf(plugin) === -1) {
plugins.push(plugin);
localIds[plugin.id] = true;
@ -5174,6 +5178,11 @@ function getAxisFromDefaultScaleID(id, indexAxis) {
function getDefaultScaleIDFromAxis(axis, indexAxis) {
return axis === indexAxis ? '_index_' : '_value_';
}
function idMatchesAxis(id) {
if (id === 'x' || id === 'y' || id === 'r') {
return id;
}
}
function axisFromPosition(position) {
if (position === 'top' || position === 'bottom') {
return 'x';
@ -5182,15 +5191,33 @@ function axisFromPosition(position) {
return 'y';
}
}
function determineAxis(id, scaleOptions) {
if (id === 'x' || id === 'y' || id === 'r') {
function determineAxis(id, ...scaleOptions) {
if (idMatchesAxis(id)) {
return id;
}
id = scaleOptions.axis || axisFromPosition(scaleOptions.position) || id.length > 1 && determineAxis(id[0].toLowerCase(), scaleOptions);
if (id) {
return id;
for (const opts of scaleOptions){
const axis = opts.axis || axisFromPosition(opts.position) || id.length > 1 && idMatchesAxis(id[0].toLowerCase());
if (axis) {
return axis;
}
}
throw new Error(`Cannot determine type of '${name}' axis. Please provide 'axis' or 'position' option.`);
throw new Error(`Cannot determine type of '${id}' axis. Please provide 'axis' or 'position' option.`);
}
function getAxisFromDataset(id, axis, dataset) {
if (dataset[axis + 'AxisID'] === id) {
return {
axis
};
}
}
function retrieveAxisFromDatasets(id, config) {
if (config.data && config.data.datasets) {
const boundDs = config.data.datasets.filter((d)=>d.xAxisID === id || d.yAxisID === id);
if (boundDs.length) {
return getAxisFromDataset(id, 'x', boundDs[0]) || getAxisFromDataset(id, 'y', boundDs[0]);
}
}
return {};
}
function mergeScaleConfig(config, options) {
const chartDefaults = overrides[config.type] || {
@ -5207,7 +5234,7 @@ function mergeScaleConfig(config, options) {
if (scaleConf._proxy) {
return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
}
const axis = determineAxis(id, scaleConf);
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
const defaultScaleOptions = chartDefaults.scales || {};
scales[id] = mergeIf(Object.create(null), [
@ -5466,7 +5493,7 @@ function needContext(proxy, names) {
return false;
}
var version = "4.2.1";
var version = "4.3.0";
const KNOWN_POSITIONS = [
'top',
@ -5949,9 +5976,9 @@ class Chart {
for(let i = 0, ilen = this.data.datasets.length; i < ilen; ++i){
this.getDatasetMeta(i).controller.configure();
}
for(let i1 = 0, ilen1 = this.data.datasets.length; i1 < ilen1; ++i1){
this._updateDataset(i1, isFunction(mode) ? mode({
datasetIndex: i1
for(let i = 0, ilen = this.data.datasets.length; i < ilen; ++i){
this._updateDataset(i, isFunction(mode) ? mode({
datasetIndex: i
}) : mode);
}
this.notifyPlugins('afterDatasetsUpdate', {
@ -6492,8 +6519,8 @@ function toRadiusCorners(value) {
ctx.lineTo(p4.x, p4.y);
// The corner segment from point 4 to point 5
if (innerEnd > 0) {
const pCenter1 = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
ctx.arc(pCenter1.x, pCenter1.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
const pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
}
// The inner arc from point 5 to point b to point 6
const innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;
@ -6501,16 +6528,16 @@ function toRadiusCorners(value) {
ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);
// The corner segment from point 6 to point 7
if (innerStart > 0) {
const pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
ctx.arc(pCenter2.x, pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
const pCenter = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
}
// The line from point 7 to point 8
const p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
ctx.lineTo(p8.x, p8.y);
// The corner segment from point 8 to point 1
if (outerStart > 0) {
const pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
ctx.arc(pCenter3.x, pCenter3.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
const pCenter = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
ctx.arc(pCenter.x, pCenter.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
}
} else {
ctx.moveTo(x, y);
@ -6541,11 +6568,13 @@ function drawArc(ctx, element, offset, spacing, circular) {
}
function drawBorder(ctx, element, offset, spacing, circular) {
const { fullCircles , startAngle , circumference , options } = element;
const { borderWidth , borderJoinStyle } = options;
const { borderWidth , borderJoinStyle , borderDash , borderDashOffset } = options;
const inner = options.borderAlign === 'inner';
if (!borderWidth) {
return;
}
ctx.setLineDash(borderDash || []);
ctx.lineDashOffset = borderDashOffset;
if (inner) {
ctx.lineWidth = borderWidth * 2;
ctx.lineJoin = borderJoinStyle || 'round';
@ -6576,6 +6605,8 @@ class ArcElement extends Element {
static defaults = {
borderAlign: 'center',
borderColor: '#fff',
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: undefined,
borderRadius: 0,
borderWidth: 2,
@ -6587,6 +6618,17 @@ class ArcElement extends Element {
static defaultRoutes = {
backgroundColor: 'backgroundColor'
};
static descriptors = {
_scriptable: true,
_indexable: (name)=>name !== 'borderDash'
};
circumference;
endAngle;
fullCircles;
innerRadius;
outerRadius;
pixelMargin;
startAngle;
constructor(cfg){
super();
this.options = undefined;
@ -6617,7 +6659,7 @@ class ArcElement extends Element {
'outerRadius',
'circumference'
], useFinalPosition);
const rAdjust = this.options.spacing / 2;
const rAdjust = (this.options.spacing + this.options.borderWidth) / 2;
const _circumference = valueOrDefault(circumference, endAngle - startAngle);
const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);
@ -6677,7 +6719,7 @@ function setStyle(ctx, options, style = options) {
function lineTo(ctx, previous, target) {
ctx.lineTo(target.x, target.y);
}
function getLineMethod(options) {
function getLineMethod(options) {
if (options.stepped) {
return _steppedLineTo;
}
@ -6961,6 +7003,9 @@ function inRange$1(el, pos, axis, useFinalPosition) {
}
class PointElement extends Element {
static id = 'point';
parsed;
skip;
stop;
/**
* @type {any}
*/ static defaults = {
@ -7222,9 +7267,9 @@ class BarElement extends Element {
var elements = /*#__PURE__*/Object.freeze({
__proto__: null,
ArcElement: ArcElement,
BarElement: BarElement,
LineElement: LineElement,
PointElement: PointElement,
BarElement: BarElement
PointElement: PointElement
});
const BORDER_COLORS = [
@ -8276,15 +8321,15 @@ class Legend extends Element {
} else {
let col = 0;
let top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
for (const hitbox1 of hitboxes){
if (hitbox1.col !== col) {
col = hitbox1.col;
for (const hitbox of hitboxes){
if (hitbox.col !== col) {
col = hitbox.col;
top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
}
hitbox1.top = top;
hitbox1.left += this.left + padding;
hitbox1.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox1.left), hitbox1.width);
top += hitbox1.height + padding;
hitbox.top = top;
hitbox.left += this.left + padding;
hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox.left), hitbox.width);
top += hitbox.height + padding;
}
}
}
@ -9383,9 +9428,9 @@ class Tooltip extends Element {
}
}
_drawColorBox(ctx, pt, i, rtlHelper, options) {
const labelColors = this.labelColors[i];
const labelColor = this.labelColors[i];
const labelPointStyle = this.labelPointStyles[i];
const { boxHeight , boxWidth , boxPadding } = options;
const { boxHeight , boxWidth } = options;
const bodyFont = toFont(options.bodyFont);
const colorX = getAlignedX(this, 'left', options);
const rtlColorX = rtlHelper.x(colorX);
@ -9403,17 +9448,17 @@ class Tooltip extends Element {
ctx.strokeStyle = options.multiKeyBackground;
ctx.fillStyle = options.multiKeyBackground;
drawPoint(ctx, drawOptions, centerX, centerY);
ctx.strokeStyle = labelColors.borderColor;
ctx.fillStyle = labelColors.backgroundColor;
ctx.strokeStyle = labelColor.borderColor;
ctx.fillStyle = labelColor.backgroundColor;
drawPoint(ctx, drawOptions, centerX, centerY);
} else {
ctx.lineWidth = isObject(labelColors.borderWidth) ? Math.max(...Object.values(labelColors.borderWidth)) : labelColors.borderWidth || 1;
ctx.strokeStyle = labelColors.borderColor;
ctx.setLineDash(labelColors.borderDash || []);
ctx.lineDashOffset = labelColors.borderDashOffset || 0;
const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth - boxPadding);
const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - boxPadding - 2);
const borderRadius = toTRBLCorners(labelColors.borderRadius);
ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : labelColor.borderWidth || 1;
ctx.strokeStyle = labelColor.borderColor;
ctx.setLineDash(labelColor.borderDash || []);
ctx.lineDashOffset = labelColor.borderDashOffset || 0;
const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);
const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);
const borderRadius = toTRBLCorners(labelColor.borderRadius);
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
ctx.fillStyle = options.multiKeyBackground;
@ -9426,7 +9471,7 @@ class Tooltip extends Element {
});
ctx.fill();
ctx.stroke();
ctx.fillStyle = labelColors.backgroundColor;
ctx.fillStyle = labelColor.backgroundColor;
ctx.beginPath();
addRoundedRectPath(ctx, {
x: innerX,
@ -9440,7 +9485,7 @@ class Tooltip extends Element {
ctx.fillStyle = options.multiKeyBackground;
ctx.fillRect(outerX, colorY, boxWidth, boxHeight);
ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);
ctx.fillStyle = labelColors.backgroundColor;
ctx.fillStyle = labelColor.backgroundColor;
ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);
}
}
@ -10005,8 +10050,12 @@ function generateTicks$1(generationOptions, dataRange) {
}
}
for(; j < numSpaces; ++j){
const tickValue = Math.round((niceMin + j * spacing) * factor) / factor;
if (maxDefined && tickValue > max) {
break;
}
ticks.push({
value: Math.round((niceMin + j * spacing) * factor) / factor
value: tickValue
});
}
if (maxDefined && includeBounds && niceMax !== max) {
@ -10428,29 +10477,66 @@ function updateLimits(limits, orig, angle, hLimits, vLimits) {
limits.b = Math.max(limits.b, orig.b + y);
}
}
function createPointLabelItem(scale, index, itemOpts) {
const outerDistance = scale.drawingArea;
const { extra , additionalAngle , padding , size } = itemOpts;
const pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle);
const angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));
const y = yForAngle(pointLabelPosition.y, size.h, angle);
const textAlign = getTextAlignForAngle(angle);
const left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
return {
visible: true,
x: pointLabelPosition.x,
y,
textAlign,
left,
top: y,
right: left + size.w,
bottom: y + size.h
};
}
function isNotOverlapped(item, area) {
if (!area) {
return true;
}
const { left , top , right , bottom } = item;
const apexesInArea = _isPointInArea({
x: left,
y: top
}, area) || _isPointInArea({
x: left,
y: bottom
}, area) || _isPointInArea({
x: right,
y: top
}, area) || _isPointInArea({
x: right,
y: bottom
}, area);
return !apexesInArea;
}
function buildPointLabelItems(scale, labelSizes, padding) {
const items = [];
const valueCount = scale._pointLabels.length;
const opts = scale.options;
const extra = getTickBackdropHeight(opts) / 2;
const outerDistance = scale.drawingArea;
const additionalAngle = opts.pointLabels.centerPointLabels ? PI / valueCount : 0;
const { centerPointLabels , display } = opts.pointLabels;
const itemOpts = {
extra: getTickBackdropHeight(opts) / 2,
additionalAngle: centerPointLabels ? PI / valueCount : 0
};
let area;
for(let i = 0; i < valueCount; i++){
const pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + padding[i], additionalAngle);
const angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));
const size = labelSizes[i];
const y = yForAngle(pointLabelPosition.y, size.h, angle);
const textAlign = getTextAlignForAngle(angle);
const left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
items.push({
x: pointLabelPosition.x,
y,
textAlign,
left,
top: y,
right: left + size.w,
bottom: y + size.h
});
itemOpts.padding = padding[i];
itemOpts.size = labelSizes[i];
const item = createPointLabelItem(scale, i, itemOpts);
items.push(item);
if (display === 'auto') {
item.visible = isNotOverlapped(item, area);
if (item.visible) {
area = item;
}
}
}
return items;
}
@ -10478,35 +10564,43 @@ function yForAngle(y, h, angle) {
}
return y;
}
function drawPointLabelBox(ctx, opts, item) {
const { left , top , right , bottom } = item;
const { backdropColor } = opts;
if (!isNullOrUndef(backdropColor)) {
const borderRadius = toTRBLCorners(opts.borderRadius);
const padding = toPadding(opts.backdropPadding);
ctx.fillStyle = backdropColor;
const backdropLeft = left - padding.left;
const backdropTop = top - padding.top;
const backdropWidth = right - left + padding.width;
const backdropHeight = bottom - top + padding.height;
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
addRoundedRectPath(ctx, {
x: backdropLeft,
y: backdropTop,
w: backdropWidth,
h: backdropHeight,
radius: borderRadius
});
ctx.fill();
} else {
ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
}
}
}
function drawPointLabels(scale, labelCount) {
const { ctx , options: { pointLabels } } = scale;
for(let i = labelCount - 1; i >= 0; i--){
const optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
const plFont = toFont(optsAtIndex.font);
const { x , y , textAlign , left , top , right , bottom } = scale._pointLabelItems[i];
const { backdropColor } = optsAtIndex;
if (!isNullOrUndef(backdropColor)) {
const borderRadius = toTRBLCorners(optsAtIndex.borderRadius);
const padding = toPadding(optsAtIndex.backdropPadding);
ctx.fillStyle = backdropColor;
const backdropLeft = left - padding.left;
const backdropTop = top - padding.top;
const backdropWidth = right - left + padding.width;
const backdropHeight = bottom - top + padding.height;
if (Object.values(borderRadius).some((v)=>v !== 0)) {
ctx.beginPath();
addRoundedRectPath(ctx, {
x: backdropLeft,
y: backdropTop,
w: backdropWidth,
h: backdropHeight,
radius: borderRadius
});
ctx.fill();
} else {
ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
}
const item = scale._pointLabelItems[i];
if (!item.visible) {
continue;
}
const optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
drawPointLabelBox(ctx, optsAtIndex, item);
const plFont = toFont(optsAtIndex.font);
const { x , y , textAlign } = item;
renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {
color: optsAtIndex.color,
textAlign: textAlign,
@ -11326,5 +11420,5 @@ const registerables = [
scales
];
export { Animation, Animations, ArcElement, BarController, BarElement, BasePlatform, BasicPlatform, BubbleController, CategoryScale, Chart, plugin_colors as Colors, DatasetController, plugin_decimation as Decimation, DomPlatform, DoughnutController, Element, index as Filler, Interaction, plugin_legend as Legend, LineController, LineElement, LinearScale, LogarithmicScale, PieController, PointElement, PolarAreaController, RadarController, RadialLinearScale, Scale, ScatterController, plugin_subtitle as SubTitle, TimeScale, TimeSeriesScale, plugin_title as Title, plugin_tooltip as Tooltip, adapters as _adapters, _detectPlatform, animator, controllers, elements, layouts, plugins, registerables, registry, scales };
export { Animation, Animations, ArcElement, BarController, BarElement, BasePlatform, BasicPlatform, BubbleController, CategoryScale, Chart, plugin_colors as Colors, DatasetController, plugin_decimation as Decimation, DomPlatform, DoughnutController, Element, index as Filler, Interaction, plugin_legend as Legend, LineController, LineElement, LinearScale, LogarithmicScale, PieController, PointElement, PolarAreaController, RadarController, RadialLinearScale, Scale, ScatterController, plugin_subtitle as SubTitle, Ticks, TimeScale, TimeSeriesScale, plugin_title as Title, plugin_tooltip as Tooltip, adapters as _adapters, _detectPlatform, animator, controllers, defaults, elements, layouts, plugins, registerables, registry, scales };
//# sourceMappingURL=chart.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
@ -549,12 +549,8 @@ function unlistenArrayEvents(array, listener) {
/**
* @param items
*/ function _arrayUnique(items) {
const set = new Set();
let i, ilen;
for(i = 0, ilen = items.length; i < ilen; ++i){
set.add(items[i]);
}
if (set.size === ilen) {
const set = new Set(items);
if (set.size === items.length) {
return items;
}
return Array.from(set);
@ -879,7 +875,7 @@ const formatters = {
delta = calculateDelta(tickValue, ticks);
}
const logDelta = log10(Math.abs(delta));
const numDecimal = Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
const numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
const options = {
notation,
minimumFractionDigits: numDecimal,
@ -1110,13 +1106,20 @@ var defaults = /* #__PURE__ */ new Defaults({
applyScaleDefaults
]);
function toFontString(font) {
/**
* Converts the given font object into a CSS font string.
* @param font - A font object.
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @private
*/ function toFontString(font) {
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
return null;
}
return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;
}
function _measureText(ctx, data, gc, longest, string) {
/**
* @private
*/ function _measureText(ctx, data, gc, longest, string) {
let textWidth = data[string];
if (!textWidth) {
textWidth = data[string] = ctx.measureText(string).width;
@ -1127,7 +1130,10 @@ function toFontString(font) {
}
return longest;
}
function _longestText(ctx, font, arrayOfThings, cache) {
/**
* @private
*/ // eslint-disable-next-line complexity
function _longestText(ctx, font, arrayOfThings, cache) {
cache = cache || {};
let data = cache.data = cache.data || {};
let gc = cache.garbageCollect = cache.garbageCollect || [];
@ -1143,11 +1149,15 @@ function toFontString(font) {
let i, j, jlen, thing, nestedThing;
for(i = 0; i < ilen; i++){
thing = arrayOfThings[i];
if (thing !== undefined && thing !== null && isArray(thing) !== true) {
// Undefined strings and arrays should not be measured
if (thing !== undefined && thing !== null && !isArray(thing)) {
longest = _measureText(ctx, data, gc, longest, thing);
} else if (isArray(thing)) {
// if it is an array lets measure each element
// to do maybe simplify this function a bit so we can do this more recursively?
for(j = 0, jlen = thing.length; j < jlen; j++){
nestedThing = thing[j];
// Undefined strings and arrays should not be measured
if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {
longest = _measureText(ctx, data, gc, longest, nestedThing);
}
@ -1164,21 +1174,34 @@ function toFontString(font) {
}
return longest;
}
function _alignPixel(chart, pixel, width) {
/**
* Returns the aligned pixel value to avoid anti-aliasing blur
* @param chart - The chart instance.
* @param pixel - A pixel value.
* @param width - The width of the element.
* @returns The aligned pixel value.
* @private
*/ function _alignPixel(chart, pixel, width) {
const devicePixelRatio = chart.currentDevicePixelRatio;
const halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;
return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
}
function clearCanvas(canvas, ctx) {
/**
* Clears the entire canvas.
*/ function clearCanvas(canvas, ctx) {
ctx = ctx || canvas.getContext('2d');
ctx.save();
// canvas.width and canvas.height do not consider the canvas transform,
// while clearRect does
ctx.resetTransform();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.restore();
}
function drawPoint(ctx, options, x, y) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
drawPointLegend(ctx, options, x, y, null);
}
// eslint-disable-next-line complexity
function drawPointLegend(ctx, options, x, y, w) {
let type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;
const style = options.pointStyle;
@ -1201,6 +1224,7 @@ function drawPointLegend(ctx, options, x, y, w) {
}
ctx.beginPath();
switch(style){
// Default includes circle
default:
if (w) {
ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);
@ -1219,6 +1243,13 @@ function drawPointLegend(ctx, options, x, y, w) {
ctx.closePath();
break;
case 'rectRounded':
// NOTE: the rounded rect implementation changed to use `arc` instead of
// `quadraticCurveTo` since it generates better results when rect is
// almost a circle. 0.516 (instead of 0.5) produces results with visually
// closer proportion to the previous impl and it is inscribed in the
// circle with `radius`. For more details, see the following PRs:
// https://github.com/chartjs/Chart.js/issues/5597
// https://github.com/chartjs/Chart.js/issues/5858
cornerRadius = radius * 0.516;
size = radius - cornerRadius;
xOffset = Math.cos(rad + QUARTER_PI) * size;
@ -1239,7 +1270,7 @@ function drawPointLegend(ctx, options, x, y, w) {
break;
}
rad += QUARTER_PI;
case 'rectRot':
/* falls through */ case 'rectRot':
xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
@ -1252,7 +1283,7 @@ function drawPointLegend(ctx, options, x, y, w) {
break;
case 'crossRot':
rad += QUARTER_PI;
case 'cross':
/* falls through */ case 'cross':
xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
@ -1300,8 +1331,14 @@ function drawPointLegend(ctx, options, x, y, w) {
ctx.stroke();
}
}
function _isPointInArea(point, area, margin) {
margin = margin || 0.5;
/**
* Returns true if the point is inside the rectangle
* @param point - The point to test
* @param area - The rectangle
* @param margin - allowed margin
* @private
*/ function _isPointInArea(point, area, margin) {
margin = margin || 0.5; // margin - default is to match rounded decimals
return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;
}
function clipArea(ctx, area) {
@ -1313,7 +1350,9 @@ function clipArea(ctx, area) {
function unclipArea(ctx) {
ctx.restore();
}
function _steppedLineTo(ctx, previous, target, flip, mode) {
/**
* @private
*/ function _steppedLineTo(ctx, previous, target, flip, mode) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
@ -1328,13 +1367,62 @@ function unclipArea(ctx) {
}
ctx.lineTo(target.x, target.y);
}
function _bezierCurveTo(ctx, previous, target, flip) {
/**
* @private
*/ function _bezierCurveTo(ctx, previous, target, flip) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);
}
function renderText(ctx, text, x, y, font, opts = {}) {
function setRenderOpts(ctx, opts) {
if (opts.translation) {
ctx.translate(opts.translation[0], opts.translation[1]);
}
if (!isNullOrUndef(opts.rotation)) {
ctx.rotate(opts.rotation);
}
if (opts.color) {
ctx.fillStyle = opts.color;
}
if (opts.textAlign) {
ctx.textAlign = opts.textAlign;
}
if (opts.textBaseline) {
ctx.textBaseline = opts.textBaseline;
}
}
function decorateText(ctx, x, y, line, opts) {
if (opts.strikethrough || opts.underline) {
/**
* Now that IE11 support has been dropped, we can use more
* of the TextMetrics object. The actual bounding boxes
* are unflagged in Chrome, Firefox, Edge, and Safari so they
* can be safely used.
* See https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics#Browser_compatibility
*/ const metrics = ctx.measureText(line);
const left = x - metrics.actualBoundingBoxLeft;
const right = x + metrics.actualBoundingBoxRight;
const top = y - metrics.actualBoundingBoxAscent;
const bottom = y + metrics.actualBoundingBoxDescent;
const yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;
ctx.strokeStyle = ctx.fillStyle;
ctx.beginPath();
ctx.lineWidth = opts.decorationWidth || 2;
ctx.moveTo(left, yDecoration);
ctx.lineTo(right, yDecoration);
ctx.stroke();
}
}
function drawBackdrop(ctx, opts) {
const oldColor = ctx.fillStyle;
ctx.fillStyle = opts.color;
ctx.fillRect(opts.left, opts.top, opts.width, opts.height);
ctx.fillStyle = oldColor;
}
/**
* Render text onto the canvas
*/ function renderText(ctx, text, x, y, font, opts = {}) {
const lines = isArray(text) ? text : [
text
];
@ -1359,58 +1447,31 @@ function unclipArea(ctx) {
}
ctx.fillText(line, x, y, opts.maxWidth);
decorateText(ctx, x, y, line, opts);
y += font.lineHeight;
y += Number(font.lineHeight);
}
ctx.restore();
}
function setRenderOpts(ctx, opts) {
if (opts.translation) {
ctx.translate(opts.translation[0], opts.translation[1]);
}
if (!isNullOrUndef(opts.rotation)) {
ctx.rotate(opts.rotation);
}
if (opts.color) {
ctx.fillStyle = opts.color;
}
if (opts.textAlign) {
ctx.textAlign = opts.textAlign;
}
if (opts.textBaseline) {
ctx.textBaseline = opts.textBaseline;
}
}
function decorateText(ctx, x, y, line, opts) {
if (opts.strikethrough || opts.underline) {
const metrics = ctx.measureText(line);
const left = x - metrics.actualBoundingBoxLeft;
const right = x + metrics.actualBoundingBoxRight;
const top = y - metrics.actualBoundingBoxAscent;
const bottom = y + metrics.actualBoundingBoxDescent;
const yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;
ctx.strokeStyle = ctx.fillStyle;
ctx.beginPath();
ctx.lineWidth = opts.decorationWidth || 2;
ctx.moveTo(left, yDecoration);
ctx.lineTo(right, yDecoration);
ctx.stroke();
}
}
function drawBackdrop(ctx, opts) {
const oldColor = ctx.fillStyle;
ctx.fillStyle = opts.color;
ctx.fillRect(opts.left, opts.top, opts.width, opts.height);
ctx.fillStyle = oldColor;
}
function addRoundedRectPath(ctx, rect) {
/**
* Add a path of a rectangle with rounded corners to the current sub-path
* @param ctx - Context
* @param rect - Bounding rect
*/ function addRoundedRectPath(ctx, rect) {
const { x , y , w , h , radius } = rect;
// top left arc
ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, -HALF_PI, PI, true);
// line from top left to bottom left
ctx.lineTo(x, y + h - radius.bottomLeft);
// bottom left arc
ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);
// line from bottom left to bottom right
ctx.lineTo(x + w - radius.bottomRight, y + h);
// bottom right arc
ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);
// line from bottom right to top right
ctx.lineTo(x + w, y + radius.topRight);
// top right arc
ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);
// line from top right to top left
ctx.lineTo(x + radius.topLeft, y);
}
@ -1575,55 +1636,87 @@ function createContext(parentContext, context) {
return Object.assign(Object.create(parentContext), context);
}
function _createResolver(scopes, prefixes = [
/**
* Creates a Proxy for resolving raw values for options.
* @param scopes - The option scopes to look for values, in resolution order
* @param prefixes - The prefixes for values, in resolution order.
* @param rootScopes - The root option scopes
* @param fallback - Parent scopes fallback
* @param getTarget - callback for getting the target for changed values
* @returns Proxy
* @private
*/ function _createResolver(scopes, prefixes = [
''
], rootScopes = scopes, fallback, getTarget = ()=>scopes[0]) {
if (!defined(fallback)) {
], rootScopes, fallback, getTarget = ()=>scopes[0]) {
const finalRootScopes = rootScopes || scopes;
if (typeof fallback === 'undefined') {
fallback = _resolve('_fallback', scopes);
}
const cache = {
[Symbol.toStringTag]: 'Object',
_cacheable: true,
_scopes: scopes,
_rootScopes: rootScopes,
_rootScopes: finalRootScopes,
_fallback: fallback,
_getTarget: getTarget,
override: (scope)=>_createResolver([
scope,
...scopes
], prefixes, rootScopes, fallback)
], prefixes, finalRootScopes, fallback)
};
return new Proxy(cache, {
deleteProperty (target, prop) {
delete target[prop];
delete target._keys;
delete scopes[0][prop];
/**
* A trap for the delete operator.
*/ deleteProperty (target, prop) {
delete target[prop]; // remove from cache
delete target._keys; // remove cached keys
delete scopes[0][prop]; // remove from top level scope
return true;
},
get (target, prop) {
/**
* A trap for getting property values.
*/ get (target, prop) {
return _cached(target, prop, ()=>_resolveWithPrefixes(prop, prefixes, scopes, target));
},
getOwnPropertyDescriptor (target, prop) {
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/ getOwnPropertyDescriptor (target, prop) {
return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
},
getPrototypeOf () {
/**
* A trap for Object.getPrototypeOf.
*/ getPrototypeOf () {
return Reflect.getPrototypeOf(scopes[0]);
},
has (target, prop) {
/**
* A trap for the in operator.
*/ has (target, prop) {
return getKeysFromAllScopes(target).includes(prop);
},
ownKeys (target) {
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/ ownKeys (target) {
return getKeysFromAllScopes(target);
},
set (target, prop, value) {
/**
* A trap for setting property values.
*/ set (target, prop, value) {
const storage = target._storage || (target._storage = getTarget());
target[prop] = storage[prop] = value;
delete target._keys;
target[prop] = storage[prop] = value; // set to top level scope + cache
delete target._keys; // remove cached keys
return true;
}
});
}
function _attachContext(proxy, context, subProxy, descriptorDefaults) {
/**
* Returns an Proxy for resolving option values with context.
* @param proxy - The Proxy returned by `_createResolver`
* @param context - Context object for scriptable/indexable options
* @param subProxy - The proxy provided for scriptable options
* @param descriptorDefaults - Defaults for descriptors
* @private
*/ function _attachContext(proxy, context, subProxy, descriptorDefaults) {
const cache = {
_cacheable: false,
_proxy: proxy,
@ -1635,37 +1728,54 @@ function _createResolver(scopes, prefixes = [
override: (scope)=>_attachContext(proxy.override(scope), context, subProxy, descriptorDefaults)
};
return new Proxy(cache, {
deleteProperty (target, prop) {
delete target[prop];
delete proxy[prop];
/**
* A trap for the delete operator.
*/ deleteProperty (target, prop) {
delete target[prop]; // remove from cache
delete proxy[prop]; // remove from proxy
return true;
},
get (target, prop, receiver) {
/**
* A trap for getting property values.
*/ get (target, prop, receiver) {
return _cached(target, prop, ()=>_resolveWithContext(target, prop, receiver));
},
getOwnPropertyDescriptor (target, prop) {
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/ getOwnPropertyDescriptor (target, prop) {
return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {
enumerable: true,
configurable: true
} : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);
},
getPrototypeOf () {
/**
* A trap for Object.getPrototypeOf.
*/ getPrototypeOf () {
return Reflect.getPrototypeOf(proxy);
},
has (target, prop) {
/**
* A trap for the in operator.
*/ has (target, prop) {
return Reflect.has(proxy, prop);
},
ownKeys () {
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/ ownKeys () {
return Reflect.ownKeys(proxy);
},
set (target, prop, value) {
proxy[prop] = value;
delete target[prop];
/**
* A trap for setting property values.
*/ set (target, prop, value) {
proxy[prop] = value; // set to proxy
delete target[prop]; // remove from cache
return true;
}
});
}
function _descriptors(proxy, defaults = {
/**
* @private
*/ function _descriptors(proxy, defaults = {
scriptable: true,
indexable: true
}) {
@ -1685,12 +1795,14 @@ function _cached(target, prop, resolve) {
return target[prop];
}
const value = resolve();
// cache the resolved value
target[prop] = value;
return value;
}
function _resolveWithContext(target, prop, receiver) {
const { _proxy , _context , _subProxy , _descriptors: descriptors } = target;
let value = _proxy[prop];
let value = _proxy[prop]; // resolve from proxy
// resolve with context
if (isFunction(value) && descriptors.isScriptable(prop)) {
value = _resolveScriptable(prop, value, target, receiver);
}
@ -1698,28 +1810,31 @@ function _resolveWithContext(target, prop, receiver) {
value = _resolveArray(prop, value, target, descriptors.isIndexable);
}
if (needsSubResolver(prop, value)) {
// if the resolved value is an object, create a sub resolver for it
value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);
}
return value;
}
function _resolveScriptable(prop, value, target, receiver) {
function _resolveScriptable(prop, getValue, target, receiver) {
const { _proxy , _context , _subProxy , _stack } = target;
if (_stack.has(prop)) {
throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);
}
_stack.add(prop);
value = value(_context, _subProxy || receiver);
let value = getValue(_context, _subProxy || receiver);
_stack.delete(prop);
if (needsSubResolver(prop, value)) {
// When scriptable option returns an object, create a resolver on that.
value = createSubResolver(_proxy._scopes, _proxy, prop, value);
}
return value;
}
function _resolveArray(prop, value, target, isIndexable) {
const { _proxy , _context , _subProxy , _descriptors: descriptors } = target;
if (defined(_context.index) && isIndexable(prop)) {
value = value[_context.index % value.length];
if (typeof _context.index !== 'undefined' && isIndexable(prop)) {
return value[_context.index % value.length];
} else if (isObject(value[0])) {
// Array of objects, return array or resolvers
const arr = value;
const scopes = _proxy._scopes.filter((s)=>s !== arr);
value = [];
@ -1740,10 +1855,14 @@ function addScopes(set, parentScopes, key, parentFallback, value) {
if (scope) {
set.add(scope);
const fallback = resolveFallback(scope._fallback, key, value);
if (defined(fallback) && fallback !== key && fallback !== parentFallback) {
if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {
// When we reach the descriptor that defines a new _fallback, return that.
// The fallback will resume to that new scope.
return fallback;
}
} else if (scope === false && defined(parentFallback) && key !== parentFallback) {
} else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {
// Fallback to `false` results to `false`, when falling back to different key.
// For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`
return null;
}
}
@ -1762,7 +1881,7 @@ function createSubResolver(parentScopes, resolver, prop, value) {
if (key === null) {
return false;
}
if (defined(fallback) && fallback !== prop) {
if (typeof fallback !== 'undefined' && fallback !== prop) {
key = addScopesFromKey(set, allScopes, fallback, key, value);
if (key === null) {
return false;
@ -1785,6 +1904,7 @@ function subGetTarget(resolver, prop, value) {
}
const target = parent[prop];
if (isArray(target) && isObject(value)) {
// For array of objects, the object is used to store updated values
return value;
}
return target || {};
@ -1793,7 +1913,7 @@ function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
let value;
for (const prefix of prefixes){
value = _resolve(readKey(prefix, prop), scopes);
if (defined(value)) {
if (typeof value !== 'undefined') {
return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;
}
}
@ -1804,7 +1924,7 @@ function _resolve(key, scopes) {
continue;
}
const value = scope[key];
if (defined(value)) {
if (typeof value !== 'undefined') {
return value;
}
}
@ -2605,7 +2725,20 @@ function readStyle(options) {
};
}
function styleChanged(style, prevStyle) {
return prevStyle && JSON.stringify(style) !== JSON.stringify(prevStyle);
if (!prevStyle) {
return false;
}
const cache = [];
const replacer = function(key, value) {
if (!isPatternOrGradient(value)) {
return value;
}
if (!cache.includes(value)) {
cache.push(value);
}
return cache.indexOf(value);
};
return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
}
exports.HALF_PI = HALF_PI;

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
@ -547,12 +547,8 @@ function unlistenArrayEvents(array, listener) {
/**
* @param items
*/ function _arrayUnique(items) {
const set = new Set();
let i, ilen;
for(i = 0, ilen = items.length; i < ilen; ++i){
set.add(items[i]);
}
if (set.size === ilen) {
const set = new Set(items);
if (set.size === items.length) {
return items;
}
return Array.from(set);
@ -877,7 +873,7 @@ const formatters = {
delta = calculateDelta(tickValue, ticks);
}
const logDelta = log10(Math.abs(delta));
const numDecimal = Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
const numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
const options = {
notation,
minimumFractionDigits: numDecimal,
@ -1108,13 +1104,20 @@ var defaults = /* #__PURE__ */ new Defaults({
applyScaleDefaults
]);
function toFontString(font) {
/**
* Converts the given font object into a CSS font string.
* @param font - A font object.
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @private
*/ function toFontString(font) {
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
return null;
}
return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;
}
function _measureText(ctx, data, gc, longest, string) {
/**
* @private
*/ function _measureText(ctx, data, gc, longest, string) {
let textWidth = data[string];
if (!textWidth) {
textWidth = data[string] = ctx.measureText(string).width;
@ -1125,7 +1128,10 @@ function toFontString(font) {
}
return longest;
}
function _longestText(ctx, font, arrayOfThings, cache) {
/**
* @private
*/ // eslint-disable-next-line complexity
function _longestText(ctx, font, arrayOfThings, cache) {
cache = cache || {};
let data = cache.data = cache.data || {};
let gc = cache.garbageCollect = cache.garbageCollect || [];
@ -1141,11 +1147,15 @@ function toFontString(font) {
let i, j, jlen, thing, nestedThing;
for(i = 0; i < ilen; i++){
thing = arrayOfThings[i];
if (thing !== undefined && thing !== null && isArray(thing) !== true) {
// Undefined strings and arrays should not be measured
if (thing !== undefined && thing !== null && !isArray(thing)) {
longest = _measureText(ctx, data, gc, longest, thing);
} else if (isArray(thing)) {
// if it is an array lets measure each element
// to do maybe simplify this function a bit so we can do this more recursively?
for(j = 0, jlen = thing.length; j < jlen; j++){
nestedThing = thing[j];
// Undefined strings and arrays should not be measured
if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {
longest = _measureText(ctx, data, gc, longest, nestedThing);
}
@ -1162,21 +1172,34 @@ function toFontString(font) {
}
return longest;
}
function _alignPixel(chart, pixel, width) {
/**
* Returns the aligned pixel value to avoid anti-aliasing blur
* @param chart - The chart instance.
* @param pixel - A pixel value.
* @param width - The width of the element.
* @returns The aligned pixel value.
* @private
*/ function _alignPixel(chart, pixel, width) {
const devicePixelRatio = chart.currentDevicePixelRatio;
const halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;
return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
}
function clearCanvas(canvas, ctx) {
/**
* Clears the entire canvas.
*/ function clearCanvas(canvas, ctx) {
ctx = ctx || canvas.getContext('2d');
ctx.save();
// canvas.width and canvas.height do not consider the canvas transform,
// while clearRect does
ctx.resetTransform();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.restore();
}
function drawPoint(ctx, options, x, y) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
drawPointLegend(ctx, options, x, y, null);
}
// eslint-disable-next-line complexity
function drawPointLegend(ctx, options, x, y, w) {
let type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;
const style = options.pointStyle;
@ -1199,6 +1222,7 @@ function drawPointLegend(ctx, options, x, y, w) {
}
ctx.beginPath();
switch(style){
// Default includes circle
default:
if (w) {
ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);
@ -1217,6 +1241,13 @@ function drawPointLegend(ctx, options, x, y, w) {
ctx.closePath();
break;
case 'rectRounded':
// NOTE: the rounded rect implementation changed to use `arc` instead of
// `quadraticCurveTo` since it generates better results when rect is
// almost a circle. 0.516 (instead of 0.5) produces results with visually
// closer proportion to the previous impl and it is inscribed in the
// circle with `radius`. For more details, see the following PRs:
// https://github.com/chartjs/Chart.js/issues/5597
// https://github.com/chartjs/Chart.js/issues/5858
cornerRadius = radius * 0.516;
size = radius - cornerRadius;
xOffset = Math.cos(rad + QUARTER_PI) * size;
@ -1237,7 +1268,7 @@ function drawPointLegend(ctx, options, x, y, w) {
break;
}
rad += QUARTER_PI;
case 'rectRot':
/* falls through */ case 'rectRot':
xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
@ -1250,7 +1281,7 @@ function drawPointLegend(ctx, options, x, y, w) {
break;
case 'crossRot':
rad += QUARTER_PI;
case 'cross':
/* falls through */ case 'cross':
xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
xOffset = Math.cos(rad) * radius;
yOffset = Math.sin(rad) * radius;
@ -1298,8 +1329,14 @@ function drawPointLegend(ctx, options, x, y, w) {
ctx.stroke();
}
}
function _isPointInArea(point, area, margin) {
margin = margin || 0.5;
/**
* Returns true if the point is inside the rectangle
* @param point - The point to test
* @param area - The rectangle
* @param margin - allowed margin
* @private
*/ function _isPointInArea(point, area, margin) {
margin = margin || 0.5; // margin - default is to match rounded decimals
return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;
}
function clipArea(ctx, area) {
@ -1311,7 +1348,9 @@ function clipArea(ctx, area) {
function unclipArea(ctx) {
ctx.restore();
}
function _steppedLineTo(ctx, previous, target, flip, mode) {
/**
* @private
*/ function _steppedLineTo(ctx, previous, target, flip, mode) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
@ -1326,13 +1365,62 @@ function unclipArea(ctx) {
}
ctx.lineTo(target.x, target.y);
}
function _bezierCurveTo(ctx, previous, target, flip) {
/**
* @private
*/ function _bezierCurveTo(ctx, previous, target, flip) {
if (!previous) {
return ctx.lineTo(target.x, target.y);
}
ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);
}
function renderText(ctx, text, x, y, font, opts = {}) {
function setRenderOpts(ctx, opts) {
if (opts.translation) {
ctx.translate(opts.translation[0], opts.translation[1]);
}
if (!isNullOrUndef(opts.rotation)) {
ctx.rotate(opts.rotation);
}
if (opts.color) {
ctx.fillStyle = opts.color;
}
if (opts.textAlign) {
ctx.textAlign = opts.textAlign;
}
if (opts.textBaseline) {
ctx.textBaseline = opts.textBaseline;
}
}
function decorateText(ctx, x, y, line, opts) {
if (opts.strikethrough || opts.underline) {
/**
* Now that IE11 support has been dropped, we can use more
* of the TextMetrics object. The actual bounding boxes
* are unflagged in Chrome, Firefox, Edge, and Safari so they
* can be safely used.
* See https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics#Browser_compatibility
*/ const metrics = ctx.measureText(line);
const left = x - metrics.actualBoundingBoxLeft;
const right = x + metrics.actualBoundingBoxRight;
const top = y - metrics.actualBoundingBoxAscent;
const bottom = y + metrics.actualBoundingBoxDescent;
const yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;
ctx.strokeStyle = ctx.fillStyle;
ctx.beginPath();
ctx.lineWidth = opts.decorationWidth || 2;
ctx.moveTo(left, yDecoration);
ctx.lineTo(right, yDecoration);
ctx.stroke();
}
}
function drawBackdrop(ctx, opts) {
const oldColor = ctx.fillStyle;
ctx.fillStyle = opts.color;
ctx.fillRect(opts.left, opts.top, opts.width, opts.height);
ctx.fillStyle = oldColor;
}
/**
* Render text onto the canvas
*/ function renderText(ctx, text, x, y, font, opts = {}) {
const lines = isArray(text) ? text : [
text
];
@ -1357,58 +1445,31 @@ function unclipArea(ctx) {
}
ctx.fillText(line, x, y, opts.maxWidth);
decorateText(ctx, x, y, line, opts);
y += font.lineHeight;
y += Number(font.lineHeight);
}
ctx.restore();
}
function setRenderOpts(ctx, opts) {
if (opts.translation) {
ctx.translate(opts.translation[0], opts.translation[1]);
}
if (!isNullOrUndef(opts.rotation)) {
ctx.rotate(opts.rotation);
}
if (opts.color) {
ctx.fillStyle = opts.color;
}
if (opts.textAlign) {
ctx.textAlign = opts.textAlign;
}
if (opts.textBaseline) {
ctx.textBaseline = opts.textBaseline;
}
}
function decorateText(ctx, x, y, line, opts) {
if (opts.strikethrough || opts.underline) {
const metrics = ctx.measureText(line);
const left = x - metrics.actualBoundingBoxLeft;
const right = x + metrics.actualBoundingBoxRight;
const top = y - metrics.actualBoundingBoxAscent;
const bottom = y + metrics.actualBoundingBoxDescent;
const yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;
ctx.strokeStyle = ctx.fillStyle;
ctx.beginPath();
ctx.lineWidth = opts.decorationWidth || 2;
ctx.moveTo(left, yDecoration);
ctx.lineTo(right, yDecoration);
ctx.stroke();
}
}
function drawBackdrop(ctx, opts) {
const oldColor = ctx.fillStyle;
ctx.fillStyle = opts.color;
ctx.fillRect(opts.left, opts.top, opts.width, opts.height);
ctx.fillStyle = oldColor;
}
function addRoundedRectPath(ctx, rect) {
/**
* Add a path of a rectangle with rounded corners to the current sub-path
* @param ctx - Context
* @param rect - Bounding rect
*/ function addRoundedRectPath(ctx, rect) {
const { x , y , w , h , radius } = rect;
// top left arc
ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, -HALF_PI, PI, true);
// line from top left to bottom left
ctx.lineTo(x, y + h - radius.bottomLeft);
// bottom left arc
ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);
// line from bottom left to bottom right
ctx.lineTo(x + w - radius.bottomRight, y + h);
// bottom right arc
ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);
// line from bottom right to top right
ctx.lineTo(x + w, y + radius.topRight);
// top right arc
ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);
// line from top right to top left
ctx.lineTo(x + radius.topLeft, y);
}
@ -1573,55 +1634,87 @@ function createContext(parentContext, context) {
return Object.assign(Object.create(parentContext), context);
}
function _createResolver(scopes, prefixes = [
/**
* Creates a Proxy for resolving raw values for options.
* @param scopes - The option scopes to look for values, in resolution order
* @param prefixes - The prefixes for values, in resolution order.
* @param rootScopes - The root option scopes
* @param fallback - Parent scopes fallback
* @param getTarget - callback for getting the target for changed values
* @returns Proxy
* @private
*/ function _createResolver(scopes, prefixes = [
''
], rootScopes = scopes, fallback, getTarget = ()=>scopes[0]) {
if (!defined(fallback)) {
], rootScopes, fallback, getTarget = ()=>scopes[0]) {
const finalRootScopes = rootScopes || scopes;
if (typeof fallback === 'undefined') {
fallback = _resolve('_fallback', scopes);
}
const cache = {
[Symbol.toStringTag]: 'Object',
_cacheable: true,
_scopes: scopes,
_rootScopes: rootScopes,
_rootScopes: finalRootScopes,
_fallback: fallback,
_getTarget: getTarget,
override: (scope)=>_createResolver([
scope,
...scopes
], prefixes, rootScopes, fallback)
], prefixes, finalRootScopes, fallback)
};
return new Proxy(cache, {
deleteProperty (target, prop) {
delete target[prop];
delete target._keys;
delete scopes[0][prop];
/**
* A trap for the delete operator.
*/ deleteProperty (target, prop) {
delete target[prop]; // remove from cache
delete target._keys; // remove cached keys
delete scopes[0][prop]; // remove from top level scope
return true;
},
get (target, prop) {
/**
* A trap for getting property values.
*/ get (target, prop) {
return _cached(target, prop, ()=>_resolveWithPrefixes(prop, prefixes, scopes, target));
},
getOwnPropertyDescriptor (target, prop) {
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/ getOwnPropertyDescriptor (target, prop) {
return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
},
getPrototypeOf () {
/**
* A trap for Object.getPrototypeOf.
*/ getPrototypeOf () {
return Reflect.getPrototypeOf(scopes[0]);
},
has (target, prop) {
/**
* A trap for the in operator.
*/ has (target, prop) {
return getKeysFromAllScopes(target).includes(prop);
},
ownKeys (target) {
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/ ownKeys (target) {
return getKeysFromAllScopes(target);
},
set (target, prop, value) {
/**
* A trap for setting property values.
*/ set (target, prop, value) {
const storage = target._storage || (target._storage = getTarget());
target[prop] = storage[prop] = value;
delete target._keys;
target[prop] = storage[prop] = value; // set to top level scope + cache
delete target._keys; // remove cached keys
return true;
}
});
}
function _attachContext(proxy, context, subProxy, descriptorDefaults) {
/**
* Returns an Proxy for resolving option values with context.
* @param proxy - The Proxy returned by `_createResolver`
* @param context - Context object for scriptable/indexable options
* @param subProxy - The proxy provided for scriptable options
* @param descriptorDefaults - Defaults for descriptors
* @private
*/ function _attachContext(proxy, context, subProxy, descriptorDefaults) {
const cache = {
_cacheable: false,
_proxy: proxy,
@ -1633,37 +1726,54 @@ function _createResolver(scopes, prefixes = [
override: (scope)=>_attachContext(proxy.override(scope), context, subProxy, descriptorDefaults)
};
return new Proxy(cache, {
deleteProperty (target, prop) {
delete target[prop];
delete proxy[prop];
/**
* A trap for the delete operator.
*/ deleteProperty (target, prop) {
delete target[prop]; // remove from cache
delete proxy[prop]; // remove from proxy
return true;
},
get (target, prop, receiver) {
/**
* A trap for getting property values.
*/ get (target, prop, receiver) {
return _cached(target, prop, ()=>_resolveWithContext(target, prop, receiver));
},
getOwnPropertyDescriptor (target, prop) {
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/ getOwnPropertyDescriptor (target, prop) {
return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {
enumerable: true,
configurable: true
} : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);
},
getPrototypeOf () {
/**
* A trap for Object.getPrototypeOf.
*/ getPrototypeOf () {
return Reflect.getPrototypeOf(proxy);
},
has (target, prop) {
/**
* A trap for the in operator.
*/ has (target, prop) {
return Reflect.has(proxy, prop);
},
ownKeys () {
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/ ownKeys () {
return Reflect.ownKeys(proxy);
},
set (target, prop, value) {
proxy[prop] = value;
delete target[prop];
/**
* A trap for setting property values.
*/ set (target, prop, value) {
proxy[prop] = value; // set to proxy
delete target[prop]; // remove from cache
return true;
}
});
}
function _descriptors(proxy, defaults = {
/**
* @private
*/ function _descriptors(proxy, defaults = {
scriptable: true,
indexable: true
}) {
@ -1683,12 +1793,14 @@ function _cached(target, prop, resolve) {
return target[prop];
}
const value = resolve();
// cache the resolved value
target[prop] = value;
return value;
}
function _resolveWithContext(target, prop, receiver) {
const { _proxy , _context , _subProxy , _descriptors: descriptors } = target;
let value = _proxy[prop];
let value = _proxy[prop]; // resolve from proxy
// resolve with context
if (isFunction(value) && descriptors.isScriptable(prop)) {
value = _resolveScriptable(prop, value, target, receiver);
}
@ -1696,28 +1808,31 @@ function _resolveWithContext(target, prop, receiver) {
value = _resolveArray(prop, value, target, descriptors.isIndexable);
}
if (needsSubResolver(prop, value)) {
// if the resolved value is an object, create a sub resolver for it
value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);
}
return value;
}
function _resolveScriptable(prop, value, target, receiver) {
function _resolveScriptable(prop, getValue, target, receiver) {
const { _proxy , _context , _subProxy , _stack } = target;
if (_stack.has(prop)) {
throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);
}
_stack.add(prop);
value = value(_context, _subProxy || receiver);
let value = getValue(_context, _subProxy || receiver);
_stack.delete(prop);
if (needsSubResolver(prop, value)) {
// When scriptable option returns an object, create a resolver on that.
value = createSubResolver(_proxy._scopes, _proxy, prop, value);
}
return value;
}
function _resolveArray(prop, value, target, isIndexable) {
const { _proxy , _context , _subProxy , _descriptors: descriptors } = target;
if (defined(_context.index) && isIndexable(prop)) {
value = value[_context.index % value.length];
if (typeof _context.index !== 'undefined' && isIndexable(prop)) {
return value[_context.index % value.length];
} else if (isObject(value[0])) {
// Array of objects, return array or resolvers
const arr = value;
const scopes = _proxy._scopes.filter((s)=>s !== arr);
value = [];
@ -1738,10 +1853,14 @@ function addScopes(set, parentScopes, key, parentFallback, value) {
if (scope) {
set.add(scope);
const fallback = resolveFallback(scope._fallback, key, value);
if (defined(fallback) && fallback !== key && fallback !== parentFallback) {
if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {
// When we reach the descriptor that defines a new _fallback, return that.
// The fallback will resume to that new scope.
return fallback;
}
} else if (scope === false && defined(parentFallback) && key !== parentFallback) {
} else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {
// Fallback to `false` results to `false`, when falling back to different key.
// For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`
return null;
}
}
@ -1760,7 +1879,7 @@ function createSubResolver(parentScopes, resolver, prop, value) {
if (key === null) {
return false;
}
if (defined(fallback) && fallback !== prop) {
if (typeof fallback !== 'undefined' && fallback !== prop) {
key = addScopesFromKey(set, allScopes, fallback, key, value);
if (key === null) {
return false;
@ -1783,6 +1902,7 @@ function subGetTarget(resolver, prop, value) {
}
const target = parent[prop];
if (isArray(target) && isObject(value)) {
// For array of objects, the object is used to store updated values
return value;
}
return target || {};
@ -1791,7 +1911,7 @@ function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
let value;
for (const prefix of prefixes){
value = _resolve(readKey(prefix, prop), scopes);
if (defined(value)) {
if (typeof value !== 'undefined') {
return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;
}
}
@ -1802,7 +1922,7 @@ function _resolve(key, scopes) {
continue;
}
const value = scope[key];
if (defined(value)) {
if (typeof value !== 'undefined') {
return value;
}
}
@ -2603,7 +2723,20 @@ function readStyle(options) {
};
}
function styleChanged(style, prevStyle) {
return prevStyle && JSON.stringify(style) !== JSON.stringify(prevStyle);
if (!prevStyle) {
return false;
}
const cache = [];
const replacer = function(key, value) {
if (!isPatternOrGradient(value)) {
return value;
}
if (!cache.includes(value)) {
cache.push(value);
}
return cache.indexOf(value);
};
return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
}
export { unclipArea as $, _rlookupByKey as A, _lookupByKey as B, _isPointInArea as C, getAngleFromPoint as D, toPadding as E, each as F, getMaximumSize as G, HALF_PI as H, _getParentNode as I, readUsedSize as J, supportsEventListenerOptions as K, throttled as L, _isDomSupported as M, _factorize as N, finiteOrDefault as O, PI as P, callback as Q, _addGrace as R, _limitValue as S, TAU as T, toDegrees as U, _measureText as V, _int16Range as W, _alignPixel as X, clipArea as Y, renderText as Z, _arrayUnique as _, resolve as a, fontString as a$, toFont as a0, _toLeftRightCenter as a1, _alignStartEnd as a2, overrides as a3, merge as a4, _capitalize as a5, descriptors as a6, isFunction as a7, _attachContext as a8, _createResolver as a9, overrideTextDirection as aA, _textX as aB, restoreTextDirection as aC, drawPointLegend as aD, distanceBetweenPoints as aE, noop as aF, _setMinAndMaxByKey as aG, niceNum as aH, almostWhole as aI, almostEquals as aJ, _decimalPlaces as aK, Ticks as aL, log10 as aM, _longestText as aN, _filterBetween as aO, _lookup as aP, isPatternOrGradient as aQ, getHoverColor as aR, clone as aS, _merger as aT, _mergerIf as aU, _deprecated as aV, _splitKey as aW, toFontString as aX, splineCurve as aY, splineCurveMonotone as aZ, getStyle as a_, _descriptors as aa, mergeIf as ab, uid as ac, debounce as ad, retinaScale as ae, clearCanvas as af, setsEqual as ag, _elementsEqual as ah, _isClickEvent as ai, _isBetween as aj, _readValueToProps as ak, _updateBezierControlPoints as al, _computeSegments as am, _boundSegments as an, _steppedInterpolation as ao, _bezierInterpolation as ap, _pointInLine as aq, _steppedLineTo as ar, _bezierCurveTo as as, drawPoint as at, addRoundedRectPath as au, toTRBL as av, toTRBLCorners as aw, _boundSegment as ax, _normalizeAngle as ay, getRtlAdapter as az, isArray as b, toLineHeight as b0, PITAU as b1, INFINITY as b2, RAD_PER_DEG as b3, QUARTER_PI as b4, TWO_THIRDS_PI as b5, _angleDiff as b6, color as c, defaults as d, effects as e, resolveObjectKey as f, isNumberFinite as g, defined as h, isObject as i, createContext as j, isNullOrUndef as k, listenArrayEvents as l, toPercentage as m, toDimension as n, formatNumber as o, _angleBetween as p, _getStartAndCountOfVisiblePoints as q, requestAnimFrame as r, sign as s, toRadians as t, unlistenArrayEvents as u, valueOrDefault as v, _scaleRangesChanged as w, isNumber as x, _parseObjectDataRadialScale as y, getRelativePosition as z };

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,9 @@ export default class PolarAreaController extends DatasetController {
label: any;
value: string;
};
parseObjectData(meta: any, data: any, start: any, count: any): any[];
parseObjectData(meta: any, data: any, start: any, count: any): {
r: unknown;
}[];
update(mode: any): void;
/**
* @protected

View file

@ -11,7 +11,9 @@ export default class RadarController extends DatasetController {
label: any;
value: string;
};
parseObjectData(meta: any, data: any, start: any, count: any): any[];
parseObjectData(meta: any, data: any, start: any, count: any): {
r: unknown;
}[];
update(mode: any): void;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -5,7 +5,7 @@
*/
import type { AnyObject } from '../types/basic.js';
import type { ChartOptions } from '../types/index.js';
export declare type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
export interface DateAdapter<T extends AnyObject = AnyObject> {
readonly options: T;
/**

View file

@ -1,5 +1,5 @@
export function getIndexAxis(type: any, options: any): any;
export function determineAxis(id: any, scaleOptions: any): any;
export function determineAxis(id: any, ...scaleOptions: any[]): any;
export default class Config {
constructor(config: any);
_config: any;

View file

@ -13,29 +13,6 @@ declare namespace _default {
* @return {InteractionItem[]} - items that are found
*/
function index(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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 - 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 position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function index(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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 from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function dataset(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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
@ -58,27 +35,6 @@ declare namespace _default {
* @return {InteractionItem[]} - items that are found
*/
function point(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function point(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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 position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function nearest(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* nearest mode returns the element closest to the point
* @function Chart.Interaction.modes.intersect
@ -99,26 +55,6 @@ declare namespace _default {
* @return {InteractionItem[]} - items that are found
*/
function x(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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 element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function x(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* 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 element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function y(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* y mode returns the elements that hit-test at the current y coordinate
* @function Chart.Interaction.modes.y

View file

@ -6,19 +6,6 @@ declare namespace _default {
* @param {LayoutItem} item - the item to add to be laid out
*/
function addBox(chart: import("./core.controller.js").default, item: LayoutItem): void;
/**
* 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
*/
function addBox(chart: import("./core.controller.js").default, item: LayoutItem): void;
/**
* 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
*/
function removeBox(chart: import("./core.controller.js").default, layoutItem: LayoutItem): void;
/**
* Remove a layoutItem from a chart
* @param {Chart} chart - the chart to remove the box from
@ -32,22 +19,6 @@ declare namespace _default {
* @param {object} options - the new item options.
*/
function configure(chart: import("./core.controller.js").default, item: LayoutItem, options: any): void;
/**
* 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.
*/
function configure(chart: import("./core.controller.js").default, item: LayoutItem, options: any): void;
/**
* 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 area
*/
function update(chart: import("./core.controller.js").default, width: number, height: number, minPadding: number): void;
/**
* Fits boxes of the given chart into the given size by having each box measure itself
* then running a fitting algorithm

View file

@ -47,7 +47,7 @@ export default class Scale extends Element<import("../types/basic.js").AnyObject
min: any;
max: any;
_range: {
min: number; /** @type {object[]|null} */
min: number;
max: number;
};
/** @type {Tick[]} */
@ -127,7 +127,7 @@ export default class Scale extends Element<import("../types/basic.js").AnyObject
/**
* @return {import('../types.js').LabelItem[]}
*/
getLabelItems(chartArea?: any): import('../types.js').LabelItem[];
getLabelItems(chartArea?: import("../types.js").ChartArea): import('../types.js').LabelItem[];
beforeLayout(): void;
beforeUpdate(): void;
/**
@ -333,7 +333,7 @@ export default class Scale extends Element<import("../types/basic.js").AnyObject
*/
protected _maxDigits(): number;
}
export type Chart = import('./core.controller.js').default;
export type Chart = import('../types/index.js').Chart;
export type Tick = {
value: number | string;
label?: string;

View file

@ -3,13 +3,6 @@ declare namespace _default {
}
export default _default;
declare namespace formatters {
/**
* Formatter for value labels
* @method Chart.Ticks.formatters.values
* @param value the value to display
* @return {string|string[]} the label to display
*/
function values(value: any): string | string[];
/**
* Formatter for value labels
* @method Chart.Ticks.formatters.values
@ -26,24 +19,6 @@ declare namespace formatters {
* @return {string} string representation of the tickValue parameter
*/
function numeric(tickValue: number, index: number, ticks: any[]): string;
/**
* 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 parameter
*/
function numeric(tickValue: number, index: number, ticks: any[]): string;
/**
* 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 tickValue parameter
*/
function logarithmic(tickValue: number, index: number, ticks: any[]): string;
/**
* Formatter for logarithmic ticks
* @method Chart.Ticks.formatters.logarithmic

View file

@ -12,6 +12,8 @@ export default class ArcElement extends Element<ArcProps, ArcOptions> {
static defaults: {
borderAlign: string;
borderColor: string;
borderDash: any[];
borderDashOffset: number;
borderJoinStyle: any;
borderRadius: number;
borderWidth: number;
@ -23,6 +25,10 @@ export default class ArcElement extends Element<ArcProps, ArcOptions> {
static defaultRoutes: {
backgroundColor: string;
};
static descriptors: {
_scriptable: boolean;
_indexable: (name: any) => boolean;
};
circumference: number;
endAngle: number;
fullCircles: number;

View file

@ -1,6 +1,6 @@
import Element from '../core/core.element.js';
import type { CartesianParsedData, ChartArea, Point, PointHoverOptions, PointOptions } from '../types/index.js';
export declare type PointProps = Point;
export type PointProps = Point;
export default class PointElement extends Element<PointProps, PointOptions & PointHoverOptions> {
static id: string;
parsed: CartesianParsedData;

View file

@ -1,5 +1,5 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License

View file

@ -1,5 +1,5 @@
/*!
* Chart.js v4.2.1
* Chart.js v4.3.0
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License

View file

@ -1,85 +1,75 @@
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
* @typedef { import('../core/core.controller.js').default } canvas.Chart
* @typedef { import('../types/index.js').Point } Point
*/
/**
* @namespace Chart.helpers.canvas
*/
import type { Chart, Point, FontSpec, CanvasFontSpec, PointStyle, RenderTextOpts } from '../types/index.js';
import type { TRBL, SplinePoint, RoundedRect, TRBLCorners } from '../types/geometric.js';
/**
* Converts the given font object into a CSS font string.
* @param {object} font - A font object.
* @return {string|null} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @param font - A font object.
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @private
*/
export function toFontString(font: object): string | null;
export declare function toFontString(font: FontSpec): string;
/**
* @private
*/
export function _measureText(ctx: any, data: any, gc: any, longest: any, string: any): any;
export declare function _measureText(ctx: CanvasRenderingContext2D, data: Record<string, number>, gc: string[], longest: number, string: string): number;
type Thing = string | undefined | null;
type Things = (Thing | Thing[])[];
/**
* @private
*/
export function _longestText(ctx: any, font: any, arrayOfThings: any, cache: any): number;
export declare function _longestText(ctx: CanvasRenderingContext2D, font: string, arrayOfThings: Things, cache?: {
data?: Record<string, number>;
garbageCollect?: string[];
font?: string;
}): number;
/**
* Returns the aligned pixel value to avoid anti-aliasing blur
* @param {canvas.Chart} chart - The chart instance.
* @param {number} pixel - A pixel value.
* @param {number} width - The width of the element.
* @returns {number} The aligned pixel value.
* @param chart - The chart instance.
* @param pixel - A pixel value.
* @param width - The width of the element.
* @returns The aligned pixel value.
* @private
*/
export function _alignPixel(chart: canvas.Chart, pixel: number, width: number): number;
export declare function _alignPixel(chart: Chart, pixel: number, width: number): number;
/**
* Clears the entire canvas.
* @param {HTMLCanvasElement} canvas
* @param {CanvasRenderingContext2D} [ctx]
*/
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
export function drawPoint(ctx: any, options: any, x: any, y: any): void;
export function drawPointLegend(ctx: any, options: any, x: any, y: any, w: any): void;
export declare function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
export interface DrawPointOptions {
pointStyle: PointStyle;
rotation?: number;
radius: number;
borderWidth: number;
}
export declare function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
export declare function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;
/**
* Returns true if the point is inside the rectangle
* @param {Point} point - The point to test
* @param {object} area - The rectangle
* @param {number} [margin] - allowed margin
* @returns {boolean}
* @param point - The point to test
* @param area - The rectangle
* @param margin - allowed margin
* @private
*/
export function _isPointInArea(point: Point, area: object, margin?: number): boolean;
export function clipArea(ctx: any, area: any): void;
export function unclipArea(ctx: any): void;
export declare function _isPointInArea(point: Point, area: TRBL, margin?: number): boolean;
export declare function clipArea(ctx: CanvasRenderingContext2D, area: TRBL): void;
export declare function unclipArea(ctx: CanvasRenderingContext2D): void;
/**
* @private
*/
export function _steppedLineTo(ctx: any, previous: any, target: any, flip: any, mode: any): any;
export declare function _steppedLineTo(ctx: CanvasRenderingContext2D, previous: Point, target: Point, flip?: boolean, mode?: string): void;
/**
* @private
*/
export function _bezierCurveTo(ctx: any, previous: any, target: any, flip: any): any;
export declare function _bezierCurveTo(ctx: CanvasRenderingContext2D, previous: SplinePoint, target: SplinePoint, flip?: boolean): void;
/**
* Render text onto the canvas
*/
export function renderText(ctx: any, text: any, x: any, y: any, font: any, opts?: {}): void;
export declare function renderText(ctx: CanvasRenderingContext2D, text: string | string[], x: number, y: number, font: CanvasFontSpec, opts?: RenderTextOpts): void;
/**
* Add a path of a rectangle with rounded corners to the current sub-path
* @param {CanvasRenderingContext2D} ctx Context
* @param {*} rect Bounding rect
* @param ctx - Context
* @param rect - Bounding rect
*/
export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: any): void;
export namespace canvas {
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
*/
type Chart = import('../core/core.controller.js').default;
}
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
*/
export type Point = import('../types/index.js').Point;
export declare function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect & {
radius: TRBLCorners;
}): void;
export {};

View file

@ -1,61 +1,31 @@
import type { AnyObject } from '../types/basic.js';
import type { ChartMeta } from '../types/index.js';
import type { ResolverObjectKey, ResolverCache, ResolverProxy, DescriptorDefaults, Descriptor, ContextProxy } from './helpers.config.types.js';
export * from './helpers.config.types.js';
/**
* Creates a Proxy for resolving raw values for options.
* @param {object[]} scopes - The option scopes to look for values, in resolution order
* @param {string[]} [prefixes] - The prefixes for values, in resolution order.
* @param {object[]} [rootScopes] - The root option scopes
* @param {string|boolean} [fallback] - Parent scopes fallback
* @param {function} [getTarget] - callback for getting the target for changed values
* @param scopes - The option scopes to look for values, in resolution order
* @param prefixes - The prefixes for values, in resolution order.
* @param rootScopes - The root option scopes
* @param fallback - Parent scopes fallback
* @param getTarget - callback for getting the target for changed values
* @returns Proxy
* @private
*/
export function _createResolver(scopes: object[], prefixes?: string[], rootScopes?: object[], fallback?: string | boolean, getTarget?: Function): {
[Symbol.toStringTag]: string;
_cacheable: boolean;
_scopes: any[];
_rootScopes: any[];
_fallback: string | boolean;
_getTarget: Function;
override: (scope: any) => any;
};
export declare function _createResolver<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T>(scopes: T, prefixes?: string[], rootScopes?: R, fallback?: ResolverObjectKey, getTarget?: () => AnyObject): any;
/**
* Returns an Proxy for resolving option values with context.
* @param {object} proxy - The Proxy returned by `_createResolver`
* @param {object} context - Context object for scriptable/indexable options
* @param {object} [subProxy] - The proxy provided for scriptable options
* @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults] - Defaults for descriptors
* @param proxy - The Proxy returned by `_createResolver`
* @param context - Context object for scriptable/indexable options
* @param subProxy - The proxy provided for scriptable options
* @param descriptorDefaults - Defaults for descriptors
* @private
*/
export function _attachContext(proxy: object, context: object, subProxy?: object, descriptorDefaults?: {
scriptable: boolean;
indexable: boolean;
allKeys?: boolean;
}): {
_cacheable: boolean;
_proxy: any;
_context: any;
_subProxy: any;
_stack: Set<any>;
_descriptors: {
allKeys: any;
scriptable: any;
indexable: any;
isScriptable: (...args: any[]) => any;
isIndexable: (...args: any[]) => any;
};
setContext: (ctx: any) => any;
override: (scope: any) => any;
};
export declare function _attachContext<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T>(proxy: ResolverProxy<T, R>, context: AnyObject, subProxy?: ResolverProxy<T, R>, descriptorDefaults?: DescriptorDefaults): ContextProxy<T, R>;
/**
* @private
*/
export function _descriptors(proxy: any, defaults?: {
scriptable: boolean;
indexable: boolean;
}): {
allKeys: any;
scriptable: any;
indexable: any;
isScriptable: (...args: any[]) => any;
isIndexable: (...args: any[]) => any;
};
export function _parseObjectDataRadialScale(meta: any, data: any, start: any, count: any): any[];
export declare function _descriptors(proxy: ResolverCache, defaults?: DescriptorDefaults): Descriptor;
export declare function _parseObjectDataRadialScale(meta: ChartMeta<'line' | 'scatter'>, data: AnyObject[], start: number, count: number): {
r: unknown;
}[];

View file

@ -132,7 +132,7 @@ export declare function _deprecated(scope: string, value: unknown, previous: str
* @private
*/
export declare function _splitKey(key: string): string[];
export declare function resolveObjectKey(obj: AnyObject, key: string): AnyObject;
export declare function resolveObjectKey(obj: AnyObject, key: string): any;
/**
* @private
*/

View file

@ -1,13 +1,5 @@
import type { ChartArea } from '../types/index.js';
export interface SplinePoint {
x: number;
y: number;
skip?: boolean;
cp1x?: number;
cp1y?: number;
cp2x?: number;
cp2y?: number;
}
import type { SplinePoint } from '../types/geometric.js';
export declare function splineCurve(firstPoint: SplinePoint, middlePoint: SplinePoint, afterPoint: SplinePoint, t: number): {
previous: SplinePoint;
next: SplinePoint;

View file

@ -36,5 +36,5 @@ declare const effects: {
readonly easeOutBounce: (t: number) => number;
readonly easeInOutBounce: (t: number) => number;
};
export declare type EasingFunction = keyof typeof effects;
export type EasingFunction = keyof typeof effects;
export default effects;

View file

@ -1,5 +1,4 @@
import type { Point } from '../types/geometric.js';
import type { SplinePoint } from './helpers.curve.js';
import type { Point, SplinePoint } from '../types/geometric.js';
/**
* @private
*/

View file

@ -1,5 +1,4 @@
import { Point } from './helpers.canvas.js';
import type { ChartArea, FontSpec } from '../types/index.js';
import type { ChartArea, FontSpec, Point } from '../types/index.js';
import type { TRBL, TRBLCorners } from '../types/geometric.js';
/**
* @alias Chart.helpers.options
@ -46,9 +45,6 @@ export declare function toTRBLCorners(value: number | TRBLCorners): Record<"topL
* @since 2.7.0
*/
export declare function toPadding(value?: number | TRBL): ChartArea;
export interface CanvasFontSpec extends FontSpec {
string: string;
}
/**
* Parses font options and returns the font object.
* @param options - A object that contains font options to be parsed.

View file

@ -1,17 +0,0 @@
/**
* Temporary entry point of the types at the time of the transition.
* After transition done need to remove it in favor of index.ts
*/
export * from './helpers.color.js';
export * from './helpers.collection.js';
export * from './helpers.core.js';
export * from './helpers.curve.js';
export * from './helpers.dom.js';
export * from './helpers.easing.js';
export * from './helpers.extras.js';
export * from './helpers.interpolation.js';
export * from './helpers.intl.js';
export * from './helpers.math.js';
export * from './helpers.options.js';
export * from './helpers.rtl.js';
export * from '../types/helpers/index.js';

View file

@ -6,6 +6,5 @@ declare namespace _default {
}
function beforeElementsUpdate(chart: any, args: any, options: any): void;
function destroy(chart: any): void;
function destroy(chart: any): void;
}
export default _default;

View file

@ -1,12 +1,8 @@
declare namespace _default {
const id: string;
function afterDatasetsUpdate(chart: any, _args: any, options: any): void;
function afterDatasetsUpdate(chart: any, _args: any, options: any): void;
function beforeDraw(chart: any, _args: any, options: any): void;
function beforeDraw(chart: any, _args: any, options: any): void;
function beforeDatasetsDraw(chart: any, _args: any, options: any): void;
function beforeDatasetsDraw(chart: any, _args: any, options: any): void;
function beforeDatasetDraw(chart: any, args: any, options: any): void;
function beforeDatasetDraw(chart: any, args: any, options: any): void;
namespace defaults {
const propagate: boolean;

View file

@ -70,14 +70,9 @@ declare namespace _default {
export const id: string;
export { Legend as _element };
export function start(chart: any, _args: any, options: any): void;
export function start(chart: any, _args: any, options: any): void;
export function stop(chart: any): void;
export function stop(chart: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function afterUpdate(chart: any): void;
export function afterUpdate(chart: any): void;
export function afterEvent(chart: any, args: any): void;
export function afterEvent(chart: any, args: any): void;
export namespace defaults {
const display: boolean;
@ -87,7 +82,6 @@ declare namespace _default {
const reverse: boolean;
const weight: number;
function onClick(e: any, legendItem: any, legend: any): void;
function onClick(e: any, legendItem: any, legend: any): void;
const onHover: any;
const onLeave: any;
namespace labels {
@ -95,7 +89,6 @@ declare namespace _default {
const boxWidth: number;
const padding: number;
function generateLabels(chart: any): any;
function generateLabels(chart: any): any;
}
namespace title {
export function color_1(ctx: any): any;

View file

@ -1,10 +1,7 @@
declare namespace _default {
const id: string;
function start(chart: any, _args: any, options: any): void;
function start(chart: any, _args: any, options: any): void;
function stop(chart: any): void;
function stop(chart: any): void;
function beforeUpdate(chart: any, _args: any, options: any): void;
function beforeUpdate(chart: any, _args: any, options: any): void;
namespace defaults {
export const align: string;

View file

@ -34,10 +34,7 @@ declare namespace _default {
export const id: string;
export { Title as _element };
export function start(chart: any, _args: any, options: any): void;
export function start(chart: any, _args: any, options: any): void;
export function stop(chart: any): void;
export function stop(chart: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export namespace defaults {
export const align: string;

View file

@ -150,14 +150,9 @@ declare namespace _default {
export { Tooltip as _element };
export { positioners };
export function afterInit(chart: any, _args: any, options: any): void;
export function afterInit(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function reset(chart: any, _args: any, options: any): void;
export function reset(chart: any, _args: any, options: any): void;
export function afterDraw(chart: any): void;
export function afterDraw(chart: any): void;
export function afterEvent(chart: any, args: any): void;
export function afterEvent(chart: any, args: any): void;
export namespace defaults {
export const enabled: boolean;
@ -256,20 +251,6 @@ declare namespace positioners {
x: number;
y: number;
};
/**
* Average mode places the tooltip at the average position of the elements shown
*/
function average(items: any): false | {
x: number;
y: number;
};
/**
* Gets the tooltip position nearest of the item nearest to the event position
*/
function nearest(items: any, eventPosition: any): false | {
x: any;
y: any;
};
/**
* Gets the tooltip position nearest of the item nearest to the event position
*/
@ -281,20 +262,10 @@ declare namespace positioners {
declare namespace defaultCallbacks {
export { noop as beforeTitle };
export function title(tooltipItems: any): any;
export function title(tooltipItems: any): any;
export { noop as afterTitle };
export { noop as beforeBody };
export { noop as beforeLabel };
export function label(tooltipItem: any): any;
export function label(tooltipItem: any): any;
export function labelColor(tooltipItem: any): {
borderColor: any;
backgroundColor: any;
borderWidth: any;
borderDash: any;
borderDashOffset: any;
borderRadius: number;
};
export function labelColor(tooltipItem: any): {
borderColor: any;
backgroundColor: any;
@ -304,11 +275,6 @@ declare namespace defaultCallbacks {
borderRadius: number;
};
export function labelTextColor(): any;
export function labelTextColor(): any;
export function labelPointStyle(tooltipItem: any): {
pointStyle: any;
rotation: any;
};
export function labelPointStyle(tooltipItem: any): {
pointStyle: any;
rotation: any;

View file

@ -37,3 +37,16 @@ export type RoundedRect = {
}
export type Padding = Partial<TRBL> | number | Point;
export interface SplinePoint {
x: number;
y: number;
skip?: boolean;
// Both Bezier and monotone interpolations have these fields
// but they are added in different spots
cp1x?: number;
cp1y?: number;
cp2x?: number;
cp2y?: number;
}

View file

@ -1,135 +0,0 @@
import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
import {Color} from '../color.js';
import {ChartArea, RoundedRect} from '../geometric.js';
import {CanvasFontSpec} from '../../helpers/helpers.options.js';
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
export function clipArea(ctx: CanvasRenderingContext2D, area: ChartArea): void;
export function unclipArea(ctx: CanvasRenderingContext2D): void;
export interface DrawPointOptions {
pointStyle: PointStyle;
rotation?: number;
radius: number;
borderWidth: number;
}
export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
export function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;
/**
* Converts the given font object into a CSS font string.
* @param font a font object
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
*/
export function toFontString(font: { size: number; family: string; style?: string; weight?: string }): string | null;
export interface RenderTextOpts {
/**
* The fill color of the text. If unset, the existing
* fillStyle property of the canvas is unchanged.
*/
color?: Color;
/**
* The width of the strikethrough / underline
* @default 2
*/
decorationWidth?: number;
/**
* The max width of the text in pixels
*/
maxWidth?: number;
/**
* A rotation to be applied to the canvas
* This is applied after the translation is applied
*/
rotation?: number;
/**
* Apply a strikethrough effect to the text
*/
strikethrough?: boolean;
/**
* The color of the text stroke. If unset, the existing
* strokeStyle property of the context is unchanged
*/
strokeColor?: Color;
/**
* The text stroke width. If unset, the existing
* lineWidth property of the context is unchanged
*/
strokeWidth?: number;
/**
* The text alignment to use. If unset, the existing
* textAlign property of the context is unchanged
*/
textAlign?: CanvasTextAlign;
/**
* The text baseline to use. If unset, the existing
* textBaseline property of the context is unchanged
*/
textBaseline?: CanvasTextBaseline;
/**
* If specified, a translation to apply to the context
*/
translation?: [number, number];
/**
* Underline the text
*/
underline?: boolean;
/**
* Dimensions for drawing the label backdrop
*/
backdrop?: BackdropOptions;
}
export interface BackdropOptions {
/**
* Left position of backdrop as pixel
*/
left: number;
/**
* Top position of backdrop as pixel
*/
top: number;
/**
* Width of backdrop in pixels
*/
width: number;
/**
* Height of backdrop in pixels
*/
height: number;
/**
* Color of label backdrops.
*/
color: Scriptable<Color, ScriptableScaleContext>;
}
export function renderText(
ctx: CanvasRenderingContext2D,
text: string | string[],
x: number,
y: number,
font: CanvasFontSpec,
opts?: RenderTextOpts
): void;
export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect): void;

View file

@ -1 +0,0 @@
export {};

View file

@ -1,3 +0,0 @@
export * from './helpers.canvas.js';
export * from './helpers.canvas.js';
export * from './helpers.segment.js';

View file

@ -10,9 +10,7 @@ import {Color} from './color.js';
import Element from '../core/core.element.js';
import {ChartArea, Padding, Point} from './geometric.js';
import {LayoutItem, LayoutPosition} from './layout.js';
import {RenderTextOpts} from './helpers/helpers.canvas.js';
import {CanvasFontSpec} from '../helpers/helpers.options.js';
import type {ColorsPluginOptions} from '../plugins/plugin.colors.js';
import {ColorsPluginOptions} from '../plugins/plugin.colors.js';
export {EasingFunction} from '../helpers/helpers.easing.js';
export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
@ -548,6 +546,8 @@ export declare class Chart<
isPluginEnabled(pluginId: string): boolean;
getContext(): { chart: Chart, type: string };
static readonly defaults: Defaults;
static readonly overrides: Overrides;
static readonly version: string;
@ -1359,6 +1359,102 @@ export interface ScriptableScalePointLabelContext {
type: string;
}
export interface RenderTextOpts {
/**
* The fill color of the text. If unset, the existing
* fillStyle property of the canvas is unchanged.
*/
color?: Color;
/**
* The width of the strikethrough / underline
* @default 2
*/
decorationWidth?: number;
/**
* The max width of the text in pixels
*/
maxWidth?: number;
/**
* A rotation to be applied to the canvas
* This is applied after the translation is applied
*/
rotation?: number;
/**
* Apply a strikethrough effect to the text
*/
strikethrough?: boolean;
/**
* The color of the text stroke. If unset, the existing
* strokeStyle property of the context is unchanged
*/
strokeColor?: Color;
/**
* The text stroke width. If unset, the existing
* lineWidth property of the context is unchanged
*/
strokeWidth?: number;
/**
* The text alignment to use. If unset, the existing
* textAlign property of the context is unchanged
*/
textAlign?: CanvasTextAlign;
/**
* The text baseline to use. If unset, the existing
* textBaseline property of the context is unchanged
*/
textBaseline?: CanvasTextBaseline;
/**
* If specified, a translation to apply to the context
*/
translation?: [number, number];
/**
* Underline the text
*/
underline?: boolean;
/**
* Dimensions for drawing the label backdrop
*/
backdrop?: BackdropOptions;
}
export interface BackdropOptions {
/**
* Left position of backdrop as pixel
*/
left: number;
/**
* Top position of backdrop as pixel
*/
top: number;
/**
* Width of backdrop in pixels
*/
width: number;
/**
* Height of backdrop in pixels
*/
height: number;
/**
* Color of label backdrops.
*/
color: Scriptable<Color, ScriptableScaleContext>;
}
export interface LabelItem {
label: string | string[];
font: CanvasFontSpec;
@ -1658,6 +1754,10 @@ export interface FontSpec {
lineHeight: number | string;
}
export interface CanvasFontSpec extends FontSpec {
string: string;
}
export type TextAlign = 'left' | 'center' | 'right';
export type Align = 'start' | 'center' | 'end';
@ -1700,7 +1800,16 @@ export interface ArcOptions extends CommonElementOptions {
* Arc stroke alignment.
*/
borderAlign: 'center' | 'inner';
/**
* Line dash. See MDN.
* @default []
*/
borderDash: number[];
/**
* Line dash offset. See MDN.
* @default 0.0
*/
borderDashOffset: number;
/**
* Line join style. See MDN. Default is 'round' when `borderAlign` is 'inner', else 'bevel'.
*/
@ -1730,6 +1839,8 @@ export interface ArcOptions extends CommonElementOptions {
}
export interface ArcHoverOptions extends CommonHoverOptions {
hoverBorderDash: number[];
hoverBorderDashOffset: number;
hoverOffset: number;
}
@ -3389,10 +3500,10 @@ export type RadialLinearScaleOptions = CoreScaleOptions & {
borderRadius: Scriptable<number | BorderRadius, ScriptableScalePointLabelContext>;
/**
* if true, point labels are shown.
* if true, point labels are shown. When `display: 'auto'`, the label is hidden if it overlaps with another label.
* @default true
*/
display: boolean;
display: boolean | 'auto';
/**
* Color of label
* @see Defaults.color
@ -3644,6 +3755,8 @@ export interface ChartData<
TLabel = unknown
> {
labels?: TLabel[];
xLabels?: TLabel[];
yLabels?: TLabel[];
datasets: ChartDataset<TType, TData>[];
}
@ -3653,6 +3766,8 @@ export interface ChartDataCustomTypesPerDataset<
TLabel = unknown
> {
labels?: TLabel[];
xLabels?: TLabel[];
yLabels?: TLabel[];
datasets: ChartDatasetCustomTypesPerDataset<TType, TData>[];
}

View file

@ -18,3 +18,13 @@ export type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never
// https://stackoverflow.com/a/50375286
export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
export type AllKeys<T> = T extends any ? keyof T : never;
export type PickType<T, K extends AllKeys<T>> = T extends { [k in K]?: any }
? T[K]
: undefined;
export type Merge<T extends object> = {
[k in AllKeys<T>]: PickType<T, k>;
};

4
node_modules/chart.js/package.json generated vendored
View file

@ -2,7 +2,7 @@
"name": "chart.js",
"homepage": "https://www.chartjs.org",
"description": "Simple HTML5 charts using the canvas element.",
"version": "4.2.1",
"version": "4.3.0",
"license": "MIT",
"type": "module",
"sideEffects": [
@ -125,7 +125,7 @@
"yargs": "^17.5.1"
},
"engines": {
"pnpm": "^7.0.0"
"pnpm": ">=7"
},
"packageManager": "pnpm@7.9.0",
"pnpm": {