@automattic/charts 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -2
- package/README.md +7 -54
- package/dist/index.cjs +9607 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +32 -49
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1612 -33
- package/dist/index.d.ts +1612 -33
- package/dist/index.js +9640 -54
- package/dist/index.js.map +1 -1
- package/package.json +9 -126
- package/src/charts/bar-chart/bar-chart.module.scss +0 -5
- package/src/charts/bar-chart/bar-chart.tsx +142 -149
- package/src/charts/bar-chart/test/bar-chart.test.tsx +48 -31
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +54 -74
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +4 -5
- package/src/charts/leaderboard-chart/types.ts +1 -11
- package/src/charts/line-chart/line-chart.module.scss +0 -5
- package/src/charts/line-chart/line-chart.tsx +202 -193
- package/src/charts/line-chart/private/line-chart-annotations-overlay.tsx +1 -2
- package/src/charts/line-chart/test/line-chart.test.tsx +49 -27
- package/src/charts/line-chart/types.ts +0 -1
- package/src/charts/pie-chart/pie-chart.module.scss +2 -10
- package/src/charts/pie-chart/pie-chart.tsx +212 -212
- package/src/charts/pie-chart/test/composition-api.test.tsx +44 -3
- package/src/charts/pie-chart/test/pie-chart.test.tsx +51 -44
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +2 -8
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +166 -168
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +58 -30
- package/src/charts/private/chart-composition/index.ts +2 -0
- package/src/charts/private/chart-composition/render-legend-slot.ts +22 -0
- package/src/charts/private/chart-composition/test/render-legend-slot.test.tsx +60 -0
- package/src/charts/private/chart-composition/test/use-chart-children.test.tsx +91 -0
- package/src/charts/private/chart-composition/use-chart-children.ts +34 -2
- package/src/charts/private/chart-layout/chart-layout.module.scss +7 -0
- package/src/charts/private/chart-layout/chart-layout.tsx +106 -0
- package/src/charts/private/chart-layout/index.ts +2 -0
- package/src/charts/private/chart-layout/test/chart-layout.test.tsx +167 -0
- package/src/charts/private/single-chart-context/single-chart-context.tsx +2 -2
- package/src/charts/private/svg-empty-state/index.ts +1 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +7 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.tsx +40 -0
- package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +12 -8
- package/src/components/legend/hooks/use-chart-legend-items.ts +12 -13
- package/src/components/legend/index.ts +1 -8
- package/src/components/legend/legend.tsx +33 -8
- package/src/components/legend/private/base-legend.module.scss +19 -37
- package/src/components/legend/private/base-legend.tsx +0 -2
- package/src/components/legend/test/legend.test.tsx +93 -1
- package/src/components/legend/types.ts +7 -34
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-data-with-percentages.ts +24 -0
- package/src/hooks/use-interactive-legend-data.ts +18 -15
- package/src/index.ts +66 -9
- package/src/providers/chart-context/global-charts-provider.tsx +7 -1
- package/src/providers/chart-context/hooks/use-chart-registration.ts +2 -1
- package/src/providers/chart-context/types.ts +2 -2
- package/src/types.ts +110 -45
- package/src/utils/date-parsing.ts +10 -1
- package/src/utils/test/date-parsing.test.ts +12 -0
- package/src/utils/test/resolve-css-var.test.ts +4 -2
- package/tsup.config.ts +1 -1
- package/dist/base-tooltip-DOq93wjU.d.cts +0 -38
- package/dist/base-tooltip-DOq93wjU.d.ts +0 -38
- package/dist/charts/bar-chart/index.cjs +0 -15
- package/dist/charts/bar-chart/index.cjs.map +0 -1
- package/dist/charts/bar-chart/index.css +0 -153
- package/dist/charts/bar-chart/index.css.map +0 -1
- package/dist/charts/bar-chart/index.d.cts +0 -37
- package/dist/charts/bar-chart/index.d.ts +0 -37
- package/dist/charts/bar-chart/index.js +0 -15
- package/dist/charts/bar-chart/index.js.map +0 -1
- package/dist/charts/bar-list-chart/index.cjs +0 -16
- package/dist/charts/bar-list-chart/index.cjs.map +0 -1
- package/dist/charts/bar-list-chart/index.css +0 -153
- package/dist/charts/bar-list-chart/index.css.map +0 -1
- package/dist/charts/bar-list-chart/index.d.cts +0 -92
- package/dist/charts/bar-list-chart/index.d.ts +0 -92
- package/dist/charts/bar-list-chart/index.js +0 -16
- package/dist/charts/bar-list-chart/index.js.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.cjs +0 -11
- package/dist/charts/conversion-funnel-chart/index.cjs.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.css +0 -251
- package/dist/charts/conversion-funnel-chart/index.css.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +0 -97
- package/dist/charts/conversion-funnel-chart/index.d.ts +0 -97
- package/dist/charts/conversion-funnel-chart/index.js +0 -11
- package/dist/charts/conversion-funnel-chart/index.js.map +0 -1
- package/dist/charts/geo-chart/index.cjs +0 -13
- package/dist/charts/geo-chart/index.cjs.map +0 -1
- package/dist/charts/geo-chart/index.css +0 -117
- package/dist/charts/geo-chart/index.css.map +0 -1
- package/dist/charts/geo-chart/index.d.cts +0 -67
- package/dist/charts/geo-chart/index.d.ts +0 -67
- package/dist/charts/geo-chart/index.js +0 -13
- package/dist/charts/geo-chart/index.js.map +0 -1
- package/dist/charts/leaderboard-chart/index.cjs +0 -20
- package/dist/charts/leaderboard-chart/index.cjs.map +0 -1
- package/dist/charts/leaderboard-chart/index.css +0 -172
- package/dist/charts/leaderboard-chart/index.css.map +0 -1
- package/dist/charts/leaderboard-chart/index.d.cts +0 -46
- package/dist/charts/leaderboard-chart/index.d.ts +0 -46
- package/dist/charts/leaderboard-chart/index.js +0 -20
- package/dist/charts/leaderboard-chart/index.js.map +0 -1
- package/dist/charts/line-chart/index.cjs +0 -15
- package/dist/charts/line-chart/index.cjs.map +0 -1
- package/dist/charts/line-chart/index.css +0 -225
- package/dist/charts/line-chart/index.css.map +0 -1
- package/dist/charts/line-chart/index.d.cts +0 -99
- package/dist/charts/line-chart/index.d.ts +0 -99
- package/dist/charts/line-chart/index.js +0 -15
- package/dist/charts/line-chart/index.js.map +0 -1
- package/dist/charts/pie-chart/index.cjs +0 -18
- package/dist/charts/pie-chart/index.cjs.map +0 -1
- package/dist/charts/pie-chart/index.css +0 -143
- package/dist/charts/pie-chart/index.css.map +0 -1
- package/dist/charts/pie-chart/index.d.cts +0 -97
- package/dist/charts/pie-chart/index.d.ts +0 -97
- package/dist/charts/pie-chart/index.js +0 -18
- package/dist/charts/pie-chart/index.js.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.cjs +0 -17
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.css +0 -144
- package/dist/charts/pie-semi-circle-chart/index.css.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +0 -94
- package/dist/charts/pie-semi-circle-chart/index.d.ts +0 -94
- package/dist/charts/pie-semi-circle-chart/index.js +0 -17
- package/dist/charts/pie-semi-circle-chart/index.js.map +0 -1
- package/dist/charts/sparkline/index.cjs +0 -16
- package/dist/charts/sparkline/index.cjs.map +0 -1
- package/dist/charts/sparkline/index.css +0 -242
- package/dist/charts/sparkline/index.css.map +0 -1
- package/dist/charts/sparkline/index.d.cts +0 -113
- package/dist/charts/sparkline/index.d.ts +0 -113
- package/dist/charts/sparkline/index.js +0 -16
- package/dist/charts/sparkline/index.js.map +0 -1
- package/dist/chunk-2A34OA5O.cjs +0 -51
- package/dist/chunk-2A34OA5O.cjs.map +0 -1
- package/dist/chunk-2NCY7R4G.js +0 -3897
- package/dist/chunk-2NCY7R4G.js.map +0 -1
- package/dist/chunk-32DH6JDF.js +0 -1263
- package/dist/chunk-32DH6JDF.js.map +0 -1
- package/dist/chunk-4OPFE4RM.js +0 -614
- package/dist/chunk-4OPFE4RM.js.map +0 -1
- package/dist/chunk-6CCZL2JJ.js +0 -63
- package/dist/chunk-6CCZL2JJ.js.map +0 -1
- package/dist/chunk-77OKCVQN.cjs +0 -421
- package/dist/chunk-77OKCVQN.cjs.map +0 -1
- package/dist/chunk-7FQX4ALL.cjs +0 -219
- package/dist/chunk-7FQX4ALL.cjs.map +0 -1
- package/dist/chunk-ASLARV7L.cjs +0 -81
- package/dist/chunk-ASLARV7L.cjs.map +0 -1
- package/dist/chunk-BCX5THDQ.js +0 -403
- package/dist/chunk-BCX5THDQ.js.map +0 -1
- package/dist/chunk-BPYKWMI7.js +0 -194
- package/dist/chunk-BPYKWMI7.js.map +0 -1
- package/dist/chunk-CZGYJKG6.js +0 -421
- package/dist/chunk-CZGYJKG6.js.map +0 -1
- package/dist/chunk-D2UH4CFE.cjs +0 -120
- package/dist/chunk-D2UH4CFE.cjs.map +0 -1
- package/dist/chunk-DAU3HNEG.js +0 -344
- package/dist/chunk-DAU3HNEG.js.map +0 -1
- package/dist/chunk-H2V4JMSA.js +0 -219
- package/dist/chunk-H2V4JMSA.js.map +0 -1
- package/dist/chunk-I2276W3I.cjs +0 -66
- package/dist/chunk-I2276W3I.cjs.map +0 -1
- package/dist/chunk-I35UYJJR.cjs +0 -468
- package/dist/chunk-I35UYJJR.cjs.map +0 -1
- package/dist/chunk-IU4DYUAV.js +0 -120
- package/dist/chunk-IU4DYUAV.js.map +0 -1
- package/dist/chunk-KXRWNFQJ.js +0 -51
- package/dist/chunk-KXRWNFQJ.js.map +0 -1
- package/dist/chunk-OP6PHB2U.js +0 -81
- package/dist/chunk-OP6PHB2U.js.map +0 -1
- package/dist/chunk-PXLEMUGJ.js +0 -165
- package/dist/chunk-PXLEMUGJ.js.map +0 -1
- package/dist/chunk-RCY6XLGU.cjs +0 -63
- package/dist/chunk-RCY6XLGU.cjs.map +0 -1
- package/dist/chunk-RHHVEJHJ.cjs +0 -1263
- package/dist/chunk-RHHVEJHJ.cjs.map +0 -1
- package/dist/chunk-TO3OQBXG.cjs +0 -165
- package/dist/chunk-TO3OQBXG.cjs.map +0 -1
- package/dist/chunk-V36ERY7Y.js +0 -375
- package/dist/chunk-V36ERY7Y.js.map +0 -1
- package/dist/chunk-VJM5XCB4.cjs +0 -614
- package/dist/chunk-VJM5XCB4.cjs.map +0 -1
- package/dist/chunk-VTS3PNMS.cjs +0 -344
- package/dist/chunk-VTS3PNMS.cjs.map +0 -1
- package/dist/chunk-WLODYNLB.js +0 -1067
- package/dist/chunk-WLODYNLB.js.map +0 -1
- package/dist/chunk-XKRJL2QT.cjs +0 -375
- package/dist/chunk-XKRJL2QT.cjs.map +0 -1
- package/dist/chunk-XWYZIFZW.js +0 -66
- package/dist/chunk-XWYZIFZW.js.map +0 -1
- package/dist/chunk-Y3NNQMAX.cjs +0 -194
- package/dist/chunk-Y3NNQMAX.cjs.map +0 -1
- package/dist/chunk-YE2T52VZ.cjs +0 -1067
- package/dist/chunk-YE2T52VZ.cjs.map +0 -1
- package/dist/chunk-Z26M4V2M.js +0 -468
- package/dist/chunk-Z26M4V2M.js.map +0 -1
- package/dist/chunk-Z45KX47P.cjs +0 -3897
- package/dist/chunk-Z45KX47P.cjs.map +0 -1
- package/dist/chunk-ZH4F5RMG.cjs +0 -403
- package/dist/chunk-ZH4F5RMG.cjs.map +0 -1
- package/dist/components/legend/index.cjs +0 -11
- package/dist/components/legend/index.cjs.map +0 -1
- package/dist/components/legend/index.css +0 -103
- package/dist/components/legend/index.css.map +0 -1
- package/dist/components/legend/index.d.cts +0 -37
- package/dist/components/legend/index.d.ts +0 -37
- package/dist/components/legend/index.js +0 -11
- package/dist/components/legend/index.js.map +0 -1
- package/dist/components/tooltip/index.cjs +0 -12
- package/dist/components/tooltip/index.cjs.map +0 -1
- package/dist/components/tooltip/index.css +0 -13
- package/dist/components/tooltip/index.css.map +0 -1
- package/dist/components/tooltip/index.d.cts +0 -71
- package/dist/components/tooltip/index.d.ts +0 -71
- package/dist/components/tooltip/index.js +0 -12
- package/dist/components/tooltip/index.js.map +0 -1
- package/dist/components/trend-indicator/index.cjs +0 -8
- package/dist/components/trend-indicator/index.cjs.map +0 -1
- package/dist/components/trend-indicator/index.css +0 -27
- package/dist/components/trend-indicator/index.css.map +0 -1
- package/dist/components/trend-indicator/index.d.cts +0 -44
- package/dist/components/trend-indicator/index.d.ts +0 -44
- package/dist/components/trend-indicator/index.js +0 -8
- package/dist/components/trend-indicator/index.js.map +0 -1
- package/dist/format-metric-value-MXm5DtQ_.d.cts +0 -24
- package/dist/format-metric-value-MXm5DtQ_.d.ts +0 -24
- package/dist/hooks/index.cjs +0 -31
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.css +0 -103
- package/dist/hooks/index.css.map +0 -1
- package/dist/hooks/index.d.cts +0 -272
- package/dist/hooks/index.d.ts +0 -272
- package/dist/hooks/index.js +0 -31
- package/dist/hooks/index.js.map +0 -1
- package/dist/leaderboard-chart-BKYYXcg2.d.ts +0 -83
- package/dist/leaderboard-chart-DR7CGb0L.d.cts +0 -83
- package/dist/legend-C2grwnWk.d.cts +0 -9
- package/dist/legend-Cj0xM5dU.d.ts +0 -9
- package/dist/providers/index.cjs +0 -21
- package/dist/providers/index.cjs.map +0 -1
- package/dist/providers/index.css +0 -103
- package/dist/providers/index.css.map +0 -1
- package/dist/providers/index.d.cts +0 -28
- package/dist/providers/index.d.ts +0 -28
- package/dist/providers/index.js +0 -21
- package/dist/providers/index.js.map +0 -1
- package/dist/themes-BmVGrYnF.d.ts +0 -67
- package/dist/themes-CyjKm-P_.d.cts +0 -67
- package/dist/types-CuUEszrM.d.ts +0 -19
- package/dist/types-DZordNiO.d.cts +0 -505
- package/dist/types-DZordNiO.d.ts +0 -505
- package/dist/types-I67mddpr.d.cts +0 -78
- package/dist/types-I67mddpr.d.ts +0 -78
- package/dist/types-KtOPPzPX.d.cts +0 -19
- package/dist/utils/index.cjs +0 -44
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -226
- package/dist/utils/index.d.ts +0 -226
- package/dist/utils/index.js +0 -44
- package/dist/utils/index.js.map +0 -1
- package/dist/with-responsive-CNfhzAUu.d.cts +0 -18
- package/dist/with-responsive-CNfhzAUu.d.ts +0 -18
- package/src/hooks/use-has-legend-child.ts +0 -22
package/dist/chunk-YE2T52VZ.cjs
DELETED
|
@@ -1,1067 +0,0 @@
|
|
|
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 _chunkI35UYJJRcjs = require('./chunk-I35UYJJR.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkASLARV7Lcjs = require('./chunk-ASLARV7L.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _chunkRHHVEJHJcjs = require('./chunk-RHHVEJHJ.cjs');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _chunkVTS3PNMScjs = require('./chunk-VTS3PNMS.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 = _chunkVTS3PNMScjs.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
|
-
} = _chunkRHHVEJHJcjs.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 = _chunkRHHVEJHJcjs.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 _chunkVTS3PNMScjs.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 = _chunkRHHVEJHJcjs.useGlobalChartsTheme.call(void 0, );
|
|
738
|
-
const theme = _chunkRHHVEJHJcjs.useXYChartTheme.call(void 0, data);
|
|
739
|
-
const chartId = _chunkRHHVEJHJcjs.useChartId.call(void 0, providedChartId);
|
|
740
|
-
const [svgWrapperRef, , svgWrapperHeight] = _chunkRHHVEJHJcjs.useElementSize.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 = _chunkRHHVEJHJcjs.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 = _chunkRHHVEJHJcjs.useChartDataTransform.call(void 0, data);
|
|
758
|
-
const {
|
|
759
|
-
getElementStyles,
|
|
760
|
-
isSeriesVisible
|
|
761
|
-
} = _chunkRHHVEJHJcjs.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 = _chunkRHHVEJHJcjs.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 = _chunkRHHVEJHJcjs.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
|
-
_chunkRHHVEJHJcjs.useChartRegistration.call(void 0, {
|
|
861
|
-
chartId,
|
|
862
|
-
legendItems,
|
|
863
|
-
chartType: "line",
|
|
864
|
-
isDataValid,
|
|
865
|
-
metadata: chartMetadata
|
|
866
|
-
});
|
|
867
|
-
const prefersReducedMotion = _chunkRHHVEJHJcjs.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, _chunkRHHVEJHJcjs.Legend, {
|
|
879
|
-
orientation: legendOrientation,
|
|
880
|
-
alignment: legendAlignment,
|
|
881
|
-
position: legendPosition,
|
|
882
|
-
labelStyles: {
|
|
883
|
-
maxWidth: legendMaxWidth,
|
|
884
|
-
textOverflow: legendTextOverflow
|
|
885
|
-
},
|
|
886
|
-
itemClassName: legendItemClassName,
|
|
887
|
-
className: line_chart_module_default["line-chart__legend"],
|
|
888
|
-
shape: legendShape,
|
|
889
|
-
chartId,
|
|
890
|
-
interactive: legendInteractive
|
|
891
|
-
});
|
|
892
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRHHVEJHJcjs.SingleChartContext.Provider, {
|
|
893
|
-
value: {
|
|
894
|
-
chartId,
|
|
895
|
-
chartRef: internalChartRef,
|
|
896
|
-
chartWidth: width,
|
|
897
|
-
chartHeight
|
|
898
|
-
},
|
|
899
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkI35UYJJRcjs.Stack, {
|
|
900
|
-
direction: "column",
|
|
901
|
-
gap,
|
|
902
|
-
className: _clsx2.default.call(void 0, "line-chart", line_chart_module_default["line-chart"], {
|
|
903
|
-
[line_chart_module_default["line-chart--animated"]]: animation && !prefersReducedMotion
|
|
904
|
-
}, className),
|
|
905
|
-
style: {
|
|
906
|
-
width,
|
|
907
|
-
height,
|
|
908
|
-
visibility: isWaitingForMeasurement ? "hidden" : "visible"
|
|
909
|
-
},
|
|
910
|
-
children: [legendPosition === "top" && legendElement, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
911
|
-
className: line_chart_module_default["line-chart__svg-wrapper"],
|
|
912
|
-
ref: svgWrapperRef,
|
|
913
|
-
role: "grid",
|
|
914
|
-
"aria-label": _i18n.__.call(void 0, "Line chart", "jetpack-charts"),
|
|
915
|
-
tabIndex: 0,
|
|
916
|
-
onKeyDown: onChartKeyDown,
|
|
917
|
-
onFocus: onChartFocus,
|
|
918
|
-
onBlur: onChartBlur,
|
|
919
|
-
children: !isWaitingForMeasurement && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
920
|
-
ref: chartRef,
|
|
921
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _xychart.XYChart, {
|
|
922
|
-
theme,
|
|
923
|
-
width,
|
|
924
|
-
height: chartHeight,
|
|
925
|
-
margin: {
|
|
926
|
-
...defaultMargin,
|
|
927
|
-
...margin
|
|
928
|
-
},
|
|
929
|
-
xScale: chartOptions.xScale,
|
|
930
|
-
yScale: chartOptions.yScale,
|
|
931
|
-
onPointerDown,
|
|
932
|
-
onPointerUp,
|
|
933
|
-
onPointerMove,
|
|
934
|
-
onPointerOut,
|
|
935
|
-
pointerEventsDataKey: "nearest",
|
|
936
|
-
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Grid, {
|
|
937
|
-
columns: false,
|
|
938
|
-
numTicks: 4
|
|
939
|
-
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
940
|
-
...chartOptions.axis.x
|
|
941
|
-
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
942
|
-
...chartOptions.axis.y
|
|
943
|
-
}), allSeriesHidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
944
|
-
x: width / 2,
|
|
945
|
-
y: chartHeight / 2,
|
|
946
|
-
textAnchor: "middle",
|
|
947
|
-
fill: _optionalChain([providerTheme, 'access', _70 => _70.gridStyles, 'optionalAccess', _71 => _71.stroke]) || "#ccc",
|
|
948
|
-
fontSize: "14",
|
|
949
|
-
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
950
|
-
children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
951
|
-
}) : null, seriesWithVisibility.map(({
|
|
952
|
-
series: seriesData,
|
|
953
|
-
index,
|
|
954
|
-
isVisible
|
|
955
|
-
}) => {
|
|
956
|
-
if (!isVisible) {
|
|
957
|
-
return null;
|
|
958
|
-
}
|
|
959
|
-
const {
|
|
960
|
-
color,
|
|
961
|
-
lineStyles,
|
|
962
|
-
glyph
|
|
963
|
-
} = getElementStyles({
|
|
964
|
-
data: seriesData,
|
|
965
|
-
index
|
|
966
|
-
});
|
|
967
|
-
const lineProps = {
|
|
968
|
-
stroke: color,
|
|
969
|
-
...lineStyles
|
|
970
|
-
};
|
|
971
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "g", {
|
|
972
|
-
children: [withGradientFill && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _gradient.LinearGradient, {
|
|
973
|
-
id: `area-gradient-${chartId}-${index + 1}`,
|
|
974
|
-
from: color,
|
|
975
|
-
fromOpacity: 0.4,
|
|
976
|
-
toOpacity: 0.1,
|
|
977
|
-
to: providerTheme.backgroundColor,
|
|
978
|
-
..._optionalChain([seriesData, 'access', _72 => _72.options, 'optionalAccess', _73 => _73.gradient]),
|
|
979
|
-
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", {
|
|
980
|
-
offset: stop.offset,
|
|
981
|
-
stopColor: stop.color || color,
|
|
982
|
-
stopOpacity: _nullishCoalesce(stop.opacity, () => ( 1))
|
|
983
|
-
}, `${stop.offset}-${stop.color || color}`))])
|
|
984
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
|
|
985
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess', _79 => _79.label]),
|
|
986
|
-
data: seriesData.data,
|
|
987
|
-
...accessors,
|
|
988
|
-
fill: withGradientFill ? `url(#area-gradient-${chartId}-${index + 1})` : "transparent",
|
|
989
|
-
renderLine: true,
|
|
990
|
-
curve: getCurveType(curveType, smoothing),
|
|
991
|
-
lineProps
|
|
992
|
-
}, _optionalChain([seriesData, 'optionalAccess', _80 => _80.label])), withStartGlyphs && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, line_chart_glyph_default, {
|
|
993
|
-
index,
|
|
994
|
-
data: seriesData,
|
|
995
|
-
color,
|
|
996
|
-
renderGlyph: _nullishCoalesce(glyph, () => ( renderGlyph)),
|
|
997
|
-
accessors,
|
|
998
|
-
glyphStyle,
|
|
999
|
-
position: "start"
|
|
1000
|
-
}), withEndGlyphs && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, line_chart_glyph_default, {
|
|
1001
|
-
index,
|
|
1002
|
-
data: seriesData,
|
|
1003
|
-
color,
|
|
1004
|
-
renderGlyph: _nullishCoalesce(glyph, () => ( renderGlyph)),
|
|
1005
|
-
accessors,
|
|
1006
|
-
glyphStyle,
|
|
1007
|
-
position: "end"
|
|
1008
|
-
})]
|
|
1009
|
-
}, _optionalChain([seriesData, 'optionalAccess', _81 => _81.label]) || index);
|
|
1010
|
-
}), withTooltips && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3NNQMAXcjs.AccessibleTooltip, {
|
|
1011
|
-
detectBounds: true,
|
|
1012
|
-
snapTooltipToDatumX: true,
|
|
1013
|
-
snapTooltipToDatumY: true,
|
|
1014
|
-
showSeriesGlyphs: true,
|
|
1015
|
-
renderTooltip,
|
|
1016
|
-
renderGlyph: tooltipRenderGlyph,
|
|
1017
|
-
glyphStyle,
|
|
1018
|
-
showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _82 => _82.showVertical]),
|
|
1019
|
-
showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _83 => _83.showHorizontal]),
|
|
1020
|
-
selectedIndex,
|
|
1021
|
-
tooltipRef,
|
|
1022
|
-
keyboardFocusedClassName: line_chart_module_default["line-chart__tooltip--keyboard-focused"],
|
|
1023
|
-
series: dataSorted
|
|
1024
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartScalesRef, {
|
|
1025
|
-
chartRef: internalChartRef,
|
|
1026
|
-
width,
|
|
1027
|
-
height,
|
|
1028
|
-
margin
|
|
1029
|
-
})]
|
|
1030
|
-
})
|
|
1031
|
-
})
|
|
1032
|
-
}), legendPosition === "bottom" && legendElement, children]
|
|
1033
|
-
})
|
|
1034
|
-
});
|
|
1035
|
-
});
|
|
1036
|
-
var LineChartWithProvider = /* @__PURE__ */ _react.forwardRef.call(void 0, (props, ref) => {
|
|
1037
|
-
const existingContext = _react.useContext.call(void 0, _chunkRHHVEJHJcjs.GlobalChartsContext);
|
|
1038
|
-
if (existingContext) {
|
|
1039
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartInternal, {
|
|
1040
|
-
...props,
|
|
1041
|
-
ref
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRHHVEJHJcjs.GlobalChartsProvider, {
|
|
1045
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineChartInternal, {
|
|
1046
|
-
...props,
|
|
1047
|
-
ref
|
|
1048
|
-
})
|
|
1049
|
-
});
|
|
1050
|
-
});
|
|
1051
|
-
LineChartWithProvider.displayName = "LineChart";
|
|
1052
|
-
var LineChart = _chunkVTS3PNMScjs.attachSubComponents.call(void 0, LineChartWithProvider, {
|
|
1053
|
-
Legend: _chunkRHHVEJHJcjs.Legend,
|
|
1054
|
-
AnnotationsOverlay: line_chart_annotations_overlay_default,
|
|
1055
|
-
Annotation: line_chart_annotation_default
|
|
1056
|
-
});
|
|
1057
|
-
var LineChartResponsive = _chunkVTS3PNMScjs.attachSubComponents.call(void 0, _chunkASLARV7Lcjs.withResponsive.call(void 0, LineChartWithProvider), {
|
|
1058
|
-
Legend: _chunkRHHVEJHJcjs.Legend,
|
|
1059
|
-
AnnotationsOverlay: line_chart_annotations_overlay_default,
|
|
1060
|
-
Annotation: line_chart_annotation_default
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
exports.LineChart = LineChart; exports.LineChartResponsive = LineChartResponsive;
|
|
1067
|
-
//# sourceMappingURL=chunk-YE2T52VZ.cjs.map
|