@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-VJM5XCB4.cjs
DELETED
|
@@ -1,614 +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/bar-chart/bar-chart.tsx
|
|
35
|
-
var _numberformatters = require('@automattic/number-formatters');
|
|
36
|
-
var _pattern = require('@visx/pattern');
|
|
37
|
-
var _xychart = require('@visx/xychart');
|
|
38
|
-
var _i18n = require('@wordpress/i18n');
|
|
39
|
-
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
40
|
-
var _react = require('react');
|
|
41
|
-
|
|
42
|
-
// src/charts/bar-chart/bar-chart.module.scss
|
|
43
|
-
var bar_chart_module_default = {
|
|
44
|
-
"bar-chart__svg-wrapper": "a8ccharts-9CsqC0",
|
|
45
|
-
"bar-chart": "a8ccharts-3gflnB",
|
|
46
|
-
"bar-chart--animated": "a8ccharts-98W-yu",
|
|
47
|
-
"rise": "a8ccharts-z6AsiQ",
|
|
48
|
-
"bar-chart--animated-horizontal": "a8ccharts-HFA3FF",
|
|
49
|
-
"stretch": "a8ccharts-DQp37O"
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/charts/bar-chart/private/use-bar-chart-options.ts
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// src/charts/bar-chart/private/truncated-tick-component.tsx
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
60
|
-
var getScaleBandwidth = (scale) => {
|
|
61
|
-
return scale && "bandwidth" in scale ? _nullishCoalesce(scale.bandwidth(), () => ( 0)) : 0;
|
|
62
|
-
};
|
|
63
|
-
var MIN_TICK_LABEL_WIDTH = 20;
|
|
64
|
-
var TruncatedTickComponent = ({
|
|
65
|
-
x,
|
|
66
|
-
y,
|
|
67
|
-
formattedValue,
|
|
68
|
-
axis,
|
|
69
|
-
textAnchor,
|
|
70
|
-
fill,
|
|
71
|
-
dy,
|
|
72
|
-
...textProps
|
|
73
|
-
}) => {
|
|
74
|
-
const {
|
|
75
|
-
xScale,
|
|
76
|
-
yScale
|
|
77
|
-
} = _react.useContext.call(void 0, _xychart.DataContext) || {};
|
|
78
|
-
const scale = axis === "x" ? xScale : yScale;
|
|
79
|
-
const bandwidth = getScaleBandwidth(scale);
|
|
80
|
-
const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);
|
|
81
|
-
let textAlign = "center";
|
|
82
|
-
if (textAnchor === "start") {
|
|
83
|
-
textAlign = "left";
|
|
84
|
-
} else if (textAnchor === "end") {
|
|
85
|
-
textAlign = "right";
|
|
86
|
-
} else if (textAnchor === "middle") {
|
|
87
|
-
textAlign = "center";
|
|
88
|
-
}
|
|
89
|
-
let xOffset = 0;
|
|
90
|
-
if (textAlign === "center") {
|
|
91
|
-
xOffset = -maxWidth / 2;
|
|
92
|
-
} else if (textAlign === "right") {
|
|
93
|
-
xOffset = -maxWidth;
|
|
94
|
-
}
|
|
95
|
-
const {
|
|
96
|
-
fontSize,
|
|
97
|
-
fontFamily,
|
|
98
|
-
fontWeight,
|
|
99
|
-
fontStyle,
|
|
100
|
-
letterSpacing,
|
|
101
|
-
opacity
|
|
102
|
-
} = textProps;
|
|
103
|
-
const textStyles = {
|
|
104
|
-
/**
|
|
105
|
-
* SVG <text> elements are vertically aligned to the baseline by default, but HTML <div> elements inside <foreignObject>
|
|
106
|
-
* are positioned relative to the top-left corner. To visually align the tick label like SVG text,
|
|
107
|
-
* we shift the div up by 100% of its height and adjust by twice the SVG dy value (from visx) to approximate original placement.
|
|
108
|
-
*/
|
|
109
|
-
transform: `translateY(calc(-100% + ${_nullishCoalesce(dy, () => ( "0"))} * 2))`,
|
|
110
|
-
// Safari doesn't work well with foreignObject positioning. Use position: fixed as a workaround.
|
|
111
|
-
..._chunkVTS3PNMScjs.isSafari.call(void 0, ) ? {
|
|
112
|
-
position: "fixed"
|
|
113
|
-
} : {},
|
|
114
|
-
// Apply compatible SVG text styles
|
|
115
|
-
fontSize,
|
|
116
|
-
fontFamily,
|
|
117
|
-
fontWeight,
|
|
118
|
-
fontStyle,
|
|
119
|
-
letterSpacing,
|
|
120
|
-
opacity,
|
|
121
|
-
// Convert svg text styles to CSS styles for the div
|
|
122
|
-
color: _nullishCoalesce(fill, () => ( "inherit")),
|
|
123
|
-
textAlign,
|
|
124
|
-
// Ensure text is truncated with ellipsis, remains on one line, and shows the full value in a tooltip on hover.
|
|
125
|
-
// The surrounding div uses CSS to handle overflow, and the 'title' attribute is set for accessibility.
|
|
126
|
-
width: maxWidth,
|
|
127
|
-
overflow: "hidden",
|
|
128
|
-
textOverflow: "ellipsis",
|
|
129
|
-
whiteSpace: "nowrap",
|
|
130
|
-
cursor: "default",
|
|
131
|
-
pointerEvents: "auto"
|
|
132
|
-
};
|
|
133
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "foreignObject", {
|
|
134
|
-
x: x + xOffset,
|
|
135
|
-
y,
|
|
136
|
-
width: maxWidth,
|
|
137
|
-
height: 0,
|
|
138
|
-
overflow: "visible",
|
|
139
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
140
|
-
style: textStyles,
|
|
141
|
-
title: formattedValue,
|
|
142
|
-
children: formattedValue
|
|
143
|
-
})
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
var createTruncatedTickComponent = (axis) => (props) => {
|
|
147
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TruncatedTickComponent, {
|
|
148
|
-
...props,
|
|
149
|
-
axis
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
var TruncatedXTickComponent = createTruncatedTickComponent("x");
|
|
153
|
-
var TruncatedYTickComponent = createTruncatedTickComponent("y");
|
|
154
|
-
|
|
155
|
-
// src/charts/bar-chart/private/use-bar-chart-options.ts
|
|
156
|
-
var formatDateTick = (timestamp) => {
|
|
157
|
-
const date = new Date(timestamp);
|
|
158
|
-
return date.toLocaleDateString(void 0, {
|
|
159
|
-
month: "short",
|
|
160
|
-
day: "numeric"
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
var getGroupPadding = (scale) => {
|
|
164
|
-
return typeof scale.paddingInner === "number" ? scale.paddingInner : 0;
|
|
165
|
-
};
|
|
166
|
-
function useBarChartOptions(data, horizontal, options = {}) {
|
|
167
|
-
const defaultOptions = _react.useMemo.call(void 0, () => {
|
|
168
|
-
const bandScale = {
|
|
169
|
-
type: "band",
|
|
170
|
-
padding: 0.2,
|
|
171
|
-
paddingInner: 0.1
|
|
172
|
-
};
|
|
173
|
-
const linearScale = {
|
|
174
|
-
type: "linear",
|
|
175
|
-
nice: true,
|
|
176
|
-
zero: false
|
|
177
|
-
};
|
|
178
|
-
const labelFormatter = _optionalChain([data, 'optionalAccess', _ => _[0], 'optionalAccess', _2 => _2.data, 'optionalAccess', _3 => _3[0], 'optionalAccess', _4 => _4.label]) ? (label) => label : formatDateTick;
|
|
179
|
-
const valueFormatter = _numberformatters.formatNumberCompact;
|
|
180
|
-
const labelAccessor = (d) => _optionalChain([d, 'optionalAccess', _5 => _5.label]) || _optionalChain([d, 'optionalAccess', _6 => _6.date]);
|
|
181
|
-
const valueAccessor = (d) => {
|
|
182
|
-
const enhancedPoint = d;
|
|
183
|
-
return _optionalChain([enhancedPoint, 'optionalAccess', _7 => _7.visualValue]) !== void 0 ? enhancedPoint.visualValue : _optionalChain([d, 'optionalAccess', _8 => _8.value]);
|
|
184
|
-
};
|
|
185
|
-
return {
|
|
186
|
-
vertical: {
|
|
187
|
-
xTickFormat: labelFormatter,
|
|
188
|
-
yTickFormat: valueFormatter,
|
|
189
|
-
tooltipLabelFormatter: labelFormatter,
|
|
190
|
-
xAccessor: labelAccessor,
|
|
191
|
-
yAccessor: valueAccessor,
|
|
192
|
-
gridVisibility: "x",
|
|
193
|
-
xScale: bandScale,
|
|
194
|
-
yScale: linearScale
|
|
195
|
-
},
|
|
196
|
-
horizontal: {
|
|
197
|
-
xTickFormat: valueFormatter,
|
|
198
|
-
yTickFormat: labelFormatter,
|
|
199
|
-
tooltipLabelFormatter: labelFormatter,
|
|
200
|
-
xAccessor: valueAccessor,
|
|
201
|
-
yAccessor: labelAccessor,
|
|
202
|
-
gridVisibility: "y",
|
|
203
|
-
xScale: linearScale,
|
|
204
|
-
yScale: bandScale
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}, [data]);
|
|
208
|
-
return _react.useMemo.call(void 0, () => {
|
|
209
|
-
const orientationKey = horizontal ? "horizontal" : "vertical";
|
|
210
|
-
const {
|
|
211
|
-
xTickFormat,
|
|
212
|
-
yTickFormat,
|
|
213
|
-
tooltipLabelFormatter: defaultTooltipLabelFormatter,
|
|
214
|
-
xAccessor,
|
|
215
|
-
yAccessor,
|
|
216
|
-
gridVisibility,
|
|
217
|
-
xScale: baseXScale,
|
|
218
|
-
yScale: baseYScale
|
|
219
|
-
} = defaultOptions[orientationKey];
|
|
220
|
-
const xScale = { ...baseXScale, ...options.xScale || {} };
|
|
221
|
-
const yScale = { ...baseYScale, ...options.yScale || {} };
|
|
222
|
-
const providedToolTipLabelFormatter = horizontal ? _optionalChain([options, 'access', _9 => _9.axis, 'optionalAccess', _10 => _10.y, 'optionalAccess', _11 => _11.tickFormat]) : _optionalChain([options, 'access', _12 => _12.axis, 'optionalAccess', _13 => _13.x, 'optionalAccess', _14 => _14.tickFormat]);
|
|
223
|
-
const { labelOverflow: xLabelOverflow, ...xAxisOptions } = _optionalChain([options, 'access', _15 => _15.axis, 'optionalAccess', _16 => _16.x]) || {};
|
|
224
|
-
const { labelOverflow: yLabelOverflow, ...yAxisOptions } = _optionalChain([options, 'access', _17 => _17.axis, 'optionalAccess', _18 => _18.y]) || {};
|
|
225
|
-
return {
|
|
226
|
-
gridVisibility,
|
|
227
|
-
xScale,
|
|
228
|
-
yScale,
|
|
229
|
-
accessors: {
|
|
230
|
-
xAccessor,
|
|
231
|
-
yAccessor
|
|
232
|
-
},
|
|
233
|
-
axis: {
|
|
234
|
-
x: {
|
|
235
|
-
orientation: "bottom",
|
|
236
|
-
numTicks: 4,
|
|
237
|
-
tickFormat: xTickFormat,
|
|
238
|
-
...xLabelOverflow === "ellipsis" ? { tickComponent: TruncatedXTickComponent } : {},
|
|
239
|
-
...xAxisOptions
|
|
240
|
-
},
|
|
241
|
-
y: {
|
|
242
|
-
orientation: "left",
|
|
243
|
-
numTicks: 4,
|
|
244
|
-
tickFormat: yTickFormat,
|
|
245
|
-
...yLabelOverflow === "ellipsis" ? { tickComponent: TruncatedYTickComponent } : {},
|
|
246
|
-
...yAxisOptions
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
barGroup: {
|
|
250
|
-
padding: getGroupPadding(horizontal ? yScale : xScale)
|
|
251
|
-
},
|
|
252
|
-
tooltip: {
|
|
253
|
-
labelFormatter: providedToolTipLabelFormatter || defaultTooltipLabelFormatter
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
}, [defaultOptions, options, horizontal]);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// src/charts/bar-chart/bar-chart.tsx
|
|
260
|
-
|
|
261
|
-
var validateData = (data) => {
|
|
262
|
-
if (!_optionalChain([data, 'optionalAccess', _19 => _19.length])) return "No data available";
|
|
263
|
-
const hasInvalidData = data.some((series) => series.data.some((point) => isNaN(point.value) || point.value === null || point.value === void 0 || !point.label && (!("date" in point && point.date) || isNaN(point.date.getTime()))));
|
|
264
|
-
if (hasInvalidData) return "Invalid data";
|
|
265
|
-
return null;
|
|
266
|
-
};
|
|
267
|
-
var getPatternId = (chartId, index) => `bar-pattern-${chartId}-${index}`;
|
|
268
|
-
var BarChartInternal = ({
|
|
269
|
-
data,
|
|
270
|
-
chartId: providedChartId,
|
|
271
|
-
width,
|
|
272
|
-
height,
|
|
273
|
-
className,
|
|
274
|
-
margin,
|
|
275
|
-
withTooltips = false,
|
|
276
|
-
showLegend = false,
|
|
277
|
-
legendOrientation = "horizontal",
|
|
278
|
-
legendPosition = "bottom",
|
|
279
|
-
legendAlignment = "center",
|
|
280
|
-
legendMaxWidth,
|
|
281
|
-
legendTextOverflow = "wrap",
|
|
282
|
-
legendItemClassName,
|
|
283
|
-
legendShape = "rect",
|
|
284
|
-
gridVisibility: gridVisibilityProp,
|
|
285
|
-
renderTooltip,
|
|
286
|
-
options = {},
|
|
287
|
-
orientation = "vertical",
|
|
288
|
-
withPatterns = false,
|
|
289
|
-
showZeroValues = false,
|
|
290
|
-
legendInteractive = false,
|
|
291
|
-
animation,
|
|
292
|
-
children,
|
|
293
|
-
gap = "md"
|
|
294
|
-
}) => {
|
|
295
|
-
const horizontal = orientation === "horizontal";
|
|
296
|
-
const chartId = _chunkRHHVEJHJcjs.useChartId.call(void 0, providedChartId);
|
|
297
|
-
const theme = _chunkRHHVEJHJcjs.useXYChartTheme.call(void 0, data);
|
|
298
|
-
const dataSorted = _chunkRHHVEJHJcjs.useChartDataTransform.call(void 0, data);
|
|
299
|
-
const dataWithVisibleZeros = _chunkRHHVEJHJcjs.useZeroValueDisplay.call(void 0, dataSorted, {
|
|
300
|
-
enabled: showZeroValues,
|
|
301
|
-
valueAxisLength: horizontal ? width : height
|
|
302
|
-
});
|
|
303
|
-
const legendItems = _chunkRHHVEJHJcjs.useChartLegendItems.call(void 0, dataSorted);
|
|
304
|
-
const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, options);
|
|
305
|
-
const defaultMargin = _chunkRHHVEJHJcjs.useChartMargin.call(void 0, height, chartOptions, dataSorted, theme, horizontal);
|
|
306
|
-
const [svgWrapperRef, , svgWrapperHeight] = _chunkRHHVEJHJcjs.useElementSize.call(void 0, );
|
|
307
|
-
const chartRef = _react.useRef.call(void 0, null);
|
|
308
|
-
const hasLegendChild = _chunkRHHVEJHJcjs.useHasLegendChild.call(void 0, children);
|
|
309
|
-
const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;
|
|
310
|
-
const hasLegend = showLegend || hasLegendChild;
|
|
311
|
-
const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;
|
|
312
|
-
const [selectedIndex, setSelectedIndex] = _react.useState.call(void 0, void 0);
|
|
313
|
-
const [isNavigating, setIsNavigating] = _react.useState.call(void 0, false);
|
|
314
|
-
const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access', _20 => _20.data, 'optionalAccess', _21 => _21.length]) || 0)) * data.length;
|
|
315
|
-
const {
|
|
316
|
-
tooltipRef,
|
|
317
|
-
onChartFocus,
|
|
318
|
-
onChartBlur,
|
|
319
|
-
onChartKeyDown
|
|
320
|
-
} = _chunkY3NNQMAXcjs.useKeyboardNavigation.call(void 0, {
|
|
321
|
-
selectedIndex,
|
|
322
|
-
setSelectedIndex,
|
|
323
|
-
isNavigating,
|
|
324
|
-
setIsNavigating,
|
|
325
|
-
chartRef,
|
|
326
|
-
totalPoints
|
|
327
|
-
});
|
|
328
|
-
const {
|
|
329
|
-
getElementStyles,
|
|
330
|
-
isSeriesVisible
|
|
331
|
-
} = _chunkRHHVEJHJcjs.useGlobalChartsContext.call(void 0, );
|
|
332
|
-
const providerTheme = _chunkRHHVEJHJcjs.useGlobalChartsTheme.call(void 0, );
|
|
333
|
-
const seriesWithVisibility = _react.useMemo.call(void 0, () => {
|
|
334
|
-
if (!chartId || !legendInteractive) {
|
|
335
|
-
return dataWithVisibleZeros.map((series, index) => ({
|
|
336
|
-
series,
|
|
337
|
-
index,
|
|
338
|
-
isVisible: true
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
return dataWithVisibleZeros.map((series, index) => ({
|
|
342
|
-
series,
|
|
343
|
-
index,
|
|
344
|
-
isVisible: isSeriesVisible(chartId, series.label)
|
|
345
|
-
}));
|
|
346
|
-
}, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);
|
|
347
|
-
const allSeriesHidden = _react.useMemo.call(void 0, () => {
|
|
348
|
-
return seriesWithVisibility.every(({
|
|
349
|
-
isVisible
|
|
350
|
-
}) => !isVisible);
|
|
351
|
-
}, [seriesWithVisibility]);
|
|
352
|
-
const getBarBackground = _react.useCallback.call(void 0, (index) => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({
|
|
353
|
-
data: dataSorted[index],
|
|
354
|
-
index
|
|
355
|
-
}).color, [withPatterns, getElementStyles, dataSorted, chartId]);
|
|
356
|
-
const renderDefaultTooltip = _react.useCallback.call(void 0, ({
|
|
357
|
-
tooltipData
|
|
358
|
-
}) => {
|
|
359
|
-
const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _22 => _22.nearestDatum, 'optionalAccess', _23 => _23.datum]);
|
|
360
|
-
if (!nearestDatum) return null;
|
|
361
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
362
|
-
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
363
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
364
|
-
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
365
|
-
children: _optionalChain([tooltipData, 'optionalAccess', _24 => _24.nearestDatum, 'optionalAccess', _25 => _25.key])
|
|
366
|
-
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
367
|
-
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
368
|
-
children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
369
|
-
className: bar_chart_module_default["bar-chart__tooltip-label"],
|
|
370
|
-
children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), ":"]
|
|
371
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
372
|
-
className: bar_chart_module_default["bar-chart__tooltip-value"],
|
|
373
|
-
children: _numberformatters.formatNumber.call(void 0, nearestDatum.value)
|
|
374
|
-
})]
|
|
375
|
-
})]
|
|
376
|
-
});
|
|
377
|
-
}, [chartOptions.tooltip]);
|
|
378
|
-
const renderPattern = _react.useCallback.call(void 0, (index, color) => {
|
|
379
|
-
const patternType = index % 4;
|
|
380
|
-
const id = getPatternId(chartId, index);
|
|
381
|
-
const commonProps = {
|
|
382
|
-
id,
|
|
383
|
-
stroke: "white",
|
|
384
|
-
strokeWidth: 1,
|
|
385
|
-
background: color
|
|
386
|
-
};
|
|
387
|
-
switch (patternType) {
|
|
388
|
-
case 0:
|
|
389
|
-
default:
|
|
390
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternLines, {
|
|
391
|
-
...commonProps,
|
|
392
|
-
width: 5,
|
|
393
|
-
height: 5,
|
|
394
|
-
orientation: ["diagonal"]
|
|
395
|
-
}, id);
|
|
396
|
-
case 1:
|
|
397
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternCircles, {
|
|
398
|
-
...commonProps,
|
|
399
|
-
width: 6,
|
|
400
|
-
height: 6,
|
|
401
|
-
fill: "white"
|
|
402
|
-
}, id);
|
|
403
|
-
case 2:
|
|
404
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternWaves, {
|
|
405
|
-
...commonProps,
|
|
406
|
-
width: 4,
|
|
407
|
-
height: 4
|
|
408
|
-
}, id);
|
|
409
|
-
case 3:
|
|
410
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pattern.PatternHexagons, {
|
|
411
|
-
...commonProps,
|
|
412
|
-
size: 8,
|
|
413
|
-
height: 3
|
|
414
|
-
}, id);
|
|
415
|
-
}
|
|
416
|
-
}, [chartId]);
|
|
417
|
-
const createPatternBorderStyle = _react.useCallback.call(void 0, (index, color) => {
|
|
418
|
-
const patternId = getPatternId(chartId, index);
|
|
419
|
-
return `
|
|
420
|
-
.visx-bar[fill="url(#${patternId})"] {
|
|
421
|
-
stroke: ${color};
|
|
422
|
-
stroke-width: 1;
|
|
423
|
-
}
|
|
424
|
-
`;
|
|
425
|
-
}, [chartId]);
|
|
426
|
-
const createKeyboardHighlightStyle = _react.useCallback.call(void 0, () => {
|
|
427
|
-
if (selectedIndex === void 0) return "";
|
|
428
|
-
const maxDataPoints = Math.max(...data.map((s) => s.data.length));
|
|
429
|
-
const dataPointIndex = Math.floor(selectedIndex / data.length);
|
|
430
|
-
const seriesIndex = selectedIndex % data.length;
|
|
431
|
-
if (dataPointIndex >= maxDataPoints || seriesIndex >= data.length) {
|
|
432
|
-
return "";
|
|
433
|
-
}
|
|
434
|
-
const seriesData = data[seriesIndex];
|
|
435
|
-
if (dataPointIndex >= seriesData.data.length) {
|
|
436
|
-
return "";
|
|
437
|
-
}
|
|
438
|
-
const actualBarIndex = seriesIndex * maxDataPoints + dataPointIndex;
|
|
439
|
-
const generatedStyles = `
|
|
440
|
-
.bar-chart[data-chart-id="bar-chart-${chartId}"] .visx-bar-group .visx-bar:nth-child(${actualBarIndex + 1}) {
|
|
441
|
-
stroke: #005fcc;
|
|
442
|
-
stroke-width: 2px;
|
|
443
|
-
}
|
|
444
|
-
`;
|
|
445
|
-
return generatedStyles;
|
|
446
|
-
}, [selectedIndex, data, chartId]);
|
|
447
|
-
const error = validateData(dataSorted);
|
|
448
|
-
const isDataValid = !error;
|
|
449
|
-
const chartMetadata = _react.useMemo.call(void 0, () => ({
|
|
450
|
-
orientation,
|
|
451
|
-
withPatterns
|
|
452
|
-
}), [orientation, withPatterns]);
|
|
453
|
-
_chunkRHHVEJHJcjs.useChartRegistration.call(void 0, {
|
|
454
|
-
chartId,
|
|
455
|
-
legendItems,
|
|
456
|
-
chartType: "bar",
|
|
457
|
-
isDataValid,
|
|
458
|
-
metadata: chartMetadata
|
|
459
|
-
});
|
|
460
|
-
const prefersReducedMotion = _chunkRHHVEJHJcjs.usePrefersReducedMotion.call(void 0, );
|
|
461
|
-
if (error) {
|
|
462
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
463
|
-
className: _clsx2.default.call(void 0, "bar-chart", bar_chart_module_default["bar-chart"]),
|
|
464
|
-
children: error
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
const gridVisibility = _nullishCoalesce(gridVisibilityProp, () => ( chartOptions.gridVisibility));
|
|
468
|
-
const highlightedBarStyle = createKeyboardHighlightStyle();
|
|
469
|
-
const legendElement = showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRHHVEJHJcjs.Legend, {
|
|
470
|
-
orientation: legendOrientation,
|
|
471
|
-
position: legendPosition,
|
|
472
|
-
alignment: legendAlignment,
|
|
473
|
-
labelStyles: {
|
|
474
|
-
maxWidth: legendMaxWidth,
|
|
475
|
-
textOverflow: legendTextOverflow
|
|
476
|
-
},
|
|
477
|
-
itemClassName: legendItemClassName,
|
|
478
|
-
className: bar_chart_module_default["bar-chart__legend"],
|
|
479
|
-
shape: legendShape,
|
|
480
|
-
chartId,
|
|
481
|
-
interactive: legendInteractive
|
|
482
|
-
});
|
|
483
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRHHVEJHJcjs.SingleChartContext.Provider, {
|
|
484
|
-
value: {
|
|
485
|
-
chartId,
|
|
486
|
-
chartWidth: width,
|
|
487
|
-
chartHeight
|
|
488
|
-
},
|
|
489
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkI35UYJJRcjs.Stack, {
|
|
490
|
-
direction: "column",
|
|
491
|
-
gap,
|
|
492
|
-
className: _clsx2.default.call(void 0, "bar-chart", bar_chart_module_default["bar-chart"], {
|
|
493
|
-
[bar_chart_module_default[`bar-chart--animated${horizontal ? "-horizontal" : ""}`]]: animation && !prefersReducedMotion
|
|
494
|
-
}, className),
|
|
495
|
-
style: {
|
|
496
|
-
width,
|
|
497
|
-
height,
|
|
498
|
-
visibility: isWaitingForMeasurement ? "hidden" : "visible"
|
|
499
|
-
},
|
|
500
|
-
"data-chart-id": `bar-chart-${chartId}`,
|
|
501
|
-
children: [legendPosition === "top" && legendElement, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
502
|
-
className: bar_chart_module_default["bar-chart__svg-wrapper"],
|
|
503
|
-
ref: svgWrapperRef,
|
|
504
|
-
role: "grid",
|
|
505
|
-
"aria-label": _i18n.__.call(void 0, "Bar chart", "jetpack-charts"),
|
|
506
|
-
tabIndex: 0,
|
|
507
|
-
onKeyDown: onChartKeyDown,
|
|
508
|
-
onFocus: onChartFocus,
|
|
509
|
-
onBlur: onChartBlur,
|
|
510
|
-
children: !isWaitingForMeasurement && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
511
|
-
ref: chartRef,
|
|
512
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _xychart.XYChart, {
|
|
513
|
-
theme,
|
|
514
|
-
width,
|
|
515
|
-
height: chartHeight,
|
|
516
|
-
margin: {
|
|
517
|
-
...defaultMargin,
|
|
518
|
-
...margin
|
|
519
|
-
},
|
|
520
|
-
xScale: chartOptions.xScale,
|
|
521
|
-
yScale: chartOptions.yScale,
|
|
522
|
-
horizontal,
|
|
523
|
-
pointerEventsDataKey: "nearest",
|
|
524
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Grid, {
|
|
525
|
-
columns: gridVisibility.includes("y"),
|
|
526
|
-
rows: gridVisibility.includes("x"),
|
|
527
|
-
numTicks: 4
|
|
528
|
-
}), withPatterns && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
529
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "defs", {
|
|
530
|
-
children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({
|
|
531
|
-
data: seriesData,
|
|
532
|
-
index
|
|
533
|
-
}).color))
|
|
534
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", {
|
|
535
|
-
children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({
|
|
536
|
-
data: seriesData,
|
|
537
|
-
index
|
|
538
|
-
}).color))
|
|
539
|
-
})]
|
|
540
|
-
}), highlightedBarStyle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", {
|
|
541
|
-
children: highlightedBarStyle
|
|
542
|
-
}), allSeriesHidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
543
|
-
x: width / 2,
|
|
544
|
-
y: chartHeight / 2,
|
|
545
|
-
textAnchor: "middle",
|
|
546
|
-
fill: _optionalChain([providerTheme, 'access', _26 => _26.gridStyles, 'optionalAccess', _27 => _27.stroke]) || "#ccc",
|
|
547
|
-
fontSize: "14",
|
|
548
|
-
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
549
|
-
children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
550
|
-
}) : null, /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarGroup, {
|
|
551
|
-
padding: chartOptions.barGroup.padding,
|
|
552
|
-
children: seriesWithVisibility.map(({
|
|
553
|
-
series: seriesData,
|
|
554
|
-
index,
|
|
555
|
-
isVisible
|
|
556
|
-
}) => {
|
|
557
|
-
if (!isVisible) {
|
|
558
|
-
return null;
|
|
559
|
-
}
|
|
560
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarSeries, {
|
|
561
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess', _28 => _28.label]),
|
|
562
|
-
data: seriesData.data,
|
|
563
|
-
yAccessor: chartOptions.accessors.yAccessor,
|
|
564
|
-
xAccessor: chartOptions.accessors.xAccessor,
|
|
565
|
-
colorAccessor: getBarBackground(index)
|
|
566
|
-
}, _optionalChain([seriesData, 'optionalAccess', _29 => _29.label]));
|
|
567
|
-
})
|
|
568
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
569
|
-
...chartOptions.axis.x
|
|
570
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
571
|
-
...chartOptions.axis.y
|
|
572
|
-
}), withTooltips && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3NNQMAXcjs.AccessibleTooltip, {
|
|
573
|
-
detectBounds: true,
|
|
574
|
-
snapTooltipToDatumX: true,
|
|
575
|
-
snapTooltipToDatumY: true,
|
|
576
|
-
renderTooltip: renderTooltip || renderDefaultTooltip,
|
|
577
|
-
selectedIndex,
|
|
578
|
-
tooltipRef,
|
|
579
|
-
keyboardFocusedClassName: bar_chart_module_default["bar-chart__tooltip--keyboard-focused"],
|
|
580
|
-
series: data,
|
|
581
|
-
mode: "individual"
|
|
582
|
-
})]
|
|
583
|
-
})
|
|
584
|
-
})
|
|
585
|
-
}), legendPosition === "bottom" && legendElement, children]
|
|
586
|
-
})
|
|
587
|
-
});
|
|
588
|
-
};
|
|
589
|
-
var BarChartWithProvider = (props) => {
|
|
590
|
-
const existingContext = _react.useContext.call(void 0, _chunkRHHVEJHJcjs.GlobalChartsContext);
|
|
591
|
-
if (existingContext) {
|
|
592
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BarChartInternal, {
|
|
593
|
-
...props
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRHHVEJHJcjs.GlobalChartsProvider, {
|
|
597
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BarChartInternal, {
|
|
598
|
-
...props
|
|
599
|
-
})
|
|
600
|
-
});
|
|
601
|
-
};
|
|
602
|
-
BarChartWithProvider.displayName = "BarChart";
|
|
603
|
-
var BarChart = _chunkVTS3PNMScjs.attachSubComponents.call(void 0, BarChartWithProvider, {
|
|
604
|
-
Legend: _chunkRHHVEJHJcjs.Legend
|
|
605
|
-
});
|
|
606
|
-
var BarChartResponsive = _chunkVTS3PNMScjs.attachSubComponents.call(void 0, _chunkASLARV7Lcjs.withResponsive.call(void 0, BarChartWithProvider), {
|
|
607
|
-
Legend: _chunkRHHVEJHJcjs.Legend
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
exports.BarChart = BarChart; exports.BarChartResponsive = BarChartResponsive;
|
|
614
|
-
//# sourceMappingURL=chunk-VJM5XCB4.cjs.map
|