@automattic/charts 0.56.3 → 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 +9 -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 +5 -1
- 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
|
@@ -0,0 +1,1065 @@
|
|
|
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
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkY3NNQMAXcjs = require('./chunk-Y3NNQMAX.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkSH32YSZOcjs = require('./chunk-SH32YSZO.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk7QDEU3KNcjs = require('./chunk-7QDEU3KN.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var _chunkLSV7F26Bcjs = require('./chunk-LSV7F26B.cjs');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _chunkZVGEDXDPcjs = require('./chunk-ZVGEDXDP.cjs');
|
|
33
|
+
|
|
34
|
+
// src/charts/line-chart/line-chart.tsx
|
|
35
|
+
var _numberformatters = require('@automattic/number-formatters');
|
|
36
|
+
var _curve = require('@visx/curve');
|
|
37
|
+
var _gradient = require('@visx/gradient');
|
|
38
|
+
var _scale = require('@visx/scale');
|
|
39
|
+
var _xychart = require('@visx/xychart');
|
|
40
|
+
var _i18n = require('@wordpress/i18n');
|
|
41
|
+
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
42
|
+
var _datefns = require('date-fns');
|
|
43
|
+
var _react = require('react');
|
|
44
|
+
|
|
45
|
+
// src/charts/private/default-glyph/default-glyph.tsx
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
49
|
+
var DefaultGlyph = (props) => {
|
|
50
|
+
const {
|
|
51
|
+
theme
|
|
52
|
+
} = _react.useContext.call(void 0, _xychart.DataContext) || {};
|
|
53
|
+
const position = props.position || "start";
|
|
54
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", {
|
|
55
|
+
cx: props.x,
|
|
56
|
+
cy: props.y,
|
|
57
|
+
r: props.size,
|
|
58
|
+
fill: props.color,
|
|
59
|
+
stroke: _optionalChain([theme, 'optionalAccess', _ => _.backgroundColor]),
|
|
60
|
+
strokeWidth: 1.5,
|
|
61
|
+
paintOrder: "fill",
|
|
62
|
+
...props.glyphStyle
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/charts/line-chart/line-chart.module.scss
|
|
67
|
+
var line_chart_module_default = {
|
|
68
|
+
"line-chart": "a8ccharts-v-oO8E",
|
|
69
|
+
"line-chart__svg-wrapper": "a8ccharts-cpMNjj",
|
|
70
|
+
"line-chart--animated": "a8ccharts-QrkuTW",
|
|
71
|
+
"rise": "a8ccharts--rxDU3",
|
|
72
|
+
"line-chart__tooltip": "a8ccharts-Tu0rR-",
|
|
73
|
+
"line-chart__annotation-label-popover": "a8ccharts--RSWXi",
|
|
74
|
+
"line-chart__tooltip-date": "a8ccharts-Q-b5A1",
|
|
75
|
+
"line-chart__tooltip-row": "a8ccharts-19N7T9",
|
|
76
|
+
"line-chart__tooltip-label": "a8ccharts-HOAXrD",
|
|
77
|
+
"line-chart__annotations-overlay": "a8ccharts-rQiY8O",
|
|
78
|
+
"line-chart__annotation-label": "a8ccharts-8AKWOe",
|
|
79
|
+
"line-chart__annotation-label-trigger-button": "a8ccharts-7mh3Cl",
|
|
80
|
+
"line-chart__annotation-label-popover--visible": "a8ccharts-VAeVuJ",
|
|
81
|
+
"line-chart__annotation-label-popover--safari": "a8ccharts-TEe-iV",
|
|
82
|
+
"line-chart__annotation-label-popover-header": "a8ccharts-LAUpx7",
|
|
83
|
+
"line-chart__annotation-label-popover-content": "a8ccharts-b76gEu",
|
|
84
|
+
"line-chart__annotation-label-popover-close-button": "a8ccharts-LIpFoS"
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/charts/line-chart/private/line-chart-annotation-label-popover.tsx
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
var _gridicons = require('gridicons'); var _gridicons2 = _interopRequireDefault(_gridicons);
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
var POPOVER_BUTTON_SIZE = 44;
|
|
94
|
+
var LineChartAnnotationLabelWithPopover = ({
|
|
95
|
+
title,
|
|
96
|
+
subtitle,
|
|
97
|
+
renderLabel,
|
|
98
|
+
renderLabelPopover
|
|
99
|
+
}) => {
|
|
100
|
+
const popoverId = _react.useId.call(void 0, );
|
|
101
|
+
const buttonRef = _react.useRef.call(void 0, null);
|
|
102
|
+
const popoverRef = _react.useRef.call(void 0, null);
|
|
103
|
+
const [isPositioned, setIsPositioned] = _react.useState.call(void 0, false);
|
|
104
|
+
const isBrowserSafari = _chunkZVGEDXDPcjs.isSafari.call(void 0, );
|
|
105
|
+
_react.useEffect.call(void 0, () => {
|
|
106
|
+
const button = buttonRef.current;
|
|
107
|
+
const popover = popoverRef.current;
|
|
108
|
+
if (!button || !popover) return;
|
|
109
|
+
const positionPopover = () => {
|
|
110
|
+
if (!isBrowserSafari) {
|
|
111
|
+
const buttonRect = button.getBoundingClientRect();
|
|
112
|
+
popover.style.left = `${buttonRect.right}px`;
|
|
113
|
+
popover.style.top = `${buttonRect.top}px`;
|
|
114
|
+
}
|
|
115
|
+
setIsPositioned(true);
|
|
116
|
+
};
|
|
117
|
+
popover.addEventListener("toggle", (e) => {
|
|
118
|
+
if (e.newState === "open") {
|
|
119
|
+
positionPopover();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
try {
|
|
123
|
+
if (popover.matches(":popover-open")) {
|
|
124
|
+
positionPopover();
|
|
125
|
+
}
|
|
126
|
+
} catch (e2) {
|
|
127
|
+
}
|
|
128
|
+
}, [isBrowserSafari]);
|
|
129
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
130
|
+
className: line_chart_module_default["line-chart__annotation-label"],
|
|
131
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", {
|
|
132
|
+
ref: buttonRef,
|
|
133
|
+
popovertarget: popoverId,
|
|
134
|
+
className: line_chart_module_default["line-chart__annotation-label-trigger-button"],
|
|
135
|
+
style: {
|
|
136
|
+
width: `${POPOVER_BUTTON_SIZE}px`,
|
|
137
|
+
height: `${POPOVER_BUTTON_SIZE}px`,
|
|
138
|
+
transform: `translate(${POPOVER_BUTTON_SIZE / 2}px, 0)`
|
|
139
|
+
},
|
|
140
|
+
"aria-label": title || _i18n.__.call(void 0, "View details", "jetpack-charts"),
|
|
141
|
+
children: renderLabel({
|
|
142
|
+
title,
|
|
143
|
+
subtitle
|
|
144
|
+
})
|
|
145
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
146
|
+
ref: popoverRef,
|
|
147
|
+
id: popoverId,
|
|
148
|
+
popover: "auto",
|
|
149
|
+
className: _clsx2.default.call(void 0, line_chart_module_default["line-chart__annotation-label-popover"], isPositioned && line_chart_module_default["line-chart__annotation-label-popover--visible"], isBrowserSafari && line_chart_module_default["line-chart__annotation-label-popover--safari"]),
|
|
150
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
151
|
+
className: line_chart_module_default["line-chart__annotation-label-popover-header"],
|
|
152
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
153
|
+
className: line_chart_module_default["line-chart__annotation-label-popover-content"],
|
|
154
|
+
children: renderLabelPopover({
|
|
155
|
+
title,
|
|
156
|
+
subtitle
|
|
157
|
+
})
|
|
158
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", {
|
|
159
|
+
popovertarget: popoverId,
|
|
160
|
+
popovertargetaction: "hide",
|
|
161
|
+
className: line_chart_module_default["line-chart__annotation-label-popover-close-button"],
|
|
162
|
+
"aria-label": _i18n.__.call(void 0, "Close", "jetpack-charts"),
|
|
163
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _gridicons2.default, {
|
|
164
|
+
icon: "cross",
|
|
165
|
+
size: 16
|
|
166
|
+
})
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
var line_chart_annotation_label_popover_default = LineChartAnnotationLabelWithPopover;
|
|
173
|
+
|
|
174
|
+
// src/charts/line-chart/private/line-chart-annotations-overlay.tsx
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
var LineChartAnnotationsOverlay = ({
|
|
179
|
+
children
|
|
180
|
+
}) => {
|
|
181
|
+
const {
|
|
182
|
+
chartRef,
|
|
183
|
+
chartWidth,
|
|
184
|
+
chartHeight
|
|
185
|
+
} = _chunkLSV7F26Bcjs.useSingleChartContext.call(void 0, );
|
|
186
|
+
const [scales, setScales] = _react.useState.call(void 0, null);
|
|
187
|
+
const [scalesStable, setScalesStable] = _react.useState.call(void 0, false);
|
|
188
|
+
const createScaleSignature = _react.useCallback.call(void 0, (scaleData) => {
|
|
189
|
+
const xDomain = scaleData.xScale.domain();
|
|
190
|
+
const yDomain = scaleData.yScale.domain();
|
|
191
|
+
const xRange = scaleData.xScale.range();
|
|
192
|
+
const yRange = scaleData.yScale.range();
|
|
193
|
+
return `${xDomain.join(",")}-${yDomain.join(",")}-${xRange.join(",")}-${yRange.join(",")}`;
|
|
194
|
+
}, []);
|
|
195
|
+
const getScalesData = _react.useCallback.call(void 0, () => {
|
|
196
|
+
if (_optionalChain([chartRef, 'optionalAccess', _2 => _2.current])) {
|
|
197
|
+
const scaleData = chartRef.current.getScales();
|
|
198
|
+
if (scaleData) {
|
|
199
|
+
const scaleInfo = {
|
|
200
|
+
xScale: scaleData.xScale,
|
|
201
|
+
yScale: scaleData.yScale
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
scales: scaleInfo,
|
|
205
|
+
signature: createScaleSignature(scaleInfo)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}, [chartRef, createScaleSignature]);
|
|
211
|
+
_react.useEffect.call(void 0, () => {
|
|
212
|
+
let timeoutId = null;
|
|
213
|
+
let lastSignature = null;
|
|
214
|
+
let retryCount = 0;
|
|
215
|
+
const maxRetries = 20;
|
|
216
|
+
const checkInterval = 50;
|
|
217
|
+
setScalesStable(false);
|
|
218
|
+
const monitorScales = () => {
|
|
219
|
+
const currentScaleData = getScalesData();
|
|
220
|
+
if (currentScaleData) {
|
|
221
|
+
const scalesSettled = lastSignature && currentScaleData.signature === lastSignature;
|
|
222
|
+
if (scalesSettled) {
|
|
223
|
+
setScalesStable(true);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
setScales(currentScaleData.scales);
|
|
227
|
+
lastSignature = currentScaleData.signature;
|
|
228
|
+
}
|
|
229
|
+
if (retryCount < maxRetries) {
|
|
230
|
+
retryCount++;
|
|
231
|
+
timeoutId = setTimeout(monitorScales, checkInterval);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
monitorScales();
|
|
235
|
+
return () => {
|
|
236
|
+
if (timeoutId) {
|
|
237
|
+
clearTimeout(timeoutId);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}, [getScalesData, chartWidth, chartHeight]);
|
|
241
|
+
if (!chartRef || !children) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
if (!scales || !scalesStable) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const dataContextValue = {
|
|
248
|
+
xScale: scales.xScale,
|
|
249
|
+
yScale: scales.yScale,
|
|
250
|
+
margin: {
|
|
251
|
+
top: 0,
|
|
252
|
+
right: 0,
|
|
253
|
+
bottom: 0,
|
|
254
|
+
left: 0
|
|
255
|
+
},
|
|
256
|
+
width: chartWidth,
|
|
257
|
+
height: chartHeight
|
|
258
|
+
};
|
|
259
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.DataContext.Provider, {
|
|
260
|
+
value: dataContextValue,
|
|
261
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", {
|
|
262
|
+
width: chartWidth,
|
|
263
|
+
height: chartHeight,
|
|
264
|
+
className: line_chart_module_default["line-chart__annotations-overlay"],
|
|
265
|
+
children
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
var line_chart_annotations_overlay_default = LineChartAnnotationsOverlay;
|
|
270
|
+
|
|
271
|
+
// src/charts/line-chart/private/line-chart-annotation.tsx
|
|
272
|
+
var _annotation = require('@visx/annotation');
|
|
273
|
+
|
|
274
|
+
var _deepmerge = require('deepmerge'); var _deepmerge2 = _interopRequireDefault(_deepmerge);
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
var ANNOTATION_MAX_WIDTH = 125;
|
|
278
|
+
var ANNOTATION_INIT_HEIGHT = 100;
|
|
279
|
+
var getLabelPosition = ({
|
|
280
|
+
subjectType,
|
|
281
|
+
x,
|
|
282
|
+
xMax,
|
|
283
|
+
y,
|
|
284
|
+
yMin,
|
|
285
|
+
yMax,
|
|
286
|
+
maxWidth,
|
|
287
|
+
height
|
|
288
|
+
}) => {
|
|
289
|
+
const annotationMaxWidth = _nullishCoalesce(maxWidth, () => ( ANNOTATION_MAX_WIDTH));
|
|
290
|
+
const annotationHeight = _nullishCoalesce(height, () => ( ANNOTATION_INIT_HEIGHT));
|
|
291
|
+
let dx = 15;
|
|
292
|
+
let dy = 15;
|
|
293
|
+
let isFlippedHorizontally = false;
|
|
294
|
+
let isFlippedVertically = false;
|
|
295
|
+
if (subjectType === "line-horizontal") {
|
|
296
|
+
dx = 0;
|
|
297
|
+
dy = 20;
|
|
298
|
+
}
|
|
299
|
+
if (subjectType === "line-vertical") {
|
|
300
|
+
dx = 20;
|
|
301
|
+
dy = 0;
|
|
302
|
+
}
|
|
303
|
+
const effectiveX = x + dx;
|
|
304
|
+
if (effectiveX + annotationMaxWidth > xMax) {
|
|
305
|
+
isFlippedHorizontally = true;
|
|
306
|
+
if (subjectType === "circle") {
|
|
307
|
+
dx = -dx;
|
|
308
|
+
} else if (subjectType === "line-vertical") {
|
|
309
|
+
dx = -20;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (subjectType === "circle") {
|
|
313
|
+
if (y + dy + annotationHeight > yMin) {
|
|
314
|
+
isFlippedVertically = true;
|
|
315
|
+
dy = -Math.abs(dy);
|
|
316
|
+
}
|
|
317
|
+
} else if (y - annotationHeight < yMax) {
|
|
318
|
+
if (subjectType === "line-horizontal") {
|
|
319
|
+
isFlippedVertically = true;
|
|
320
|
+
dy = Math.abs(dy);
|
|
321
|
+
} else if (subjectType === "line-vertical") {
|
|
322
|
+
isFlippedVertically = true;
|
|
323
|
+
}
|
|
324
|
+
} else if (y + annotationHeight > yMin) {
|
|
325
|
+
if (subjectType === "line-horizontal") {
|
|
326
|
+
isFlippedVertically = true;
|
|
327
|
+
dy = -Math.abs(dy);
|
|
328
|
+
} else if (subjectType === "line-vertical") {
|
|
329
|
+
isFlippedVertically = true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
dx,
|
|
334
|
+
dy,
|
|
335
|
+
isFlippedHorizontally,
|
|
336
|
+
isFlippedVertically
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
var getHorizontalAnchor = (subjectType, isFlippedHorizontally) => {
|
|
340
|
+
if (subjectType === "line-horizontal") {
|
|
341
|
+
return isFlippedHorizontally ? "end" : "start";
|
|
342
|
+
}
|
|
343
|
+
return void 0;
|
|
344
|
+
};
|
|
345
|
+
var getVerticalAnchor = (subjectType, isFlippedVertically, y, yMax, height) => {
|
|
346
|
+
if (subjectType === "line-vertical") {
|
|
347
|
+
if (isFlippedVertically) {
|
|
348
|
+
return y - height < yMax ? "start" : "end";
|
|
349
|
+
}
|
|
350
|
+
return "start";
|
|
351
|
+
}
|
|
352
|
+
return void 0;
|
|
353
|
+
};
|
|
354
|
+
var LineChartAnnotation = ({
|
|
355
|
+
datum,
|
|
356
|
+
title,
|
|
357
|
+
subtitle,
|
|
358
|
+
subjectType = "circle",
|
|
359
|
+
styles: datumStyles,
|
|
360
|
+
testId,
|
|
361
|
+
renderLabel,
|
|
362
|
+
renderLabelPopover
|
|
363
|
+
}) => {
|
|
364
|
+
const providerTheme = _chunkLSV7F26Bcjs.useGlobalChartsTheme.call(void 0, );
|
|
365
|
+
const {
|
|
366
|
+
xScale,
|
|
367
|
+
yScale
|
|
368
|
+
} = _react.useContext.call(void 0, _xychart.DataContext) || {};
|
|
369
|
+
const labelRef = _react.useRef.call(void 0, null);
|
|
370
|
+
const [height, setHeight] = _react.useState.call(void 0, null);
|
|
371
|
+
const styles = _deepmerge2.default.call(void 0, _nullishCoalesce(providerTheme.annotationStyles, () => ( {})), _nullishCoalesce(datumStyles, () => ( {})));
|
|
372
|
+
_react.useEffect.call(void 0, () => {
|
|
373
|
+
if (_optionalChain([labelRef, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.getBBox])) {
|
|
374
|
+
const bbox = labelRef.current.getBBox();
|
|
375
|
+
setHeight(bbox.height);
|
|
376
|
+
}
|
|
377
|
+
}, []);
|
|
378
|
+
const positionData = _react.useMemo.call(void 0, () => {
|
|
379
|
+
if (!datum || !datum.date || datum.value == null || !xScale || !yScale) return null;
|
|
380
|
+
const x2 = xScale(datum.date);
|
|
381
|
+
const y2 = yScale(datum.value);
|
|
382
|
+
if (typeof x2 !== "number" || typeof y2 !== "number") return null;
|
|
383
|
+
const [yMin2, yMax2] = yScale.range().map(Number);
|
|
384
|
+
const [xMin2, xMax2] = xScale.range().map(Number);
|
|
385
|
+
if (renderLabel) {
|
|
386
|
+
return {
|
|
387
|
+
x: x2,
|
|
388
|
+
dx: 0,
|
|
389
|
+
y: y2,
|
|
390
|
+
dy: 0,
|
|
391
|
+
yMin: yMin2,
|
|
392
|
+
yMax: yMax2,
|
|
393
|
+
xMin: xMin2,
|
|
394
|
+
xMax: xMax2,
|
|
395
|
+
isFlippedHorizontally: false,
|
|
396
|
+
isFlippedVertically: false
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
const position = getLabelPosition({
|
|
400
|
+
subjectType,
|
|
401
|
+
x: x2,
|
|
402
|
+
xMax: xMax2,
|
|
403
|
+
y: y2,
|
|
404
|
+
yMin: yMin2,
|
|
405
|
+
yMax: yMax2,
|
|
406
|
+
maxWidth: _optionalChain([styles, 'optionalAccess', _5 => _5.label, 'optionalAccess', _6 => _6.maxWidth]),
|
|
407
|
+
height
|
|
408
|
+
});
|
|
409
|
+
return {
|
|
410
|
+
x: x2,
|
|
411
|
+
y: y2,
|
|
412
|
+
yMin: yMin2,
|
|
413
|
+
yMax: yMax2,
|
|
414
|
+
xMin: xMin2,
|
|
415
|
+
xMax: xMax2,
|
|
416
|
+
...position
|
|
417
|
+
};
|
|
418
|
+
}, [datum, xScale, yScale, subjectType, _optionalChain([styles, 'optionalAccess', _7 => _7.label, 'optionalAccess', _8 => _8.maxWidth]), height, renderLabel]);
|
|
419
|
+
if (!positionData) return null;
|
|
420
|
+
const {
|
|
421
|
+
x,
|
|
422
|
+
y,
|
|
423
|
+
yMin,
|
|
424
|
+
yMax,
|
|
425
|
+
xMin,
|
|
426
|
+
xMax,
|
|
427
|
+
dx,
|
|
428
|
+
dy,
|
|
429
|
+
isFlippedHorizontally,
|
|
430
|
+
isFlippedVertically
|
|
431
|
+
} = positionData;
|
|
432
|
+
const getLabelY = () => {
|
|
433
|
+
const labelY = _optionalChain([styles, 'optionalAccess', _9 => _9.label, 'optionalAccess', _10 => _10.y]);
|
|
434
|
+
if (labelY === "start") return yMax;
|
|
435
|
+
if (labelY === "end") return yMin;
|
|
436
|
+
return labelY;
|
|
437
|
+
};
|
|
438
|
+
const getLabelX = () => {
|
|
439
|
+
const labelX = _optionalChain([styles, 'optionalAccess', _11 => _11.label, 'optionalAccess', _12 => _12.x]);
|
|
440
|
+
if (labelX === "start") return xMin;
|
|
441
|
+
if (labelX === "end") return xMax;
|
|
442
|
+
return labelX;
|
|
443
|
+
};
|
|
444
|
+
const labelPosition = {
|
|
445
|
+
x: getLabelX(),
|
|
446
|
+
y: getLabelY()
|
|
447
|
+
};
|
|
448
|
+
const getSafariHTMLLabelPosition = () => {
|
|
449
|
+
const labelWidth = POPOVER_BUTTON_SIZE;
|
|
450
|
+
const labelHeight = POPOVER_BUTTON_SIZE;
|
|
451
|
+
return _chunkZVGEDXDPcjs.isSafari.call(void 0, ) ? {
|
|
452
|
+
transform: `translate(${x + (dx || 0) + (typeof labelPosition.x === "number" ? labelPosition.x - x : 0) - labelWidth}px, ${y + (dy || 0) + (typeof labelPosition.y === "number" ? labelPosition.y - y : 0) - labelHeight}px)`,
|
|
453
|
+
width: labelWidth,
|
|
454
|
+
height: labelHeight
|
|
455
|
+
} : void 0;
|
|
456
|
+
};
|
|
457
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "g", {
|
|
458
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _annotation.Annotation, {
|
|
459
|
+
x,
|
|
460
|
+
y,
|
|
461
|
+
dx,
|
|
462
|
+
dy,
|
|
463
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.Connector, {
|
|
464
|
+
..._optionalChain([styles, 'optionalAccess', _13 => _13.connector])
|
|
465
|
+
}), subjectType === "circle" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.CircleSubject, {
|
|
466
|
+
..._optionalChain([styles, 'optionalAccess', _14 => _14.circleSubject])
|
|
467
|
+
}), subjectType === "line-vertical" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.LineSubject, {
|
|
468
|
+
min: yMax,
|
|
469
|
+
max: yMin,
|
|
470
|
+
..._optionalChain([styles, 'optionalAccess', _15 => _15.lineSubject]),
|
|
471
|
+
orientation: "vertical"
|
|
472
|
+
}), subjectType === "line-horizontal" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.LineSubject, {
|
|
473
|
+
min: xMin,
|
|
474
|
+
max: xMax,
|
|
475
|
+
..._optionalChain([styles, 'optionalAccess', _16 => _16.lineSubject]),
|
|
476
|
+
orientation: "horizontal"
|
|
477
|
+
}), renderLabel ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.HtmlLabel, {
|
|
478
|
+
..._optionalChain([styles, 'optionalAccess', _17 => _17.label]),
|
|
479
|
+
...labelPosition,
|
|
480
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
481
|
+
style: getSafariHTMLLabelPosition(),
|
|
482
|
+
children: renderLabelPopover ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, line_chart_annotation_label_popover_default, {
|
|
483
|
+
title,
|
|
484
|
+
subtitle,
|
|
485
|
+
renderLabel,
|
|
486
|
+
renderLabelPopover
|
|
487
|
+
}) : renderLabel({
|
|
488
|
+
title,
|
|
489
|
+
subtitle
|
|
490
|
+
})
|
|
491
|
+
})
|
|
492
|
+
}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "g", {
|
|
493
|
+
ref: labelRef,
|
|
494
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _annotation.Label, {
|
|
495
|
+
title,
|
|
496
|
+
subtitle,
|
|
497
|
+
..._optionalChain([styles, 'optionalAccess', _18 => _18.label]),
|
|
498
|
+
...labelPosition,
|
|
499
|
+
horizontalAnchor: getHorizontalAnchor(subjectType, isFlippedHorizontally),
|
|
500
|
+
verticalAnchor: getVerticalAnchor(subjectType, isFlippedVertically, y, yMax, _nullishCoalesce(height, () => ( ANNOTATION_INIT_HEIGHT)))
|
|
501
|
+
})
|
|
502
|
+
})]
|
|
503
|
+
})
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
var line_chart_annotation_default = LineChartAnnotation;
|
|
507
|
+
|
|
508
|
+
// src/charts/line-chart/private/line-chart-glyph.tsx
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
var toNumber = (val) => {
|
|
512
|
+
const num = typeof val === "number" ? val : parseFloat(val);
|
|
513
|
+
return isNaN(num) ? void 0 : num;
|
|
514
|
+
};
|
|
515
|
+
var LineChartGlyph = ({
|
|
516
|
+
data,
|
|
517
|
+
index,
|
|
518
|
+
color,
|
|
519
|
+
glyphStyle,
|
|
520
|
+
renderGlyph,
|
|
521
|
+
accessors,
|
|
522
|
+
position
|
|
523
|
+
}) => {
|
|
524
|
+
const {
|
|
525
|
+
xScale,
|
|
526
|
+
yScale
|
|
527
|
+
} = _react.useContext.call(void 0, _xychart.DataContext) || {};
|
|
528
|
+
if (!xScale || !yScale) return null;
|
|
529
|
+
if (data.data.length === 0) return null;
|
|
530
|
+
const point = position === "start" ? data.data[0] : data.data[data.data.length - 1];
|
|
531
|
+
const x = xScale(accessors.xAccessor(point));
|
|
532
|
+
const y = yScale(accessors.yAccessor(point));
|
|
533
|
+
if (typeof x !== "number" || typeof y !== "number") return null;
|
|
534
|
+
const size = Math.max(0, _nullishCoalesce(toNumber(_optionalChain([glyphStyle, 'optionalAccess', _19 => _19.radius])), () => ( 4)));
|
|
535
|
+
return renderGlyph({
|
|
536
|
+
key: `${position}-glyph-${data.label}`,
|
|
537
|
+
index,
|
|
538
|
+
datum: point,
|
|
539
|
+
color,
|
|
540
|
+
size,
|
|
541
|
+
x,
|
|
542
|
+
y,
|
|
543
|
+
glyphStyle,
|
|
544
|
+
position
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
var line_chart_glyph_default = LineChartGlyph;
|
|
548
|
+
|
|
549
|
+
// src/charts/line-chart/line-chart.tsx
|
|
550
|
+
|
|
551
|
+
var X_TICK_WIDTH = 60;
|
|
552
|
+
var defaultRenderGlyph = (props) => {
|
|
553
|
+
return /* @__PURE__ */ _react.createElement.call(void 0, DefaultGlyph, {
|
|
554
|
+
...props,
|
|
555
|
+
key: props.key
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
var toNumber2 = (val) => {
|
|
559
|
+
const num = typeof val === "number" ? val : parseFloat(val);
|
|
560
|
+
return isNaN(num) ? void 0 : num;
|
|
561
|
+
};
|
|
562
|
+
var getCurveType = (type, smoothing) => {
|
|
563
|
+
if (!type) {
|
|
564
|
+
return smoothing ? _curve.curveCatmullRom : _curve.curveLinear;
|
|
565
|
+
}
|
|
566
|
+
switch (type) {
|
|
567
|
+
case "smooth":
|
|
568
|
+
return _curve.curveCatmullRom;
|
|
569
|
+
case "monotone":
|
|
570
|
+
return _curve.curveMonotoneX;
|
|
571
|
+
case "linear":
|
|
572
|
+
return _curve.curveLinear;
|
|
573
|
+
default:
|
|
574
|
+
return _curve.curveLinear;
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
var renderDefaultTooltip = (params) => {
|
|
578
|
+
const {
|
|
579
|
+
tooltipData
|
|
580
|
+
} = params;
|
|
581
|
+
const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _20 => _20.nearestDatum, 'optionalAccess', _21 => _21.datum]);
|
|
582
|
+
if (!nearestDatum) return null;
|
|
583
|
+
const tooltipPoints = Object.entries(_optionalChain([tooltipData, 'optionalAccess', _22 => _22.datumByKey]) || {}).map(([key, {
|
|
584
|
+
datum
|
|
585
|
+
}]) => ({
|
|
586
|
+
key,
|
|
587
|
+
value: datum.value
|
|
588
|
+
})).sort((a, b) => b.value - a.value);
|
|
589
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
590
|
+
className: line_chart_module_default["line-chart__tooltip"],
|
|
591
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
592
|
+
className: line_chart_module_default["line-chart__tooltip-date"],
|
|
593
|
+
children: _optionalChain([nearestDatum, 'access', _23 => _23.date, 'optionalAccess', _24 => _24.toLocaleDateString, 'call', _25 => _25()])
|
|
594
|
+
}), tooltipPoints.map((point) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
595
|
+
className: line_chart_module_default["line-chart__tooltip-row"],
|
|
596
|
+
children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
597
|
+
className: line_chart_module_default["line-chart__tooltip-label"],
|
|
598
|
+
children: [point.key, ":"]
|
|
599
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
600
|
+
className: line_chart_module_default["line-chart__tooltip-value"],
|
|
601
|
+
children: _numberformatters.formatNumber.call(void 0, point.value)
|
|
602
|
+
})]
|
|
603
|
+
}, point.key))]
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
var formatYearTick = (timestamp) => {
|
|
607
|
+
const date = new Date(timestamp);
|
|
608
|
+
return date.toLocaleDateString(void 0, {
|
|
609
|
+
year: "numeric"
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
var formatDateTick = (timestamp) => {
|
|
613
|
+
const date = new Date(timestamp);
|
|
614
|
+
return date.toLocaleDateString(void 0, {
|
|
615
|
+
month: "short",
|
|
616
|
+
day: "numeric"
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
var formatHourTick = (timestamp) => {
|
|
620
|
+
const date = new Date(timestamp);
|
|
621
|
+
return date.toLocaleTimeString(void 0, {
|
|
622
|
+
hour: "numeric",
|
|
623
|
+
hour12: true
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
var getFormatter = (sortedData) => {
|
|
627
|
+
const minX = Math.min(...sortedData.map((datom) => _optionalChain([datom, 'access', _26 => _26.data, 'access', _27 => _27.at, 'call', _28 => _28(0), 'optionalAccess', _29 => _29.date])));
|
|
628
|
+
const maxX = Math.max(...sortedData.map((datom) => _optionalChain([datom, 'access', _30 => _30.data, 'access', _31 => _31.at, 'call', _32 => _32(-1), 'optionalAccess', _33 => _33.date])));
|
|
629
|
+
const diffInHours = Math.abs(_datefns.differenceInHours.call(void 0, maxX, minX));
|
|
630
|
+
if (diffInHours <= 24) {
|
|
631
|
+
return formatHourTick;
|
|
632
|
+
}
|
|
633
|
+
const diffInYears = Math.abs(_datefns.differenceInYears.call(void 0, maxX, minX));
|
|
634
|
+
if (diffInYears <= 1) {
|
|
635
|
+
return formatDateTick;
|
|
636
|
+
}
|
|
637
|
+
return formatYearTick;
|
|
638
|
+
};
|
|
639
|
+
var guessOptimalNumTicks = (data, chartWidth, tickFormatter) => {
|
|
640
|
+
const minX = Math.min(...data.map((datom) => _optionalChain([datom, 'access', _34 => _34.data, 'access', _35 => _35.at, 'call', _36 => _36(0), 'optionalAccess', _37 => _37.date])));
|
|
641
|
+
const maxX = Math.max(...data.map((datom) => _optionalChain([datom, 'access', _38 => _38.data, 'access', _39 => _39.at, 'call', _40 => _40(-1), 'optionalAccess', _41 => _41.date])));
|
|
642
|
+
const xScale = _scale.scaleTime.call(void 0, {
|
|
643
|
+
domain: [minX, maxX]
|
|
644
|
+
});
|
|
645
|
+
const upperBound = Math.min(
|
|
646
|
+
_optionalChain([data, 'access', _42 => _42[0], 'optionalAccess', _43 => _43.data, 'access', _44 => _44.length]) || 3,
|
|
647
|
+
// A sane fallback to avoid NaN when no data is present
|
|
648
|
+
Math.ceil(chartWidth / X_TICK_WIDTH)
|
|
649
|
+
);
|
|
650
|
+
let secondBestGuess = 1;
|
|
651
|
+
for (let numTicks = upperBound; numTicks > 1; --numTicks) {
|
|
652
|
+
const ticks = xScale.ticks(numTicks).map((d) => tickFormatter(d.getTime()));
|
|
653
|
+
if (ticks.length > upperBound) {
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
secondBestGuess = Math.max(secondBestGuess, ticks.length);
|
|
657
|
+
const uniqueTicks = Array.from(new Set(ticks));
|
|
658
|
+
if (uniqueTicks.length === 1) {
|
|
659
|
+
return 1;
|
|
660
|
+
}
|
|
661
|
+
const hasConsecutiveDuplicate = ticks.some((tick, idx) => idx > 0 && tick === ticks[idx - 1]);
|
|
662
|
+
if (hasConsecutiveDuplicate) {
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
return ticks.length;
|
|
666
|
+
}
|
|
667
|
+
return secondBestGuess;
|
|
668
|
+
};
|
|
669
|
+
var validateData = (data) => {
|
|
670
|
+
if (!_optionalChain([data, 'optionalAccess', _45 => _45.length])) return "No data available";
|
|
671
|
+
const hasInvalidData = data.some((series) => series.data.some((point) => isNaN(point.value) || point.value === null || point.value === void 0 || "date" in point && point.date && isNaN(point.date.getTime())));
|
|
672
|
+
if (hasInvalidData) return "Invalid data";
|
|
673
|
+
return null;
|
|
674
|
+
};
|
|
675
|
+
var LineChartScalesRef = ({
|
|
676
|
+
chartRef,
|
|
677
|
+
width,
|
|
678
|
+
height,
|
|
679
|
+
margin
|
|
680
|
+
}) => {
|
|
681
|
+
const context = _react.useContext.call(void 0, _xychart.DataContext);
|
|
682
|
+
_react.useImperativeHandle.call(void 0, chartRef, () => ({
|
|
683
|
+
getScales: () => {
|
|
684
|
+
if (!_optionalChain([context, 'optionalAccess', _46 => _46.xScale]) || !_optionalChain([context, 'optionalAccess', _47 => _47.yScale])) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
return {
|
|
688
|
+
xScale: context.xScale,
|
|
689
|
+
yScale: context.yScale
|
|
690
|
+
};
|
|
691
|
+
},
|
|
692
|
+
getChartDimensions: () => ({
|
|
693
|
+
width,
|
|
694
|
+
height,
|
|
695
|
+
margin: margin || {}
|
|
696
|
+
})
|
|
697
|
+
}), [context, width, height, margin]);
|
|
698
|
+
return null;
|
|
699
|
+
};
|
|
700
|
+
var LineChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
701
|
+
data,
|
|
702
|
+
chartId: providedChartId,
|
|
703
|
+
width,
|
|
704
|
+
height,
|
|
705
|
+
className,
|
|
706
|
+
margin,
|
|
707
|
+
withTooltips = true,
|
|
708
|
+
withTooltipCrosshairs,
|
|
709
|
+
showLegend = false,
|
|
710
|
+
legendOrientation = "horizontal",
|
|
711
|
+
legendAlignment = "center",
|
|
712
|
+
legendPosition = "bottom",
|
|
713
|
+
legendMaxWidth,
|
|
714
|
+
legendTextOverflow = "wrap",
|
|
715
|
+
legendItemClassName,
|
|
716
|
+
renderGlyph = defaultRenderGlyph,
|
|
717
|
+
glyphStyle = {},
|
|
718
|
+
legendShape = "line",
|
|
719
|
+
withLegendGlyph = false,
|
|
720
|
+
withGradientFill = false,
|
|
721
|
+
smoothing = true,
|
|
722
|
+
curveType,
|
|
723
|
+
renderTooltip = renderDefaultTooltip,
|
|
724
|
+
withStartGlyphs = false,
|
|
725
|
+
withEndGlyphs = false,
|
|
726
|
+
legendInteractive = false,
|
|
727
|
+
animation,
|
|
728
|
+
options = {},
|
|
729
|
+
onPointerDown = void 0,
|
|
730
|
+
onPointerUp = void 0,
|
|
731
|
+
onPointerMove = void 0,
|
|
732
|
+
onPointerOut = void 0,
|
|
733
|
+
children,
|
|
734
|
+
gridVisibility,
|
|
735
|
+
gap = "md"
|
|
736
|
+
}, ref) => {
|
|
737
|
+
const providerTheme = _chunkLSV7F26Bcjs.useGlobalChartsTheme.call(void 0, );
|
|
738
|
+
const theme = _chunkLSV7F26Bcjs.useXYChartTheme.call(void 0, data);
|
|
739
|
+
const chartId = _chunkLSV7F26Bcjs.useChartId.call(void 0, providedChartId);
|
|
740
|
+
const [svgWrapperRef, svgWrapperHeight] = _chunkLSV7F26Bcjs.useElementHeight.call(void 0, );
|
|
741
|
+
const chartRef = _react.useRef.call(void 0, null);
|
|
742
|
+
const [selectedIndex, setSelectedIndex] = _react.useState.call(void 0, void 0);
|
|
743
|
+
const [isNavigating, setIsNavigating] = _react.useState.call(void 0, false);
|
|
744
|
+
const internalChartRef = _react.useRef.call(void 0, null);
|
|
745
|
+
const hasLegendChild = _chunkLSV7F26Bcjs.useHasLegendChild.call(void 0, children);
|
|
746
|
+
const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;
|
|
747
|
+
const hasLegend = showLegend || hasLegendChild;
|
|
748
|
+
const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;
|
|
749
|
+
_react.useImperativeHandle.call(void 0, ref, () => ({
|
|
750
|
+
getScales: () => _optionalChain([internalChartRef, 'access', _48 => _48.current, 'optionalAccess', _49 => _49.getScales, 'call', _50 => _50()]) || null,
|
|
751
|
+
getChartDimensions: () => _optionalChain([internalChartRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.getChartDimensions, 'call', _53 => _53()]) || {
|
|
752
|
+
width: 0,
|
|
753
|
+
height: 0,
|
|
754
|
+
margin: {}
|
|
755
|
+
}
|
|
756
|
+
}), [internalChartRef]);
|
|
757
|
+
const dataSorted = _chunkLSV7F26Bcjs.useChartDataTransform.call(void 0, data);
|
|
758
|
+
const {
|
|
759
|
+
getElementStyles,
|
|
760
|
+
isSeriesVisible
|
|
761
|
+
} = _chunkLSV7F26Bcjs.useGlobalChartsContext.call(void 0, );
|
|
762
|
+
const seriesWithVisibility = _react.useMemo.call(void 0, () => {
|
|
763
|
+
if (!chartId || !legendInteractive) {
|
|
764
|
+
return dataSorted.map((series, index) => ({
|
|
765
|
+
series,
|
|
766
|
+
index,
|
|
767
|
+
isVisible: true
|
|
768
|
+
}));
|
|
769
|
+
}
|
|
770
|
+
return dataSorted.map((series, index) => ({
|
|
771
|
+
series,
|
|
772
|
+
index,
|
|
773
|
+
isVisible: isSeriesVisible(chartId, series.label)
|
|
774
|
+
}));
|
|
775
|
+
}, [dataSorted, chartId, isSeriesVisible, legendInteractive]);
|
|
776
|
+
const allSeriesHidden = _react.useMemo.call(void 0, () => {
|
|
777
|
+
return seriesWithVisibility.every(({
|
|
778
|
+
isVisible
|
|
779
|
+
}) => !isVisible);
|
|
780
|
+
}, [seriesWithVisibility]);
|
|
781
|
+
const {
|
|
782
|
+
tooltipRef,
|
|
783
|
+
onChartFocus,
|
|
784
|
+
onChartBlur,
|
|
785
|
+
onChartKeyDown
|
|
786
|
+
} = _chunkY3NNQMAXcjs.useKeyboardNavigation.call(void 0, {
|
|
787
|
+
selectedIndex,
|
|
788
|
+
setSelectedIndex,
|
|
789
|
+
isNavigating,
|
|
790
|
+
setIsNavigating,
|
|
791
|
+
chartRef,
|
|
792
|
+
totalPoints: _optionalChain([dataSorted, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.data, 'access', _56 => _56.length]) || 0
|
|
793
|
+
});
|
|
794
|
+
const chartOptions = _react.useMemo.call(void 0, () => {
|
|
795
|
+
const formatter = _optionalChain([options, 'optionalAccess', _57 => _57.axis, 'optionalAccess', _58 => _58.x, 'optionalAccess', _59 => _59.tickFormat]) || getFormatter(dataSorted);
|
|
796
|
+
return {
|
|
797
|
+
axis: {
|
|
798
|
+
x: {
|
|
799
|
+
orientation: "bottom",
|
|
800
|
+
numTicks: guessOptimalNumTicks(dataSorted, width, formatter),
|
|
801
|
+
tickFormat: formatter,
|
|
802
|
+
display: true,
|
|
803
|
+
..._optionalChain([options, 'optionalAccess', _60 => _60.axis, 'optionalAccess', _61 => _61.x])
|
|
804
|
+
},
|
|
805
|
+
y: {
|
|
806
|
+
orientation: "left",
|
|
807
|
+
numTicks: 4,
|
|
808
|
+
tickFormat: _numberformatters.formatNumberCompact,
|
|
809
|
+
display: true,
|
|
810
|
+
..._optionalChain([options, 'optionalAccess', _62 => _62.axis, 'optionalAccess', _63 => _63.y])
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
xScale: {
|
|
814
|
+
type: "time",
|
|
815
|
+
..._optionalChain([options, 'optionalAccess', _64 => _64.xScale])
|
|
816
|
+
},
|
|
817
|
+
yScale: {
|
|
818
|
+
type: "linear",
|
|
819
|
+
nice: true,
|
|
820
|
+
zero: false,
|
|
821
|
+
..._optionalChain([options, 'optionalAccess', _65 => _65.yScale])
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}, [options, dataSorted, width]);
|
|
825
|
+
const tooltipRenderGlyph = _react.useMemo.call(void 0, () => {
|
|
826
|
+
return (props) => {
|
|
827
|
+
const seriesIndex = dataSorted.findIndex((series) => series.label === props.key || series.data.includes(props.datum));
|
|
828
|
+
const seriesData = dataSorted[seriesIndex];
|
|
829
|
+
const {
|
|
830
|
+
color,
|
|
831
|
+
glyph: themeGlyph
|
|
832
|
+
} = getElementStyles({
|
|
833
|
+
data: seriesData,
|
|
834
|
+
index: seriesIndex
|
|
835
|
+
});
|
|
836
|
+
const propsWithResolvedColor = {
|
|
837
|
+
...props,
|
|
838
|
+
color
|
|
839
|
+
};
|
|
840
|
+
return themeGlyph ? themeGlyph(propsWithResolvedColor) : renderGlyph(propsWithResolvedColor);
|
|
841
|
+
};
|
|
842
|
+
}, [dataSorted, renderGlyph, getElementStyles]);
|
|
843
|
+
const defaultMargin = _chunkLSV7F26Bcjs.useChartMargin.call(void 0, height, chartOptions, dataSorted, theme);
|
|
844
|
+
const error = validateData(dataSorted);
|
|
845
|
+
const isDataValid = !error;
|
|
846
|
+
const legendOptions = _react.useMemo.call(void 0, () => ({
|
|
847
|
+
withGlyph: withLegendGlyph,
|
|
848
|
+
glyphSize: Math.max(0, _nullishCoalesce(toNumber2(_optionalChain([glyphStyle, 'optionalAccess', _66 => _66.radius])), () => ( 4))),
|
|
849
|
+
renderGlyph
|
|
850
|
+
}), [withLegendGlyph, _optionalChain([glyphStyle, 'optionalAccess', _67 => _67.radius]), renderGlyph]);
|
|
851
|
+
const legendItems = _chunkLSV7F26Bcjs.useChartLegendItems.call(void 0, dataSorted, legendOptions, legendShape);
|
|
852
|
+
const chartMetadata = _react.useMemo.call(void 0, () => ({
|
|
853
|
+
withGradientFill,
|
|
854
|
+
smoothing,
|
|
855
|
+
curveType,
|
|
856
|
+
withStartGlyphs,
|
|
857
|
+
withEndGlyphs,
|
|
858
|
+
withLegendGlyph
|
|
859
|
+
}), [withGradientFill, smoothing, curveType, withStartGlyphs, withEndGlyphs, withLegendGlyph]);
|
|
860
|
+
_chunkLSV7F26Bcjs.useChartRegistration.call(void 0, {
|
|
861
|
+
chartId,
|
|
862
|
+
legendItems,
|
|
863
|
+
chartType: "line",
|
|
864
|
+
isDataValid,
|
|
865
|
+
metadata: chartMetadata
|
|
866
|
+
});
|
|
867
|
+
const prefersReducedMotion = _chunkLSV7F26Bcjs.usePrefersReducedMotion.call(void 0, );
|
|
868
|
+
const accessors = {
|
|
869
|
+
xAccessor: (d) => _optionalChain([d, 'optionalAccess', _68 => _68.date]),
|
|
870
|
+
yAccessor: (d) => _optionalChain([d, 'optionalAccess', _69 => _69.value])
|
|
871
|
+
};
|
|
872
|
+
if (error) {
|
|
873
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
874
|
+
className: _clsx2.default.call(void 0, "line-chart", line_chart_module_default["line-chart"]),
|
|
875
|
+
children: error
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.Legend, {
|
|
879
|
+
orientation: legendOrientation,
|
|
880
|
+
alignment: legendAlignment,
|
|
881
|
+
position: legendPosition,
|
|
882
|
+
maxWidth: legendMaxWidth,
|
|
883
|
+
textOverflow: legendTextOverflow,
|
|
884
|
+
legendItemClassName,
|
|
885
|
+
className: line_chart_module_default["line-chart__legend"],
|
|
886
|
+
shape: legendShape,
|
|
887
|
+
chartId,
|
|
888
|
+
interactive: legendInteractive
|
|
889
|
+
});
|
|
890
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.SingleChartContext.Provider, {
|
|
891
|
+
value: {
|
|
892
|
+
chartId,
|
|
893
|
+
chartRef: internalChartRef,
|
|
894
|
+
chartWidth: width,
|
|
895
|
+
chartHeight
|
|
896
|
+
},
|
|
897
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkSH32YSZOcjs.Stack, {
|
|
898
|
+
direction: "column",
|
|
899
|
+
gap,
|
|
900
|
+
className: _clsx2.default.call(void 0, "line-chart", line_chart_module_default["line-chart"], {
|
|
901
|
+
[line_chart_module_default["line-chart--animated"]]: animation && !prefersReducedMotion
|
|
902
|
+
}, className),
|
|
903
|
+
style: {
|
|
904
|
+
width,
|
|
905
|
+
height,
|
|
906
|
+
visibility: isWaitingForMeasurement ? "hidden" : "visible"
|
|
907
|
+
},
|
|
908
|
+
children: [legendPosition === "top" && legendElement, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
909
|
+
className: line_chart_module_default["line-chart__svg-wrapper"],
|
|
910
|
+
ref: svgWrapperRef,
|
|
911
|
+
role: "grid",
|
|
912
|
+
"aria-label": _i18n.__.call(void 0, "Line chart", "jetpack-charts"),
|
|
913
|
+
tabIndex: 0,
|
|
914
|
+
onKeyDown: onChartKeyDown,
|
|
915
|
+
onFocus: onChartFocus,
|
|
916
|
+
onBlur: onChartBlur,
|
|
917
|
+
children: !isWaitingForMeasurement && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
918
|
+
ref: chartRef,
|
|
919
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _xychart.XYChart, {
|
|
920
|
+
theme,
|
|
921
|
+
width,
|
|
922
|
+
height: chartHeight,
|
|
923
|
+
margin: {
|
|
924
|
+
...defaultMargin,
|
|
925
|
+
...margin
|
|
926
|
+
},
|
|
927
|
+
xScale: chartOptions.xScale,
|
|
928
|
+
yScale: chartOptions.yScale,
|
|
929
|
+
onPointerDown,
|
|
930
|
+
onPointerUp,
|
|
931
|
+
onPointerMove,
|
|
932
|
+
onPointerOut,
|
|
933
|
+
pointerEventsDataKey: "nearest",
|
|
934
|
+
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Grid, {
|
|
935
|
+
columns: false,
|
|
936
|
+
numTicks: 4
|
|
937
|
+
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
938
|
+
...chartOptions.axis.x
|
|
939
|
+
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
940
|
+
...chartOptions.axis.y
|
|
941
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
942
|
+
x: width / 2,
|
|
943
|
+
y: chartHeight / 2,
|
|
944
|
+
textAnchor: "middle",
|
|
945
|
+
fill: _optionalChain([providerTheme, 'access', _70 => _70.gridStyles, 'optionalAccess', _71 => _71.stroke]) || "#ccc",
|
|
946
|
+
fontSize: "14",
|
|
947
|
+
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
948
|
+
children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
949
|
+
}) : null, seriesWithVisibility.map(({
|
|
950
|
+
series: seriesData,
|
|
951
|
+
index,
|
|
952
|
+
isVisible
|
|
953
|
+
}) => {
|
|
954
|
+
if (!isVisible) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
const {
|
|
958
|
+
color,
|
|
959
|
+
lineStyles,
|
|
960
|
+
glyph
|
|
961
|
+
} = getElementStyles({
|
|
962
|
+
data: seriesData,
|
|
963
|
+
index
|
|
964
|
+
});
|
|
965
|
+
const lineProps = {
|
|
966
|
+
stroke: color,
|
|
967
|
+
...lineStyles
|
|
968
|
+
};
|
|
969
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "g", {
|
|
970
|
+
children: [withGradientFill && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _gradient.LinearGradient, {
|
|
971
|
+
id: `area-gradient-${chartId}-${index + 1}`,
|
|
972
|
+
from: color,
|
|
973
|
+
fromOpacity: 0.4,
|
|
974
|
+
toOpacity: 0.1,
|
|
975
|
+
to: providerTheme.backgroundColor,
|
|
976
|
+
..._optionalChain([seriesData, 'access', _72 => _72.options, 'optionalAccess', _73 => _73.gradient]),
|
|
977
|
+
children: _optionalChain([seriesData, 'access', _74 => _74.options, 'optionalAccess', _75 => _75.gradient, 'optionalAccess', _76 => _76.stops, 'optionalAccess', _77 => _77.map, 'call', _78 => _78((stop, stopIndex) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "stop", {
|
|
978
|
+
offset: stop.offset,
|
|
979
|
+
stopColor: stop.color || color,
|
|
980
|
+
stopOpacity: _nullishCoalesce(stop.opacity, () => ( 1))
|
|
981
|
+
}, `${stop.offset}-${stop.color || color}`))])
|
|
982
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
|
|
983
|
+
dataKey: _optionalChain([seriesData, 'optionalAccess', _79 => _79.label]),
|
|
984
|
+
data: seriesData.data,
|
|
985
|
+
...accessors,
|
|
986
|
+
fill: withGradientFill ? `url(#area-gradient-${chartId}-${index + 1})` : "transparent",
|
|
987
|
+
renderLine: true,
|
|
988
|
+
curve: getCurveType(curveType, smoothing),
|
|
989
|
+
lineProps
|
|
990
|
+
}, _optionalChain([seriesData, 'optionalAccess', _80 => _80.label])), withStartGlyphs && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, line_chart_glyph_default, {
|
|
991
|
+
index,
|
|
992
|
+
data: seriesData,
|
|
993
|
+
color,
|
|
994
|
+
renderGlyph: _nullishCoalesce(glyph, () => ( renderGlyph)),
|
|
995
|
+
accessors,
|
|
996
|
+
glyphStyle,
|
|
997
|
+
position: "start"
|
|
998
|
+
}), withEndGlyphs && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, line_chart_glyph_default, {
|
|
999
|
+
index,
|
|
1000
|
+
data: seriesData,
|
|
1001
|
+
color,
|
|
1002
|
+
renderGlyph: _nullishCoalesce(glyph, () => ( renderGlyph)),
|
|
1003
|
+
accessors,
|
|
1004
|
+
glyphStyle,
|
|
1005
|
+
position: "end"
|
|
1006
|
+
})]
|
|
1007
|
+
}, _optionalChain([seriesData, 'optionalAccess', _81 => _81.label]) || index);
|
|
1008
|
+
}), withTooltips && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3NNQMAXcjs.AccessibleTooltip, {
|
|
1009
|
+
detectBounds: true,
|
|
1010
|
+
snapTooltipToDatumX: true,
|
|
1011
|
+
snapTooltipToDatumY: true,
|
|
1012
|
+
showSeriesGlyphs: true,
|
|
1013
|
+
renderTooltip,
|
|
1014
|
+
renderGlyph: tooltipRenderGlyph,
|
|
1015
|
+
glyphStyle,
|
|
1016
|
+
showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _82 => _82.showVertical]),
|
|
1017
|
+
showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _83 => _83.showHorizontal]),
|
|
1018
|
+
selectedIndex,
|
|
1019
|
+
tooltipRef,
|
|
1020
|
+
keyboardFocusedClassName: line_chart_module_default["line-chart__tooltip--keyboard-focused"],
|
|
1021
|
+
series: dataSorted
|
|
1022
|
+
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartScalesRef, {
|
|
1023
|
+
chartRef: internalChartRef,
|
|
1024
|
+
width,
|
|
1025
|
+
height,
|
|
1026
|
+
margin
|
|
1027
|
+
})]
|
|
1028
|
+
})
|
|
1029
|
+
})
|
|
1030
|
+
}), legendPosition === "bottom" && legendElement, children]
|
|
1031
|
+
})
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
var LineChartWithProvider = /* @__PURE__ */ _react.forwardRef.call(void 0, (props, ref) => {
|
|
1035
|
+
const existingContext = _react.useContext.call(void 0, _chunkLSV7F26Bcjs.GlobalChartsContext);
|
|
1036
|
+
if (existingContext) {
|
|
1037
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartInternal, {
|
|
1038
|
+
...props,
|
|
1039
|
+
ref
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLSV7F26Bcjs.GlobalChartsProvider, {
|
|
1043
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartInternal, {
|
|
1044
|
+
...props,
|
|
1045
|
+
ref
|
|
1046
|
+
})
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
LineChartWithProvider.displayName = "LineChart";
|
|
1050
|
+
var LineChart = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, LineChartWithProvider, {
|
|
1051
|
+
Legend: _chunkLSV7F26Bcjs.Legend,
|
|
1052
|
+
AnnotationsOverlay: line_chart_annotations_overlay_default,
|
|
1053
|
+
Annotation: line_chart_annotation_default
|
|
1054
|
+
});
|
|
1055
|
+
var LineChartResponsive = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, _chunk7QDEU3KNcjs.withResponsive.call(void 0, LineChartWithProvider), {
|
|
1056
|
+
Legend: _chunkLSV7F26Bcjs.Legend,
|
|
1057
|
+
AnnotationsOverlay: line_chart_annotations_overlay_default,
|
|
1058
|
+
Annotation: line_chart_annotation_default
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
exports.LineChart = LineChart; exports.LineChartResponsive = LineChartResponsive;
|
|
1065
|
+
//# sourceMappingURL=chunk-66BXSWMW.cjs.map
|