@oliasoft-open-source/charts-library 5.7.2 → 5.8.0-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Color-6BZIO3FS-yUBzcx3f.js +1 -0
- package/dist/assets/DocsRenderer-LL677BLK-Cv-RiZgp.js +41 -0
- package/dist/assets/{WithTooltip-65CFNBJE-BQ4nRetu.js → WithTooltip-65CFNBJE-D5MURczo.js} +1 -1
- package/dist/assets/bar-chart.stories-Djw9G9WY.js +138 -0
- package/dist/assets/{chunk-YKABRMAI-ChBkp0ra.js → chunk-YKABRMAI-BiEoGPFq.js} +2 -2
- package/dist/assets/components-pYTrE2NN.js +92 -0
- package/dist/assets/formatter-EIJCOSYU-BdIFWCzD.js +1 -0
- package/dist/assets/get-draggableData-8RjJz0R1.js +2 -0
- package/dist/assets/{iframe-DvGneWFZ.js → iframe-B2fw5Bei.js} +4 -4
- package/dist/assets/{legend-DnGwExsY.js → legend-Bzoldcm9.js} +40 -40
- package/dist/assets/{legend-context-DrT75Hl_.js → legend-context-BQsaMMe8.js} +3 -3
- package/dist/assets/line-chart-CAC71aZW.js +1 -0
- package/dist/assets/line-chart.stories-BktUzznZ.js +1211 -0
- package/dist/assets/{line-chart.test-case.stories-BPzBXXrt.js → line-chart.test-case.stories-OoYj9tVX.js} +1 -1
- package/dist/assets/pie-chart.stories-2jQBIUKO.js +45 -0
- package/dist/assets/{react-18-CaPDGmKz.js → react-18-KGjvEL53.js} +1 -1
- package/dist/assets/{react-B3R5p1NM.js → react-BMTEiBr5.js} +1 -1
- package/dist/assets/{react-dom-DuTm0_Xz.js → react-dom-BVFy65_E.js} +1 -1
- package/dist/assets/scatter-chart.stories-R4ZiS_uH.js +41 -0
- package/dist/assets/syntaxhighlighter-ED5Y7EFY-OlsfIhDT.js +6 -0
- package/dist/assets/{theming-Y5Cbkxro.js → theming-B7gQRU4z.js} +1 -1
- package/dist/common/common.interface.d.ts +7 -0
- package/dist/iframe.html +2 -2
- package/dist/index.js +259 -59
- package/dist/index.json +1 -1
- package/dist/line-chart/plugins/vertical-markers-plugin/draw.d.ts +24 -0
- package/dist/line-chart/plugins/vertical-markers-plugin/types.d.ts +42 -0
- package/dist/line-chart/plugins/vertical-markers-plugin/utils.d.ts +23 -0
- package/dist/line-chart/plugins/vertical-markers-plugin/vertical-markers-plugin.d.ts +54 -0
- package/dist/project.json +1 -1
- package/dist/src/components/common/common.interface.d.ts +7 -0
- package/dist/src/components/line-chart/plugins/vertical-markers-plugin/draw.d.ts +24 -0
- package/dist/src/components/line-chart/plugins/vertical-markers-plugin/types.d.ts +42 -0
- package/dist/src/components/line-chart/plugins/vertical-markers-plugin/utils.d.ts +23 -0
- package/dist/src/components/line-chart/plugins/vertical-markers-plugin/vertical-markers-plugin.d.ts +54 -0
- package/package.json +1 -1
- package/dist/assets/Color-6BZIO3FS-BaAvX6Yp.js +0 -1
- package/dist/assets/DocsRenderer-LL677BLK-BK5C7Jzn.js +0 -41
- package/dist/assets/bar-chart.stories-D5i9vPgt.js +0 -138
- package/dist/assets/components-DgLnPVTi.js +0 -92
- package/dist/assets/formatter-EIJCOSYU-By9veOc8.js +0 -1
- package/dist/assets/get-draggableData-C4qYyiBf.js +0 -2
- package/dist/assets/jsx-runtime-S4TgXXQD.js +0 -1
- package/dist/assets/line-chart-Ds2L0-Ky.js +0 -1
- package/dist/assets/line-chart.stories-8UAM62iU.js +0 -1207
- package/dist/assets/pie-chart.stories-qKjdYhwq.js +0 -45
- package/dist/assets/scatter-chart.stories-CzYwqOiR.js +0 -41
- package/dist/assets/syntaxhighlighter-ED5Y7EFY-BHci-LOP.js +0 -6
- /package/dist/assets/{bar-chart-const-Dmo8UTJN.js → bar-chart-const-BupPLp8f.js} +0 -0
- /package/dist/assets/{chunk-242VQQM5-DegdISsM.js → chunk-242VQQM5-By-lqKqL.js} +0 -0
- /package/dist/assets/{get-custom-legend-plugin-example-Decjgf1l.js → get-custom-legend-plugin-example-Bo7hTtyz.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DndProvider, useDrag, useDrop } from "react-dnd";
|
|
|
4
4
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
5
5
|
import { displayNumber, isCloseTo, round, roundByMagnitude } from "@oliasoft-open-source/units";
|
|
6
6
|
import cx from "classnames";
|
|
7
|
-
import { cloneDeep, debounce, defaultTo, find, findIndex, get, has, isArray, isEmpty, isNil, map, noop, set, some, startCase } from "es-toolkit/compat";
|
|
7
|
+
import { cloneDeep, debounce, defaultTo, find, findIndex, get, has, isArray, isEmpty, isNil, isNumber, isObject, map, noop, set, some, startCase } from "es-toolkit/compat";
|
|
8
8
|
import { produce } from "immer";
|
|
9
9
|
import { Button, ButtonGroup, Field, Flex, Icon, InputGroup, InputGroupAddon, Menu, NumberInput, Popover, Portal, Select, Spacer, Text, Tooltip } from "@oliasoft-open-source/react-ui-library";
|
|
10
10
|
import { useMeasure } from "react-use";
|
|
@@ -632,7 +632,7 @@ function isArray$1(value) {
|
|
|
632
632
|
if (type.slice(0, 7) === "[object" && type.slice(-6) === "Array]") return true;
|
|
633
633
|
return false;
|
|
634
634
|
}
|
|
635
|
-
function isObject(value) {
|
|
635
|
+
function isObject$1(value) {
|
|
636
636
|
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
637
637
|
}
|
|
638
638
|
function isNumberFinite(value) {
|
|
@@ -655,7 +655,7 @@ function each(loopable, fn, thisArg, reverse) {
|
|
|
655
655
|
len = loopable.length;
|
|
656
656
|
if (reverse) for (i = len - 1; i >= 0; i--) fn.call(thisArg, loopable[i], i);
|
|
657
657
|
else for (i = 0; i < len; i++) fn.call(thisArg, loopable[i], i);
|
|
658
|
-
} else if (isObject(loopable)) {
|
|
658
|
+
} else if (isObject$1(loopable)) {
|
|
659
659
|
keys = Object.keys(loopable);
|
|
660
660
|
len = keys.length;
|
|
661
661
|
for (i = 0; i < len; i++) fn.call(thisArg, loopable[keys[i]], keys[i]);
|
|
@@ -673,7 +673,7 @@ function _elementsEqual(a0, a1) {
|
|
|
673
673
|
}
|
|
674
674
|
function clone(source) {
|
|
675
675
|
if (isArray$1(source)) return source.map(clone);
|
|
676
|
-
if (isObject(source)) {
|
|
676
|
+
if (isObject$1(source)) {
|
|
677
677
|
const target = Object.create(null);
|
|
678
678
|
const keys = Object.keys(source);
|
|
679
679
|
const klen = keys.length;
|
|
@@ -694,19 +694,19 @@ function _merger(key, target, source, options) {
|
|
|
694
694
|
if (!isValidKey(key)) return;
|
|
695
695
|
const tval = target[key];
|
|
696
696
|
const sval = source[key];
|
|
697
|
-
if (isObject(tval) && isObject(sval)) merge(tval, sval, options);
|
|
697
|
+
if (isObject$1(tval) && isObject$1(sval)) merge(tval, sval, options);
|
|
698
698
|
else target[key] = clone(sval);
|
|
699
699
|
}
|
|
700
700
|
function merge(target, source, options) {
|
|
701
701
|
const sources = isArray$1(source) ? source : [source];
|
|
702
702
|
const ilen = sources.length;
|
|
703
|
-
if (!isObject(target)) return target;
|
|
703
|
+
if (!isObject$1(target)) return target;
|
|
704
704
|
options = options || {};
|
|
705
705
|
const merger = options.merger || _merger;
|
|
706
706
|
let current;
|
|
707
707
|
for (let i = 0; i < ilen; ++i) {
|
|
708
708
|
current = sources[i];
|
|
709
|
-
if (!isObject(current)) continue;
|
|
709
|
+
if (!isObject$1(current)) continue;
|
|
710
710
|
const keys = Object.keys(current);
|
|
711
711
|
for (let k = 0, klen = keys.length; k < klen; ++k) merger(keys[k], target, current, options);
|
|
712
712
|
}
|
|
@@ -719,7 +719,7 @@ function _mergerIf(key, target, source) {
|
|
|
719
719
|
if (!isValidKey(key)) return;
|
|
720
720
|
const tval = target[key];
|
|
721
721
|
const sval = source[key];
|
|
722
|
-
if (isObject(tval) && isObject(sval)) mergeIf(tval, sval);
|
|
722
|
+
if (isObject$1(tval) && isObject$1(sval)) mergeIf(tval, sval);
|
|
723
723
|
else if (!Object.prototype.hasOwnProperty.call(target, key)) target[key] = clone(sval);
|
|
724
724
|
}
|
|
725
725
|
var keyResolvers = {
|
|
@@ -802,7 +802,7 @@ function _factorize(value) {
|
|
|
802
802
|
function isNonPrimitive(n) {
|
|
803
803
|
return typeof n === "symbol" || typeof n === "object" && n !== null && !(Symbol.toPrimitive in n || "toString" in n || "valueOf" in n);
|
|
804
804
|
}
|
|
805
|
-
function isNumber(n) {
|
|
805
|
+
function isNumber$1(n) {
|
|
806
806
|
return !isNonPrimitive(n) && !isNaN(parseFloat(n)) && isFinite(n);
|
|
807
807
|
}
|
|
808
808
|
function almostWhole(x, epsilon) {
|
|
@@ -1387,7 +1387,7 @@ var Defaults = class {
|
|
|
1387
1387
|
get() {
|
|
1388
1388
|
const local = this[privateName];
|
|
1389
1389
|
const target = targetScopeObject[targetName];
|
|
1390
|
-
if (isObject(local)) return Object.assign({}, target, local);
|
|
1390
|
+
if (isObject$1(local)) return Object.assign({}, target, local);
|
|
1391
1391
|
return valueOrDefault(local, target);
|
|
1392
1392
|
},
|
|
1393
1393
|
set(value) {
|
|
@@ -1690,9 +1690,9 @@ function toLineHeight(value, size) {
|
|
|
1690
1690
|
var numberOrZero = (v) => +v || 0;
|
|
1691
1691
|
function _readValueToProps(value, props) {
|
|
1692
1692
|
const ret = {};
|
|
1693
|
-
const objProps = isObject(props);
|
|
1693
|
+
const objProps = isObject$1(props);
|
|
1694
1694
|
const keys = objProps ? Object.keys(props) : props;
|
|
1695
|
-
const read = isObject(value) ? objProps ? (prop) => valueOrDefault(value[prop], value[props[prop]]) : (prop) => value[prop] : () => value;
|
|
1695
|
+
const read = isObject$1(value) ? objProps ? (prop) => valueOrDefault(value[prop], value[props[prop]]) : (prop) => value[prop] : () => value;
|
|
1696
1696
|
for (const prop of keys) ret[prop] = numberOrZero(read(prop));
|
|
1697
1697
|
return ret;
|
|
1698
1698
|
}
|
|
@@ -1869,7 +1869,7 @@ function _descriptors(proxy, defaults = {
|
|
|
1869
1869
|
};
|
|
1870
1870
|
}
|
|
1871
1871
|
var readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name;
|
|
1872
|
-
var needsSubResolver = (prop, value) => isObject(value) && prop !== "adapters" && (Object.getPrototypeOf(value) === null || value.constructor === Object);
|
|
1872
|
+
var needsSubResolver = (prop, value) => isObject$1(value) && prop !== "adapters" && (Object.getPrototypeOf(value) === null || value.constructor === Object);
|
|
1873
1873
|
function _cached(target, prop, resolve) {
|
|
1874
1874
|
if (Object.prototype.hasOwnProperty.call(target, prop) || prop === "constructor") return target[prop];
|
|
1875
1875
|
const value = resolve();
|
|
@@ -1896,7 +1896,7 @@ function _resolveScriptable(prop, getValue, target, receiver) {
|
|
|
1896
1896
|
function _resolveArray(prop, value, target, isIndexable) {
|
|
1897
1897
|
const { _proxy, _context, _subProxy, _descriptors: descriptors } = target;
|
|
1898
1898
|
if (typeof _context.index !== "undefined" && isIndexable(prop)) return value[_context.index % value.length];
|
|
1899
|
-
else if (isObject(value[0])) {
|
|
1899
|
+
else if (isObject$1(value[0])) {
|
|
1900
1900
|
const arr = value;
|
|
1901
1901
|
const scopes = _proxy._scopes.filter((s) => s !== arr);
|
|
1902
1902
|
value = [];
|
|
@@ -1944,7 +1944,7 @@ function subGetTarget(resolver, prop, value) {
|
|
|
1944
1944
|
const parent = resolver._getTarget();
|
|
1945
1945
|
if (!(prop in parent)) parent[prop] = {};
|
|
1946
1946
|
const target = parent[prop];
|
|
1947
|
-
if (isArray$1(target) && isObject(value)) return value;
|
|
1947
|
+
if (isArray$1(target) && isObject$1(value)) return value;
|
|
1948
1948
|
return target || {};
|
|
1949
1949
|
}
|
|
1950
1950
|
function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
|
|
@@ -2840,12 +2840,12 @@ var Animations = class {
|
|
|
2840
2840
|
this.configure(config);
|
|
2841
2841
|
}
|
|
2842
2842
|
configure(config) {
|
|
2843
|
-
if (!isObject(config)) return;
|
|
2843
|
+
if (!isObject$1(config)) return;
|
|
2844
2844
|
const animationOptions = Object.keys(defaults$1.animation);
|
|
2845
2845
|
const animatedProps = this._properties;
|
|
2846
2846
|
Object.getOwnPropertyNames(config).forEach((key) => {
|
|
2847
2847
|
const cfg = config[key];
|
|
2848
|
-
if (!isObject(cfg)) return;
|
|
2848
|
+
if (!isObject$1(cfg)) return;
|
|
2849
2849
|
const resolved = {};
|
|
2850
2850
|
for (const option of animationOptions) resolved[option] = cfg[option];
|
|
2851
2851
|
(isArray$1(cfg.properties) && cfg.properties || [key]).forEach((prop) => {
|
|
@@ -2950,7 +2950,7 @@ function defaultClip(xScale, yScale, allowedOverflow) {
|
|
|
2950
2950
|
}
|
|
2951
2951
|
function toClip(value) {
|
|
2952
2952
|
let t, r, b, l;
|
|
2953
|
-
if (isObject(value)) {
|
|
2953
|
+
if (isObject$1(value)) {
|
|
2954
2954
|
t = value.top;
|
|
2955
2955
|
r = value.right;
|
|
2956
2956
|
b = value.bottom;
|
|
@@ -3176,7 +3176,7 @@ var DatasetController = class {
|
|
|
3176
3176
|
const dataset = this.getDataset();
|
|
3177
3177
|
const data = dataset.data || (dataset.data = []);
|
|
3178
3178
|
const _data = this._data;
|
|
3179
|
-
if (isObject(data)) {
|
|
3179
|
+
if (isObject$1(data)) {
|
|
3180
3180
|
const meta = this._cachedMeta;
|
|
3181
3181
|
this._data = convertObjectDataToArray(data, meta);
|
|
3182
3182
|
} else if (_data !== data) {
|
|
@@ -3235,7 +3235,7 @@ var DatasetController = class {
|
|
|
3235
3235
|
parsed = data;
|
|
3236
3236
|
} else {
|
|
3237
3237
|
if (isArray$1(data[start])) parsed = this.parseArrayData(meta, data, start, count);
|
|
3238
|
-
else if (isObject(data[start])) parsed = this.parseObjectData(meta, data, start, count);
|
|
3238
|
+
else if (isObject$1(data[start])) parsed = this.parseObjectData(meta, data, start, count);
|
|
3239
3239
|
else parsed = this.parsePrimitiveData(meta, data, start, count);
|
|
3240
3240
|
const isNotInOrderComparedToPrev = () => cur[iAxis] === null || prev && cur[iAxis] < prev[iAxis];
|
|
3241
3241
|
for (i = 0; i < count; ++i) {
|
|
@@ -4150,7 +4150,7 @@ var DoughnutController = class extends DatasetController {
|
|
|
4150
4150
|
if (this._parsing === false) meta._parsed = data;
|
|
4151
4151
|
else {
|
|
4152
4152
|
let getter = (i) => +data[i];
|
|
4153
|
-
if (isObject(data[start])) {
|
|
4153
|
+
if (isObject$1(data[start])) {
|
|
4154
4154
|
const { key = "value" } = this._parsing;
|
|
4155
4155
|
getter = (i) => +resolveObjectKey(data[i], key);
|
|
4156
4156
|
}
|
|
@@ -4352,7 +4352,7 @@ var LineController = class extends DatasetController {
|
|
|
4352
4352
|
const iAxis = iScale.axis;
|
|
4353
4353
|
const vAxis = vScale.axis;
|
|
4354
4354
|
const { spanGaps, segment } = this.options;
|
|
4355
|
-
const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
|
|
4355
|
+
const maxGapLength = isNumber$1(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
|
|
4356
4356
|
const directUpdate = this.chart._animationsDisabled || reset || mode === "none";
|
|
4357
4357
|
const end = start + count;
|
|
4358
4358
|
const pointsCount = points.length;
|
|
@@ -4475,7 +4475,7 @@ var ScatterController = class extends DatasetController {
|
|
|
4475
4475
|
const iAxis = iScale.axis;
|
|
4476
4476
|
const vAxis = vScale.axis;
|
|
4477
4477
|
const { spanGaps, segment } = this.options;
|
|
4478
|
-
const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
|
|
4478
|
+
const maxGapLength = isNumber$1(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
|
|
4479
4479
|
const directUpdate = this.chart._animationsDisabled || reset || mode === "none";
|
|
4480
4480
|
let prevParsed = start > 0 && this.getParsed(start - 1);
|
|
4481
4481
|
for (let i = start; i < start + count; ++i) {
|
|
@@ -4838,7 +4838,7 @@ function updateMaxPadding(maxPadding, boxPadding) {
|
|
|
4838
4838
|
function updateDims(chartArea, params, layout, stacks) {
|
|
4839
4839
|
const { pos, box } = layout;
|
|
4840
4840
|
const maxPadding = chartArea.maxPadding;
|
|
4841
|
-
if (!isObject(pos)) {
|
|
4841
|
+
if (!isObject$1(pos)) {
|
|
4842
4842
|
if (layout.size) chartArea[pos] -= layout.size;
|
|
4843
4843
|
const stack = stacks[layout.stack] || {
|
|
4844
4844
|
size: 0,
|
|
@@ -5281,7 +5281,7 @@ var Element = class {
|
|
|
5281
5281
|
};
|
|
5282
5282
|
}
|
|
5283
5283
|
hasValue() {
|
|
5284
|
-
return isNumber(this.x) && isNumber(this.y);
|
|
5284
|
+
return isNumber$1(this.x) && isNumber$1(this.y);
|
|
5285
5285
|
}
|
|
5286
5286
|
getProps(props, final) {
|
|
5287
5287
|
const anims = this.$animations;
|
|
@@ -5456,7 +5456,7 @@ function titleArgs(scale, offset, position, align) {
|
|
|
5456
5456
|
const width = right - left;
|
|
5457
5457
|
if (scale.isHorizontal()) {
|
|
5458
5458
|
titleX = _alignStartEnd(align, left, right);
|
|
5459
|
-
if (isObject(position)) {
|
|
5459
|
+
if (isObject$1(position)) {
|
|
5460
5460
|
const positionAxisID = Object.keys(position)[0];
|
|
5461
5461
|
const value = position[positionAxisID];
|
|
5462
5462
|
titleY = scales[positionAxisID].getPixelForValue(value) + height - offset;
|
|
@@ -5464,7 +5464,7 @@ function titleArgs(scale, offset, position, align) {
|
|
|
5464
5464
|
else titleY = offsetFromEdge(scale, position, offset);
|
|
5465
5465
|
maxWidth = right - left;
|
|
5466
5466
|
} else {
|
|
5467
|
-
if (isObject(position)) {
|
|
5467
|
+
if (isObject$1(position)) {
|
|
5468
5468
|
const positionAxisID = Object.keys(position)[0];
|
|
5469
5469
|
const value = position[positionAxisID];
|
|
5470
5470
|
titleX = scales[positionAxisID].getPixelForValue(value) - width + offset;
|
|
@@ -6026,7 +6026,7 @@ var Scale = class Scale extends Element {
|
|
|
6026
6026
|
tx2 = this.left + tl;
|
|
6027
6027
|
} else if (axis === "x") {
|
|
6028
6028
|
if (position === "center") borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + .5);
|
|
6029
|
-
else if (isObject(position)) {
|
|
6029
|
+
else if (isObject$1(position)) {
|
|
6030
6030
|
const positionAxisID = Object.keys(position)[0];
|
|
6031
6031
|
const value = position[positionAxisID];
|
|
6032
6032
|
borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));
|
|
@@ -6037,7 +6037,7 @@ var Scale = class Scale extends Element {
|
|
|
6037
6037
|
ty2 = ty1 + tl;
|
|
6038
6038
|
} else if (axis === "y") {
|
|
6039
6039
|
if (position === "center") borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
|
|
6040
|
-
else if (isObject(position)) {
|
|
6040
|
+
else if (isObject$1(position)) {
|
|
6041
6041
|
const positionAxisID = Object.keys(position)[0];
|
|
6042
6042
|
const value = position[positionAxisID];
|
|
6043
6043
|
borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));
|
|
@@ -6119,7 +6119,7 @@ var Scale = class Scale extends Element {
|
|
|
6119
6119
|
x = ret.x;
|
|
6120
6120
|
} else if (axis === "x") {
|
|
6121
6121
|
if (position === "center") y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;
|
|
6122
|
-
else if (isObject(position)) {
|
|
6122
|
+
else if (isObject$1(position)) {
|
|
6123
6123
|
const positionAxisID = Object.keys(position)[0];
|
|
6124
6124
|
const value = position[positionAxisID];
|
|
6125
6125
|
y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding;
|
|
@@ -6127,7 +6127,7 @@ var Scale = class Scale extends Element {
|
|
|
6127
6127
|
textAlign = this._getXAxisLabelAlignment();
|
|
6128
6128
|
} else if (axis === "y") {
|
|
6129
6129
|
if (position === "center") x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;
|
|
6130
|
-
else if (isObject(position)) {
|
|
6130
|
+
else if (isObject$1(position)) {
|
|
6131
6131
|
const positionAxisID = Object.keys(position)[0];
|
|
6132
6132
|
const value = position[positionAxisID];
|
|
6133
6133
|
x = this.chart.scales[positionAxisID].getPixelForValue(value);
|
|
@@ -6408,7 +6408,7 @@ var Scale = class Scale extends Element {
|
|
|
6408
6408
|
const padding = toPadding(title.padding);
|
|
6409
6409
|
const align = title.align;
|
|
6410
6410
|
let offset = font.lineHeight / 2;
|
|
6411
|
-
if (position === "bottom" || position === "center" || isObject(position)) {
|
|
6411
|
+
if (position === "bottom" || position === "center" || isObject$1(position)) {
|
|
6412
6412
|
offset += padding.bottom;
|
|
6413
6413
|
if (isArray$1(title.text)) offset += font.lineHeight * (title.text.length - 1);
|
|
6414
6414
|
} else offset += padding.top;
|
|
@@ -6782,7 +6782,7 @@ function mergeScaleConfig(config, options) {
|
|
|
6782
6782
|
const scales = Object.create(null);
|
|
6783
6783
|
Object.keys(configScales).forEach((id) => {
|
|
6784
6784
|
const scaleConf = configScales[id];
|
|
6785
|
-
if (!isObject(scaleConf)) return console.error(`Invalid scale configuration for scale: ${id}`);
|
|
6785
|
+
if (!isObject$1(scaleConf)) return console.error(`Invalid scale configuration for scale: ${id}`);
|
|
6786
6786
|
if (scaleConf._proxy) return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
|
|
6787
6787
|
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults$1.scales[scaleConf.type]);
|
|
6788
6788
|
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
|
|
@@ -6961,7 +6961,7 @@ var Config = class {
|
|
|
6961
6961
|
}
|
|
6962
6962
|
createResolver(scopes, context, prefixes = [""], descriptorDefaults) {
|
|
6963
6963
|
const { resolver } = getResolver(this._resolverCache, scopes, prefixes);
|
|
6964
|
-
return isObject(context) ? _attachContext(resolver, context, void 0, descriptorDefaults) : resolver;
|
|
6964
|
+
return isObject$1(context) ? _attachContext(resolver, context, void 0, descriptorDefaults) : resolver;
|
|
6965
6965
|
}
|
|
6966
6966
|
};
|
|
6967
6967
|
function getResolver(resolverCache, scopes, prefixes) {
|
|
@@ -6981,7 +6981,7 @@ function getResolver(resolverCache, scopes, prefixes) {
|
|
|
6981
6981
|
}
|
|
6982
6982
|
return cached;
|
|
6983
6983
|
}
|
|
6984
|
-
var hasFunction = (value) => isObject(value) && Object.getOwnPropertyNames(value).some((key) => isFunction(value[key]));
|
|
6984
|
+
var hasFunction = (value) => isObject$1(value) && Object.getOwnPropertyNames(value).some((key) => isFunction(value[key]));
|
|
6985
6985
|
function needContext(proxy, names) {
|
|
6986
6986
|
const { isScriptable, isIndexable } = _descriptors(proxy);
|
|
6987
6987
|
for (const prop of names) {
|
|
@@ -8355,7 +8355,7 @@ function parseBorderRadius(bar, maxW, maxH) {
|
|
|
8355
8355
|
const o = toTRBLCorners(value);
|
|
8356
8356
|
const maxR = Math.min(maxW, maxH);
|
|
8357
8357
|
const skip = bar.borderSkipped;
|
|
8358
|
-
const enableBorder = enableBorderRadius || isObject(value);
|
|
8358
|
+
const enableBorder = enableBorderRadius || isObject$1(value);
|
|
8359
8359
|
return {
|
|
8360
8360
|
topLeft: skipOrLimit(!enableBorder || skip.top || skip.left, o.topLeft, 0, maxR),
|
|
8361
8361
|
topRight: skipOrLimit(!enableBorder || skip.top || skip.right, o.topRight, 0, maxR),
|
|
@@ -8604,7 +8604,7 @@ function _resolveTarget(sources, index, propagate) {
|
|
|
8604
8604
|
}
|
|
8605
8605
|
function _decodeFill(line, index, count) {
|
|
8606
8606
|
const fill = parseFillOption(line);
|
|
8607
|
-
if (isObject(fill)) return isNaN(fill.value) ? false : fill;
|
|
8607
|
+
if (isObject$1(fill)) return isNaN(fill.value) ? false : fill;
|
|
8608
8608
|
let target = parseFloat(fill);
|
|
8609
8609
|
if (isNumberFinite(target) && Math.floor(target) === target) return decodeTargetIndex(fill[0], index, target, count);
|
|
8610
8610
|
return [
|
|
@@ -8624,7 +8624,7 @@ function _getTargetPixel(fill, scale) {
|
|
|
8624
8624
|
let pixel = null;
|
|
8625
8625
|
if (fill === "start") pixel = scale.bottom;
|
|
8626
8626
|
else if (fill === "end") pixel = scale.top;
|
|
8627
|
-
else if (isObject(fill)) pixel = scale.getPixelForValue(fill.value);
|
|
8627
|
+
else if (isObject$1(fill)) pixel = scale.getPixelForValue(fill.value);
|
|
8628
8628
|
else if (scale.getBasePixel) pixel = scale.getBasePixel();
|
|
8629
8629
|
return pixel;
|
|
8630
8630
|
}
|
|
@@ -8632,7 +8632,7 @@ function _getTargetValue(fill, scale, startValue) {
|
|
|
8632
8632
|
let value;
|
|
8633
8633
|
if (fill === "start") value = startValue;
|
|
8634
8634
|
else if (fill === "end") value = scale.options.reverse ? scale.min : scale.max;
|
|
8635
|
-
else if (isObject(fill)) value = fill.value;
|
|
8635
|
+
else if (isObject$1(fill)) value = fill.value;
|
|
8636
8636
|
else value = scale.getBaseValue();
|
|
8637
8637
|
return value;
|
|
8638
8638
|
}
|
|
@@ -10141,7 +10141,7 @@ var Tooltip$1 = class extends Element {
|
|
|
10141
10141
|
ctx.fillStyle = labelColor.backgroundColor;
|
|
10142
10142
|
drawPoint$1(ctx, drawOptions, centerX, centerY);
|
|
10143
10143
|
} else {
|
|
10144
|
-
ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : labelColor.borderWidth || 1;
|
|
10144
|
+
ctx.lineWidth = isObject$1(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : labelColor.borderWidth || 1;
|
|
10145
10145
|
ctx.strokeStyle = labelColor.borderColor;
|
|
10146
10146
|
ctx.setLineDash(labelColor.borderDash || []);
|
|
10147
10147
|
ctx.lineDashOffset = labelColor.borderDashOffset || 0;
|
|
@@ -11390,7 +11390,7 @@ function parse(scale, input) {
|
|
|
11390
11390
|
if (typeof parser === "function") value = parser(value);
|
|
11391
11391
|
if (!isNumberFinite(value)) value = typeof parser === "string" ? adapter.parse(value, parser) : adapter.parse(value);
|
|
11392
11392
|
if (value === null) return null;
|
|
11393
|
-
if (round) value = round === "week" && (isNumber(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, "isoWeek", isoWeekday) : adapter.startOf(value, round);
|
|
11393
|
+
if (round) value = round === "week" && (isNumber$1(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, "isoWeek", isoWeekday) : adapter.startOf(value, round);
|
|
11394
11394
|
return +value;
|
|
11395
11395
|
}
|
|
11396
11396
|
function determineUnitForAutoTicks(minUnit, min, max, capacity) {
|
|
@@ -11585,7 +11585,7 @@ var TimeScale = class extends Scale {
|
|
|
11585
11585
|
const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));
|
|
11586
11586
|
const stepSize = valueOrDefault(options.ticks.stepSize, 1);
|
|
11587
11587
|
const weekday = minor === "week" ? timeOpts.isoWeekday : false;
|
|
11588
|
-
const hasWeekday = isNumber(weekday) || weekday === true;
|
|
11588
|
+
const hasWeekday = isNumber$1(weekday) || weekday === true;
|
|
11589
11589
|
const ticks = {};
|
|
11590
11590
|
let first = min;
|
|
11591
11591
|
let time, count;
|
|
@@ -13597,7 +13597,7 @@ function isZoomingOrPanning(chart) {
|
|
|
13597
13597
|
const state = getState(chart);
|
|
13598
13598
|
return state.panning || state.dragging;
|
|
13599
13599
|
}
|
|
13600
|
-
var clamp$
|
|
13600
|
+
var clamp$2 = (x, from, to) => Math.min(to, Math.max(from, x));
|
|
13601
13601
|
function removeHandler(chart, type) {
|
|
13602
13602
|
const { handlers } = getState(chart);
|
|
13603
13603
|
const handler = handlers[type];
|
|
@@ -13683,8 +13683,8 @@ function applyAspectRatio({ begin, end }, aspectRatio) {
|
|
|
13683
13683
|
end.y = begin.y + height;
|
|
13684
13684
|
}
|
|
13685
13685
|
function applyMinMaxProps(rect, chartArea, points, { min, max, prop }) {
|
|
13686
|
-
rect[min] = clamp$
|
|
13687
|
-
rect[max] = clamp$
|
|
13686
|
+
rect[min] = clamp$2(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
|
|
13687
|
+
rect[max] = clamp$2(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
|
|
13688
13688
|
}
|
|
13689
13689
|
function getRelativePoints(chart, pointEvents, maintainAspectRatio) {
|
|
13690
13690
|
const points = {
|
|
@@ -14793,7 +14793,7 @@ var formatter = function(value) {
|
|
|
14793
14793
|
if (isNullOrUndef(value)) return null;
|
|
14794
14794
|
var label = value;
|
|
14795
14795
|
var keys, klen, k;
|
|
14796
|
-
if (isObject(value)) if (!isNullOrUndef(value.label)) label = value.label;
|
|
14796
|
+
if (isObject$1(value)) if (!isNullOrUndef(value.label)) label = value.label;
|
|
14797
14797
|
else if (!isNullOrUndef(value.r)) label = value.r;
|
|
14798
14798
|
else {
|
|
14799
14799
|
label = "";
|
|
@@ -15073,10 +15073,10 @@ function rotated(point, center, angle) {
|
|
|
15073
15073
|
}
|
|
15074
15074
|
var isOlderPart = (act, req) => req > act || act.length > req.length && act.slice(0, req.length) === req;
|
|
15075
15075
|
var EPSILON = .001;
|
|
15076
|
-
var clamp = (x, from, to) => Math.min(to, Math.max(from, x));
|
|
15076
|
+
var clamp$1 = (x, from, to) => Math.min(to, Math.max(from, x));
|
|
15077
15077
|
var inLimit = (limit, hitSize) => limit.value >= limit.start - hitSize && limit.value <= limit.end + hitSize;
|
|
15078
15078
|
function clampAll(obj, from, to) {
|
|
15079
|
-
for (const key of Object.keys(obj)) obj[key] = clamp(obj[key], from, to);
|
|
15079
|
+
for (const key of Object.keys(obj)) obj[key] = clamp$1(obj[key], from, to);
|
|
15080
15080
|
return obj;
|
|
15081
15081
|
}
|
|
15082
15082
|
function inPointRange(point, center, radius, hitSize) {
|
|
@@ -15117,7 +15117,7 @@ function requireVersion(pkg, min, ver, strict = true) {
|
|
|
15117
15117
|
}
|
|
15118
15118
|
var isPercentString = (s) => typeof s === "string" && s.endsWith("%");
|
|
15119
15119
|
var toPercent = (s) => parseFloat(s) / 100;
|
|
15120
|
-
var toPositivePercent = (s) => clamp(toPercent(s), 0, 1);
|
|
15120
|
+
var toPositivePercent = (s) => clamp$1(toPercent(s), 0, 1);
|
|
15121
15121
|
var boxAppering = (x, y) => ({
|
|
15122
15122
|
x,
|
|
15123
15123
|
y,
|
|
@@ -15166,7 +15166,7 @@ function calculateTextAlignment(size, options) {
|
|
|
15166
15166
|
return x;
|
|
15167
15167
|
}
|
|
15168
15168
|
function measureLabelRectangle(point, labelSize, { borderWidth, position, xAdjust, yAdjust }, padding) {
|
|
15169
|
-
const hasPadding = isObject(padding);
|
|
15169
|
+
const hasPadding = isObject$1(padding);
|
|
15170
15170
|
const width = labelSize.width + (hasPadding ? padding.width : 0) + borderWidth;
|
|
15171
15171
|
const height = labelSize.height + (hasPadding ? padding.height : 0) + borderWidth;
|
|
15172
15172
|
const positionObj = toPosition(position);
|
|
@@ -15184,7 +15184,7 @@ function measureLabelRectangle(point, labelSize, { borderWidth, position, xAdjus
|
|
|
15184
15184
|
};
|
|
15185
15185
|
}
|
|
15186
15186
|
function toPosition(value, defaultValue = "center") {
|
|
15187
|
-
if (isObject(value)) return {
|
|
15187
|
+
if (isObject$1(value)) return {
|
|
15188
15188
|
x: valueOrDefault(value.x, defaultValue),
|
|
15189
15189
|
y: valueOrDefault(value.y, defaultValue)
|
|
15190
15190
|
};
|
|
@@ -15238,7 +15238,7 @@ function execCallback(chart, properties, options) {
|
|
|
15238
15238
|
options
|
|
15239
15239
|
}]);
|
|
15240
15240
|
if (result === true) return applyDefault(properties, options);
|
|
15241
|
-
else if (isObject(result)) return result;
|
|
15241
|
+
else if (isObject$1(result)) return result;
|
|
15242
15242
|
}
|
|
15243
15243
|
var widthCache = /* @__PURE__ */ new Map();
|
|
15244
15244
|
var notRadius = (radius) => isNaN(radius) || radius <= 0;
|
|
@@ -15499,8 +15499,8 @@ function applyLabelContent(ctx, { x, y }, labels, { fonts, colors }) {
|
|
|
15499
15499
|
});
|
|
15500
15500
|
}
|
|
15501
15501
|
function getOpacity(value, elementValue) {
|
|
15502
|
-
const opacity = isNumber(value) ? value : elementValue;
|
|
15503
|
-
return isNumber(opacity) ? clamp(opacity, 0, 1) : 1;
|
|
15502
|
+
const opacity = isNumber$1(value) ? value : elementValue;
|
|
15503
|
+
return isNumber$1(opacity) ? clamp$1(opacity, 0, 1) : 1;
|
|
15504
15504
|
}
|
|
15505
15505
|
var positions = [
|
|
15506
15506
|
"left",
|
|
@@ -16834,7 +16834,7 @@ function calculateTAdjust(lineSize, sizes, label, space) {
|
|
|
16834
16834
|
const lineH = lineSize.h * space.dy;
|
|
16835
16835
|
const x = lineW > 0 && (labelSize.w / 2 + padding.left - space.x) / lineW;
|
|
16836
16836
|
const y = lineH > 0 && (labelSize.h / 2 + padding.top - space.y) / lineH;
|
|
16837
|
-
return clamp(Math.max(x, y), 0, .25);
|
|
16837
|
+
return clamp$1(Math.max(x, y), 0, .25);
|
|
16838
16838
|
}
|
|
16839
16839
|
function spaceAround(properties, chartArea) {
|
|
16840
16840
|
const { x, x2, y, y2 } = properties;
|
|
@@ -17264,7 +17264,7 @@ Object.keys(annotationTypes).forEach((key) => {
|
|
|
17264
17264
|
});
|
|
17265
17265
|
var directUpdater = { update: Object.assign };
|
|
17266
17266
|
var hooks$1 = eventHooks.concat(elementHooks);
|
|
17267
|
-
var resolve = (value, optDefs) => isObject(optDefs) ? resolveObj(value, optDefs) : value;
|
|
17267
|
+
var resolve = (value, optDefs) => isObject$1(optDefs) ? resolveObj(value, optDefs) : value;
|
|
17268
17268
|
var isIndexable = (prop) => prop === "color" || prop === "font";
|
|
17269
17269
|
function resolveType(type = "line") {
|
|
17270
17270
|
if (annotationTypes[type]) return type;
|
|
@@ -17390,9 +17390,9 @@ var annotation = {
|
|
|
17390
17390
|
const state = chartStates.get(chart);
|
|
17391
17391
|
const annotations = state.annotations = [];
|
|
17392
17392
|
let annotationOptions = options.annotations;
|
|
17393
|
-
if (isObject(annotationOptions)) Object.keys(annotationOptions).forEach((key) => {
|
|
17393
|
+
if (isObject$1(annotationOptions)) Object.keys(annotationOptions).forEach((key) => {
|
|
17394
17394
|
const value = annotationOptions[key];
|
|
17395
|
-
if (isObject(value)) {
|
|
17395
|
+
if (isObject$1(value)) {
|
|
17396
17396
|
value.id = key;
|
|
17397
17397
|
annotations.push(value);
|
|
17398
17398
|
}
|
|
@@ -18805,6 +18805,21 @@ var defaultAnnotations$2 = (annotations) => ({
|
|
|
18805
18805
|
controlAnnotation: annotations?.controlAnnotation ?? false,
|
|
18806
18806
|
enableDragAnnotation: annotations?.enableDragAnnotation ?? false,
|
|
18807
18807
|
enableCalloutAnnotation: annotations?.enableCalloutAnnotation ?? false,
|
|
18808
|
+
verticalMarkersAnnotation: {
|
|
18809
|
+
enabled: annotations?.verticalMarkersAnnotation?.enabled ?? false,
|
|
18810
|
+
itemGapPx: annotations?.verticalMarkersAnnotation?.itemGapPx ?? 4,
|
|
18811
|
+
edgePaddingPx: annotations?.verticalMarkersAnnotation?.edgePaddingPx ?? 8,
|
|
18812
|
+
stickToEdge: annotations?.verticalMarkersAnnotation?.stickToEdge ?? true,
|
|
18813
|
+
stickSide: annotations?.verticalMarkersAnnotation?.stickSide ?? "right",
|
|
18814
|
+
reverse: annotations?.verticalMarkersAnnotation?.reverse ?? false,
|
|
18815
|
+
xValue: annotations?.verticalMarkersAnnotation?.xValue,
|
|
18816
|
+
yStartValue: annotations?.verticalMarkersAnnotation?.yStartValue,
|
|
18817
|
+
color: annotations?.verticalMarkersAnnotation?.color ?? "rgba(20,20,20,0.9)",
|
|
18818
|
+
opacity: annotations?.verticalMarkersAnnotation?.opacity ?? 1,
|
|
18819
|
+
lineWidth: annotations?.verticalMarkersAnnotation?.lineWidth ?? 1,
|
|
18820
|
+
lineDash: annotations?.verticalMarkersAnnotation?.lineDash ?? [],
|
|
18821
|
+
items: annotations?.verticalMarkersAnnotation?.items ?? []
|
|
18822
|
+
},
|
|
18808
18823
|
annotationsData: defaultAnnotationsData$2(annotations?.annotationsData)
|
|
18809
18824
|
});
|
|
18810
18825
|
var defaultLegend$3 = (legend) => ({
|
|
@@ -19947,10 +19962,13 @@ const useChartOptions = ({ chartRef, state, options, dispatch, generatedDatasets
|
|
|
19947
19962
|
onUpdateEdited(true);
|
|
19948
19963
|
}
|
|
19949
19964
|
}), [zoomEnabled]);
|
|
19965
|
+
const verticalMarkersAnnotation = options?.annotations?.verticalMarkersAnnotation ?? {};
|
|
19966
|
+
const verticalMarkersPluginEnabled = Boolean(options?.plugins?.verticalMarkersPlugin?.enabled ?? verticalMarkersAnnotation?.enabled);
|
|
19950
19967
|
const plugins = {
|
|
19951
19968
|
datalabels,
|
|
19952
19969
|
annotationDraggerPlugin: { enabled: state?.enableDragAnnotation },
|
|
19953
19970
|
calloutConnectorPlugin: { enableCalloutAnnotation: options?.annotations.enableCalloutAnnotation },
|
|
19971
|
+
verticalMarkersPlugin: { enabled: verticalMarkersPluginEnabled },
|
|
19954
19972
|
annotation: toAnnotationObject(annotation),
|
|
19955
19973
|
zoom: {
|
|
19956
19974
|
pan: panOptions,
|
|
@@ -19996,6 +20014,7 @@ const useChartOptions = ({ chartRef, state, options, dispatch, generatedDatasets
|
|
|
19996
20014
|
tension: 0
|
|
19997
20015
|
} },
|
|
19998
20016
|
scales,
|
|
20017
|
+
annotations: options?.annotations,
|
|
19999
20018
|
plugins,
|
|
20000
20019
|
events: Object.values(Events)
|
|
20001
20020
|
}), [
|
|
@@ -20544,6 +20563,187 @@ const calloutConnectorPlugin = {
|
|
|
20544
20563
|
});
|
|
20545
20564
|
}
|
|
20546
20565
|
};
|
|
20566
|
+
const isFiniteNumber = (v) => {
|
|
20567
|
+
return isNumber(v) && Number.isFinite(v);
|
|
20568
|
+
};
|
|
20569
|
+
const asArray = (v) => {
|
|
20570
|
+
return isArray(v) ? v : [];
|
|
20571
|
+
};
|
|
20572
|
+
const asObject = (v) => {
|
|
20573
|
+
if (!isObject(v) || isArray(v)) return void 0;
|
|
20574
|
+
return v;
|
|
20575
|
+
};
|
|
20576
|
+
const getFirstScaleByAxis = (chart, axis) => {
|
|
20577
|
+
return asArray(Object.values(chart.scales)).find((s) => s?.axis === axis);
|
|
20578
|
+
};
|
|
20579
|
+
const resolveScale = (chart, scaleID, axis) => {
|
|
20580
|
+
return (scaleID ? (chart?.scales)?.[scaleID] : void 0) ?? getFirstScaleByAxis(chart, axis);
|
|
20581
|
+
};
|
|
20582
|
+
const getPixelForValueSafe = (scale, value) => {
|
|
20583
|
+
return scale && isFiniteNumber(value) ? scale.getPixelForValue(value) : void 0;
|
|
20584
|
+
};
|
|
20585
|
+
const clamp = (v, min, max) => {
|
|
20586
|
+
return Math.max(min, Math.min(max, v));
|
|
20587
|
+
};
|
|
20588
|
+
const crispLinePx = (v) => {
|
|
20589
|
+
return Math.round(v) + .5;
|
|
20590
|
+
};
|
|
20591
|
+
const drawVerticalLine = ({ chart, xPx, y1, y2, color, opacity, lineWidth, lineDash }) => {
|
|
20592
|
+
const { ctx } = chart ?? {};
|
|
20593
|
+
const x = crispLinePx(xPx);
|
|
20594
|
+
ctx?.save?.();
|
|
20595
|
+
ctx.globalAlpha = opacity;
|
|
20596
|
+
ctx?.beginPath?.();
|
|
20597
|
+
ctx.lineWidth = lineWidth;
|
|
20598
|
+
ctx.strokeStyle = color;
|
|
20599
|
+
ctx?.setLineDash?.(lineDash);
|
|
20600
|
+
ctx.lineCap = "round";
|
|
20601
|
+
ctx?.moveTo?.(x, y1);
|
|
20602
|
+
ctx?.lineTo?.(x, y2);
|
|
20603
|
+
ctx?.stroke?.();
|
|
20604
|
+
ctx?.restore?.();
|
|
20605
|
+
return x;
|
|
20606
|
+
};
|
|
20607
|
+
const drawTick = (args) => {
|
|
20608
|
+
const { ctx, x, y, side, tick, defaultColor, defaultFont } = args ?? {};
|
|
20609
|
+
const reverse = Boolean(args?.reverse);
|
|
20610
|
+
const color = tick?.color ?? defaultColor;
|
|
20611
|
+
const font = tick?.font ?? defaultFont;
|
|
20612
|
+
const labelOffset = tick?.labelOffsetPx ?? 6;
|
|
20613
|
+
const bootSize = 6;
|
|
20614
|
+
const dir = side === "left" ? 1 : -1;
|
|
20615
|
+
const xTickEnd = x;
|
|
20616
|
+
ctx?.save?.();
|
|
20617
|
+
ctx.strokeStyle = color;
|
|
20618
|
+
ctx.fillStyle = color;
|
|
20619
|
+
ctx.lineWidth = 1;
|
|
20620
|
+
const xOuter = xTickEnd + dir * bootSize;
|
|
20621
|
+
ctx?.beginPath?.();
|
|
20622
|
+
ctx?.moveTo?.(xTickEnd, y);
|
|
20623
|
+
ctx?.lineTo?.(xOuter, y);
|
|
20624
|
+
ctx?.lineTo?.(xTickEnd, reverse ? y + bootSize : y - bootSize);
|
|
20625
|
+
ctx?.closePath?.();
|
|
20626
|
+
ctx?.fill?.();
|
|
20627
|
+
const label = tick.label;
|
|
20628
|
+
if (label) {
|
|
20629
|
+
ctx.font = font;
|
|
20630
|
+
ctx.textBaseline = "middle";
|
|
20631
|
+
ctx.textAlign = side === "left" ? "left" : "right";
|
|
20632
|
+
const tx = xOuter + dir * labelOffset;
|
|
20633
|
+
if (Array.isArray(label)) {
|
|
20634
|
+
const lineH = 12;
|
|
20635
|
+
const startY = y - (label.length - 1) * lineH / 2;
|
|
20636
|
+
label?.forEach((line, i) => ctx?.fillText?.(String(line), tx, startY + i * lineH));
|
|
20637
|
+
} else ctx?.fillText?.(String(label), tx, y);
|
|
20638
|
+
}
|
|
20639
|
+
ctx?.restore?.();
|
|
20640
|
+
};
|
|
20641
|
+
var readPluginEnable = (chart) => {
|
|
20642
|
+
const { verticalMarkersPlugin } = chart?.options?.plugins ?? {};
|
|
20643
|
+
return asObject(verticalMarkersPlugin)?.enabled === true;
|
|
20644
|
+
};
|
|
20645
|
+
var readAnnotationConfig = (chart) => {
|
|
20646
|
+
const optionsWithAnnotations = chart?.options;
|
|
20647
|
+
const configWithAnnotations = chart?.config?.options;
|
|
20648
|
+
return asObject(configWithAnnotations?.annotations?.verticalMarkersAnnotation) ?? asObject(optionsWithAnnotations?.annotations?.verticalMarkersAnnotation);
|
|
20649
|
+
};
|
|
20650
|
+
var readOwnBoolean = (obj, key) => {
|
|
20651
|
+
if (!obj || typeof obj !== "object") return void 0;
|
|
20652
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
20653
|
+
if (!descriptor || !("value" in descriptor)) return void 0;
|
|
20654
|
+
return typeof descriptor?.value === "boolean" ? descriptor?.value : void 0;
|
|
20655
|
+
};
|
|
20656
|
+
var computeXPxBase = (args) => {
|
|
20657
|
+
const { chart, chartArea, item, global } = args ?? {};
|
|
20658
|
+
const stickToEdge = item?.stickToEdge ?? global?.stickToEdge ?? true;
|
|
20659
|
+
const stickSide = item?.stickSide ?? global?.stickSide ?? "right";
|
|
20660
|
+
const edgePaddingPx = global?.edgePaddingPx ?? 0;
|
|
20661
|
+
const xValue = item?.xValue ?? global?.xValue;
|
|
20662
|
+
if (isFiniteNumber(xValue)) return getPixelForValueSafe(resolveScale(chart, item?.xScaleID, "x"), xValue);
|
|
20663
|
+
if (stickToEdge) return clamp(stickSide === "left" ? chartArea?.left + edgePaddingPx : chartArea?.right - edgePaddingPx, chartArea?.left, chartArea?.right);
|
|
20664
|
+
};
|
|
20665
|
+
var computeYSpan = (args) => {
|
|
20666
|
+
const { chart, chartArea, item, global } = args ?? {};
|
|
20667
|
+
const yScale = resolveScale(chart, item?.yScaleID, "y");
|
|
20668
|
+
if (!yScale) return void 0;
|
|
20669
|
+
const yStartValue = item?.yStartValue ?? global?.yStartValue;
|
|
20670
|
+
const reverse = readOwnBoolean(item, "reverse") ?? readOwnBoolean(global, "reverse") ?? false;
|
|
20671
|
+
const itemValue = item?.value;
|
|
20672
|
+
if (!isFiniteNumber(itemValue)) return void 0;
|
|
20673
|
+
const yStartPx = isFiniteNumber(yStartValue) ? clamp(yScale.getPixelForValue(yStartValue), chartArea?.top, chartArea?.bottom) : reverse ? chartArea?.bottom : chartArea?.top;
|
|
20674
|
+
const yEndPxRaw = clamp(yScale.getPixelForValue(itemValue), chartArea?.top, chartArea?.bottom);
|
|
20675
|
+
return {
|
|
20676
|
+
yStartPx,
|
|
20677
|
+
yEndPx: reverse ? Math.min(yStartPx, yEndPxRaw) : Math.max(yStartPx, yEndPxRaw),
|
|
20678
|
+
endTick: {
|
|
20679
|
+
label: item.label,
|
|
20680
|
+
color: item.color,
|
|
20681
|
+
font: item.font,
|
|
20682
|
+
labelOffsetPx: item.labelOffsetPx
|
|
20683
|
+
},
|
|
20684
|
+
reverse
|
|
20685
|
+
};
|
|
20686
|
+
};
|
|
20687
|
+
const verticalMarkersPlugin = {
|
|
20688
|
+
id: "verticalMarkers",
|
|
20689
|
+
afterDraw: (chart) => {
|
|
20690
|
+
if (!readPluginEnable(chart)) return;
|
|
20691
|
+
const cfg = readAnnotationConfig(chart);
|
|
20692
|
+
if (!cfg?.enabled) return;
|
|
20693
|
+
const ctx = chart?.ctx;
|
|
20694
|
+
const chartArea = chart?.chartArea;
|
|
20695
|
+
if (!ctx || !chartArea) return;
|
|
20696
|
+
const items = asArray(cfg?.items);
|
|
20697
|
+
if (!items.length) return;
|
|
20698
|
+
const itemGapPx = cfg?.itemGapPx ?? 0;
|
|
20699
|
+
const globalStickSide = cfg?.stickSide ?? "right";
|
|
20700
|
+
let visibleIndex = 0;
|
|
20701
|
+
items?.forEach((item) => {
|
|
20702
|
+
if (!item || item?.display === false) return;
|
|
20703
|
+
const baseXPx = computeXPxBase({
|
|
20704
|
+
chart,
|
|
20705
|
+
chartArea,
|
|
20706
|
+
item,
|
|
20707
|
+
global: cfg
|
|
20708
|
+
});
|
|
20709
|
+
if (!isFiniteNumber(baseXPx)) return;
|
|
20710
|
+
const side = item?.stickSide ?? globalStickSide;
|
|
20711
|
+
const xPx = baseXPx + (side === "left" ? 1 : -1) * visibleIndex * itemGapPx;
|
|
20712
|
+
visibleIndex += 1;
|
|
20713
|
+
const ySpan = computeYSpan({
|
|
20714
|
+
chart,
|
|
20715
|
+
chartArea,
|
|
20716
|
+
item,
|
|
20717
|
+
global: cfg
|
|
20718
|
+
});
|
|
20719
|
+
if (!ySpan) return;
|
|
20720
|
+
const color = item?.color ?? cfg?.color;
|
|
20721
|
+
const opacity = item?.opacity ?? cfg?.opacity;
|
|
20722
|
+
const lineWidth = item?.lineWidth ?? cfg?.lineWidth;
|
|
20723
|
+
const lineDash = asArray(item?.lineDash ?? cfg?.lineDash);
|
|
20724
|
+
if (!color || !isFiniteNumber(opacity) || !isFiniteNumber(lineWidth)) return;
|
|
20725
|
+
drawTick({
|
|
20726
|
+
ctx,
|
|
20727
|
+
x: drawVerticalLine({
|
|
20728
|
+
chart,
|
|
20729
|
+
xPx,
|
|
20730
|
+
y1: ySpan?.yStartPx,
|
|
20731
|
+
y2: ySpan?.yEndPx,
|
|
20732
|
+
color,
|
|
20733
|
+
opacity,
|
|
20734
|
+
lineWidth,
|
|
20735
|
+
lineDash
|
|
20736
|
+
}),
|
|
20737
|
+
y: ySpan?.yEndPx,
|
|
20738
|
+
side,
|
|
20739
|
+
reverse: ySpan?.reverse,
|
|
20740
|
+
tick: ySpan?.endTick,
|
|
20741
|
+
defaultColor: color,
|
|
20742
|
+
defaultFont: "12px sans-serif"
|
|
20743
|
+
});
|
|
20744
|
+
});
|
|
20745
|
+
}
|
|
20746
|
+
};
|
|
20547
20747
|
let defaultTranslations = /* @__PURE__ */ function(defaultTranslations) {
|
|
20548
20748
|
defaultTranslations["label"] = "Label";
|
|
20549
20749
|
defaultTranslations["pointsLines"] = "Points & lines";
|
|
@@ -20973,7 +21173,7 @@ var Legend = ({ chartRef, legendConfig }) => {
|
|
|
20973
21173
|
}, measureRect.width)
|
|
20974
21174
|
] });
|
|
20975
21175
|
};
|
|
20976
|
-
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin, calloutConnectorPlugin);
|
|
21176
|
+
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin, calloutConnectorPlugin, verticalMarkersPlugin);
|
|
20977
21177
|
var LineChart = (props) => {
|
|
20978
21178
|
setDefaultTheme();
|
|
20979
21179
|
const chartRef = useRef(null);
|