@automattic/charts 0.58.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 +20 -0
- package/README.md +7 -54
- package/dist/index.cjs +9606 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -25
- 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 -56
- package/dist/index.js.map +1 -1
- package/package.json +8 -125
- package/src/charts/bar-chart/bar-chart.module.scss +0 -5
- package/src/charts/bar-chart/bar-chart.tsx +131 -137
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +23 -40
- package/src/charts/line-chart/line-chart.module.scss +0 -5
- package/src/charts/line-chart/line-chart.tsx +190 -183
- package/src/charts/line-chart/private/line-chart-annotations-overlay.tsx +1 -2
- package/src/charts/pie-chart/pie-chart.module.scss +2 -10
- package/src/charts/pie-chart/pie-chart.tsx +198 -199
- package/src/charts/pie-chart/test/composition-api.test.tsx +3 -3
- package/src/charts/pie-chart/test/pie-chart.test.tsx +42 -35
- 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 +155 -155
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +25 -25
- 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/legend.tsx +33 -8
- package/src/components/legend/test/legend.test.tsx +93 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-data-with-percentages.ts +24 -0
- package/src/hooks/use-interactive-legend-data.ts +18 -15
- package/src/index.ts +65 -2
- 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 +27 -7
- package/src/utils/test/resolve-css-var.test.ts +2 -0
- 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 -17
- package/dist/charts/bar-chart/index.cjs.map +0 -1
- package/dist/charts/bar-chart/index.css +0 -141
- package/dist/charts/bar-chart/index.css.map +0 -1
- package/dist/charts/bar-chart/index.d.cts +0 -36
- package/dist/charts/bar-chart/index.d.ts +0 -36
- package/dist/charts/bar-chart/index.js +0 -17
- package/dist/charts/bar-chart/index.js.map +0 -1
- package/dist/charts/bar-list-chart/index.cjs +0 -18
- package/dist/charts/bar-list-chart/index.cjs.map +0 -1
- package/dist/charts/bar-list-chart/index.css +0 -141
- 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 -18
- 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 -157
- 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 -23
- 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 -21
- package/dist/charts/leaderboard-chart/index.cjs.map +0 -1
- package/dist/charts/leaderboard-chart/index.css +0 -160
- 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 -21
- package/dist/charts/leaderboard-chart/index.js.map +0 -1
- package/dist/charts/line-chart/index.cjs +0 -17
- package/dist/charts/line-chart/index.cjs.map +0 -1
- package/dist/charts/line-chart/index.css +0 -213
- package/dist/charts/line-chart/index.css.map +0 -1
- package/dist/charts/line-chart/index.d.cts +0 -98
- package/dist/charts/line-chart/index.d.ts +0 -98
- package/dist/charts/line-chart/index.js +0 -17
- package/dist/charts/line-chart/index.js.map +0 -1
- package/dist/charts/pie-chart/index.cjs +0 -19
- package/dist/charts/pie-chart/index.cjs.map +0 -1
- package/dist/charts/pie-chart/index.css +0 -131
- package/dist/charts/pie-chart/index.css.map +0 -1
- package/dist/charts/pie-chart/index.d.cts +0 -91
- package/dist/charts/pie-chart/index.d.ts +0 -91
- package/dist/charts/pie-chart/index.js +0 -19
- package/dist/charts/pie-chart/index.js.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.cjs +0 -18
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.css +0 -132
- package/dist/charts/pie-semi-circle-chart/index.css.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.d.ts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.js +0 -18
- package/dist/charts/pie-semi-circle-chart/index.js.map +0 -1
- package/dist/charts/sparkline/index.cjs +0 -18
- package/dist/charts/sparkline/index.cjs.map +0 -1
- package/dist/charts/sparkline/index.css +0 -230
- 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 -18
- 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-2I67QUIV.js +0 -895
- package/dist/chunk-2I67QUIV.js.map +0 -1
- package/dist/chunk-2ICEEQOC.js +0 -1071
- package/dist/chunk-2ICEEQOC.js.map +0 -1
- package/dist/chunk-4B7BL2DD.js +0 -120
- package/dist/chunk-4B7BL2DD.js.map +0 -1
- package/dist/chunk-4OXMTKAL.js +0 -401
- package/dist/chunk-4OXMTKAL.js.map +0 -1
- package/dist/chunk-ASLARV7L.cjs +0 -81
- package/dist/chunk-ASLARV7L.cjs.map +0 -1
- package/dist/chunk-B6NLZFRW.js +0 -617
- package/dist/chunk-B6NLZFRW.js.map +0 -1
- package/dist/chunk-BBAUQOW6.cjs +0 -120
- package/dist/chunk-BBAUQOW6.cjs.map +0 -1
- package/dist/chunk-BPYKWMI7.js +0 -194
- package/dist/chunk-BPYKWMI7.js.map +0 -1
- package/dist/chunk-CMMHCTBX.cjs +0 -373
- package/dist/chunk-CMMHCTBX.cjs.map +0 -1
- package/dist/chunk-CPPXJATQ.cjs +0 -1071
- package/dist/chunk-CPPXJATQ.cjs.map +0 -1
- package/dist/chunk-DKU775VC.js +0 -219
- package/dist/chunk-DKU775VC.js.map +0 -1
- package/dist/chunk-GRA7Y2ZG.cjs +0 -401
- package/dist/chunk-GRA7Y2ZG.cjs.map +0 -1
- package/dist/chunk-I2276W3I.cjs +0 -66
- package/dist/chunk-I2276W3I.cjs.map +0 -1
- package/dist/chunk-JJIMABHT.js +0 -351
- package/dist/chunk-JJIMABHT.js.map +0 -1
- package/dist/chunk-KJHWXOCZ.js +0 -421
- package/dist/chunk-KJHWXOCZ.js.map +0 -1
- package/dist/chunk-KRWGSOJ2.js +0 -91
- package/dist/chunk-KRWGSOJ2.js.map +0 -1
- package/dist/chunk-KXRWNFQJ.js +0 -51
- package/dist/chunk-KXRWNFQJ.js.map +0 -1
- package/dist/chunk-LTFH7SEG.js +0 -373
- package/dist/chunk-LTFH7SEG.js.map +0 -1
- package/dist/chunk-MUNOKLLE.js +0 -165
- package/dist/chunk-MUNOKLLE.js.map +0 -1
- package/dist/chunk-MXGLYWVP.cjs +0 -351
- package/dist/chunk-MXGLYWVP.cjs.map +0 -1
- package/dist/chunk-OP6PHB2U.js +0 -81
- package/dist/chunk-OP6PHB2U.js.map +0 -1
- package/dist/chunk-OYC34VTO.cjs +0 -3957
- package/dist/chunk-OYC34VTO.cjs.map +0 -1
- package/dist/chunk-PQL5I3F6.cjs +0 -421
- package/dist/chunk-PQL5I3F6.cjs.map +0 -1
- package/dist/chunk-REZTQ4PH.cjs +0 -488
- package/dist/chunk-REZTQ4PH.cjs.map +0 -1
- package/dist/chunk-TZRUHQOH.cjs +0 -91
- package/dist/chunk-TZRUHQOH.cjs.map +0 -1
- package/dist/chunk-UTYVIOWZ.js +0 -3957
- package/dist/chunk-UTYVIOWZ.js.map +0 -1
- package/dist/chunk-W2LDIX26.cjs +0 -165
- package/dist/chunk-W2LDIX26.cjs.map +0 -1
- package/dist/chunk-WSG64BVN.cjs +0 -219
- package/dist/chunk-WSG64BVN.cjs.map +0 -1
- package/dist/chunk-WTQYGUNF.js +0 -400
- package/dist/chunk-WTQYGUNF.js.map +0 -1
- package/dist/chunk-WYK7EL5R.cjs +0 -895
- package/dist/chunk-WYK7EL5R.cjs.map +0 -1
- package/dist/chunk-XC4KHJYX.cjs +0 -617
- package/dist/chunk-XC4KHJYX.cjs.map +0 -1
- package/dist/chunk-XVBH5XHE.cjs +0 -400
- package/dist/chunk-XVBH5XHE.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-YAFQVVDI.js +0 -488
- package/dist/chunk-YAFQVVDI.js.map +0 -1
- package/dist/components/legend/index.cjs +0 -12
- package/dist/components/legend/index.cjs.map +0 -1
- package/dist/components/legend/index.css +0 -91
- 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 -12
- 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 -29
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.css +0 -9
- package/dist/hooks/index.css.map +0 -1
- package/dist/hooks/index.d.cts +0 -264
- package/dist/hooks/index.d.ts +0 -264
- package/dist/hooks/index.js +0 -29
- package/dist/hooks/index.js.map +0 -1
- package/dist/leaderboard-chart-BSbg0ufV.d.cts +0 -79
- package/dist/leaderboard-chart-odEYxxEC.d.ts +0 -79
- package/dist/legend-DFkosEvC.d.cts +0 -9
- package/dist/legend-DLswHhOk.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 -9
- 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-D0qc5JaW.d.cts +0 -67
- package/dist/themes-itO4Ht5g.d.ts +0 -67
- package/dist/types-B5f6XQ7Q.d.cts +0 -19
- package/dist/types-BsHooDbM.d.ts +0 -19
- package/dist/types-BuSrRM4p.d.ts +0 -49
- package/dist/types-ChOUI9-N.d.cts +0 -545
- package/dist/types-ChOUI9-N.d.ts +0 -545
- package/dist/types-Dfw9VOKI.d.cts +0 -49
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.0",
|
|
4
4
|
"description": "Display charts within Automattic products.",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/charts/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -22,79 +22,7 @@
|
|
|
22
22
|
"import": "./dist/index.js",
|
|
23
23
|
"require": "./dist/index.cjs"
|
|
24
24
|
},
|
|
25
|
-
"./bar-chart": {
|
|
26
|
-
"import": "./dist/charts/bar-chart/index.js",
|
|
27
|
-
"require": "./dist/charts/bar-chart/index.cjs"
|
|
28
|
-
},
|
|
29
|
-
"./bar-chart/style.css": "./dist/charts/bar-chart/index.css",
|
|
30
|
-
"./bar-list-chart": {
|
|
31
|
-
"import": "./dist/charts/bar-list-chart/index.js",
|
|
32
|
-
"require": "./dist/charts/bar-list-chart/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./bar-list-chart/style.css": "./dist/charts/bar-list-chart/index.css",
|
|
35
|
-
"./conversion-funnel-chart": {
|
|
36
|
-
"import": "./dist/charts/conversion-funnel-chart/index.js",
|
|
37
|
-
"require": "./dist/charts/conversion-funnel-chart/index.cjs"
|
|
38
|
-
},
|
|
39
|
-
"./conversion-funnel-chart/style.css": "./dist/charts/conversion-funnel-chart/index.css",
|
|
40
|
-
"./geo-chart": {
|
|
41
|
-
"import": "./dist/charts/geo-chart/index.js",
|
|
42
|
-
"require": "./dist/charts/geo-chart/index.cjs"
|
|
43
|
-
},
|
|
44
|
-
"./geo-chart/style.css": "./dist/charts/geo-chart/index.css",
|
|
45
|
-
"./hooks": {
|
|
46
|
-
"import": "./dist/hooks/index.js",
|
|
47
|
-
"require": "./dist/hooks/index.cjs"
|
|
48
|
-
},
|
|
49
|
-
"./leaderboard-chart": {
|
|
50
|
-
"import": "./dist/charts/leaderboard-chart/index.js",
|
|
51
|
-
"require": "./dist/charts/leaderboard-chart/index.cjs"
|
|
52
|
-
},
|
|
53
|
-
"./leaderboard-chart/style.css": "./dist/charts/leaderboard-chart/index.css",
|
|
54
|
-
"./legend": {
|
|
55
|
-
"import": "./dist/components/legend/index.js",
|
|
56
|
-
"require": "./dist/components/legend/index.cjs"
|
|
57
|
-
},
|
|
58
|
-
"./legend/style.css": "./dist/components/legend/index.css",
|
|
59
|
-
"./line-chart": {
|
|
60
|
-
"import": "./dist/charts/line-chart/index.js",
|
|
61
|
-
"require": "./dist/charts/line-chart/index.cjs"
|
|
62
|
-
},
|
|
63
|
-
"./line-chart/style.css": "./dist/charts/line-chart/index.css",
|
|
64
|
-
"./pie-chart": {
|
|
65
|
-
"import": "./dist/charts/pie-chart/index.js",
|
|
66
|
-
"require": "./dist/charts/pie-chart/index.cjs"
|
|
67
|
-
},
|
|
68
|
-
"./pie-chart/style.css": "./dist/charts/pie-chart/index.css",
|
|
69
|
-
"./pie-semi-circle-chart": {
|
|
70
|
-
"import": "./dist/charts/pie-semi-circle-chart/index.js",
|
|
71
|
-
"require": "./dist/charts/pie-semi-circle-chart/index.cjs"
|
|
72
|
-
},
|
|
73
|
-
"./pie-semi-circle-chart/style.css": "./dist/charts/pie-semi-circle-chart/index.css",
|
|
74
|
-
"./providers": {
|
|
75
|
-
"import": "./dist/providers/index.js",
|
|
76
|
-
"require": "./dist/providers/index.cjs"
|
|
77
|
-
},
|
|
78
|
-
"./sparkline": {
|
|
79
|
-
"import": "./dist/charts/sparkline/index.js",
|
|
80
|
-
"require": "./dist/charts/sparkline/index.cjs"
|
|
81
|
-
},
|
|
82
|
-
"./sparkline/style.css": "./dist/charts/sparkline/index.css",
|
|
83
25
|
"./style.css": "./dist/index.css",
|
|
84
|
-
"./tooltip": {
|
|
85
|
-
"import": "./dist/components/tooltip/index.js",
|
|
86
|
-
"require": "./dist/components/tooltip/index.cjs"
|
|
87
|
-
},
|
|
88
|
-
"./tooltip/style.css": "./dist/components/tooltip/index.css",
|
|
89
|
-
"./trend-indicator": {
|
|
90
|
-
"import": "./dist/components/trend-indicator/index.js",
|
|
91
|
-
"require": "./dist/components/trend-indicator/index.cjs"
|
|
92
|
-
},
|
|
93
|
-
"./trend-indicator/style.css": "./dist/components/trend-indicator/index.css",
|
|
94
|
-
"./utils": {
|
|
95
|
-
"import": "./dist/utils/index.js",
|
|
96
|
-
"require": "./dist/utils/index.cjs"
|
|
97
|
-
},
|
|
98
26
|
"./visx/group": {
|
|
99
27
|
"import": "./dist/visx/group/index.js",
|
|
100
28
|
"require": "./dist/visx/group/index.cjs"
|
|
@@ -115,51 +43,6 @@
|
|
|
115
43
|
".": [
|
|
116
44
|
"./dist/index.d.ts"
|
|
117
45
|
],
|
|
118
|
-
"bar-chart": [
|
|
119
|
-
"./dist/charts/bar-chart/index.d.ts"
|
|
120
|
-
],
|
|
121
|
-
"bar-list-chart": [
|
|
122
|
-
"./dist/charts/bar-list-chart/index.d.ts"
|
|
123
|
-
],
|
|
124
|
-
"conversion-funnel-chart": [
|
|
125
|
-
"./dist/charts/conversion-funnel-chart/index.d.ts"
|
|
126
|
-
],
|
|
127
|
-
"geo-chart": [
|
|
128
|
-
"./dist/charts/geo-chart/index.d.ts"
|
|
129
|
-
],
|
|
130
|
-
"hooks": [
|
|
131
|
-
"./dist/hooks/index.d.ts"
|
|
132
|
-
],
|
|
133
|
-
"leaderboard-chart": [
|
|
134
|
-
"./dist/charts/leaderboard-chart/index.d.ts"
|
|
135
|
-
],
|
|
136
|
-
"legend": [
|
|
137
|
-
"./dist/components/legend/index.d.ts"
|
|
138
|
-
],
|
|
139
|
-
"line-chart": [
|
|
140
|
-
"./dist/charts/line-chart/index.d.ts"
|
|
141
|
-
],
|
|
142
|
-
"pie-chart": [
|
|
143
|
-
"./dist/charts/pie-chart/index.d.ts"
|
|
144
|
-
],
|
|
145
|
-
"pie-semi-circle-chart": [
|
|
146
|
-
"./dist/charts/pie-semi-circle-chart/index.d.ts"
|
|
147
|
-
],
|
|
148
|
-
"sparkline": [
|
|
149
|
-
"./dist/charts/sparkline/index.d.ts"
|
|
150
|
-
],
|
|
151
|
-
"providers": [
|
|
152
|
-
"./dist/providers/index.d.ts"
|
|
153
|
-
],
|
|
154
|
-
"tooltip": [
|
|
155
|
-
"./dist/components/tooltip/index.d.ts"
|
|
156
|
-
],
|
|
157
|
-
"trend-indicator": [
|
|
158
|
-
"./dist/components/trend-indicator/index.d.ts"
|
|
159
|
-
],
|
|
160
|
-
"utils": [
|
|
161
|
-
"./dist/utils/index.d.ts"
|
|
162
|
-
],
|
|
163
46
|
"visx/group": [
|
|
164
47
|
"./dist/visx/group/index.d.ts"
|
|
165
48
|
],
|
|
@@ -200,8 +83,8 @@
|
|
|
200
83
|
"@visx/vendor": "^3.12.0",
|
|
201
84
|
"@visx/xychart": "^3.12.0",
|
|
202
85
|
"@wordpress/i18n": "^6.0.0",
|
|
203
|
-
"@wordpress/theme": "0.
|
|
204
|
-
"@wordpress/ui": "0.
|
|
86
|
+
"@wordpress/theme": "0.9.0",
|
|
87
|
+
"@wordpress/ui": "0.9.0",
|
|
205
88
|
"clsx": "2.1.1",
|
|
206
89
|
"date-fns": "^4.1.0",
|
|
207
90
|
"deepmerge": "4.3.1",
|
|
@@ -215,8 +98,8 @@
|
|
|
215
98
|
"@babel/core": "7.29.0",
|
|
216
99
|
"@babel/preset-react": "7.28.5",
|
|
217
100
|
"@babel/preset-typescript": "7.28.5",
|
|
218
|
-
"@storybook/addon-docs": "10.
|
|
219
|
-
"@storybook/react": "10.
|
|
101
|
+
"@storybook/addon-docs": "10.3.1",
|
|
102
|
+
"@storybook/react": "10.3.1",
|
|
220
103
|
"@testing-library/dom": "^10.0.0",
|
|
221
104
|
"@testing-library/jest-dom": "^6.0.0",
|
|
222
105
|
"@testing-library/react": "^16.0.0",
|
|
@@ -226,8 +109,8 @@
|
|
|
226
109
|
"@types/react-dom": "18.3.7",
|
|
227
110
|
"@typescript/native-preview": "7.0.0-dev.20260225.1",
|
|
228
111
|
"@visx/glyph": "3.12.0",
|
|
229
|
-
"@wordpress/components": "32.
|
|
230
|
-
"@wordpress/element": "6.
|
|
112
|
+
"@wordpress/components": "32.4.0",
|
|
113
|
+
"@wordpress/element": "6.42.0",
|
|
231
114
|
"babel-jest": "30.2.0",
|
|
232
115
|
"babel-plugin-react-remove-properties": "^0.3.1",
|
|
233
116
|
"esbuild": "0.25.9",
|
|
@@ -241,7 +124,7 @@
|
|
|
241
124
|
"react": "18.3.1",
|
|
242
125
|
"react-dom": "18.3.1",
|
|
243
126
|
"sass-embedded": "1.97.3",
|
|
244
|
-
"storybook": "10.
|
|
127
|
+
"storybook": "10.3.1",
|
|
245
128
|
"tsup": "8.5.1",
|
|
246
129
|
"typescript": "5.9.3"
|
|
247
130
|
},
|
|
@@ -2,7 +2,6 @@ import { formatNumber } from '@automattic/number-formatters';
|
|
|
2
2
|
import { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from '@visx/pattern';
|
|
3
3
|
import { Axis, BarSeries, BarGroup, Grid, XYChart } from '@visx/xychart';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { Stack } from '@wordpress/ui';
|
|
6
5
|
import clsx from 'clsx';
|
|
7
6
|
import { useCallback, useContext, useState, useRef, useMemo } from 'react';
|
|
8
7
|
import { Legend, useChartLegendItems } from '../../components/legend';
|
|
@@ -12,7 +11,6 @@ import {
|
|
|
12
11
|
useChartDataTransform,
|
|
13
12
|
useZeroValueDisplay,
|
|
14
13
|
useChartMargin,
|
|
15
|
-
useElementSize,
|
|
16
14
|
usePrefersReducedMotion,
|
|
17
15
|
} from '../../hooks';
|
|
18
16
|
import {
|
|
@@ -20,12 +18,13 @@ import {
|
|
|
20
18
|
useChartId,
|
|
21
19
|
useChartRegistration,
|
|
22
20
|
useGlobalChartsContext,
|
|
23
|
-
useGlobalChartsTheme,
|
|
24
21
|
GlobalChartsContext,
|
|
25
22
|
} from '../../providers';
|
|
26
23
|
import { attachSubComponents } from '../../utils';
|
|
27
|
-
import { useChartChildren
|
|
24
|
+
import { useChartChildren } from '../private/chart-composition';
|
|
25
|
+
import { ChartLayout } from '../private/chart-layout';
|
|
28
26
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
27
|
+
import { SvgEmptyState } from '../private/svg-empty-state';
|
|
29
28
|
import { withResponsive } from '../private/with-responsive';
|
|
30
29
|
import styles from './bar-chart.module.scss';
|
|
31
30
|
import { useBarChartOptions } from './private';
|
|
@@ -113,19 +112,19 @@ const BarChartInternal: FC< BarChartProps > = ( {
|
|
|
113
112
|
const legendItems = useChartLegendItems( dataSorted );
|
|
114
113
|
const chartOptions = useBarChartOptions( dataWithVisibleZeros, horizontal, options );
|
|
115
114
|
const defaultMargin = useChartMargin( height, chartOptions, dataSorted, theme, horizontal );
|
|
116
|
-
const [ svgWrapperRef, , svgWrapperHeight ] = useElementSize< HTMLDivElement >();
|
|
117
115
|
const chartRef = useRef< HTMLDivElement >( null );
|
|
118
116
|
|
|
119
117
|
// Process children for composition API (Legend, etc.)
|
|
120
118
|
const { legendChildren, nonLegendChildren } = useChartChildren( children, 'BarChart' );
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
const [ measuredChartHeight, setMeasuredChartHeight ] = useState< number | undefined >();
|
|
120
|
+
|
|
121
|
+
const handleContentHeightChange = useCallback(
|
|
122
|
+
( contentHeight: number ) => {
|
|
123
|
+
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
124
|
+
setMeasuredChartHeight( chartHeight );
|
|
125
|
+
},
|
|
126
|
+
[ height ]
|
|
127
|
+
);
|
|
129
128
|
const [ selectedIndex, setSelectedIndex ] = useState< number | undefined >( undefined );
|
|
130
129
|
const [ isNavigating, setIsNavigating ] = useState( false );
|
|
131
130
|
|
|
@@ -143,7 +142,6 @@ const BarChartInternal: FC< BarChartProps > = ( {
|
|
|
143
142
|
} );
|
|
144
143
|
|
|
145
144
|
const { getElementStyles, isSeriesVisible } = useGlobalChartsContext();
|
|
146
|
-
const providerTheme = useGlobalChartsTheme();
|
|
147
145
|
|
|
148
146
|
// Add visibility information to series when using interactive legends
|
|
149
147
|
const seriesWithVisibility = useMemo( () => {
|
|
@@ -343,11 +341,13 @@ const BarChartInternal: FC< BarChartProps > = ( {
|
|
|
343
341
|
value={ {
|
|
344
342
|
chartId,
|
|
345
343
|
chartWidth: width,
|
|
346
|
-
chartHeight,
|
|
344
|
+
chartHeight: measuredChartHeight || 0,
|
|
347
345
|
} }
|
|
348
346
|
>
|
|
349
|
-
<
|
|
350
|
-
|
|
347
|
+
<ChartLayout
|
|
348
|
+
legendPosition={ legendPosition }
|
|
349
|
+
legendElement={ legendElement }
|
|
350
|
+
legendChildren={ legendChildren }
|
|
351
351
|
gap={ gap }
|
|
352
352
|
className={ clsx(
|
|
353
353
|
'bar-chart',
|
|
@@ -358,133 +358,127 @@ const BarChartInternal: FC< BarChartProps > = ( {
|
|
|
358
358
|
},
|
|
359
359
|
className
|
|
360
360
|
) }
|
|
361
|
+
style={ { width, height } }
|
|
361
362
|
data-testid="bar-chart"
|
|
362
|
-
style={ {
|
|
363
|
-
width,
|
|
364
|
-
height,
|
|
365
|
-
visibility: isWaitingForMeasurement ? 'hidden' : 'visible',
|
|
366
|
-
} }
|
|
367
363
|
data-chart-id={ `bar-chart-${ chartId }` }
|
|
364
|
+
trailingContent={ nonLegendChildren }
|
|
365
|
+
onContentHeightChange={ handleContentHeightChange }
|
|
368
366
|
>
|
|
369
|
-
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
pointerEventsDataKey="nearest"
|
|
396
|
-
>
|
|
397
|
-
<Grid
|
|
398
|
-
columns={ gridVisibility.includes( 'y' ) }
|
|
399
|
-
rows={ gridVisibility.includes( 'x' ) }
|
|
400
|
-
numTicks={ 4 }
|
|
401
|
-
/>
|
|
402
|
-
|
|
403
|
-
{ withPatterns && (
|
|
404
|
-
<>
|
|
405
|
-
<defs data-testid="bar-chart-patterns">
|
|
406
|
-
{ dataSorted.map( ( seriesData, index ) =>
|
|
407
|
-
renderPattern(
|
|
408
|
-
index,
|
|
409
|
-
getElementStyles( { data: seriesData, index } ).color
|
|
410
|
-
)
|
|
411
|
-
) }
|
|
412
|
-
</defs>
|
|
413
|
-
<style>
|
|
414
|
-
{ dataSorted.map( ( seriesData, index ) =>
|
|
415
|
-
createPatternBorderStyle(
|
|
416
|
-
index,
|
|
417
|
-
getElementStyles( { data: seriesData, index } ).color
|
|
418
|
-
)
|
|
419
|
-
) }
|
|
420
|
-
</style>
|
|
421
|
-
</>
|
|
422
|
-
) }
|
|
423
|
-
|
|
424
|
-
{ highlightedBarStyle && <style>{ highlightedBarStyle }</style> }
|
|
425
|
-
|
|
426
|
-
{ allSeriesHidden ? (
|
|
427
|
-
<text
|
|
428
|
-
x={ width / 2 }
|
|
429
|
-
y={ chartHeight / 2 }
|
|
430
|
-
textAnchor="middle"
|
|
431
|
-
fill={ providerTheme.gridStyles?.stroke || '#ccc' }
|
|
432
|
-
fontSize="14"
|
|
433
|
-
fontFamily="-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif"
|
|
367
|
+
{ ( { contentHeight } ) => {
|
|
368
|
+
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
369
|
+
|
|
370
|
+
return (
|
|
371
|
+
<div
|
|
372
|
+
role="grid"
|
|
373
|
+
aria-label={ __( 'Bar chart', 'jetpack-charts' ) }
|
|
374
|
+
tabIndex={ 0 }
|
|
375
|
+
onKeyDown={ onChartKeyDown }
|
|
376
|
+
onFocus={ onChartFocus }
|
|
377
|
+
onBlur={ onChartBlur }
|
|
378
|
+
>
|
|
379
|
+
{ chartHeight > 0 && (
|
|
380
|
+
<div ref={ chartRef }>
|
|
381
|
+
<XYChart
|
|
382
|
+
theme={ theme }
|
|
383
|
+
width={ width }
|
|
384
|
+
height={ chartHeight }
|
|
385
|
+
margin={ {
|
|
386
|
+
...defaultMargin,
|
|
387
|
+
...margin,
|
|
388
|
+
} }
|
|
389
|
+
xScale={ chartOptions.xScale }
|
|
390
|
+
yScale={ chartOptions.yScale }
|
|
391
|
+
horizontal={ horizontal }
|
|
392
|
+
pointerEventsDataKey="nearest"
|
|
434
393
|
>
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
'
|
|
394
|
+
<Grid
|
|
395
|
+
columns={ gridVisibility.includes( 'y' ) }
|
|
396
|
+
rows={ gridVisibility.includes( 'x' ) }
|
|
397
|
+
numTicks={ 4 }
|
|
398
|
+
/>
|
|
399
|
+
|
|
400
|
+
{ withPatterns && (
|
|
401
|
+
<>
|
|
402
|
+
<defs data-testid="bar-chart-patterns">
|
|
403
|
+
{ dataSorted.map( ( seriesData, index ) =>
|
|
404
|
+
renderPattern(
|
|
405
|
+
index,
|
|
406
|
+
getElementStyles( { data: seriesData, index } ).color
|
|
407
|
+
)
|
|
408
|
+
) }
|
|
409
|
+
</defs>
|
|
410
|
+
<style>
|
|
411
|
+
{ dataSorted.map( ( seriesData, index ) =>
|
|
412
|
+
createPatternBorderStyle(
|
|
413
|
+
index,
|
|
414
|
+
getElementStyles( { data: seriesData, index } ).color
|
|
415
|
+
)
|
|
416
|
+
) }
|
|
417
|
+
</style>
|
|
418
|
+
</>
|
|
438
419
|
) }
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
420
|
+
|
|
421
|
+
{ highlightedBarStyle && <style>{ highlightedBarStyle }</style> }
|
|
422
|
+
|
|
423
|
+
{ allSeriesHidden ? (
|
|
424
|
+
<SvgEmptyState
|
|
425
|
+
x={ width / 2 }
|
|
426
|
+
y={ chartHeight / 2 }
|
|
427
|
+
width={ width }
|
|
428
|
+
height={ chartHeight }
|
|
429
|
+
>
|
|
430
|
+
{ __(
|
|
431
|
+
'All series are hidden. Click legend items to show data.',
|
|
432
|
+
'jetpack-charts'
|
|
433
|
+
) }
|
|
434
|
+
</SvgEmptyState>
|
|
435
|
+
) : null }
|
|
436
|
+
|
|
437
|
+
<BarGroup padding={ chartOptions.barGroup.padding }>
|
|
438
|
+
{ seriesWithVisibility.map( ( { series: seriesData, index, isVisible } ) => {
|
|
439
|
+
// Skip rendering invisible series
|
|
440
|
+
if ( ! isVisible ) {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<BarSeries
|
|
446
|
+
key={ seriesData?.label }
|
|
447
|
+
dataKey={ seriesData?.label }
|
|
448
|
+
data={ seriesData.data as DataPointDate[] }
|
|
449
|
+
yAccessor={ chartOptions.accessors.yAccessor }
|
|
450
|
+
xAccessor={ chartOptions.accessors.xAccessor }
|
|
451
|
+
colorAccessor={ getBarBackground( index ) }
|
|
452
|
+
/>
|
|
453
|
+
);
|
|
454
|
+
} ) }
|
|
455
|
+
</BarGroup>
|
|
456
|
+
|
|
457
|
+
<Axis { ...chartOptions.axis.x } />
|
|
458
|
+
<Axis { ...chartOptions.axis.y } />
|
|
459
|
+
|
|
460
|
+
{ withTooltips && (
|
|
461
|
+
<AccessibleTooltip
|
|
462
|
+
detectBounds
|
|
463
|
+
snapTooltipToDatumX
|
|
464
|
+
snapTooltipToDatumY
|
|
465
|
+
renderTooltip={ renderTooltip || renderDefaultTooltip }
|
|
466
|
+
selectedIndex={ selectedIndex }
|
|
467
|
+
tooltipRef={ tooltipRef }
|
|
468
|
+
keyboardFocusedClassName={
|
|
469
|
+
styles[ 'bar-chart__tooltip--keyboard-focused' ]
|
|
470
|
+
}
|
|
471
|
+
series={ data }
|
|
472
|
+
mode="individual"
|
|
457
473
|
/>
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
</
|
|
461
|
-
|
|
462
|
-
<Axis { ...chartOptions.axis.x } />
|
|
463
|
-
<Axis { ...chartOptions.axis.y } />
|
|
464
|
-
|
|
465
|
-
{ withTooltips && (
|
|
466
|
-
<AccessibleTooltip
|
|
467
|
-
detectBounds
|
|
468
|
-
snapTooltipToDatumX
|
|
469
|
-
snapTooltipToDatumY
|
|
470
|
-
renderTooltip={ renderTooltip || renderDefaultTooltip }
|
|
471
|
-
selectedIndex={ selectedIndex }
|
|
472
|
-
tooltipRef={ tooltipRef }
|
|
473
|
-
keyboardFocusedClassName={ styles[ 'bar-chart__tooltip--keyboard-focused' ] }
|
|
474
|
-
series={ data }
|
|
475
|
-
mode="individual"
|
|
476
|
-
/>
|
|
477
|
-
) }
|
|
478
|
-
</XYChart>
|
|
474
|
+
) }
|
|
475
|
+
</XYChart>
|
|
476
|
+
</div>
|
|
477
|
+
) }
|
|
479
478
|
</div>
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
{ legendPosition === 'bottom' && legendElement }
|
|
484
|
-
{ renderLegendSlot( legendChildren, 'bottom' ) }
|
|
485
|
-
|
|
486
|
-
{ nonLegendChildren }
|
|
487
|
-
</Stack>
|
|
479
|
+
);
|
|
480
|
+
} }
|
|
481
|
+
</ChartLayout>
|
|
488
482
|
</SingleChartContext.Provider>
|
|
489
483
|
);
|
|
490
484
|
};
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
useGlobalChartsTheme,
|
|
17
17
|
} from '../../providers';
|
|
18
18
|
import { formatMetricValue, attachSubComponents } from '../../utils';
|
|
19
|
-
import { useChartChildren
|
|
19
|
+
import { useChartChildren } from '../private/chart-composition';
|
|
20
|
+
import { ChartLayout } from '../private/chart-layout';
|
|
20
21
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
21
22
|
import { withResponsive } from '../private/with-responsive';
|
|
22
23
|
import { useLeaderboardLegendItems } from './hooks';
|
|
@@ -246,37 +247,30 @@ const LeaderboardChartInternal: FC< LeaderboardChartProps > = ( {
|
|
|
246
247
|
// Handle empty or undefined data
|
|
247
248
|
if ( ! data || data.length === 0 ) {
|
|
248
249
|
return (
|
|
249
|
-
<SingleChartContext.Provider
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
} }
|
|
255
|
-
>
|
|
256
|
-
<Stack
|
|
257
|
-
direction="column"
|
|
258
|
-
data-testid="leaderboard-chart-container"
|
|
250
|
+
<SingleChartContext.Provider value={ { chartId } }>
|
|
251
|
+
<ChartLayout
|
|
252
|
+
legendPosition={ legendPosition }
|
|
253
|
+
legendElement={ false }
|
|
254
|
+
legendChildren={ legendChildren }
|
|
259
255
|
className={ clsx(
|
|
260
256
|
styles.leaderboardChart,
|
|
261
|
-
{
|
|
262
|
-
|
|
257
|
+
{
|
|
258
|
+
[ styles[ 'leaderboardChart--responsive' ] ]: ! propWidth && ! propHeight,
|
|
259
|
+
[ styles[ 'leaderboardChart--loading' ] ]: loading,
|
|
260
|
+
},
|
|
263
261
|
className
|
|
264
262
|
) }
|
|
265
263
|
gap={ gap }
|
|
266
|
-
style={ {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
height: propHeight || undefined,
|
|
270
|
-
} }
|
|
264
|
+
style={ { ...style, width: propWidth || undefined, height: propHeight || undefined } }
|
|
265
|
+
data-testid="leaderboard-chart-container"
|
|
266
|
+
trailingContent={ nonLegendChildren }
|
|
271
267
|
>
|
|
272
268
|
<div className={ styles.emptyState }>
|
|
273
269
|
{ loading
|
|
274
270
|
? __( 'Loading…', 'jetpack-charts' )
|
|
275
271
|
: __( 'No data available', 'jetpack-charts' ) }
|
|
276
272
|
</div>
|
|
277
|
-
|
|
278
|
-
{ nonLegendChildren }
|
|
279
|
-
</Stack>
|
|
273
|
+
</ChartLayout>
|
|
280
274
|
</SingleChartContext.Provider>
|
|
281
275
|
);
|
|
282
276
|
}
|
|
@@ -297,16 +291,11 @@ const LeaderboardChartInternal: FC< LeaderboardChartProps > = ( {
|
|
|
297
291
|
);
|
|
298
292
|
|
|
299
293
|
return (
|
|
300
|
-
<SingleChartContext.Provider
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} }
|
|
306
|
-
>
|
|
307
|
-
<Stack
|
|
308
|
-
direction="column"
|
|
309
|
-
data-testid="leaderboard-chart-container"
|
|
294
|
+
<SingleChartContext.Provider value={ { chartId } }>
|
|
295
|
+
<ChartLayout
|
|
296
|
+
legendPosition={ legendPosition }
|
|
297
|
+
legendElement={ legendElement }
|
|
298
|
+
legendChildren={ legendChildren }
|
|
310
299
|
className={ clsx(
|
|
311
300
|
styles.leaderboardChart,
|
|
312
301
|
{
|
|
@@ -321,10 +310,9 @@ const LeaderboardChartInternal: FC< LeaderboardChartProps > = ( {
|
|
|
321
310
|
width: propWidth || undefined,
|
|
322
311
|
height: propHeight || undefined,
|
|
323
312
|
} }
|
|
313
|
+
data-testid="leaderboard-chart-container"
|
|
314
|
+
trailingContent={ nonLegendChildren }
|
|
324
315
|
>
|
|
325
|
-
{ legendPosition === 'top' && legendElement }
|
|
326
|
-
{ renderLegendSlot( legendChildren, 'top' ) }
|
|
327
|
-
|
|
328
316
|
<div className={ styles.leaderboardChart__content }>
|
|
329
317
|
{ allSeriesHidden ? (
|
|
330
318
|
<div className={ styles.emptyState }>
|
|
@@ -372,12 +360,7 @@ const LeaderboardChartInternal: FC< LeaderboardChartProps > = ( {
|
|
|
372
360
|
</Grid>
|
|
373
361
|
) }
|
|
374
362
|
</div>
|
|
375
|
-
|
|
376
|
-
{ legendPosition === 'bottom' && legendElement }
|
|
377
|
-
{ renderLegendSlot( legendChildren, 'bottom' ) }
|
|
378
|
-
|
|
379
|
-
{ nonLegendChildren }
|
|
380
|
-
</Stack>
|
|
363
|
+
</ChartLayout>
|
|
381
364
|
</SingleChartContext.Provider>
|
|
382
365
|
);
|
|
383
366
|
};
|