@automattic/charts 0.57.0 → 0.58.0
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/CHANGELOG.md +16 -2
- package/dist/charts/bar-chart/index.cjs +7 -5
- package/dist/charts/bar-chart/index.cjs.map +1 -1
- package/dist/charts/bar-chart/index.css +12 -24
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.d.cts +3 -4
- package/dist/charts/bar-chart/index.d.ts +3 -4
- package/dist/charts/bar-chart/index.js +6 -4
- package/dist/charts/bar-list-chart/index.cjs +8 -6
- package/dist/charts/bar-list-chart/index.cjs.map +1 -1
- package/dist/charts/bar-list-chart/index.css +12 -24
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.d.cts +3 -3
- package/dist/charts/bar-list-chart/index.d.ts +3 -3
- package/dist/charts/bar-list-chart/index.js +7 -5
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -5
- package/dist/charts/conversion-funnel-chart/index.css +0 -94
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.ts +1 -1
- package/dist/charts/conversion-funnel-chart/index.js +4 -4
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +0 -94
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.d.cts +1 -1
- package/dist/charts/geo-chart/index.d.ts +1 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +7 -6
- package/dist/charts/leaderboard-chart/index.cjs.map +1 -1
- package/dist/charts/leaderboard-chart/index.css +12 -24
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.d.cts +3 -3
- package/dist/charts/leaderboard-chart/index.d.ts +3 -3
- package/dist/charts/leaderboard-chart/index.js +6 -5
- package/dist/charts/line-chart/index.cjs +7 -5
- package/dist/charts/line-chart/index.cjs.map +1 -1
- package/dist/charts/line-chart/index.css +12 -24
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.d.cts +3 -4
- package/dist/charts/line-chart/index.d.ts +3 -4
- package/dist/charts/line-chart/index.js +6 -4
- package/dist/charts/pie-chart/index.cjs +7 -6
- package/dist/charts/pie-chart/index.cjs.map +1 -1
- package/dist/charts/pie-chart/index.css +12 -24
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.d.cts +7 -13
- package/dist/charts/pie-chart/index.d.ts +7 -13
- package/dist/charts/pie-chart/index.js +6 -5
- package/dist/charts/pie-semi-circle-chart/index.cjs +7 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.css +12 -24
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.d.ts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.js +6 -5
- package/dist/charts/sparkline/index.cjs +8 -6
- package/dist/charts/sparkline/index.cjs.map +1 -1
- package/dist/charts/sparkline/index.css +12 -24
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +7 -5
- package/dist/{chunk-32DH6JDF.js → chunk-2I67QUIV.js} +52 -420
- package/dist/chunk-2I67QUIV.js.map +1 -0
- package/dist/{chunk-WLODYNLB.js → chunk-2ICEEQOC.js} +31 -27
- package/dist/chunk-2ICEEQOC.js.map +1 -0
- package/dist/{chunk-IU4DYUAV.js → chunk-4B7BL2DD.js} +3 -3
- package/dist/{chunk-BCX5THDQ.js → chunk-4OXMTKAL.js} +24 -26
- package/dist/chunk-4OXMTKAL.js.map +1 -0
- package/dist/{chunk-4OPFE4RM.js → chunk-B6NLZFRW.js} +30 -27
- package/dist/chunk-B6NLZFRW.js.map +1 -0
- package/dist/{chunk-D2UH4CFE.cjs → chunk-BBAUQOW6.cjs} +9 -9
- package/dist/{chunk-D2UH4CFE.cjs.map → chunk-BBAUQOW6.cjs.map} +1 -1
- package/dist/{chunk-XKRJL2QT.cjs → chunk-CMMHCTBX.cjs} +45 -47
- package/dist/chunk-CMMHCTBX.cjs.map +1 -0
- package/dist/{chunk-YE2T52VZ.cjs → chunk-CPPXJATQ.cjs} +51 -47
- package/dist/chunk-CPPXJATQ.cjs.map +1 -0
- package/dist/{chunk-H2V4JMSA.js → chunk-DKU775VC.js} +3 -3
- package/dist/{chunk-ZH4F5RMG.cjs → chunk-GRA7Y2ZG.cjs} +46 -48
- package/dist/chunk-GRA7Y2ZG.cjs.map +1 -0
- package/dist/{chunk-DAU3HNEG.js → chunk-JJIMABHT.js} +9 -2
- package/dist/chunk-JJIMABHT.js.map +1 -0
- package/dist/{chunk-CZGYJKG6.js → chunk-KJHWXOCZ.js} +4 -4
- package/dist/{chunk-6CCZL2JJ.js → chunk-KRWGSOJ2.js} +30 -2
- package/dist/chunk-KRWGSOJ2.js.map +1 -0
- package/dist/{chunk-V36ERY7Y.js → chunk-LTFH7SEG.js} +24 -26
- package/dist/chunk-LTFH7SEG.js.map +1 -0
- package/dist/{chunk-PXLEMUGJ.js → chunk-MUNOKLLE.js} +3 -3
- package/dist/{chunk-VTS3PNMS.cjs → chunk-MXGLYWVP.cjs} +9 -2
- package/dist/chunk-MXGLYWVP.cjs.map +1 -0
- package/dist/{chunk-Z45KX47P.cjs → chunk-OYC34VTO.cjs} +154 -94
- package/dist/chunk-OYC34VTO.cjs.map +1 -0
- package/dist/{chunk-77OKCVQN.cjs → chunk-PQL5I3F6.cjs} +17 -17
- package/dist/{chunk-77OKCVQN.cjs.map → chunk-PQL5I3F6.cjs.map} +1 -1
- package/dist/{chunk-I35UYJJR.cjs → chunk-REZTQ4PH.cjs} +41 -21
- package/dist/chunk-REZTQ4PH.cjs.map +1 -0
- package/dist/{chunk-RCY6XLGU.cjs → chunk-TZRUHQOH.cjs} +36 -8
- package/dist/chunk-TZRUHQOH.cjs.map +1 -0
- package/dist/{chunk-2NCY7R4G.js → chunk-UTYVIOWZ.js} +111 -51
- package/dist/chunk-UTYVIOWZ.js.map +1 -0
- package/dist/{chunk-TO3OQBXG.cjs → chunk-W2LDIX26.cjs} +5 -5
- package/dist/{chunk-TO3OQBXG.cjs.map → chunk-W2LDIX26.cjs.map} +1 -1
- package/dist/{chunk-7FQX4ALL.cjs → chunk-WSG64BVN.cjs} +6 -6
- package/dist/{chunk-7FQX4ALL.cjs.map → chunk-WSG64BVN.cjs.map} +1 -1
- package/dist/chunk-WTQYGUNF.js +400 -0
- package/dist/chunk-WTQYGUNF.js.map +1 -0
- package/dist/{chunk-RHHVEJHJ.cjs → chunk-WYK7EL5R.cjs} +68 -436
- package/dist/chunk-WYK7EL5R.cjs.map +1 -0
- package/dist/{chunk-VJM5XCB4.cjs → chunk-XC4KHJYX.cjs} +49 -46
- package/dist/chunk-XC4KHJYX.cjs.map +1 -0
- package/dist/chunk-XVBH5XHE.cjs +400 -0
- package/dist/chunk-XVBH5XHE.cjs.map +1 -0
- package/dist/{chunk-Z26M4V2M.js → chunk-YAFQVVDI.js} +41 -21
- package/dist/chunk-YAFQVVDI.js.map +1 -0
- package/dist/components/legend/index.cjs +4 -3
- package/dist/components/legend/index.cjs.map +1 -1
- package/dist/components/legend/index.css +12 -24
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.d.cts +4 -4
- package/dist/components/legend/index.d.ts +4 -4
- package/dist/components/legend/index.js +3 -2
- package/dist/components/tooltip/index.d.cts +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/hooks/index.cjs +3 -5
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +0 -94
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +3 -11
- package/dist/hooks/index.d.ts +3 -11
- package/dist/hooks/index.js +2 -4
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +12 -24
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -15
- package/dist/{leaderboard-chart-DR7CGb0L.d.cts → leaderboard-chart-BSbg0ufV.d.cts} +3 -7
- package/dist/{leaderboard-chart-BKYYXcg2.d.ts → leaderboard-chart-odEYxxEC.d.ts} +3 -7
- package/dist/{legend-C2grwnWk.d.cts → legend-DFkosEvC.d.cts} +1 -1
- package/dist/{legend-Cj0xM5dU.d.ts → legend-DLswHhOk.d.ts} +1 -1
- package/dist/providers/index.cjs +3 -3
- package/dist/providers/index.css +0 -94
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +2 -2
- package/dist/{themes-CyjKm-P_.d.cts → themes-D0qc5JaW.d.cts} +2 -2
- package/dist/{themes-BmVGrYnF.d.ts → themes-itO4Ht5g.d.ts} +2 -2
- package/dist/{types-KtOPPzPX.d.cts → types-B5f6XQ7Q.d.cts} +1 -1
- package/dist/{types-CuUEszrM.d.ts → types-BsHooDbM.d.ts} +1 -1
- package/dist/{types-I67mddpr.d.cts → types-BuSrRM4p.d.ts} +3 -32
- package/dist/{types-DZordNiO.d.cts → types-ChOUI9-N.d.cts} +80 -40
- package/dist/{types-DZordNiO.d.ts → types-ChOUI9-N.d.ts} +80 -40
- package/dist/{types-I67mddpr.d.ts → types-Dfw9VOKI.d.cts} +3 -32
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +6 -6
- package/src/charts/bar-chart/bar-chart.tsx +17 -18
- package/src/charts/bar-chart/test/bar-chart.test.tsx +48 -31
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +38 -41
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +4 -5
- package/src/charts/leaderboard-chart/types.ts +1 -11
- package/src/charts/line-chart/line-chart.tsx +18 -16
- package/src/charts/line-chart/test/line-chart.test.tsx +49 -27
- package/src/charts/line-chart/types.ts +0 -1
- package/src/charts/pie-chart/pie-chart.tsx +23 -22
- package/src/charts/pie-chart/test/composition-api.test.tsx +41 -0
- package/src/charts/pie-chart/test/pie-chart.test.tsx +9 -9
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +21 -23
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +33 -5
- package/src/charts/private/chart-composition/index.ts +2 -0
- package/src/charts/private/chart-composition/render-legend-slot.ts +22 -0
- package/src/charts/private/chart-composition/test/render-legend-slot.test.tsx +60 -0
- package/src/charts/private/chart-composition/test/use-chart-children.test.tsx +91 -0
- package/src/charts/private/chart-composition/use-chart-children.ts +34 -2
- package/src/components/legend/index.ts +1 -8
- package/src/components/legend/private/base-legend.module.scss +19 -37
- package/src/components/legend/private/base-legend.tsx +0 -2
- package/src/components/legend/types.ts +7 -34
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +1 -7
- package/src/types.ts +83 -38
- package/src/utils/date-parsing.ts +10 -1
- package/src/utils/test/date-parsing.test.ts +12 -0
- package/src/utils/test/resolve-css-var.test.ts +2 -2
- package/tsup.config.ts +1 -1
- package/dist/chunk-2NCY7R4G.js.map +0 -1
- package/dist/chunk-32DH6JDF.js.map +0 -1
- package/dist/chunk-4OPFE4RM.js.map +0 -1
- package/dist/chunk-6CCZL2JJ.js.map +0 -1
- package/dist/chunk-BCX5THDQ.js.map +0 -1
- package/dist/chunk-DAU3HNEG.js.map +0 -1
- package/dist/chunk-I35UYJJR.cjs.map +0 -1
- package/dist/chunk-RCY6XLGU.cjs.map +0 -1
- package/dist/chunk-RHHVEJHJ.cjs.map +0 -1
- package/dist/chunk-V36ERY7Y.js.map +0 -1
- package/dist/chunk-VJM5XCB4.cjs.map +0 -1
- package/dist/chunk-VTS3PNMS.cjs.map +0 -1
- package/dist/chunk-WLODYNLB.js.map +0 -1
- package/dist/chunk-XKRJL2QT.cjs.map +0 -1
- package/dist/chunk-YE2T52VZ.cjs.map +0 -1
- package/dist/chunk-Z26M4V2M.js.map +0 -1
- package/dist/chunk-Z45KX47P.cjs.map +0 -1
- package/dist/chunk-ZH4F5RMG.cjs.map +0 -1
- package/src/hooks/use-has-legend-child.ts +0 -22
- /package/dist/{chunk-IU4DYUAV.js.map → chunk-4B7BL2DD.js.map} +0 -0
- /package/dist/{chunk-H2V4JMSA.js.map → chunk-DKU775VC.js.map} +0 -0
- /package/dist/{chunk-CZGYJKG6.js.map → chunk-KJHWXOCZ.js.map} +0 -0
- /package/dist/{chunk-PXLEMUGJ.js.map → chunk-MUNOKLLE.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -7,15 +7,53 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
var _chunkMXGLYWVPcjs = require('./chunk-MXGLYWVP.cjs');
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkEMMSS5I5cjs = require('./chunk-EMMSS5I5.cjs');
|
|
15
|
+
|
|
16
|
+
// ../../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
17
|
+
var require_fast_deep_equal = _chunkEMMSS5I5cjs.__commonJS.call(void 0, {
|
|
18
|
+
"../../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
19
|
+
"use strict";
|
|
20
|
+
module.exports = function equal(a, b) {
|
|
21
|
+
if (a === b) return true;
|
|
22
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
23
|
+
if (a.constructor !== b.constructor) return false;
|
|
24
|
+
var length, i, keys;
|
|
25
|
+
if (Array.isArray(a)) {
|
|
26
|
+
length = a.length;
|
|
27
|
+
if (length != b.length) return false;
|
|
28
|
+
for (i = length; i-- !== 0; )
|
|
29
|
+
if (!equal(a[i], b[i])) return false;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
33
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
34
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
35
|
+
keys = Object.keys(a);
|
|
36
|
+
length = keys.length;
|
|
37
|
+
if (length !== Object.keys(b).length) return false;
|
|
38
|
+
for (i = length; i-- !== 0; )
|
|
39
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
40
|
+
for (i = length; i-- !== 0; ) {
|
|
41
|
+
var key = keys[i];
|
|
42
|
+
if (!equal(a[key], b[key])) return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return a !== a && b !== b;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
12
50
|
|
|
13
51
|
// src/hooks/use-deep-memo.ts
|
|
14
|
-
var
|
|
52
|
+
var import_fast_deep_equal = _chunkEMMSS5I5cjs.__toESM.call(void 0, require_fast_deep_equal(), 1);
|
|
15
53
|
var _react = require('react');
|
|
16
54
|
var useDeepMemo = (value) => {
|
|
17
55
|
const ref = _react.useRef.call(void 0, value);
|
|
18
|
-
if (!
|
|
56
|
+
if (!(0, import_fast_deep_equal.default)(ref.current, value)) {
|
|
19
57
|
ref.current = value;
|
|
20
58
|
}
|
|
21
59
|
return ref.current;
|
|
@@ -96,7 +134,7 @@ function installRemoveChildPatch() {
|
|
|
96
134
|
patchedRemoveChild = function(child) {
|
|
97
135
|
if (relocatedNodes.has(child) && child.parentNode !== this) {
|
|
98
136
|
relocatedNodes.delete(child);
|
|
99
|
-
_optionalChain([child, 'access',
|
|
137
|
+
_optionalChain([child, 'access', _ => _.parentNode, 'optionalAccess', _2 => _2.removeChild, 'call', _3 => _3(child)]);
|
|
100
138
|
return child;
|
|
101
139
|
}
|
|
102
140
|
return origRemoveChild.call(this, child);
|
|
@@ -115,7 +153,7 @@ function uninstallRemoveChildPatch() {
|
|
|
115
153
|
}
|
|
116
154
|
function useTooltipPortalRelocator(containerRef) {
|
|
117
155
|
_react.useEffect.call(void 0, () => {
|
|
118
|
-
const container = _optionalChain([containerRef, 'optionalAccess',
|
|
156
|
+
const container = _optionalChain([containerRef, 'optionalAccess', _4 => _4.current]);
|
|
119
157
|
if (!container) {
|
|
120
158
|
return;
|
|
121
159
|
}
|
|
@@ -229,7 +267,7 @@ var getChartColor = (index, colorCache) => {
|
|
|
229
267
|
const candidateHsl = [hue, saturation, lightness];
|
|
230
268
|
let isSufficientlyDifferent = true;
|
|
231
269
|
for (const existingHsl of existingHslColors) {
|
|
232
|
-
if (
|
|
270
|
+
if (_chunkMXGLYWVPcjs.getColorDistance.call(void 0, candidateHsl, existingHsl) < MIN_COLOR_DISTANCE) {
|
|
233
271
|
isSufficientlyDifferent = false;
|
|
234
272
|
break;
|
|
235
273
|
}
|
|
@@ -332,7 +370,7 @@ var GlobalChartsProvider = ({
|
|
|
332
370
|
const wrapperRef = _react.useRef.call(void 0, null);
|
|
333
371
|
useTooltipPortalRelocator(_nullishCoalesce(portalContainer, () => ( wrapperRef)));
|
|
334
372
|
const providerTheme = _react.useMemo.call(void 0, () => {
|
|
335
|
-
return theme ?
|
|
373
|
+
return theme ? _chunkMXGLYWVPcjs.mergeThemes.call(void 0, defaultTheme, theme) : defaultTheme;
|
|
336
374
|
}, [theme]);
|
|
337
375
|
const [colorCache, setColorCache] = _react.useState.call(void 0, () => ({
|
|
338
376
|
colors: [],
|
|
@@ -355,7 +393,7 @@ var GlobalChartsProvider = ({
|
|
|
355
393
|
if (color && typeof color === "string") {
|
|
356
394
|
let colorValue = color;
|
|
357
395
|
if (color.startsWith("--") || color.startsWith("var(")) {
|
|
358
|
-
const resolved =
|
|
396
|
+
const resolved = _chunkMXGLYWVPcjs.resolveCssVariable.call(void 0, color, wrapperRef.current);
|
|
359
397
|
if (resolved === null || resolved === "") {
|
|
360
398
|
continue;
|
|
361
399
|
}
|
|
@@ -406,7 +444,7 @@ var GlobalChartsProvider = ({
|
|
|
406
444
|
overrideColor
|
|
407
445
|
}) => {
|
|
408
446
|
if (overrideColor) {
|
|
409
|
-
return
|
|
447
|
+
return _chunkMXGLYWVPcjs.normalizeColorToHex.call(void 0, overrideColor, wrapperRef.current, _chunkMXGLYWVPcjs.resolveCssVariable);
|
|
410
448
|
}
|
|
411
449
|
if (group) {
|
|
412
450
|
const existing = groupToColorMap.get(group);
|
|
@@ -430,13 +468,13 @@ var GlobalChartsProvider = ({
|
|
|
430
468
|
const isPointPercentageData = data && typeof data === "object" && "percentage" in data;
|
|
431
469
|
return {
|
|
432
470
|
color: resolveColor({
|
|
433
|
-
group: _optionalChain([data, 'optionalAccess',
|
|
471
|
+
group: _optionalChain([data, 'optionalAccess', _5 => _5.group]),
|
|
434
472
|
index,
|
|
435
|
-
overrideColor: overrideColor || isSeriesData && _optionalChain([data, 'optionalAccess',
|
|
473
|
+
overrideColor: overrideColor || isSeriesData && _optionalChain([data, 'optionalAccess', _6 => _6.options, 'optionalAccess', _7 => _7.stroke]) || isPointPercentageData && _optionalChain([data, 'optionalAccess', _8 => _8.color])
|
|
436
474
|
}),
|
|
437
|
-
lineStyles: isSeriesData ?
|
|
438
|
-
glyph: _optionalChain([providerTheme, 'access',
|
|
439
|
-
shapeStyles: isSeriesData ?
|
|
475
|
+
lineStyles: isSeriesData ? _chunkMXGLYWVPcjs.getSeriesLineStyles.call(void 0, data, index, providerTheme) : {},
|
|
476
|
+
glyph: _optionalChain([providerTheme, 'access', _9 => _9.glyphs, 'optionalAccess', _10 => _10[index]]),
|
|
477
|
+
shapeStyles: isSeriesData ? _chunkMXGLYWVPcjs.getItemShapeStyles.call(void 0, data, index, providerTheme, legendShape) : {}
|
|
440
478
|
};
|
|
441
479
|
}, [providerTheme, resolveColor]);
|
|
442
480
|
const toggleSeriesVisibility = _react.useCallback.call(void 0, (chartId, seriesLabel) => {
|
|
@@ -543,7 +581,7 @@ var useChartRegistration = ({
|
|
|
543
581
|
|
|
544
582
|
var useGlobalChartsTheme = () => {
|
|
545
583
|
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
546
|
-
const globalTheme = _optionalChain([context, 'optionalAccess',
|
|
584
|
+
const globalTheme = _optionalChain([context, 'optionalAccess', _11 => _11.theme]);
|
|
547
585
|
return _nullishCoalesce(globalTheme, () => ( defaultTheme));
|
|
548
586
|
};
|
|
549
587
|
|
|
@@ -551,7 +589,7 @@ var useGlobalChartsTheme = () => {
|
|
|
551
589
|
var useXYChartTheme = (data) => {
|
|
552
590
|
const theme = useGlobalChartsTheme();
|
|
553
591
|
return _react.useMemo.call(void 0, () => {
|
|
554
|
-
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access',
|
|
592
|
+
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access', _12 => _12.options, 'optionalAccess', _13 => _13.stroke])).filter((color) => Boolean(color));
|
|
555
593
|
return _xychart.buildChartTheme.call(void 0, {
|
|
556
594
|
...theme,
|
|
557
595
|
colors: [...seriesColors, ..._nullishCoalesce(theme.colors, () => ( []))]
|
|
@@ -563,7 +601,7 @@ var useXYChartTheme = (data) => {
|
|
|
563
601
|
|
|
564
602
|
var useChartDataTransform = (data) => {
|
|
565
603
|
return _react.useMemo.call(void 0, () => {
|
|
566
|
-
const firstPoint = _optionalChain([data, 'optionalAccess',
|
|
604
|
+
const firstPoint = _optionalChain([data, 'optionalAccess', _14 => _14[0], 'optionalAccess', _15 => _15.data, 'optionalAccess', _16 => _16[0]]);
|
|
567
605
|
const hasDateProperties = firstPoint && ("date" in firstPoint || "dateString" in firstPoint);
|
|
568
606
|
if (!hasDateProperties) {
|
|
569
607
|
return data;
|
|
@@ -575,7 +613,7 @@ var useChartDataTransform = (data) => {
|
|
|
575
613
|
if ("date" in point && point.date) {
|
|
576
614
|
date = point.date;
|
|
577
615
|
} else if ("dateString" in point && point.dateString) {
|
|
578
|
-
date =
|
|
616
|
+
date = _chunkMXGLYWVPcjs.parseAsLocalDate.call(void 0, point.dateString);
|
|
579
617
|
}
|
|
580
618
|
return {
|
|
581
619
|
...point,
|
|
@@ -611,9 +649,9 @@ var resolveFontSize = (val) => {
|
|
|
611
649
|
return void 0;
|
|
612
650
|
};
|
|
613
651
|
var getXAxisLabelMetrics = (theme, orientation) => {
|
|
614
|
-
const xAxisStyles = orientation === "top" ? _optionalChain([theme, 'access',
|
|
615
|
-
const fontSize = resolveFontSize(_optionalChain([xAxisStyles, 'optionalAccess',
|
|
616
|
-
const tickLength = _nullishCoalesce(_optionalChain([xAxisStyles, 'optionalAccess',
|
|
652
|
+
const xAxisStyles = orientation === "top" ? _optionalChain([theme, 'access', _17 => _17.axisStyles, 'optionalAccess', _18 => _18.x, 'optionalAccess', _19 => _19.top]) : _optionalChain([theme, 'access', _20 => _20.axisStyles, 'optionalAccess', _21 => _21.x, 'optionalAccess', _22 => _22.bottom]);
|
|
653
|
+
const fontSize = resolveFontSize(_optionalChain([xAxisStyles, 'optionalAccess', _23 => _23.axisLabel, 'optionalAccess', _24 => _24.fontSize])) || resolveFontSize(_optionalChain([theme, 'access', _25 => _25.svgLabelSmall, 'optionalAccess', _26 => _26.fontSize])) || DEFAULT_FONT_SIZE;
|
|
654
|
+
const tickLength = _nullishCoalesce(_optionalChain([xAxisStyles, 'optionalAccess', _27 => _27.tickLength]), () => ( DEFAULT_TICK_LENGTH));
|
|
617
655
|
return {
|
|
618
656
|
fontSize,
|
|
619
657
|
tickLength
|
|
@@ -623,7 +661,7 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
623
661
|
const yTicks = _react.useMemo.call(void 0, () => {
|
|
624
662
|
const allDataPoints = data.flatMap((series) => series.data);
|
|
625
663
|
if (horizontal) {
|
|
626
|
-
return allDataPoints.map((d) => d.label || _optionalChain([options, 'access',
|
|
664
|
+
return allDataPoints.map((d) => d.label || _optionalChain([options, 'access', _28 => _28.axis, 'optionalAccess', _29 => _29.y, 'optionalAccess', _30 => _30.tickFormat, 'call', _31 => _31(d.date.getTime(), 0, [])]));
|
|
627
665
|
}
|
|
628
666
|
const minY = Math.min(...allDataPoints.map((d) => d.value));
|
|
629
667
|
const maxY = Math.max(...allDataPoints.map((d) => d.value));
|
|
@@ -632,7 +670,7 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
632
670
|
domain: [minY, maxY],
|
|
633
671
|
range: [height, 0]
|
|
634
672
|
});
|
|
635
|
-
return _scale.getTicks.call(void 0, yScale, _optionalChain([options, 'access',
|
|
673
|
+
return _scale.getTicks.call(void 0, yScale, _optionalChain([options, 'access', _32 => _32.axis, 'optionalAccess', _33 => _33.y, 'optionalAccess', _34 => _34.numTicks]));
|
|
636
674
|
}, [options, data, height, horizontal]);
|
|
637
675
|
return _react.useMemo.call(void 0, () => {
|
|
638
676
|
const defaultMargin = {
|
|
@@ -641,16 +679,16 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
641
679
|
bottom: DEFAULT_MARGIN_BOTTOM,
|
|
642
680
|
left: DEFAULT_MARGIN_LEFT
|
|
643
681
|
};
|
|
644
|
-
const yAxisOrientation = _optionalChain([options, 'access',
|
|
682
|
+
const yAxisOrientation = _optionalChain([options, 'access', _35 => _35.axis, 'optionalAccess', _36 => _36.y, 'optionalAccess', _37 => _37.orientation]);
|
|
645
683
|
const yAxisStyles = yAxisOrientation === "right" ? theme.axisStyles.y.right : theme.axisStyles.y.left;
|
|
646
|
-
const yTickWidth =
|
|
647
|
-
const yMarginValue = (_nullishCoalesce(yTickWidth, () => ( DEFAULT_Y_TICK_WIDTH))) + (_nullishCoalesce(_optionalChain([yAxisStyles, 'optionalAccess',
|
|
684
|
+
const yTickWidth = _chunkMXGLYWVPcjs.getLongestTickWidth.call(void 0, yTicks, _optionalChain([options, 'access', _38 => _38.axis, 'optionalAccess', _39 => _39.y, 'optionalAccess', _40 => _40.tickFormat]), yAxisStyles.axisLabel);
|
|
685
|
+
const yMarginValue = (_nullishCoalesce(yTickWidth, () => ( DEFAULT_Y_TICK_WIDTH))) + (_nullishCoalesce(_optionalChain([yAxisStyles, 'optionalAccess', _41 => _41.tickLength]), () => ( 0)));
|
|
648
686
|
if (yAxisOrientation === "right") {
|
|
649
687
|
defaultMargin.right = yMarginValue;
|
|
650
688
|
} else {
|
|
651
689
|
defaultMargin.left = yMarginValue;
|
|
652
690
|
}
|
|
653
|
-
const xOrientation = _optionalChain([options, 'access',
|
|
691
|
+
const xOrientation = _optionalChain([options, 'access', _42 => _42.axis, 'optionalAccess', _43 => _43.x, 'optionalAccess', _44 => _44.orientation]) === "top" ? "top" : "bottom";
|
|
654
692
|
const {
|
|
655
693
|
fontSize,
|
|
656
694
|
tickLength
|
|
@@ -695,407 +733,6 @@ function useElementSize({
|
|
|
695
733
|
return [refCallback, width, height];
|
|
696
734
|
}
|
|
697
735
|
|
|
698
|
-
// src/hooks/use-has-legend-child.ts
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
// src/components/legend/legend.tsx
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
// src/charts/private/single-chart-context/single-chart-context.tsx
|
|
705
|
-
|
|
706
|
-
var ChartInstanceContext = /* @__PURE__ */ _react.createContext.call(void 0, null);
|
|
707
|
-
var SingleChartContext = ChartInstanceContext;
|
|
708
|
-
|
|
709
|
-
// src/charts/private/single-chart-context/use-single-chart-context.ts
|
|
710
|
-
|
|
711
|
-
var useChartInstanceContext = () => {
|
|
712
|
-
const context = _react.useContext.call(void 0, ChartInstanceContext);
|
|
713
|
-
if (!context) {
|
|
714
|
-
throw new Error("useChartInstanceContext must be used within a Chart component");
|
|
715
|
-
}
|
|
716
|
-
return context;
|
|
717
|
-
};
|
|
718
|
-
var useSingleChartContext = useChartInstanceContext;
|
|
719
|
-
|
|
720
|
-
// src/components/legend/private/base-legend.tsx
|
|
721
|
-
var _group = require('@visx/group');
|
|
722
|
-
var _legend = require('@visx/legend');
|
|
723
|
-
|
|
724
|
-
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
// src/components/legend/utils/value-or-identity.ts
|
|
728
|
-
function valueOrIdentity(_) {
|
|
729
|
-
if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
|
|
730
|
-
return _.value;
|
|
731
|
-
return _;
|
|
732
|
-
}
|
|
733
|
-
function valueOrIdentityString(_) {
|
|
734
|
-
return String(valueOrIdentity(_));
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// src/components/legend/utils/label-transform-factory.ts
|
|
738
|
-
function labelTransformFactory({
|
|
739
|
-
scale,
|
|
740
|
-
labelFormat
|
|
741
|
-
}) {
|
|
742
|
-
return (d, i) => ({
|
|
743
|
-
datum: d,
|
|
744
|
-
index: i,
|
|
745
|
-
text: `${labelFormat(d, i)}`,
|
|
746
|
-
value: scale(d)
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// src/components/legend/private/base-legend.module.scss
|
|
751
|
-
var base_legend_module_default = {
|
|
752
|
-
"legend--horizontal": "a8ccharts-AELBvX",
|
|
753
|
-
"legend--vertical": "a8ccharts-fX8uQe",
|
|
754
|
-
"legend--alignment-start": "a8ccharts-DEe0wg",
|
|
755
|
-
"legend--alignment-center": "a8ccharts-WBKF9I",
|
|
756
|
-
"legend--alignment-end": "a8ccharts-JfwMng",
|
|
757
|
-
"legend--position-top": "a8ccharts-8Y73Kh",
|
|
758
|
-
"legend--position-bottom": "a8ccharts-TVM-IY",
|
|
759
|
-
"legend-item": "a8ccharts-Vflwq8",
|
|
760
|
-
"legend-item--interactive": "a8ccharts-qGsavM",
|
|
761
|
-
"legend-item--inactive": "a8ccharts-ZtDY-Q",
|
|
762
|
-
"legend-item-label": "a8ccharts-2H65Kr",
|
|
763
|
-
"legend-item-text--wrap": "a8ccharts-faSDBI",
|
|
764
|
-
"legend-item-text--ellipsis": "a8ccharts-FISUIO",
|
|
765
|
-
"legend-item-value": "a8ccharts-DTZlT-"
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
// src/components/legend/private/base-legend.tsx
|
|
769
|
-
|
|
770
|
-
var orientationToFlexDirection = {
|
|
771
|
-
horizontal: "row",
|
|
772
|
-
vertical: "column"
|
|
773
|
-
};
|
|
774
|
-
var LegendText = ({
|
|
775
|
-
text,
|
|
776
|
-
textOverflow,
|
|
777
|
-
maxWidth
|
|
778
|
-
}) => {
|
|
779
|
-
const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
|
|
780
|
-
const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
|
|
781
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
782
|
-
ref: textRef,
|
|
783
|
-
className: _clsx2.default.call(void 0, base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
|
|
784
|
-
style: {
|
|
785
|
-
...maxWidth != null && {
|
|
786
|
-
maxWidth,
|
|
787
|
-
minWidth: 0
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
title: isEllipsis && isTruncated ? text : void 0,
|
|
791
|
-
children: text
|
|
792
|
-
});
|
|
793
|
-
};
|
|
794
|
-
var BaseLegend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
795
|
-
items,
|
|
796
|
-
className,
|
|
797
|
-
orientation = "horizontal",
|
|
798
|
-
position = "bottom",
|
|
799
|
-
alignment = "center",
|
|
800
|
-
shape = "rect",
|
|
801
|
-
fill = valueOrIdentityString,
|
|
802
|
-
size = valueOrIdentityString,
|
|
803
|
-
labelFormat = valueOrIdentity,
|
|
804
|
-
labelTransform = labelTransformFactory,
|
|
805
|
-
itemStyles,
|
|
806
|
-
itemClassName,
|
|
807
|
-
labelStyles,
|
|
808
|
-
labelClassName,
|
|
809
|
-
shapeStyles,
|
|
810
|
-
render,
|
|
811
|
-
interactive = false,
|
|
812
|
-
chartId
|
|
813
|
-
}, ref) => {
|
|
814
|
-
const {
|
|
815
|
-
margin: itemMargin = "0",
|
|
816
|
-
flexDirection: itemDirection = "row"
|
|
817
|
-
} = _nullishCoalesce(itemStyles, () => ( {}));
|
|
818
|
-
const {
|
|
819
|
-
justifyContent: labelJustifyContent = "flex-start",
|
|
820
|
-
flex: labelFlex = "0 0 auto",
|
|
821
|
-
margin: labelMargin = "0 4px",
|
|
822
|
-
maxWidth,
|
|
823
|
-
textOverflow = "wrap"
|
|
824
|
-
} = _nullishCoalesce(labelStyles, () => ( {}));
|
|
825
|
-
const {
|
|
826
|
-
width: shapeWidth = 16,
|
|
827
|
-
height: shapeHeight = 16,
|
|
828
|
-
margin: shapeMargin = "2px 4px 2px 0"
|
|
829
|
-
} = _nullishCoalesce(shapeStyles, () => ( {}));
|
|
830
|
-
const theme = useGlobalChartsTheme();
|
|
831
|
-
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
832
|
-
const legendScale = _scale.scaleOrdinal.call(void 0, {
|
|
833
|
-
domain: items.map((item) => item.label),
|
|
834
|
-
range: items.map((item) => item.color)
|
|
835
|
-
});
|
|
836
|
-
const domain = legendScale.domain();
|
|
837
|
-
const getShapeStyle = _react.useCallback.call(void 0, ({
|
|
838
|
-
index
|
|
839
|
-
}) => _optionalChain([items, 'access', _46 => _46[index], 'optionalAccess', _47 => _47.shapeStyle]), [items]);
|
|
840
|
-
const handleLegendClick = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
841
|
-
if (interactive && chartId && context) {
|
|
842
|
-
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
843
|
-
}
|
|
844
|
-
}, [interactive, chartId, context]);
|
|
845
|
-
const isSeriesVisible = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
846
|
-
if (!interactive || !chartId || !context) {
|
|
847
|
-
return true;
|
|
848
|
-
}
|
|
849
|
-
return context.isSeriesVisible(chartId, seriesLabel);
|
|
850
|
-
}, [interactive, chartId, context]);
|
|
851
|
-
const createClickHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
852
|
-
if (!interactive) {
|
|
853
|
-
return void 0;
|
|
854
|
-
}
|
|
855
|
-
return () => handleLegendClick(labelText);
|
|
856
|
-
}, [interactive, handleLegendClick]);
|
|
857
|
-
const createKeyDownHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
858
|
-
if (!interactive) {
|
|
859
|
-
return void 0;
|
|
860
|
-
}
|
|
861
|
-
return (event) => {
|
|
862
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
863
|
-
event.preventDefault();
|
|
864
|
-
handleLegendClick(labelText);
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
}, [interactive, handleLegendClick]);
|
|
868
|
-
return render ? render(items) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendOrdinal, {
|
|
869
|
-
scale: legendScale,
|
|
870
|
-
labelFormat,
|
|
871
|
-
labelTransform,
|
|
872
|
-
children: (labels) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
873
|
-
ref,
|
|
874
|
-
role: "list",
|
|
875
|
-
className: _clsx2.default.call(void 0, base_legend_module_default.legend, base_legend_module_default[`legend--${orientation}`], base_legend_module_default[`legend--alignment-${alignment}`], base_legend_module_default[`legend--position-${position}`], className),
|
|
876
|
-
style: {
|
|
877
|
-
flexDirection: orientationToFlexDirection[orientation],
|
|
878
|
-
..._optionalChain([theme, 'access', _48 => _48.legend, 'optionalAccess', _49 => _49.containerStyles])
|
|
879
|
-
},
|
|
880
|
-
children: labels.map((label, i) => {
|
|
881
|
-
const visible = isSeriesVisible(label.text);
|
|
882
|
-
const handleClick = createClickHandler(label.text);
|
|
883
|
-
const handleKeyDown = createKeyDownHandler(label.text);
|
|
884
|
-
const matchedItem = items[i];
|
|
885
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendItem, {
|
|
886
|
-
className: _clsx2.default.call(void 0, "visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
|
|
887
|
-
margin: itemMargin,
|
|
888
|
-
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
889
|
-
onClick: handleClick,
|
|
890
|
-
onKeyDown: handleKeyDown,
|
|
891
|
-
role: interactive ? "button" : void 0,
|
|
892
|
-
tabIndex: interactive ? 0 : void 0,
|
|
893
|
-
"aria-pressed": interactive ? visible : void 0,
|
|
894
|
-
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
895
|
-
children: [_optionalChain([items, 'access', _50 => _50[i], 'optionalAccess', _51 => _51.renderGlyph]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", {
|
|
896
|
-
width: _optionalChain([items, 'access', _52 => _52[i], 'optionalAccess', _53 => _53.glyphSize]) * 2,
|
|
897
|
-
height: _optionalChain([items, 'access', _54 => _54[i], 'optionalAccess', _55 => _55.glyphSize]) * 2,
|
|
898
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _group.Group, {
|
|
899
|
-
children: _optionalChain([items, 'access', _56 => _56[i], 'optionalAccess', _57 => _57.renderGlyph, 'call', _58 => _58({
|
|
900
|
-
key: `legend-glyph-${label.text}`,
|
|
901
|
-
datum: {},
|
|
902
|
-
index: i,
|
|
903
|
-
color: fill(label),
|
|
904
|
-
size: _optionalChain([items, 'access', _59 => _59[i], 'optionalAccess', _60 => _60.glyphSize]),
|
|
905
|
-
x: _optionalChain([items, 'access', _61 => _61[i], 'optionalAccess', _62 => _62.glyphSize]),
|
|
906
|
-
y: _optionalChain([items, 'access', _63 => _63[i], 'optionalAccess', _64 => _64.glyphSize])
|
|
907
|
-
})])
|
|
908
|
-
})
|
|
909
|
-
}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendShape, {
|
|
910
|
-
shape,
|
|
911
|
-
height: shapeHeight,
|
|
912
|
-
width: shapeWidth,
|
|
913
|
-
margin: shapeMargin,
|
|
914
|
-
item: domain[i],
|
|
915
|
-
itemIndex: i,
|
|
916
|
-
label,
|
|
917
|
-
fill,
|
|
918
|
-
size,
|
|
919
|
-
shapeStyle: getShapeStyle
|
|
920
|
-
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendLabel, {
|
|
921
|
-
className: _clsx2.default.call(void 0, "visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
|
|
922
|
-
style: {
|
|
923
|
-
justifyContent: labelJustifyContent,
|
|
924
|
-
flex: labelFlex,
|
|
925
|
-
margin: labelMargin,
|
|
926
|
-
..._optionalChain([theme, 'access', _65 => _65.legend, 'optionalAccess', _66 => _66.labelStyles])
|
|
927
|
-
},
|
|
928
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LegendText, {
|
|
929
|
-
text: label.text,
|
|
930
|
-
textOverflow,
|
|
931
|
-
maxWidth
|
|
932
|
-
}), _optionalChain([matchedItem, 'optionalAccess', _67 => _67.value]) != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
933
|
-
className: base_legend_module_default["legend-item-value"],
|
|
934
|
-
children: ["\xA0", matchedItem.value]
|
|
935
|
-
})]
|
|
936
|
-
})]
|
|
937
|
-
}, `legend-${label.text}-${i}`);
|
|
938
|
-
})
|
|
939
|
-
})
|
|
940
|
-
});
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// src/components/legend/legend.tsx
|
|
944
|
-
|
|
945
|
-
var Legend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
946
|
-
chartId,
|
|
947
|
-
items,
|
|
948
|
-
...props
|
|
949
|
-
}, ref) => {
|
|
950
|
-
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
951
|
-
const singleChartContext = _react.useContext.call(void 0, SingleChartContext);
|
|
952
|
-
const contextChartId = _nullishCoalesce(chartId, () => ( _optionalChain([singleChartContext, 'optionalAccess', _68 => _68.chartId])));
|
|
953
|
-
const contextItems = _react.useMemo.call(void 0, () => {
|
|
954
|
-
return contextChartId && context ? _optionalChain([context, 'access', _69 => _69.getChartData, 'call', _70 => _70(contextChartId), 'optionalAccess', _71 => _71.legendItems]) : void 0;
|
|
955
|
-
}, [contextChartId, context]);
|
|
956
|
-
const legendItems = items || contextItems;
|
|
957
|
-
if (!legendItems) {
|
|
958
|
-
return null;
|
|
959
|
-
}
|
|
960
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseLegend, {
|
|
961
|
-
ref,
|
|
962
|
-
items: legendItems,
|
|
963
|
-
...props,
|
|
964
|
-
chartId: contextChartId
|
|
965
|
-
});
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
// src/components/legend/hooks/use-chart-legend-items.ts
|
|
969
|
-
var _numberformatters = require('@automattic/number-formatters');
|
|
970
|
-
|
|
971
|
-
function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
|
|
972
|
-
if (!showValues || legendValueDisplay === "none") {
|
|
973
|
-
return "";
|
|
974
|
-
}
|
|
975
|
-
if ("percentage" in point) {
|
|
976
|
-
const percentagePoint = point;
|
|
977
|
-
switch (legendValueDisplay) {
|
|
978
|
-
case "percentage":
|
|
979
|
-
return _chunkVTS3PNMScjs.formatPercentage.call(void 0, percentagePoint.percentage);
|
|
980
|
-
case "value":
|
|
981
|
-
return _numberformatters.formatNumber.call(void 0, percentagePoint.value);
|
|
982
|
-
case "valueDisplay":
|
|
983
|
-
return percentagePoint.valueDisplay || _numberformatters.formatNumber.call(void 0, percentagePoint.value);
|
|
984
|
-
default:
|
|
985
|
-
return "";
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
if ("value" in point) {
|
|
989
|
-
return point.value !== null ? _numberformatters.formatNumber.call(void 0, point.value) : "";
|
|
990
|
-
}
|
|
991
|
-
return "";
|
|
992
|
-
}
|
|
993
|
-
function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
|
|
994
|
-
if (withGlyph) {
|
|
995
|
-
const glyphToUse = glyph || renderGlyph;
|
|
996
|
-
if (glyphToUse) {
|
|
997
|
-
return {
|
|
998
|
-
...baseItem,
|
|
999
|
-
glyphSize,
|
|
1000
|
-
renderGlyph: glyphToUse
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return baseItem;
|
|
1005
|
-
}
|
|
1006
|
-
function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
1007
|
-
const mapper = (series, index) => {
|
|
1008
|
-
const { color, glyph, shapeStyles } = getElementStyles({
|
|
1009
|
-
data: series,
|
|
1010
|
-
index,
|
|
1011
|
-
legendShape
|
|
1012
|
-
});
|
|
1013
|
-
const baseItem = {
|
|
1014
|
-
label: series.label,
|
|
1015
|
-
value: showValues ? _optionalChain([series, 'access', _72 => _72.data, 'optionalAccess', _73 => _73.length, 'optionalAccess', _74 => _74.toString, 'call', _75 => _75()]) || "0" : "",
|
|
1016
|
-
color,
|
|
1017
|
-
shapeStyle: shapeStyles
|
|
1018
|
-
};
|
|
1019
|
-
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
1020
|
-
};
|
|
1021
|
-
return seriesData.map(mapper);
|
|
1022
|
-
}
|
|
1023
|
-
function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
1024
|
-
const mapper = (point, index) => {
|
|
1025
|
-
const { color, glyph, shapeStyles } = getElementStyles({
|
|
1026
|
-
data: point,
|
|
1027
|
-
index,
|
|
1028
|
-
legendShape
|
|
1029
|
-
});
|
|
1030
|
-
const baseItem = {
|
|
1031
|
-
label: point.label,
|
|
1032
|
-
value: formatPointValue(point, showValues, legendValueDisplay),
|
|
1033
|
-
color,
|
|
1034
|
-
shapeStyle: shapeStyles
|
|
1035
|
-
};
|
|
1036
|
-
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
1037
|
-
};
|
|
1038
|
-
return pointData.map(mapper);
|
|
1039
|
-
}
|
|
1040
|
-
function useChartLegendItems(data, options = {}, legendShape) {
|
|
1041
|
-
const {
|
|
1042
|
-
showValues = false,
|
|
1043
|
-
legendValueDisplay = "percentage",
|
|
1044
|
-
withGlyph = false,
|
|
1045
|
-
glyphSize = 8,
|
|
1046
|
-
renderGlyph
|
|
1047
|
-
} = options;
|
|
1048
|
-
const { getElementStyles } = useGlobalChartsContext();
|
|
1049
|
-
return _react.useMemo.call(void 0, () => {
|
|
1050
|
-
if (!data || !Array.isArray(data) || data.length === 0) {
|
|
1051
|
-
return [];
|
|
1052
|
-
}
|
|
1053
|
-
if ("data" in data[0]) {
|
|
1054
|
-
return processSeriesData(
|
|
1055
|
-
data,
|
|
1056
|
-
getElementStyles,
|
|
1057
|
-
showValues,
|
|
1058
|
-
withGlyph,
|
|
1059
|
-
glyphSize,
|
|
1060
|
-
renderGlyph,
|
|
1061
|
-
legendShape
|
|
1062
|
-
);
|
|
1063
|
-
}
|
|
1064
|
-
return processPointData(
|
|
1065
|
-
data,
|
|
1066
|
-
getElementStyles,
|
|
1067
|
-
showValues,
|
|
1068
|
-
legendValueDisplay,
|
|
1069
|
-
withGlyph,
|
|
1070
|
-
glyphSize,
|
|
1071
|
-
renderGlyph,
|
|
1072
|
-
legendShape
|
|
1073
|
-
);
|
|
1074
|
-
}, [
|
|
1075
|
-
data,
|
|
1076
|
-
getElementStyles,
|
|
1077
|
-
showValues,
|
|
1078
|
-
legendValueDisplay,
|
|
1079
|
-
withGlyph,
|
|
1080
|
-
glyphSize,
|
|
1081
|
-
renderGlyph,
|
|
1082
|
-
legendShape
|
|
1083
|
-
]);
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// src/hooks/use-has-legend-child.ts
|
|
1087
|
-
function useHasLegendChild(children) {
|
|
1088
|
-
return _react.useMemo.call(void 0, () => {
|
|
1089
|
-
let found = false;
|
|
1090
|
-
_react.Children.forEach(children, (child) => {
|
|
1091
|
-
if (_react.isValidElement.call(void 0, child) && child.type === Legend) {
|
|
1092
|
-
found = true;
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
return found;
|
|
1096
|
-
}, [children]);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
736
|
// src/hooks/use-text-truncation.ts
|
|
1100
737
|
|
|
1101
738
|
function useTextTruncation(enabled = true) {
|
|
@@ -1254,10 +891,5 @@ function usePrefersReducedMotion() {
|
|
|
1254
891
|
|
|
1255
892
|
|
|
1256
893
|
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
exports.SingleChartContext = SingleChartContext; exports.useSingleChartContext = useSingleChartContext; exports.useTooltipPortalRelocator = useTooltipPortalRelocator; exports.defaultTheme = defaultTheme; exports.GlobalChartsContext = GlobalChartsContext; exports.GlobalChartsProvider = GlobalChartsProvider; exports.useGlobalChartsContext = useGlobalChartsContext; exports.useChartId = useChartId; exports.useDeepMemo = useDeepMemo; exports.useChartMouseHandler = useChartMouseHandler; exports.useXYChartTheme = useXYChartTheme; exports.useChartDataTransform = useChartDataTransform; exports.useChartMargin = useChartMargin; exports.useElementSize = useElementSize; exports.useHasLegendChild = useHasLegendChild; exports.useTextTruncation = useTextTruncation; exports.useZeroValueDisplay = useZeroValueDisplay; exports.useInteractiveLegendData = useInteractiveLegendData; exports.usePrefersReducedMotion = usePrefersReducedMotion; exports.useChartRegistration = useChartRegistration; exports.useGlobalChartsTheme = useGlobalChartsTheme; exports.Legend = Legend; exports.useChartLegendItems = useChartLegendItems;
|
|
1263
|
-
//# sourceMappingURL=chunk-RHHVEJHJ.cjs.map
|
|
894
|
+
exports.useTooltipPortalRelocator = useTooltipPortalRelocator; exports.defaultTheme = defaultTheme; exports.GlobalChartsContext = GlobalChartsContext; exports.GlobalChartsProvider = GlobalChartsProvider; exports.useGlobalChartsContext = useGlobalChartsContext; exports.useChartId = useChartId; exports.useDeepMemo = useDeepMemo; exports.useChartMouseHandler = useChartMouseHandler; exports.useXYChartTheme = useXYChartTheme; exports.useChartDataTransform = useChartDataTransform; exports.useChartMargin = useChartMargin; exports.useElementSize = useElementSize; exports.useTextTruncation = useTextTruncation; exports.useZeroValueDisplay = useZeroValueDisplay; exports.useInteractiveLegendData = useInteractiveLegendData; exports.usePrefersReducedMotion = usePrefersReducedMotion; exports.useChartRegistration = useChartRegistration; exports.useGlobalChartsTheme = useGlobalChartsTheme;
|
|
895
|
+
//# sourceMappingURL=chunk-WYK7EL5R.cjs.map
|