@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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
|
-
var _chunkSH32YSZOcjs = require('./chunk-SH32YSZO.cjs');
|
|
4
3
|
|
|
4
|
+
var _chunkY3NNQMAXcjs = require('./chunk-Y3NNQMAX.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSH32YSZOcjs = require('./chunk-SH32YSZO.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk7QDEU3KNcjs = require('./chunk-7QDEU3KN.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ var _chunkNW3RUYK2cjs = require('./chunk-NW3RUYK2.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _chunkLSV7F26Bcjs = require('./chunk-LSV7F26B.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
@@ -71,7 +71,10 @@ var TruncatedTickComponent = ({
|
|
|
71
71
|
dy,
|
|
72
72
|
...textProps
|
|
73
73
|
}) => {
|
|
74
|
-
const {
|
|
74
|
+
const {
|
|
75
|
+
xScale,
|
|
76
|
+
yScale
|
|
77
|
+
} = _react.useContext.call(void 0, _xychart.DataContext) || {};
|
|
75
78
|
const scale = axis === "x" ? xScale : yScale;
|
|
76
79
|
const bandwidth = getScaleBandwidth(scale);
|
|
77
80
|
const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);
|
|
@@ -89,7 +92,14 @@ var TruncatedTickComponent = ({
|
|
|
89
92
|
} else if (textAlign === "right") {
|
|
90
93
|
xOffset = -maxWidth;
|
|
91
94
|
}
|
|
92
|
-
const {
|
|
95
|
+
const {
|
|
96
|
+
fontSize,
|
|
97
|
+
fontFamily,
|
|
98
|
+
fontWeight,
|
|
99
|
+
fontStyle,
|
|
100
|
+
letterSpacing,
|
|
101
|
+
opacity
|
|
102
|
+
} = textProps;
|
|
93
103
|
const textStyles = {
|
|
94
104
|
/**
|
|
95
105
|
* SVG <text> elements are vertically aligned to the baseline by default, but HTML <div> elements inside <foreignObject>
|
|
@@ -98,7 +108,9 @@ var TruncatedTickComponent = ({
|
|
|
98
108
|
*/
|
|
99
109
|
transform: `translateY(calc(-100% + ${_nullishCoalesce(dy, () => ( "0"))} * 2))`,
|
|
100
110
|
// Safari doesn't work well with foreignObject positioning. Use position: fixed as a workaround.
|
|
101
|
-
..._chunkZVGEDXDPcjs.isSafari.call(void 0, ) ? {
|
|
111
|
+
..._chunkZVGEDXDPcjs.isSafari.call(void 0, ) ? {
|
|
112
|
+
position: "fixed"
|
|
113
|
+
} : {},
|
|
102
114
|
// Apply compatible SVG text styles
|
|
103
115
|
fontSize,
|
|
104
116
|
fontFamily,
|
|
@@ -118,10 +130,24 @@ var TruncatedTickComponent = ({
|
|
|
118
130
|
cursor: "default",
|
|
119
131
|
pointerEvents: "auto"
|
|
120
132
|
};
|
|
121
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "foreignObject", {
|
|
133
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "foreignObject", {
|
|
134
|
+
x: x + xOffset,
|
|
135
|
+
y,
|
|
136
|
+
width: maxWidth,
|
|
137
|
+
height: 0,
|
|
138
|
+
overflow: "visible",
|
|
139
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
140
|
+
style: textStyles,
|
|
141
|
+
title: formattedValue,
|
|
142
|
+
children: formattedValue
|
|
143
|
+
})
|
|
144
|
+
});
|
|
122
145
|
};
|
|
123
146
|
var createTruncatedTickComponent = (axis) => (props) => {
|
|
124
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TruncatedTickComponent, {
|
|
147
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TruncatedTickComponent, {
|
|
148
|
+
...props,
|
|
149
|
+
axis
|
|
150
|
+
});
|
|
125
151
|
};
|
|
126
152
|
var TruncatedXTickComponent = createTruncatedTickComponent("x");
|
|
127
153
|
var TruncatedYTickComponent = createTruncatedTickComponent("y");
|
|
@@ -234,11 +260,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
234
260
|
|
|
235
261
|
var validateData = (data) => {
|
|
236
262
|
if (!_optionalChain([data, 'optionalAccess', _19 => _19.length])) return "No data available";
|
|
237
|
-
const hasInvalidData = data.some(
|
|
238
|
-
(series) => series.data.some(
|
|
239
|
-
(point) => isNaN(point.value) || point.value === null || point.value === void 0 || !point.label && (!("date" in point && point.date) || isNaN(point.date.getTime()))
|
|
240
|
-
)
|
|
241
|
-
);
|
|
263
|
+
const hasInvalidData = data.some((series) => series.data.some((point) => isNaN(point.value) || point.value === null || point.value === void 0 || !point.label && (!("date" in point && point.date) || isNaN(point.date.getTime()))));
|
|
242
264
|
if (hasInvalidData) return "Invalid data";
|
|
243
265
|
return null;
|
|
244
266
|
};
|
|
@@ -271,25 +293,30 @@ var BarChartInternal = ({
|
|
|
271
293
|
gap = "md"
|
|
272
294
|
}) => {
|
|
273
295
|
const horizontal = orientation === "horizontal";
|
|
274
|
-
const chartId =
|
|
275
|
-
const theme =
|
|
276
|
-
const dataSorted =
|
|
277
|
-
const dataWithVisibleZeros =
|
|
296
|
+
const chartId = _chunkLSV7F26Bcjs.useChartId.call(void 0, providedChartId);
|
|
297
|
+
const theme = _chunkLSV7F26Bcjs.useXYChartTheme.call(void 0, data);
|
|
298
|
+
const dataSorted = _chunkLSV7F26Bcjs.useChartDataTransform.call(void 0, data);
|
|
299
|
+
const dataWithVisibleZeros = _chunkLSV7F26Bcjs.useZeroValueDisplay.call(void 0, dataSorted, {
|
|
278
300
|
enabled: showZeroValues
|
|
279
301
|
});
|
|
280
|
-
const legendItems =
|
|
302
|
+
const legendItems = _chunkLSV7F26Bcjs.useChartLegendItems.call(void 0, dataSorted);
|
|
281
303
|
const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, options);
|
|
282
|
-
const defaultMargin =
|
|
283
|
-
const [svgWrapperRef, svgWrapperHeight] =
|
|
304
|
+
const defaultMargin = _chunkLSV7F26Bcjs.useChartMargin.call(void 0, height, chartOptions, dataSorted, theme, horizontal);
|
|
305
|
+
const [svgWrapperRef, svgWrapperHeight] = _chunkLSV7F26Bcjs.useElementHeight.call(void 0, );
|
|
284
306
|
const chartRef = _react.useRef.call(void 0, null);
|
|
285
|
-
const hasLegendChild =
|
|
307
|
+
const hasLegendChild = _chunkLSV7F26Bcjs.useHasLegendChild.call(void 0, children);
|
|
286
308
|
const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;
|
|
287
309
|
const hasLegend = showLegend || hasLegendChild;
|
|
288
310
|
const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;
|
|
289
311
|
const [selectedIndex, setSelectedIndex] = _react.useState.call(void 0, void 0);
|
|
290
312
|
const [isNavigating, setIsNavigating] = _react.useState.call(void 0, false);
|
|
291
313
|
const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access', _20 => _20.data, 'optionalAccess', _21 => _21.length]) || 0)) * data.length;
|
|
292
|
-
const {
|
|
314
|
+
const {
|
|
315
|
+
tooltipRef,
|
|
316
|
+
onChartFocus,
|
|
317
|
+
onChartBlur,
|
|
318
|
+
onChartKeyDown
|
|
319
|
+
} = _chunkY3NNQMAXcjs.useKeyboardNavigation.call(void 0, {
|
|
293
320
|
selectedIndex,
|
|
294
321
|
setSelectedIndex,
|
|
295
322
|
isNavigating,
|
|
@@ -297,8 +324,11 @@ var BarChartInternal = ({
|
|
|
297
324
|
chartRef,
|
|
298
325
|
totalPoints
|
|
299
326
|
});
|
|
300
|
-
const {
|
|
301
|
-
|
|
327
|
+
const {
|
|
328
|
+
getElementStyles,
|
|
329
|
+
isSeriesVisible
|
|
330
|
+
} = _chunkLSV7F26Bcjs.useGlobalChartsContext.call(void 0, );
|
|
331
|
+
const providerTheme = _chunkLSV7F26Bcjs.useGlobalChartsTheme.call(void 0, );
|
|
302
332
|
const seriesWithVisibility = _react.useMemo.call(void 0, () => {
|
|
303
333
|
if (!chartId || !legendInteractive) {
|
|
304
334
|
return dataWithVisibleZeros.map((series, index) => ({
|
|
@@ -314,78 +344,84 @@ var BarChartInternal = ({
|
|
|
314
344
|
}));
|
|
315
345
|
}, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);
|
|
316
346
|
const allSeriesHidden = _react.useMemo.call(void 0, () => {
|
|
317
|
-
return seriesWithVisibility.every(({
|
|
347
|
+
return seriesWithVisibility.every(({
|
|
348
|
+
isVisible
|
|
349
|
+
}) => !isVisible);
|
|
318
350
|
}, [seriesWithVisibility]);
|
|
319
|
-
const getBarBackground = _react.useCallback.call(void 0,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
);
|
|
323
|
-
const renderDefaultTooltip = _react.useCallback.call(void 0,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
351
|
+
const getBarBackground = _react.useCallback.call(void 0, (index) => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({
|
|
352
|
+
data: dataSorted[index],
|
|
353
|
+
index
|
|
354
|
+
}).color, [withPatterns, getElementStyles, dataSorted, chartId]);
|
|
355
|
+
const renderDefaultTooltip = _react.useCallback.call(void 0, ({
|
|
356
|
+
tooltipData
|
|
357
|
+
}) => {
|
|
358
|
+
const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _22 => _22.nearestDatum, 'optionalAccess', _23 => _23.datum]);
|
|
359
|
+
if (!nearestDatum) return null;
|
|
360
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
361
|
+
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
362
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
363
|
+
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
364
|
+
children: _optionalChain([tooltipData, 'optionalAccess', _24 => _24.nearestDatum, 'optionalAccess', _25 => _25.key])
|
|
365
|
+
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
366
|
+
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
367
|
+
children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
368
|
+
className: bar_chart_module_default["bar-chart__tooltip-label"],
|
|
369
|
+
children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), ":"]
|
|
370
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
371
|
+
className: bar_chart_module_default["bar-chart__tooltip-value"],
|
|
372
|
+
children: _numberformatters.formatNumber.call(void 0, nearestDatum.value)
|
|
373
|
+
})]
|
|
374
|
+
})]
|
|
375
|
+
});
|
|
376
|
+
}, [chartOptions.tooltip]);
|
|
377
|
+
const renderPattern = _react.useCallback.call(void 0, (index, color) => {
|
|
378
|
+
const patternType = index % 4;
|
|
379
|
+
const id = getPatternId(chartId, index);
|
|
380
|
+
const commonProps = {
|
|
381
|
+
id,
|
|
382
|
+
stroke: "white",
|
|
383
|
+
strokeWidth: 1,
|
|
384
|
+
background: color
|
|
385
|
+
};
|
|
386
|
+
switch (patternType) {
|
|
387
|
+
case 0:
|
|
388
|
+
default:
|
|
389
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternLines, {
|
|
390
|
+
...commonProps,
|
|
391
|
+
width: 5,
|
|
392
|
+
height: 5,
|
|
393
|
+
orientation: ["diagonal"]
|
|
394
|
+
}, id);
|
|
395
|
+
case 1:
|
|
396
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternCircles, {
|
|
397
|
+
...commonProps,
|
|
398
|
+
width: 6,
|
|
399
|
+
height: 6,
|
|
400
|
+
fill: "white"
|
|
401
|
+
}, id);
|
|
402
|
+
case 2:
|
|
403
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternWaves, {
|
|
404
|
+
...commonProps,
|
|
405
|
+
width: 4,
|
|
406
|
+
height: 4
|
|
407
|
+
}, id);
|
|
408
|
+
case 3:
|
|
409
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternHexagons, {
|
|
410
|
+
...commonProps,
|
|
411
|
+
size: 8,
|
|
412
|
+
height: 3
|
|
413
|
+
}, id);
|
|
414
|
+
}
|
|
415
|
+
}, [chartId]);
|
|
416
|
+
const createPatternBorderStyle = _react.useCallback.call(void 0, (index, color) => {
|
|
417
|
+
const patternId = getPatternId(chartId, index);
|
|
418
|
+
return `
|
|
381
419
|
.visx-bar[fill="url(#${patternId})"] {
|
|
382
420
|
stroke: ${color};
|
|
383
421
|
stroke-width: 1;
|
|
384
422
|
}
|
|
385
423
|
`;
|
|
386
|
-
|
|
387
|
-
[chartId]
|
|
388
|
-
);
|
|
424
|
+
}, [chartId]);
|
|
389
425
|
const createKeyboardHighlightStyle = _react.useCallback.call(void 0, () => {
|
|
390
426
|
if (selectedIndex === void 0) return "";
|
|
391
427
|
const maxDataPoints = Math.max(...data.map((s) => s.data.length));
|
|
@@ -409,200 +445,167 @@ var BarChartInternal = ({
|
|
|
409
445
|
}, [selectedIndex, data, chartId]);
|
|
410
446
|
const error = validateData(dataSorted);
|
|
411
447
|
const isDataValid = !error;
|
|
412
|
-
const chartMetadata = _react.useMemo.call(void 0,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
[orientation, withPatterns]
|
|
418
|
-
);
|
|
419
|
-
_chunkTVV7ZI7Ccjs.useChartRegistration.call(void 0, {
|
|
448
|
+
const chartMetadata = _react.useMemo.call(void 0, () => ({
|
|
449
|
+
orientation,
|
|
450
|
+
withPatterns
|
|
451
|
+
}), [orientation, withPatterns]);
|
|
452
|
+
_chunkLSV7F26Bcjs.useChartRegistration.call(void 0, {
|
|
420
453
|
chartId,
|
|
421
454
|
legendItems,
|
|
422
455
|
chartType: "bar",
|
|
423
456
|
isDataValid,
|
|
424
457
|
metadata: chartMetadata
|
|
425
458
|
});
|
|
426
|
-
const prefersReducedMotion =
|
|
459
|
+
const prefersReducedMotion = _chunkLSV7F26Bcjs.usePrefersReducedMotion.call(void 0, );
|
|
427
460
|
if (error) {
|
|
428
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
461
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
462
|
+
className: _clsx2.default.call(void 0, "bar-chart", bar_chart_module_default["bar-chart"]),
|
|
463
|
+
children: error
|
|
464
|
+
});
|
|
429
465
|
}
|
|
430
466
|
const gridVisibility = _nullishCoalesce(gridVisibilityProp, () => ( chartOptions.gridVisibility));
|
|
431
467
|
const highlightedBarStyle = createKeyboardHighlightStyle();
|
|
432
|
-
const legendElement = showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
468
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.Legend, {
|
|
469
|
+
orientation: legendOrientation,
|
|
470
|
+
position: legendPosition,
|
|
471
|
+
alignment: legendAlignment,
|
|
472
|
+
maxWidth: legendMaxWidth,
|
|
473
|
+
textOverflow: legendTextOverflow,
|
|
474
|
+
legendItemClassName,
|
|
475
|
+
className: bar_chart_module_default["bar-chart__legend"],
|
|
476
|
+
shape: legendShape,
|
|
477
|
+
chartId,
|
|
478
|
+
interactive: legendInteractive
|
|
479
|
+
});
|
|
480
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.SingleChartContext.Provider, {
|
|
481
|
+
value: {
|
|
443
482
|
chartId,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
483
|
+
chartWidth: width,
|
|
484
|
+
chartHeight
|
|
485
|
+
},
|
|
486
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkSH32YSZOcjs.Stack, {
|
|
487
|
+
direction: "column",
|
|
488
|
+
gap,
|
|
489
|
+
className: _clsx2.default.call(void 0, "bar-chart", bar_chart_module_default["bar-chart"], {
|
|
490
|
+
[bar_chart_module_default[`bar-chart--animated${horizontal ? "-horizontal" : ""}`]]: animation && !prefersReducedMotion
|
|
491
|
+
}, className),
|
|
492
|
+
style: {
|
|
493
|
+
width,
|
|
494
|
+
height,
|
|
495
|
+
visibility: isWaitingForMeasurement ? "hidden" : "visible"
|
|
454
496
|
},
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
style: {
|
|
497
|
+
"data-chart-id": `bar-chart-${chartId}`,
|
|
498
|
+
children: [legendPosition === "top" && legendElement, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
499
|
+
className: bar_chart_module_default["bar-chart__svg-wrapper"],
|
|
500
|
+
ref: svgWrapperRef,
|
|
501
|
+
role: "grid",
|
|
502
|
+
"aria-label": _i18n.__.call(void 0, "Bar chart", "jetpack-charts"),
|
|
503
|
+
tabIndex: 0,
|
|
504
|
+
onKeyDown: onChartKeyDown,
|
|
505
|
+
onFocus: onChartFocus,
|
|
506
|
+
onBlur: onChartBlur,
|
|
507
|
+
children: !isWaitingForMeasurement && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
508
|
+
ref: chartRef,
|
|
509
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _xychart.XYChart, {
|
|
510
|
+
theme,
|
|
470
511
|
width,
|
|
471
|
-
height,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
546
|
-
_xychart.BarSeries,
|
|
547
|
-
{
|
|
548
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess', _28 => _28.label]),
|
|
549
|
-
data: seriesData.data,
|
|
550
|
-
yAccessor: chartOptions.accessors.yAccessor,
|
|
551
|
-
xAccessor: chartOptions.accessors.xAccessor,
|
|
552
|
-
colorAccessor: getBarBackground(index)
|
|
553
|
-
},
|
|
554
|
-
_optionalChain([seriesData, 'optionalAccess', _29 => _29.label])
|
|
555
|
-
);
|
|
556
|
-
}) }),
|
|
557
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, { ...chartOptions.axis.x }),
|
|
558
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, { ...chartOptions.axis.y }),
|
|
559
|
-
withTooltips && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
560
|
-
_chunk7HROSZRScjs.AccessibleTooltip,
|
|
561
|
-
{
|
|
562
|
-
detectBounds: true,
|
|
563
|
-
snapTooltipToDatumX: true,
|
|
564
|
-
snapTooltipToDatumY: true,
|
|
565
|
-
renderTooltip: renderTooltip || renderDefaultTooltip,
|
|
566
|
-
selectedIndex,
|
|
567
|
-
tooltipRef,
|
|
568
|
-
keyboardFocusedClassName: bar_chart_module_default["bar-chart__tooltip--keyboard-focused"],
|
|
569
|
-
series: data,
|
|
570
|
-
mode: "individual"
|
|
571
|
-
}
|
|
572
|
-
)
|
|
573
|
-
]
|
|
574
|
-
}
|
|
575
|
-
) })
|
|
576
|
-
}
|
|
577
|
-
),
|
|
578
|
-
legendPosition === "bottom" && legendElement,
|
|
579
|
-
children
|
|
580
|
-
]
|
|
581
|
-
}
|
|
582
|
-
)
|
|
583
|
-
}
|
|
584
|
-
);
|
|
512
|
+
height: chartHeight,
|
|
513
|
+
margin: {
|
|
514
|
+
...defaultMargin,
|
|
515
|
+
...margin
|
|
516
|
+
},
|
|
517
|
+
xScale: chartOptions.xScale,
|
|
518
|
+
yScale: chartOptions.yScale,
|
|
519
|
+
horizontal,
|
|
520
|
+
pointerEventsDataKey: "nearest",
|
|
521
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Grid, {
|
|
522
|
+
columns: gridVisibility.includes("y"),
|
|
523
|
+
rows: gridVisibility.includes("x"),
|
|
524
|
+
numTicks: 4
|
|
525
|
+
}), withPatterns && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
526
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "defs", {
|
|
527
|
+
children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({
|
|
528
|
+
data: seriesData,
|
|
529
|
+
index
|
|
530
|
+
}).color))
|
|
531
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", {
|
|
532
|
+
children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({
|
|
533
|
+
data: seriesData,
|
|
534
|
+
index
|
|
535
|
+
}).color))
|
|
536
|
+
})]
|
|
537
|
+
}), highlightedBarStyle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", {
|
|
538
|
+
children: highlightedBarStyle
|
|
539
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
540
|
+
x: width / 2,
|
|
541
|
+
y: chartHeight / 2,
|
|
542
|
+
textAnchor: "middle",
|
|
543
|
+
fill: _optionalChain([providerTheme, 'access', _26 => _26.gridStyles, 'optionalAccess', _27 => _27.stroke]) || "#ccc",
|
|
544
|
+
fontSize: "14",
|
|
545
|
+
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
546
|
+
children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
547
|
+
}) : null, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarGroup, {
|
|
548
|
+
padding: chartOptions.barGroup.padding,
|
|
549
|
+
children: seriesWithVisibility.map(({
|
|
550
|
+
series: seriesData,
|
|
551
|
+
index,
|
|
552
|
+
isVisible
|
|
553
|
+
}) => {
|
|
554
|
+
if (!isVisible) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarSeries, {
|
|
558
|
+
dataKey: _optionalChain([seriesData, 'optionalAccess', _28 => _28.label]),
|
|
559
|
+
data: seriesData.data,
|
|
560
|
+
yAccessor: chartOptions.accessors.yAccessor,
|
|
561
|
+
xAccessor: chartOptions.accessors.xAccessor,
|
|
562
|
+
colorAccessor: getBarBackground(index)
|
|
563
|
+
}, _optionalChain([seriesData, 'optionalAccess', _29 => _29.label]));
|
|
564
|
+
})
|
|
565
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
566
|
+
...chartOptions.axis.x
|
|
567
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
568
|
+
...chartOptions.axis.y
|
|
569
|
+
}), withTooltips && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3NNQMAXcjs.AccessibleTooltip, {
|
|
570
|
+
detectBounds: true,
|
|
571
|
+
snapTooltipToDatumX: true,
|
|
572
|
+
snapTooltipToDatumY: true,
|
|
573
|
+
renderTooltip: renderTooltip || renderDefaultTooltip,
|
|
574
|
+
selectedIndex,
|
|
575
|
+
tooltipRef,
|
|
576
|
+
keyboardFocusedClassName: bar_chart_module_default["bar-chart__tooltip--keyboard-focused"],
|
|
577
|
+
series: data,
|
|
578
|
+
mode: "individual"
|
|
579
|
+
})]
|
|
580
|
+
})
|
|
581
|
+
})
|
|
582
|
+
}), legendPosition === "bottom" && legendElement, children]
|
|
583
|
+
})
|
|
584
|
+
});
|
|
585
585
|
};
|
|
586
586
|
var BarChartWithProvider = (props) => {
|
|
587
|
-
const existingContext = _react.useContext.call(void 0,
|
|
587
|
+
const existingContext = _react.useContext.call(void 0, _chunkLSV7F26Bcjs.GlobalChartsContext);
|
|
588
588
|
if (existingContext) {
|
|
589
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BarChartInternal, {
|
|
589
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BarChartInternal, {
|
|
590
|
+
...props
|
|
591
|
+
});
|
|
590
592
|
}
|
|
591
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
593
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.GlobalChartsProvider, {
|
|
594
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BarChartInternal, {
|
|
595
|
+
...props
|
|
596
|
+
})
|
|
597
|
+
});
|
|
592
598
|
};
|
|
593
599
|
BarChartWithProvider.displayName = "BarChart";
|
|
594
600
|
var BarChart = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, BarChartWithProvider, {
|
|
595
|
-
Legend:
|
|
601
|
+
Legend: _chunkLSV7F26Bcjs.Legend
|
|
602
|
+
});
|
|
603
|
+
var BarChartResponsive = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, _chunk7QDEU3KNcjs.withResponsive.call(void 0, BarChartWithProvider), {
|
|
604
|
+
Legend: _chunkLSV7F26Bcjs.Legend
|
|
596
605
|
});
|
|
597
|
-
var BarChartResponsive = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0,
|
|
598
|
-
_chunkNW3RUYK2cjs.withResponsive.call(void 0, BarChartWithProvider),
|
|
599
|
-
{
|
|
600
|
-
Legend: _chunkTVV7ZI7Ccjs.Legend
|
|
601
|
-
}
|
|
602
|
-
);
|
|
603
606
|
|
|
604
607
|
|
|
605
608
|
|
|
606
609
|
|
|
607
610
|
exports.BarChart = BarChart; exports.BarChartResponsive = BarChartResponsive;
|
|
608
|
-
//# sourceMappingURL=chunk-
|
|
611
|
+
//# sourceMappingURL=chunk-CERFRCXD.cjs.map
|