@automattic/charts 0.56.2 → 0.56.4
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 +14 -0
- package/dist/charts/bar-chart/index.cjs +5 -5
- package/dist/charts/bar-chart/index.css +12 -0
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.js +4 -4
- package/dist/charts/bar-list-chart/index.cjs +6 -6
- package/dist/charts/bar-list-chart/index.css +12 -0
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.js +5 -5
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -3
- package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.css +14 -1
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +2 -0
- package/dist/charts/conversion-funnel-chart/index.d.ts +2 -0
- package/dist/charts/conversion-funnel-chart/index.js +4 -2
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +12 -0
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +5 -5
- package/dist/charts/leaderboard-chart/index.css +12 -0
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.js +4 -4
- package/dist/charts/line-chart/index.cjs +5 -5
- package/dist/charts/line-chart/index.css +12 -0
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.js +4 -4
- package/dist/charts/pie-chart/index.cjs +7 -7
- package/dist/charts/pie-chart/index.css +12 -0
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.js +6 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs +7 -7
- package/dist/charts/pie-semi-circle-chart/index.css +12 -0
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.js +6 -6
- package/dist/charts/sparkline/index.cjs +6 -6
- package/dist/charts/sparkline/index.css +12 -0
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +5 -5
- package/dist/{chunk-OTZT3MC2.cjs → chunk-2A34OA5O.cjs} +19 -20
- package/dist/chunk-2A34OA5O.cjs.map +1 -0
- package/dist/chunk-4YYROZDJ.cjs +375 -0
- package/dist/chunk-4YYROZDJ.cjs.map +1 -0
- package/dist/{chunk-YYQ4IK5V.cjs → chunk-5N77S5N3.cjs} +103 -80
- package/dist/chunk-5N77S5N3.cjs.map +1 -0
- package/dist/chunk-66BXSWMW.cjs +1065 -0
- package/dist/chunk-66BXSWMW.cjs.map +1 -0
- package/dist/{chunk-CEZGL6YP.js → chunk-6CCZL2JJ.js} +15 -7
- package/dist/chunk-6CCZL2JJ.js.map +1 -0
- package/dist/{chunk-NW3RUYK2.cjs → chunk-7QDEU3KN.cjs} +15 -22
- package/dist/chunk-7QDEU3KN.cjs.map +1 -0
- package/dist/{chunk-H34CJSR6.js → chunk-AWNCAKZY.js} +367 -358
- package/dist/chunk-AWNCAKZY.js.map +1 -0
- package/dist/{chunk-5XI443YP.js → chunk-BPYKWMI7.js} +72 -64
- package/dist/chunk-BPYKWMI7.js.map +1 -0
- package/dist/{chunk-7UJPVCMB.cjs → chunk-CERFRCXD.cjs} +265 -262
- package/dist/chunk-CERFRCXD.cjs.map +1 -0
- package/dist/chunk-CMHPXSCI.js +351 -0
- package/dist/chunk-CMHPXSCI.js.map +1 -0
- package/dist/chunk-EBDUXL5K.js +421 -0
- package/dist/chunk-EBDUXL5K.js.map +1 -0
- package/dist/{chunk-2VPPTJS2.js → chunk-FZYJM5PN.js} +256 -253
- package/dist/chunk-FZYJM5PN.js.map +1 -0
- package/dist/chunk-GBDFC74U.cjs +165 -0
- package/dist/chunk-GBDFC74U.cjs.map +1 -0
- package/dist/{chunk-ODF5O5PV.cjs → chunk-HNEG3EFJ.cjs} +154 -170
- package/dist/chunk-HNEG3EFJ.cjs.map +1 -0
- package/dist/{chunk-SRXJLAKG.cjs → chunk-I2276W3I.cjs} +28 -37
- package/dist/chunk-I2276W3I.cjs.map +1 -0
- package/dist/chunk-KKPZ4MVF.js +375 -0
- package/dist/chunk-KKPZ4MVF.js.map +1 -0
- package/dist/chunk-KMYJJTSR.cjs +421 -0
- package/dist/chunk-KMYJJTSR.cjs.map +1 -0
- package/dist/{chunk-A3AEEGKR.js → chunk-KXRWNFQJ.js} +20 -21
- package/dist/chunk-KXRWNFQJ.js.map +1 -0
- package/dist/{chunk-TVV7ZI7C.cjs → chunk-LSV7F26B.cjs} +362 -353
- package/dist/chunk-LSV7F26B.cjs.map +1 -0
- package/dist/{chunk-T4J6TI55.js → chunk-M7PRGJFE.js} +102 -79
- package/dist/chunk-M7PRGJFE.js.map +1 -0
- package/dist/{chunk-TNRKEBTA.js → chunk-PGJAZN2H.js} +148 -164
- package/dist/{chunk-TNRKEBTA.js.map → chunk-PGJAZN2H.js.map} +1 -1
- package/dist/chunk-R23BFDIW.js +1065 -0
- package/dist/chunk-R23BFDIW.js.map +1 -0
- package/dist/{chunk-HIWNB5PK.cjs → chunk-RCY6XLGU.cjs} +13 -5
- package/dist/chunk-RCY6XLGU.cjs.map +1 -0
- package/dist/chunk-RSYD434G.cjs +351 -0
- package/dist/chunk-RSYD434G.cjs.map +1 -0
- package/dist/{chunk-C33AQZEC.js → chunk-TYIH5LMV.js} +16 -23
- package/dist/chunk-TYIH5LMV.js.map +1 -0
- package/dist/chunk-WMWAUOQ4.js +165 -0
- package/dist/chunk-WMWAUOQ4.js.map +1 -0
- package/dist/chunk-XWYZIFZW.js +66 -0
- package/dist/chunk-XWYZIFZW.js.map +1 -0
- package/dist/{chunk-7HROSZRS.cjs → chunk-Y3NNQMAX.cjs} +70 -62
- package/dist/chunk-Y3NNQMAX.cjs.map +1 -0
- package/dist/chunk-ZXEFMKVP.cjs +120 -0
- package/dist/chunk-ZXEFMKVP.cjs.map +1 -0
- package/dist/chunk-ZY4FXLMM.js +120 -0
- package/dist/chunk-ZY4FXLMM.js.map +1 -0
- package/dist/components/legend/index.cjs +2 -2
- package/dist/components/legend/index.css +12 -0
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.js +1 -1
- package/dist/components/tooltip/index.cjs +2 -2
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/trend-indicator/index.cjs +2 -2
- package/dist/components/trend-indicator/index.js +1 -1
- package/dist/hooks/index.cjs +4 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +12 -0
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +28 -2
- package/dist/hooks/index.d.ts +28 -2
- package/dist/hooks/index.js +3 -1
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +14 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -17
- package/dist/providers/index.cjs +2 -2
- package/dist/providers/index.css +12 -0
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/{themes-DQs9rbN5.d.cts → themes-BDVaIfBz.d.cts} +9 -0
- package/dist/{themes-CRV5fVzJ.d.ts → themes-mcS8QNkQ.d.ts} +9 -0
- package/package.json +7 -4
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +2 -1
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +16 -6
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +34 -0
- package/src/charts/conversion-funnel-chart/types.ts +2 -0
- package/src/charts/pie-chart/pie-chart.tsx +2 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/test/use-tooltip-portal-relocator.test.ts +216 -0
- package/src/hooks/use-tooltip-portal-relocator.module.scss +10 -0
- package/src/hooks/use-tooltip-portal-relocator.ts +177 -0
- package/src/providers/chart-context/global-charts-provider.tsx +18 -1
- package/tsup.config.ts +11 -0
- package/dist/chunk-2VPPTJS2.js.map +0 -1
- package/dist/chunk-5XI443YP.js.map +0 -1
- package/dist/chunk-7HROSZRS.cjs.map +0 -1
- package/dist/chunk-7UJPVCMB.cjs.map +0 -1
- package/dist/chunk-A3AEEGKR.js.map +0 -1
- package/dist/chunk-C33AQZEC.js.map +0 -1
- package/dist/chunk-CEZGL6YP.js.map +0 -1
- package/dist/chunk-COOC2TVQ.js +0 -167
- package/dist/chunk-COOC2TVQ.js.map +0 -1
- package/dist/chunk-EJHLLXBV.js +0 -362
- package/dist/chunk-EJHLLXBV.js.map +0 -1
- package/dist/chunk-FWMJ2FR2.js +0 -121
- package/dist/chunk-FWMJ2FR2.js.map +0 -1
- package/dist/chunk-GRYNIPWH.cjs +0 -385
- package/dist/chunk-GRYNIPWH.cjs.map +0 -1
- package/dist/chunk-H34CJSR6.js.map +0 -1
- package/dist/chunk-HIWNB5PK.cjs.map +0 -1
- package/dist/chunk-IZWC33YN.cjs +0 -357
- package/dist/chunk-IZWC33YN.cjs.map +0 -1
- package/dist/chunk-KOF32DBL.cjs +0 -1058
- package/dist/chunk-KOF32DBL.cjs.map +0 -1
- package/dist/chunk-LHWRZMF7.cjs +0 -362
- package/dist/chunk-LHWRZMF7.cjs.map +0 -1
- package/dist/chunk-MFRS2PEY.cjs +0 -121
- package/dist/chunk-MFRS2PEY.cjs.map +0 -1
- package/dist/chunk-MMDLXS6O.js +0 -75
- package/dist/chunk-MMDLXS6O.js.map +0 -1
- package/dist/chunk-NW3RUYK2.cjs.map +0 -1
- package/dist/chunk-ODF5O5PV.cjs.map +0 -1
- package/dist/chunk-OTZT3MC2.cjs.map +0 -1
- package/dist/chunk-SBRMWDWM.js +0 -357
- package/dist/chunk-SBRMWDWM.js.map +0 -1
- package/dist/chunk-SRXJLAKG.cjs.map +0 -1
- package/dist/chunk-T4J6TI55.js.map +0 -1
- package/dist/chunk-TVV7ZI7C.cjs.map +0 -1
- package/dist/chunk-XVMXWV3C.cjs +0 -167
- package/dist/chunk-XVMXWV3C.cjs.map +0 -1
- package/dist/chunk-YYQ4IK5V.cjs.map +0 -1
- package/dist/chunk-ZDNCF642.js +0 -1058
- package/dist/chunk-ZDNCF642.js.map +0 -1
- package/dist/chunk-ZWBUEHKF.js +0 -385
- package/dist/chunk-ZWBUEHKF.js.map +0 -1
|
@@ -72,13 +72,96 @@ var _xychart = require('@visx/xychart');
|
|
|
72
72
|
var _d3color = require('@visx/vendor/d3-color');
|
|
73
73
|
|
|
74
74
|
|
|
75
|
+
// src/hooks/use-tooltip-portal-relocator.ts
|
|
75
76
|
|
|
76
77
|
|
|
78
|
+
// src/hooks/use-tooltip-portal-relocator.module.scss
|
|
79
|
+
var use_tooltip_portal_relocator_module_default = {
|
|
80
|
+
"relocatedPortal": "a8ccharts-jCw5dQ"
|
|
81
|
+
};
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
// src/hooks/use-tooltip-portal-relocator.ts
|
|
84
|
+
function isVisxPortalNode(node) {
|
|
85
|
+
return node instanceof HTMLDivElement && node.parentElement === document.body && !node.id && !node.className && node.querySelector(".visx-tooltip") !== null;
|
|
86
|
+
}
|
|
87
|
+
var patchRefCount = 0;
|
|
88
|
+
var origRemoveChild = null;
|
|
89
|
+
var patchedRemoveChild = null;
|
|
90
|
+
var relocatedNodes = /* @__PURE__ */ new WeakSet();
|
|
91
|
+
function installRemoveChildPatch() {
|
|
92
|
+
if (patchRefCount++ > 0) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
origRemoveChild = document.body.removeChild;
|
|
96
|
+
patchedRemoveChild = function(child) {
|
|
97
|
+
if (relocatedNodes.has(child) && child.parentNode !== this) {
|
|
98
|
+
relocatedNodes.delete(child);
|
|
99
|
+
_optionalChain([child, 'access', _2 => _2.parentNode, 'optionalAccess', _3 => _3.removeChild, 'call', _4 => _4(child)]);
|
|
100
|
+
return child;
|
|
101
|
+
}
|
|
102
|
+
return origRemoveChild.call(this, child);
|
|
103
|
+
};
|
|
104
|
+
document.body.removeChild = patchedRemoveChild;
|
|
105
|
+
}
|
|
106
|
+
function uninstallRemoveChildPatch() {
|
|
107
|
+
if (--patchRefCount > 0) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (document.body.removeChild === patchedRemoveChild) {
|
|
111
|
+
document.body.removeChild = origRemoveChild;
|
|
112
|
+
}
|
|
113
|
+
origRemoveChild = null;
|
|
114
|
+
patchedRemoveChild = null;
|
|
115
|
+
}
|
|
116
|
+
function useTooltipPortalRelocator(containerRef) {
|
|
117
|
+
_react.useEffect.call(void 0, () => {
|
|
118
|
+
const container = _optionalChain([containerRef, 'optionalAccess', _5 => _5.current]);
|
|
119
|
+
if (!container) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const instanceNodes = /* @__PURE__ */ new Set();
|
|
123
|
+
const relocateNode = (node) => {
|
|
124
|
+
if (!isVisxPortalNode(node)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
node.classList.add(use_tooltip_portal_relocator_module_default.relocatedPortal);
|
|
128
|
+
const { activeElement } = node.ownerDocument;
|
|
129
|
+
const focusedElement = activeElement instanceof HTMLElement && node.contains(activeElement) ? activeElement : null;
|
|
130
|
+
container.insertBefore(node, container.firstChild);
|
|
131
|
+
relocatedNodes.add(node);
|
|
132
|
+
instanceNodes.add(node);
|
|
133
|
+
if (focusedElement) {
|
|
134
|
+
focusedElement.focus();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
installRemoveChildPatch();
|
|
138
|
+
for (const child of Array.from(document.body.children)) {
|
|
139
|
+
relocateNode(child);
|
|
140
|
+
}
|
|
141
|
+
const observer = new MutationObserver((mutations) => {
|
|
142
|
+
for (const mutation of mutations) {
|
|
143
|
+
for (const node of mutation.addedNodes) {
|
|
144
|
+
relocateNode(node);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
observer.observe(document.body, { childList: true });
|
|
149
|
+
return () => {
|
|
150
|
+
observer.disconnect();
|
|
151
|
+
for (const node of instanceNodes) {
|
|
152
|
+
if (node instanceof HTMLElement) {
|
|
153
|
+
node.classList.remove(use_tooltip_portal_relocator_module_default.relocatedPortal);
|
|
154
|
+
}
|
|
155
|
+
if (node.parentNode === container) {
|
|
156
|
+
document.body.appendChild(node);
|
|
157
|
+
}
|
|
158
|
+
relocatedNodes.delete(node);
|
|
159
|
+
}
|
|
160
|
+
instanceNodes.clear();
|
|
161
|
+
uninstallRemoveChildPatch();
|
|
162
|
+
};
|
|
163
|
+
}, [containerRef]);
|
|
164
|
+
}
|
|
82
165
|
|
|
83
166
|
// src/providers/chart-context/private/get-chart-color.ts
|
|
84
167
|
|
|
@@ -230,13 +313,16 @@ var defaultTheme = {
|
|
|
230
313
|
|
|
231
314
|
// src/providers/chart-context/global-charts-provider.tsx
|
|
232
315
|
var _jsxruntime = require('react/jsx-runtime');
|
|
233
|
-
var GlobalChartsContext = _react.createContext.call(void 0, null);
|
|
234
|
-
var GlobalChartsProvider = ({
|
|
316
|
+
var GlobalChartsContext = /* @__PURE__ */ _react.createContext.call(void 0, null);
|
|
317
|
+
var GlobalChartsProvider = ({
|
|
318
|
+
children,
|
|
319
|
+
theme,
|
|
320
|
+
portalContainer
|
|
321
|
+
}) => {
|
|
235
322
|
const [charts, setCharts] = _react.useState.call(void 0, () => /* @__PURE__ */ new Map());
|
|
236
|
-
const [hiddenSeries, setHiddenSeries] = _react.useState.call(void 0,
|
|
237
|
-
() => /* @__PURE__ */ new Map()
|
|
238
|
-
);
|
|
323
|
+
const [hiddenSeries, setHiddenSeries] = _react.useState.call(void 0, () => /* @__PURE__ */ new Map());
|
|
239
324
|
const wrapperRef = _react.useRef.call(void 0, null);
|
|
325
|
+
useTooltipPortalRelocator(_nullishCoalesce(portalContainer, () => ( wrapperRef)));
|
|
240
326
|
const providerTheme = _react.useMemo.call(void 0, () => {
|
|
241
327
|
return theme ? _chunkZVGEDXDPcjs.mergeThemes.call(void 0, defaultTheme, theme) : defaultTheme;
|
|
242
328
|
}, [theme]);
|
|
@@ -248,7 +334,9 @@ var GlobalChartsProvider = ({ children, theme }) => {
|
|
|
248
334
|
maxHue: 0
|
|
249
335
|
}));
|
|
250
336
|
_react.useLayoutEffect.call(void 0, () => {
|
|
251
|
-
const {
|
|
337
|
+
const {
|
|
338
|
+
colors
|
|
339
|
+
} = providerTheme;
|
|
252
340
|
const resolvedColors = [];
|
|
253
341
|
const hues = [];
|
|
254
342
|
const existingHslColors = [];
|
|
@@ -269,11 +357,7 @@ var GlobalChartsProvider = ({ children, theme }) => {
|
|
|
269
357
|
resolvedColors.push(colorValue);
|
|
270
358
|
const hslColor = _d3color.hsl.call(void 0, colorValue);
|
|
271
359
|
if (!isNaN(hslColor.h)) {
|
|
272
|
-
const hslTuple = [
|
|
273
|
-
hslColor.h,
|
|
274
|
-
hslColor.s * 100,
|
|
275
|
-
hslColor.l * 100
|
|
276
|
-
];
|
|
360
|
+
const hslTuple = [hslColor.h, hslColor.s * 100, hslColor.l * 100];
|
|
277
361
|
hues.push(hslTuple[0]);
|
|
278
362
|
existingHslColors.push(hslTuple);
|
|
279
363
|
minHue = Math.min(minHue, hslTuple[0]);
|
|
@@ -291,9 +375,7 @@ var GlobalChartsProvider = ({ children, theme }) => {
|
|
|
291
375
|
maxHue
|
|
292
376
|
});
|
|
293
377
|
}, [providerTheme]);
|
|
294
|
-
const [groupToColorMap, setGroupToColorMap] = _react.useState.call(void 0,
|
|
295
|
-
() => /* @__PURE__ */ new Map()
|
|
296
|
-
);
|
|
378
|
+
const [groupToColorMap, setGroupToColorMap] = _react.useState.call(void 0, () => /* @__PURE__ */ new Map());
|
|
297
379
|
_react.useEffect.call(void 0, () => {
|
|
298
380
|
setGroupToColorMap(/* @__PURE__ */ new Map());
|
|
299
381
|
}, [providerTheme.colors]);
|
|
@@ -307,52 +389,48 @@ var GlobalChartsProvider = ({ children, theme }) => {
|
|
|
307
389
|
return newMap;
|
|
308
390
|
});
|
|
309
391
|
}, []);
|
|
310
|
-
const getChartData = _react.useCallback.call(void 0,
|
|
311
|
-
(id)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (group) {
|
|
326
|
-
const existing = groupToColorMap.get(group);
|
|
327
|
-
if (existing) {
|
|
328
|
-
return existing;
|
|
329
|
-
}
|
|
330
|
-
const assignedCount = groupToColorMap.size;
|
|
331
|
-
const color = getChartColor(assignedCount, colorCache);
|
|
332
|
-
groupToColorMap.set(group, color);
|
|
333
|
-
return color;
|
|
392
|
+
const getChartData = _react.useCallback.call(void 0, (id) => {
|
|
393
|
+
return charts.get(id);
|
|
394
|
+
}, [charts]);
|
|
395
|
+
const resolveColor = _react.useCallback.call(void 0, ({
|
|
396
|
+
group,
|
|
397
|
+
index,
|
|
398
|
+
overrideColor
|
|
399
|
+
}) => {
|
|
400
|
+
if (overrideColor) {
|
|
401
|
+
return _chunkZVGEDXDPcjs.normalizeColorToHex.call(void 0, overrideColor, wrapperRef.current, _chunkZVGEDXDPcjs.resolveCssVariable);
|
|
402
|
+
}
|
|
403
|
+
if (group) {
|
|
404
|
+
const existing = groupToColorMap.get(group);
|
|
405
|
+
if (existing) {
|
|
406
|
+
return existing;
|
|
334
407
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
408
|
+
const assignedCount = groupToColorMap.size;
|
|
409
|
+
const color = getChartColor(assignedCount, colorCache);
|
|
410
|
+
groupToColorMap.set(group, color);
|
|
411
|
+
return color;
|
|
412
|
+
}
|
|
413
|
+
return getChartColor(index, colorCache);
|
|
414
|
+
}, [colorCache, groupToColorMap]);
|
|
415
|
+
const getElementStyles = _react.useCallback.call(void 0, ({
|
|
416
|
+
data,
|
|
417
|
+
index,
|
|
418
|
+
overrideColor,
|
|
419
|
+
legendShape
|
|
420
|
+
}) => {
|
|
421
|
+
const isSeriesData = data && typeof data === "object" && "data" in data && "options" in data;
|
|
422
|
+
const isPointPercentageData = data && typeof data === "object" && "percentage" in data;
|
|
423
|
+
return {
|
|
424
|
+
color: resolveColor({
|
|
425
|
+
group: _optionalChain([data, 'optionalAccess', _6 => _6.group]),
|
|
426
|
+
index,
|
|
427
|
+
overrideColor: overrideColor || isSeriesData && _optionalChain([data, 'optionalAccess', _7 => _7.options, 'optionalAccess', _8 => _8.stroke]) || isPointPercentageData && _optionalChain([data, 'optionalAccess', _9 => _9.color])
|
|
428
|
+
}),
|
|
429
|
+
lineStyles: isSeriesData ? _chunkZVGEDXDPcjs.getSeriesLineStyles.call(void 0, data, index, providerTheme) : {},
|
|
430
|
+
glyph: _optionalChain([providerTheme, 'access', _10 => _10.glyphs, 'optionalAccess', _11 => _11[index]]),
|
|
431
|
+
shapeStyles: isSeriesData ? _chunkZVGEDXDPcjs.getItemShapeStyles.call(void 0, data, index, providerTheme, legendShape) : {}
|
|
432
|
+
};
|
|
433
|
+
}, [providerTheme, resolveColor]);
|
|
356
434
|
const toggleSeriesVisibility = _react.useCallback.call(void 0, (chartId, seriesLabel) => {
|
|
357
435
|
setHiddenSeries((prev) => {
|
|
358
436
|
const newMap = new Map(prev);
|
|
@@ -371,45 +449,35 @@ var GlobalChartsProvider = ({ children, theme }) => {
|
|
|
371
449
|
return newMap;
|
|
372
450
|
});
|
|
373
451
|
}, []);
|
|
374
|
-
const isSeriesVisible = _react.useCallback.call(void 0,
|
|
375
|
-
(chartId
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
unregisterChart,
|
|
404
|
-
getChartData,
|
|
405
|
-
providerTheme,
|
|
406
|
-
getElementStyles,
|
|
407
|
-
toggleSeriesVisibility,
|
|
408
|
-
isSeriesVisible,
|
|
409
|
-
getHiddenSeries
|
|
410
|
-
]
|
|
411
|
-
);
|
|
412
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GlobalChartsContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: wrapperRef, style: { display: "contents" }, children }) });
|
|
452
|
+
const isSeriesVisible = _react.useCallback.call(void 0, (chartId, seriesLabel) => {
|
|
453
|
+
const chartHidden = hiddenSeries.get(chartId);
|
|
454
|
+
return !chartHidden || !chartHidden.has(seriesLabel);
|
|
455
|
+
}, [hiddenSeries]);
|
|
456
|
+
const getHiddenSeries = _react.useCallback.call(void 0, (chartId) => {
|
|
457
|
+
const set = hiddenSeries.get(chartId);
|
|
458
|
+
return set ? new Set(set) : /* @__PURE__ */ new Set();
|
|
459
|
+
}, [hiddenSeries]);
|
|
460
|
+
const value = _react.useMemo.call(void 0, () => ({
|
|
461
|
+
charts,
|
|
462
|
+
registerChart,
|
|
463
|
+
unregisterChart,
|
|
464
|
+
getChartData,
|
|
465
|
+
theme: providerTheme,
|
|
466
|
+
getElementStyles,
|
|
467
|
+
toggleSeriesVisibility,
|
|
468
|
+
isSeriesVisible,
|
|
469
|
+
getHiddenSeries
|
|
470
|
+
}), [charts, registerChart, unregisterChart, getChartData, providerTheme, getElementStyles, toggleSeriesVisibility, isSeriesVisible, getHiddenSeries]);
|
|
471
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GlobalChartsContext.Provider, {
|
|
472
|
+
value,
|
|
473
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
474
|
+
ref: wrapperRef,
|
|
475
|
+
style: {
|
|
476
|
+
display: "contents"
|
|
477
|
+
},
|
|
478
|
+
children
|
|
479
|
+
})
|
|
480
|
+
});
|
|
413
481
|
};
|
|
414
482
|
|
|
415
483
|
// src/providers/chart-context/hooks/use-global-charts-context.ts
|
|
@@ -467,7 +535,7 @@ var useChartRegistration = ({
|
|
|
467
535
|
|
|
468
536
|
var useGlobalChartsTheme = () => {
|
|
469
537
|
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
470
|
-
const globalTheme = _optionalChain([context, 'optionalAccess',
|
|
538
|
+
const globalTheme = _optionalChain([context, 'optionalAccess', _12 => _12.theme]);
|
|
471
539
|
return _nullishCoalesce(globalTheme, () => ( defaultTheme));
|
|
472
540
|
};
|
|
473
541
|
|
|
@@ -475,7 +543,7 @@ var useGlobalChartsTheme = () => {
|
|
|
475
543
|
var useXYChartTheme = (data) => {
|
|
476
544
|
const theme = useGlobalChartsTheme();
|
|
477
545
|
return _react.useMemo.call(void 0, () => {
|
|
478
|
-
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access',
|
|
546
|
+
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access', _13 => _13.options, 'optionalAccess', _14 => _14.stroke])).filter((color) => Boolean(color));
|
|
479
547
|
return _xychart.buildChartTheme.call(void 0, {
|
|
480
548
|
...theme,
|
|
481
549
|
colors: [...seriesColors, ..._nullishCoalesce(theme.colors, () => ( []))]
|
|
@@ -487,7 +555,7 @@ var useXYChartTheme = (data) => {
|
|
|
487
555
|
|
|
488
556
|
var useChartDataTransform = (data) => {
|
|
489
557
|
return _react.useMemo.call(void 0, () => {
|
|
490
|
-
const firstPoint = _optionalChain([data, 'optionalAccess',
|
|
558
|
+
const firstPoint = _optionalChain([data, 'optionalAccess', _15 => _15[0], 'optionalAccess', _16 => _16.data, 'optionalAccess', _17 => _17[0]]);
|
|
491
559
|
const hasDateProperties = firstPoint && ("date" in firstPoint || "dateString" in firstPoint);
|
|
492
560
|
if (!hasDateProperties) {
|
|
493
561
|
return data;
|
|
@@ -520,9 +588,7 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
520
588
|
const yTicks = _react.useMemo.call(void 0, () => {
|
|
521
589
|
const allDataPoints = data.flatMap((series) => series.data);
|
|
522
590
|
if (horizontal) {
|
|
523
|
-
return allDataPoints.map(
|
|
524
|
-
(d) => d.label || _optionalChain([options, 'access', _14 => _14.axis, 'optionalAccess', _15 => _15.y, 'optionalAccess', _16 => _16.tickFormat, 'call', _17 => _17(d.date.getTime(), 0, [])])
|
|
525
|
-
);
|
|
591
|
+
return allDataPoints.map((d) => d.label || _optionalChain([options, 'access', _18 => _18.axis, 'optionalAccess', _19 => _19.y, 'optionalAccess', _20 => _20.tickFormat, 'call', _21 => _21(d.date.getTime(), 0, [])]));
|
|
526
592
|
}
|
|
527
593
|
const minY = Math.min(...allDataPoints.map((d) => d.value));
|
|
528
594
|
const maxY = Math.max(...allDataPoints.map((d) => d.value));
|
|
@@ -531,25 +597,26 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
531
597
|
domain: [minY, maxY],
|
|
532
598
|
range: [height, 0]
|
|
533
599
|
});
|
|
534
|
-
return _scale.getTicks.call(void 0, yScale, _optionalChain([options, 'access',
|
|
600
|
+
return _scale.getTicks.call(void 0, yScale, _optionalChain([options, 'access', _22 => _22.axis, 'optionalAccess', _23 => _23.y, 'optionalAccess', _24 => _24.numTicks]));
|
|
535
601
|
}, [options, data, height, horizontal]);
|
|
536
602
|
return _react.useMemo.call(void 0, () => {
|
|
537
|
-
const defaultMargin = {
|
|
603
|
+
const defaultMargin = {
|
|
604
|
+
top: 10,
|
|
605
|
+
right: 20,
|
|
606
|
+
bottom: 20,
|
|
607
|
+
left: 20
|
|
608
|
+
};
|
|
538
609
|
const defaultTickWidth = 40;
|
|
539
|
-
const yAxisOrientation = _optionalChain([options, 'access',
|
|
610
|
+
const yAxisOrientation = _optionalChain([options, 'access', _25 => _25.axis, 'optionalAccess', _26 => _26.y, 'optionalAccess', _27 => _27.orientation]);
|
|
540
611
|
const yAxisStyles = yAxisOrientation === "right" ? theme.axisStyles.y.right : theme.axisStyles.y.left;
|
|
541
|
-
const yTickWidth = _chunkZVGEDXDPcjs.getLongestTickWidth.call(void 0,
|
|
542
|
-
|
|
543
|
-
_optionalChain([options, 'access', _24 => _24.axis, 'optionalAccess', _25 => _25.y, 'optionalAccess', _26 => _26.tickFormat]),
|
|
544
|
-
yAxisStyles.axisLabel
|
|
545
|
-
);
|
|
546
|
-
const yMarginValue = (_nullishCoalesce(yTickWidth, () => ( defaultTickWidth))) + (_nullishCoalesce(_optionalChain([yAxisStyles, 'optionalAccess', _27 => _27.tickLength]), () => ( 0)));
|
|
612
|
+
const yTickWidth = _chunkZVGEDXDPcjs.getLongestTickWidth.call(void 0, yTicks, _optionalChain([options, 'access', _28 => _28.axis, 'optionalAccess', _29 => _29.y, 'optionalAccess', _30 => _30.tickFormat]), yAxisStyles.axisLabel);
|
|
613
|
+
const yMarginValue = (_nullishCoalesce(yTickWidth, () => ( defaultTickWidth))) + (_nullishCoalesce(_optionalChain([yAxisStyles, 'optionalAccess', _31 => _31.tickLength]), () => ( 0)));
|
|
547
614
|
if (yAxisOrientation === "right") {
|
|
548
615
|
defaultMargin.right = yMarginValue;
|
|
549
616
|
} else {
|
|
550
617
|
defaultMargin.left = yMarginValue;
|
|
551
618
|
}
|
|
552
|
-
if (_optionalChain([options, 'access',
|
|
619
|
+
if (_optionalChain([options, 'access', _32 => _32.axis, 'optionalAccess', _33 => _33.x, 'optionalAccess', _34 => _34.orientation]) === "top") {
|
|
553
620
|
defaultMargin.top = 20;
|
|
554
621
|
defaultMargin.bottom = 10;
|
|
555
622
|
}
|
|
@@ -590,7 +657,7 @@ function useElementHeight({
|
|
|
590
657
|
|
|
591
658
|
// src/charts/private/single-chart-context/single-chart-context.tsx
|
|
592
659
|
|
|
593
|
-
var ChartInstanceContext = _react.createContext.call(void 0, null);
|
|
660
|
+
var ChartInstanceContext = /* @__PURE__ */ _react.createContext.call(void 0, null);
|
|
594
661
|
var SingleChartContext = ChartInstanceContext;
|
|
595
662
|
|
|
596
663
|
// src/charts/private/single-chart-context/use-single-chart-context.ts
|
|
@@ -611,10 +678,6 @@ var _legend = require('@visx/legend');
|
|
|
611
678
|
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
612
679
|
|
|
613
680
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
681
|
// src/components/legend/utils/value-or-identity.ts
|
|
619
682
|
function valueOrIdentity(_) {
|
|
620
683
|
if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
|
|
@@ -669,241 +732,186 @@ var LegendText = ({
|
|
|
669
732
|
}) => {
|
|
670
733
|
const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
|
|
671
734
|
const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
|
|
672
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
673
|
-
|
|
674
|
-
{
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
},
|
|
686
|
-
title: isEllipsis && isTruncated ? text : void 0,
|
|
687
|
-
children: text
|
|
688
|
-
}
|
|
689
|
-
);
|
|
735
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
736
|
+
ref: textRef,
|
|
737
|
+
className: _clsx2.default.call(void 0, base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
|
|
738
|
+
style: {
|
|
739
|
+
...maxWidth != null && {
|
|
740
|
+
maxWidth,
|
|
741
|
+
minWidth: 0
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
title: isEllipsis && isTruncated ? text : void 0,
|
|
745
|
+
children: text
|
|
746
|
+
});
|
|
690
747
|
};
|
|
691
|
-
var BaseLegend = _react.forwardRef.call(void 0,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
)
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
)
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
748
|
+
var BaseLegend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
749
|
+
items,
|
|
750
|
+
className,
|
|
751
|
+
orientation = "horizontal",
|
|
752
|
+
position = "bottom",
|
|
753
|
+
alignment = "center",
|
|
754
|
+
maxWidth,
|
|
755
|
+
textOverflow = "wrap",
|
|
756
|
+
shape = "rect",
|
|
757
|
+
fill = valueOrIdentityString,
|
|
758
|
+
size = valueOrIdentityString,
|
|
759
|
+
labelFormat = valueOrIdentity,
|
|
760
|
+
labelTransform = labelTransformFactory,
|
|
761
|
+
shapeWidth = 16,
|
|
762
|
+
shapeHeight = 16,
|
|
763
|
+
shapeMargin = "2px 4px 2px 0",
|
|
764
|
+
labelAlign = "left",
|
|
765
|
+
labelFlex = "0 0 auto",
|
|
766
|
+
// Use natural width instead of expanding to fill space
|
|
767
|
+
labelMargin = "0 4px",
|
|
768
|
+
itemMargin = "0",
|
|
769
|
+
itemDirection = "row",
|
|
770
|
+
legendLabelProps,
|
|
771
|
+
legendItemClassName,
|
|
772
|
+
render,
|
|
773
|
+
interactive = false,
|
|
774
|
+
chartId,
|
|
775
|
+
...legendItemProps
|
|
776
|
+
}, ref) => {
|
|
777
|
+
const theme = useGlobalChartsTheme();
|
|
778
|
+
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
779
|
+
const legendScale = _scale.scaleOrdinal.call(void 0, {
|
|
780
|
+
domain: items.map((item) => item.label),
|
|
781
|
+
range: items.map((item) => item.color)
|
|
782
|
+
});
|
|
783
|
+
const domain = legendScale.domain();
|
|
784
|
+
const getShapeStyle = _react.useCallback.call(void 0, ({
|
|
785
|
+
index
|
|
786
|
+
}) => _optionalChain([items, 'access', _35 => _35[index], 'optionalAccess', _36 => _36.shapeStyle]), [items]);
|
|
787
|
+
const handleLegendClick = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
788
|
+
if (interactive && chartId && context) {
|
|
789
|
+
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
790
|
+
}
|
|
791
|
+
}, [interactive, chartId, context]);
|
|
792
|
+
const isSeriesVisible = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
793
|
+
if (!interactive || !chartId || !context) {
|
|
794
|
+
return true;
|
|
795
|
+
}
|
|
796
|
+
return context.isSeriesVisible(chartId, seriesLabel);
|
|
797
|
+
}, [interactive, chartId, context]);
|
|
798
|
+
const createClickHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
799
|
+
if (!interactive) {
|
|
800
|
+
return void 0;
|
|
801
|
+
}
|
|
802
|
+
return () => handleLegendClick(labelText);
|
|
803
|
+
}, [interactive, handleLegendClick]);
|
|
804
|
+
const createKeyDownHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
805
|
+
if (!interactive) {
|
|
806
|
+
return void 0;
|
|
807
|
+
}
|
|
808
|
+
return (event) => {
|
|
809
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
810
|
+
event.preventDefault();
|
|
811
|
+
handleLegendClick(labelText);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
}, [interactive, handleLegendClick]);
|
|
815
|
+
return render ? render(items) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendOrdinal, {
|
|
816
|
+
scale: legendScale,
|
|
817
|
+
labelFormat,
|
|
818
|
+
labelTransform,
|
|
819
|
+
children: (labels) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
820
|
+
ref,
|
|
821
|
+
role: "list",
|
|
822
|
+
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),
|
|
823
|
+
style: {
|
|
824
|
+
flexDirection: orientationToFlexDirection[orientation],
|
|
825
|
+
...theme.legendContainerStyles
|
|
769
826
|
},
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
827
|
+
children: labels.map((label, i) => {
|
|
828
|
+
const visible = isSeriesVisible(label.text);
|
|
829
|
+
const handleClick = createClickHandler(label.text);
|
|
830
|
+
const handleKeyDown = createKeyDownHandler(label.text);
|
|
831
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendItem, {
|
|
832
|
+
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"], legendItemClassName),
|
|
833
|
+
margin: itemMargin,
|
|
834
|
+
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
835
|
+
onClick: handleClick,
|
|
836
|
+
onKeyDown: handleKeyDown,
|
|
837
|
+
role: interactive ? "button" : void 0,
|
|
838
|
+
tabIndex: interactive ? 0 : void 0,
|
|
839
|
+
"aria-pressed": interactive ? visible : void 0,
|
|
840
|
+
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
841
|
+
...legendItemProps,
|
|
842
|
+
children: [_optionalChain([items, 'access', _37 => _37[i], 'optionalAccess', _38 => _38.renderGlyph]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", {
|
|
843
|
+
width: _optionalChain([items, 'access', _39 => _39[i], 'optionalAccess', _40 => _40.glyphSize]) * 2,
|
|
844
|
+
height: _optionalChain([items, 'access', _41 => _41[i], 'optionalAccess', _42 => _42.glyphSize]) * 2,
|
|
845
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _group.Group, {
|
|
846
|
+
children: _optionalChain([items, 'access', _43 => _43[i], 'optionalAccess', _44 => _44.renderGlyph, 'call', _45 => _45({
|
|
847
|
+
key: `legend-glyph-${label.text}`,
|
|
848
|
+
datum: {},
|
|
849
|
+
index: i,
|
|
850
|
+
color: fill(label),
|
|
851
|
+
size: _optionalChain([items, 'access', _46 => _46[i], 'optionalAccess', _47 => _47.glyphSize]),
|
|
852
|
+
x: _optionalChain([items, 'access', _48 => _48[i], 'optionalAccess', _49 => _49.glyphSize]),
|
|
853
|
+
y: _optionalChain([items, 'access', _50 => _50[i], 'optionalAccess', _51 => _51.glyphSize])
|
|
854
|
+
})])
|
|
855
|
+
})
|
|
856
|
+
}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendShape, {
|
|
857
|
+
shape,
|
|
858
|
+
height: shapeHeight,
|
|
859
|
+
width: shapeWidth,
|
|
860
|
+
margin: shapeMargin,
|
|
861
|
+
item: domain[i],
|
|
862
|
+
itemIndex: i,
|
|
863
|
+
label,
|
|
864
|
+
fill,
|
|
865
|
+
size,
|
|
866
|
+
shapeStyle: getShapeStyle
|
|
867
|
+
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendLabel, {
|
|
868
|
+
className: _clsx2.default.call(void 0, "visx-legend-label", base_legend_module_default["legend-item-label"]),
|
|
791
869
|
style: {
|
|
792
|
-
|
|
793
|
-
|
|
870
|
+
justifyContent: labelAlign,
|
|
871
|
+
flex: labelFlex,
|
|
872
|
+
margin: labelMargin,
|
|
873
|
+
...theme.legendLabelStyles
|
|
794
874
|
},
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
margin: itemMargin,
|
|
811
|
-
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
812
|
-
onClick: handleClick,
|
|
813
|
-
onKeyDown: handleKeyDown,
|
|
814
|
-
role: interactive ? "button" : void 0,
|
|
815
|
-
tabIndex: interactive ? 0 : void 0,
|
|
816
|
-
"aria-pressed": interactive ? visible : void 0,
|
|
817
|
-
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
818
|
-
...legendItemProps,
|
|
819
|
-
children: [
|
|
820
|
-
_optionalChain([items, 'access', _33 => _33[i], 'optionalAccess', _34 => _34.renderGlyph]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
821
|
-
"svg",
|
|
822
|
-
{
|
|
823
|
-
width: _optionalChain([items, 'access', _35 => _35[i], 'optionalAccess', _36 => _36.glyphSize]) * 2,
|
|
824
|
-
height: _optionalChain([items, 'access', _37 => _37[i], 'optionalAccess', _38 => _38.glyphSize]) * 2,
|
|
825
|
-
"data-testid": "legend-glyph",
|
|
826
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _group.Group, { children: _optionalChain([items, 'access', _39 => _39[i], 'optionalAccess', _40 => _40.renderGlyph, 'call', _41 => _41({
|
|
827
|
-
key: `legend-glyph-${label.text}`,
|
|
828
|
-
datum: {},
|
|
829
|
-
index: i,
|
|
830
|
-
color: fill(label),
|
|
831
|
-
size: _optionalChain([items, 'access', _42 => _42[i], 'optionalAccess', _43 => _43.glyphSize]),
|
|
832
|
-
x: _optionalChain([items, 'access', _44 => _44[i], 'optionalAccess', _45 => _45.glyphSize]),
|
|
833
|
-
y: _optionalChain([items, 'access', _46 => _46[i], 'optionalAccess', _47 => _47.glyphSize])
|
|
834
|
-
})]) })
|
|
835
|
-
}
|
|
836
|
-
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
837
|
-
_legend.LegendShape,
|
|
838
|
-
{
|
|
839
|
-
shape,
|
|
840
|
-
height: shapeHeight,
|
|
841
|
-
width: shapeWidth,
|
|
842
|
-
margin: shapeMargin,
|
|
843
|
-
item: domain[i],
|
|
844
|
-
itemIndex: i,
|
|
845
|
-
label,
|
|
846
|
-
fill,
|
|
847
|
-
size,
|
|
848
|
-
shapeStyle: getShapeStyle
|
|
849
|
-
}
|
|
850
|
-
),
|
|
851
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
852
|
-
_legend.LegendLabel,
|
|
853
|
-
{
|
|
854
|
-
className: _clsx2.default.call(void 0, "visx-legend-label", base_legend_module_default["legend-item-label"]),
|
|
855
|
-
style: {
|
|
856
|
-
justifyContent: labelAlign,
|
|
857
|
-
flex: labelFlex,
|
|
858
|
-
margin: labelMargin,
|
|
859
|
-
...theme.legendLabelStyles
|
|
860
|
-
},
|
|
861
|
-
...legendLabelProps,
|
|
862
|
-
children: [
|
|
863
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
864
|
-
LegendText,
|
|
865
|
-
{
|
|
866
|
-
text: label.text,
|
|
867
|
-
textOverflow,
|
|
868
|
-
maxWidth
|
|
869
|
-
}
|
|
870
|
-
),
|
|
871
|
-
_optionalChain([items, 'access', _48 => _48.find, 'call', _49 => _49((item) => item.label === label.text), 'optionalAccess', _50 => _50.value]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: base_legend_module_default["legend-item-value"], children: [
|
|
872
|
-
"\xA0",
|
|
873
|
-
_optionalChain([items, 'access', _51 => _51.find, 'call', _52 => _52((item) => item.label === label.text), 'optionalAccess', _53 => _53.value])
|
|
874
|
-
] })
|
|
875
|
-
]
|
|
876
|
-
}
|
|
877
|
-
)
|
|
878
|
-
]
|
|
879
|
-
},
|
|
880
|
-
`legend-${label.text}-${i}`
|
|
881
|
-
);
|
|
882
|
-
})
|
|
883
|
-
}
|
|
884
|
-
)
|
|
885
|
-
}
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
);
|
|
875
|
+
...legendLabelProps,
|
|
876
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LegendText, {
|
|
877
|
+
text: label.text,
|
|
878
|
+
textOverflow,
|
|
879
|
+
maxWidth
|
|
880
|
+
}), _optionalChain([items, 'access', _52 => _52.find, 'call', _53 => _53((item) => item.label === label.text), 'optionalAccess', _54 => _54.value]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
881
|
+
className: base_legend_module_default["legend-item-value"],
|
|
882
|
+
children: ["\xA0", _optionalChain([items, 'access', _55 => _55.find, 'call', _56 => _56((item) => item.label === label.text), 'optionalAccess', _57 => _57.value])]
|
|
883
|
+
})]
|
|
884
|
+
})]
|
|
885
|
+
}, `legend-${label.text}-${i}`);
|
|
886
|
+
})
|
|
887
|
+
})
|
|
888
|
+
});
|
|
889
|
+
});
|
|
889
890
|
|
|
890
891
|
// src/components/legend/legend.tsx
|
|
891
892
|
|
|
892
|
-
var Legend = _react.forwardRef.call(void 0,
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
893
|
+
var Legend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
894
|
+
chartId,
|
|
895
|
+
items,
|
|
896
|
+
...props
|
|
897
|
+
}, ref) => {
|
|
898
|
+
const context = _react.useContext.call(void 0, GlobalChartsContext);
|
|
899
|
+
const singleChartContext = _react.useContext.call(void 0, SingleChartContext);
|
|
900
|
+
const contextChartId = _nullishCoalesce(chartId, () => ( _optionalChain([singleChartContext, 'optionalAccess', _58 => _58.chartId])));
|
|
901
|
+
const contextItems = _react.useMemo.call(void 0, () => {
|
|
902
|
+
return contextChartId && context ? _optionalChain([context, 'access', _59 => _59.getChartData, 'call', _60 => _60(contextChartId), 'optionalAccess', _61 => _61.legendItems]) : void 0;
|
|
903
|
+
}, [contextChartId, context]);
|
|
904
|
+
const legendItems = items || contextItems;
|
|
905
|
+
if (!legendItems) {
|
|
906
|
+
return null;
|
|
905
907
|
}
|
|
906
|
-
|
|
908
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseLegend, {
|
|
909
|
+
ref,
|
|
910
|
+
items: legendItems,
|
|
911
|
+
...props,
|
|
912
|
+
chartId: contextChartId
|
|
913
|
+
});
|
|
914
|
+
});
|
|
907
915
|
|
|
908
916
|
// src/components/legend/hooks/use-chart-legend-items.ts
|
|
909
917
|
var _numberformatters = require('@automattic/number-formatters');
|
|
@@ -952,7 +960,7 @@ function processSeriesData(seriesData, getElementStyles, showValues, withGlyph,
|
|
|
952
960
|
});
|
|
953
961
|
const baseItem = {
|
|
954
962
|
label: series.label,
|
|
955
|
-
value: showValues ? _optionalChain([series, 'access',
|
|
963
|
+
value: showValues ? _optionalChain([series, 'access', _62 => _62.data, 'optionalAccess', _63 => _63.length, 'optionalAccess', _64 => _64.toString, 'call', _65 => _65()]) || "0" : "",
|
|
956
964
|
color,
|
|
957
965
|
shapeStyle: shapeStyles
|
|
958
966
|
};
|
|
@@ -1185,5 +1193,6 @@ function usePrefersReducedMotion() {
|
|
|
1185
1193
|
|
|
1186
1194
|
|
|
1187
1195
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1196
|
+
|
|
1197
|
+
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.useElementHeight = useElementHeight; 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;
|
|
1198
|
+
//# sourceMappingURL=chunk-LSV7F26B.cjs.map
|