@automattic/charts 0.50.2 → 0.52.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 +16 -0
- package/dist/charts/bar-chart/index.cjs +15 -0
- package/dist/charts/bar-chart/index.cjs.map +1 -0
- package/dist/{components/bar-list-chart → charts/bar-chart}/index.css +11 -11
- package/dist/charts/bar-chart/index.css.map +1 -0
- package/dist/{components → charts}/bar-chart/index.d.cts +1 -1
- package/dist/{components → charts}/bar-chart/index.d.ts +1 -1
- package/dist/{components → charts}/bar-chart/index.js +4 -4
- package/dist/charts/bar-list-chart/index.cjs +16 -0
- package/dist/charts/bar-list-chart/index.cjs.map +1 -0
- package/dist/{components/bar-chart → charts/bar-list-chart}/index.css +11 -11
- package/dist/charts/bar-list-chart/index.css.map +1 -0
- package/dist/{components → charts}/bar-list-chart/index.d.cts +1 -1
- package/dist/{components → charts}/bar-list-chart/index.d.ts +1 -1
- package/dist/{components → charts}/bar-list-chart/index.js +5 -5
- package/dist/charts/conversion-funnel-chart/index.cjs +10 -0
- package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -0
- package/dist/{components → charts}/conversion-funnel-chart/index.css +23 -23
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -0
- package/dist/{components → charts}/conversion-funnel-chart/index.d.cts +1 -1
- package/dist/{components → charts}/conversion-funnel-chart/index.d.ts +1 -1
- package/dist/{components → charts}/conversion-funnel-chart/index.js +2 -2
- package/dist/charts/leaderboard-chart/index.cjs +20 -0
- package/dist/charts/leaderboard-chart/index.cjs.map +1 -0
- package/dist/{components → charts}/leaderboard-chart/index.css +16 -16
- package/dist/charts/leaderboard-chart/index.css.map +1 -0
- package/dist/{components → charts}/leaderboard-chart/index.d.cts +2 -2
- package/dist/{components → charts}/leaderboard-chart/index.d.ts +2 -2
- package/dist/{components → charts}/leaderboard-chart/index.js +5 -5
- package/dist/charts/line-chart/index.cjs +15 -0
- package/dist/charts/line-chart/index.cjs.map +1 -0
- package/dist/{components → charts}/line-chart/index.css +21 -21
- package/dist/charts/line-chart/index.css.map +1 -0
- package/dist/{components → charts}/line-chart/index.d.cts +1 -1
- package/dist/{components → charts}/line-chart/index.d.ts +1 -1
- package/dist/{components → charts}/line-chart/index.js +4 -4
- package/dist/charts/pie-chart/index.cjs +18 -0
- package/dist/charts/pie-chart/index.cjs.map +1 -0
- package/dist/{components → charts}/pie-chart/index.css +3 -3
- package/dist/charts/pie-chart/index.css.map +1 -0
- package/dist/{components → charts}/pie-chart/index.d.cts +7 -7
- package/dist/{components → charts}/pie-chart/index.d.ts +7 -7
- package/dist/{components → charts}/pie-chart/index.js +6 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs +17 -0
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -0
- package/dist/{components → charts}/pie-semi-circle-chart/index.css +5 -5
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -0
- package/dist/{components → charts}/pie-semi-circle-chart/index.d.cts +7 -7
- package/dist/{components → charts}/pie-semi-circle-chart/index.d.ts +7 -7
- package/dist/{components → charts}/pie-semi-circle-chart/index.js +6 -6
- package/dist/{chunk-N4ZDNOPY.cjs → chunk-44EBMDFI.cjs} +107 -236
- package/dist/chunk-44EBMDFI.cjs.map +1 -0
- package/dist/{chunk-XVMWJANV.js → chunk-624IQX64.js} +27 -27
- package/dist/chunk-624IQX64.js.map +1 -0
- package/dist/{chunk-BZQFCAX7.cjs → chunk-67BAKCI2.cjs} +9 -9
- package/dist/chunk-67BAKCI2.cjs.map +1 -0
- package/dist/{chunk-3OVXJFQY.js → chunk-A3AEEGKR.js} +2 -2
- package/dist/chunk-A3AEEGKR.js.map +1 -0
- package/dist/{chunk-6SGGF26Z.js → chunk-AI6GM6HS.js} +40 -37
- package/dist/chunk-AI6GM6HS.js.map +1 -0
- package/dist/{chunk-EKVFMS3A.cjs → chunk-BMWFTOSR.cjs} +38 -38
- package/dist/chunk-BMWFTOSR.cjs.map +1 -0
- package/dist/{chunk-D3DZT2EK.js → chunk-CEZGL6YP.js} +4 -4
- package/dist/chunk-CEZGL6YP.js.map +1 -0
- package/dist/{chunk-EKVLCYHS.js → chunk-DILKZ4MP.js} +5 -5
- package/dist/chunk-DILKZ4MP.js.map +1 -0
- package/dist/{chunk-VOWX5TBY.js → chunk-E6VKSUGP.js} +16 -16
- package/dist/chunk-E6VKSUGP.js.map +1 -0
- package/dist/{chunk-7OWIZ5S7.js → chunk-EELV2LG7.js} +4 -4
- package/dist/chunk-EELV2LG7.js.map +1 -0
- package/dist/{chunk-HA7WACBI.cjs → chunk-GOZNZD3N.cjs} +9 -9
- package/dist/chunk-GOZNZD3N.cjs.map +1 -0
- package/dist/{chunk-PTEEI2QM.js → chunk-GSG54JGM.js} +19 -19
- package/dist/chunk-GSG54JGM.js.map +1 -0
- package/dist/{chunk-3Z526IL2.cjs → chunk-HIWNB5PK.cjs} +4 -4
- package/dist/chunk-HIWNB5PK.cjs.map +1 -0
- package/dist/{chunk-6WQWN5BF.js → chunk-IDTLZ7KT.js} +17 -17
- package/dist/chunk-IDTLZ7KT.js.map +1 -0
- package/dist/{chunk-6UZHWL6W.cjs → chunk-JSGCFUVQ.cjs} +34 -34
- package/dist/chunk-JSGCFUVQ.cjs.map +1 -0
- package/dist/{chunk-5NI3TGRD.cjs → chunk-MUUSZ7J5.cjs} +2 -2
- package/dist/{chunk-D3E235JJ.js.map → chunk-MUUSZ7J5.cjs.map} +1 -1
- package/dist/{chunk-3PRIZR7Y.cjs → chunk-N4NZ4VJK.cjs} +34 -34
- package/dist/chunk-N4NZ4VJK.cjs.map +1 -0
- package/dist/{chunk-D3E235JJ.js → chunk-NONODB3K.js} +2 -2
- package/dist/chunk-NONODB3K.js.map +1 -0
- package/dist/{chunk-SDNRKKBP.cjs → chunk-OTZT3MC2.cjs} +2 -2
- package/dist/chunk-OTZT3MC2.cjs.map +1 -0
- package/dist/{chunk-RUG2O62B.js → chunk-S5UDYA4M.js} +22 -22
- package/dist/chunk-S5UDYA4M.js.map +1 -0
- package/dist/{chunk-KE4EDAQI.cjs → chunk-UJIP7ICA.cjs} +34 -34
- package/dist/chunk-UJIP7ICA.cjs.map +1 -0
- package/dist/{chunk-MRCTAUHL.js → chunk-ULRFJ3IU.js} +128 -257
- package/dist/chunk-ULRFJ3IU.js.map +1 -0
- package/dist/{chunk-SLO4NLKC.cjs → chunk-VEJIPJN7.cjs} +56 -53
- package/dist/chunk-VEJIPJN7.cjs.map +1 -0
- package/dist/{chunk-PEUZZ3WY.cjs → chunk-ZOCE4WND.cjs} +34 -34
- package/dist/chunk-ZOCE4WND.cjs.map +1 -0
- package/dist/components/legend/index.cjs +3 -3
- package/dist/components/legend/index.d.cts +1 -1
- package/dist/components/legend/index.d.ts +1 -1
- package/dist/components/legend/index.js +2 -2
- package/dist/components/tooltip/index.d.cts +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +188 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +96 -79
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +111 -12
- package/dist/index.d.ts +111 -12
- package/dist/index.js +179 -29
- package/dist/index.js.map +1 -1
- package/dist/{leaderboard-chart-BlBexVz4.d.cts → leaderboard-chart-Bf7z7SoM.d.cts} +1 -1
- package/dist/{leaderboard-chart-B3dPiEl8.d.ts → leaderboard-chart-Bh8M5JWL.d.ts} +1 -1
- package/dist/providers/index.cjs +2 -6
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +2 -2
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +3 -7
- package/dist/{themes-CNy453Lb.d.ts → themes-09M-mQE6.d.ts} +2 -10
- package/dist/{themes-Dv70Dz7B.d.cts → themes-DYhtyXtJ.d.cts} +2 -10
- package/dist/{types-4wyyzjot.d.cts → types-BtYG-Fdk.d.cts} +19 -0
- package/dist/{types-4wyyzjot.d.ts → types-BtYG-Fdk.d.ts} +19 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +38 -30
- package/src/{components → charts}/bar-chart/bar-chart.tsx +2 -2
- package/src/{components → charts}/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +0 -1
- package/src/charts/index.ts +8 -0
- package/src/{components → charts}/leaderboard-chart/hooks/use-leaderboard-legend-items.ts +1 -1
- package/src/{components → charts}/leaderboard-chart/leaderboard-chart.tsx +1 -1
- package/src/{components → charts}/line-chart/line-chart.tsx +8 -5
- package/src/{components → charts}/line-chart/test/line-chart.test.tsx +7 -9
- package/src/{components → charts}/pie-chart/pie-chart.tsx +3 -3
- package/src/{components → charts}/pie-semi-circle-chart/pie-semi-circle-chart.tsx +3 -3
- package/src/{components → charts}/private/chart-composition/types.ts +1 -1
- package/src/charts/sparkline/index.ts +2 -0
- package/src/charts/sparkline/sparkline.module.scss +18 -0
- package/src/charts/sparkline/sparkline.tsx +200 -0
- package/src/charts/sparkline/test/sparkline.test.tsx +196 -0
- package/src/charts/sparkline/types.ts +92 -0
- package/src/components/index.ts +2 -0
- package/src/components/legend/legend.tsx +1 -1
- package/src/compositions/index.ts +2 -0
- package/src/index.ts +12 -14
- package/src/providers/chart-context/test/chart-context.test.tsx +0 -35
- package/src/providers/chart-context/test/use-global-charts-theme.test.tsx +1 -23
- package/src/providers/chart-context/themes.ts +5 -127
- package/src/types.ts +19 -0
- package/dist/chunk-3OVXJFQY.js.map +0 -1
- package/dist/chunk-3PRIZR7Y.cjs.map +0 -1
- package/dist/chunk-3Z526IL2.cjs.map +0 -1
- package/dist/chunk-5NI3TGRD.cjs.map +0 -1
- package/dist/chunk-6SGGF26Z.js.map +0 -1
- package/dist/chunk-6UZHWL6W.cjs.map +0 -1
- package/dist/chunk-6WQWN5BF.js.map +0 -1
- package/dist/chunk-7OWIZ5S7.js.map +0 -1
- package/dist/chunk-BZQFCAX7.cjs.map +0 -1
- package/dist/chunk-D3DZT2EK.js.map +0 -1
- package/dist/chunk-EKVFMS3A.cjs.map +0 -1
- package/dist/chunk-EKVLCYHS.js.map +0 -1
- package/dist/chunk-HA7WACBI.cjs.map +0 -1
- package/dist/chunk-KE4EDAQI.cjs.map +0 -1
- package/dist/chunk-MRCTAUHL.js.map +0 -1
- package/dist/chunk-N4ZDNOPY.cjs.map +0 -1
- package/dist/chunk-PEUZZ3WY.cjs.map +0 -1
- package/dist/chunk-PTEEI2QM.js.map +0 -1
- package/dist/chunk-RUG2O62B.js.map +0 -1
- package/dist/chunk-SDNRKKBP.cjs.map +0 -1
- package/dist/chunk-SLO4NLKC.cjs.map +0 -1
- package/dist/chunk-VOWX5TBY.js.map +0 -1
- package/dist/chunk-XVMWJANV.js.map +0 -1
- package/dist/components/bar-chart/index.cjs +0 -15
- package/dist/components/bar-chart/index.cjs.map +0 -1
- package/dist/components/bar-chart/index.css.map +0 -1
- package/dist/components/bar-list-chart/index.cjs +0 -16
- package/dist/components/bar-list-chart/index.cjs.map +0 -1
- package/dist/components/bar-list-chart/index.css.map +0 -1
- package/dist/components/conversion-funnel-chart/index.cjs +0 -10
- package/dist/components/conversion-funnel-chart/index.cjs.map +0 -1
- package/dist/components/conversion-funnel-chart/index.css.map +0 -1
- package/dist/components/leaderboard-chart/index.cjs +0 -20
- package/dist/components/leaderboard-chart/index.cjs.map +0 -1
- package/dist/components/leaderboard-chart/index.css.map +0 -1
- package/dist/components/line-chart/index.cjs +0 -15
- package/dist/components/line-chart/index.cjs.map +0 -1
- package/dist/components/line-chart/index.css.map +0 -1
- package/dist/components/pie-chart/index.cjs +0 -18
- package/dist/components/pie-chart/index.cjs.map +0 -1
- package/dist/components/pie-chart/index.css.map +0 -1
- package/dist/components/pie-semi-circle-chart/index.cjs +0 -17
- package/dist/components/pie-semi-circle-chart/index.cjs.map +0 -1
- package/dist/components/pie-semi-circle-chart/index.css.map +0 -1
- /package/dist/{components → charts}/bar-chart/index.js.map +0 -0
- /package/dist/{components → charts}/bar-list-chart/index.js.map +0 -0
- /package/dist/{components → charts}/conversion-funnel-chart/index.js.map +0 -0
- /package/dist/{components → charts}/leaderboard-chart/index.js.map +0 -0
- /package/dist/{components → charts}/line-chart/index.js.map +0 -0
- /package/dist/{components → charts}/pie-chart/index.js.map +0 -0
- /package/dist/{components → charts}/pie-semi-circle-chart/index.js.map +0 -0
- /package/src/{components → charts}/bar-chart/bar-chart.module.scss +0 -0
- /package/src/{components → charts}/bar-chart/index.ts +0 -0
- /package/src/{components → charts}/bar-chart/private/index.ts +0 -0
- /package/src/{components → charts}/bar-chart/private/use-bar-chart-options.ts +0 -0
- /package/src/{components → charts}/bar-chart/test/bar-chart.test.tsx +0 -0
- /package/src/{components → charts}/bar-list-chart/bar-list-chart.tsx +0 -0
- /package/src/{components → charts}/bar-list-chart/index.ts +0 -0
- /package/src/{components → charts}/bar-list-chart/test/bar-list-chart.test.tsx +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/conversion-funnel-chart.module.scss +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/conversion-funnel-chart.tsx +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/index.ts +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/private/index.ts +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/private/use-funnel-selection.ts +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/test/use-funnel-selection.test.ts +0 -0
- /package/src/{components → charts}/conversion-funnel-chart/types.ts +0 -0
- /package/src/{components → charts}/leaderboard-chart/hooks/index.ts +0 -0
- /package/src/{components → charts}/leaderboard-chart/index.ts +0 -0
- /package/src/{components → charts}/leaderboard-chart/leaderboard-chart.module.scss +0 -0
- /package/src/{components → charts}/leaderboard-chart/test/leaderboard-chart.test.tsx +0 -0
- /package/src/{components → charts}/leaderboard-chart/test/use-leaderboard-legend-items.test.tsx +0 -0
- /package/src/{components → charts}/leaderboard-chart/types.ts +0 -0
- /package/src/{components → charts}/line-chart/index.ts +0 -0
- /package/src/{components → charts}/line-chart/line-chart.module.scss +0 -0
- /package/src/{components → charts}/line-chart/private/index.ts +0 -0
- /package/src/{components → charts}/line-chart/private/line-chart-annotation-label-popover.tsx +0 -0
- /package/src/{components → charts}/line-chart/private/line-chart-annotation.tsx +0 -0
- /package/src/{components → charts}/line-chart/private/line-chart-annotations-overlay.tsx +0 -0
- /package/src/{components → charts}/line-chart/private/line-chart-glyph.tsx +0 -0
- /package/src/{components → charts}/line-chart/test/line-chart-annotation-label-popover.test.tsx +0 -0
- /package/src/{components → charts}/line-chart/test/line-chart-annotation.test.tsx +0 -0
- /package/src/{components → charts}/line-chart/types.ts +0 -0
- /package/src/{components → charts}/pie-chart/index.ts +0 -0
- /package/src/{components → charts}/pie-chart/pie-chart.module.scss +0 -0
- /package/src/{components → charts}/pie-chart/test/composition-api.test.tsx +0 -0
- /package/src/{components → charts}/pie-chart/test/pie-chart.test.tsx +0 -0
- /package/src/{components → charts}/pie-semi-circle-chart/index.ts +0 -0
- /package/src/{components → charts}/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +0 -0
- /package/src/{components → charts}/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +0 -0
- /package/src/{components → charts}/private/chart-composition/chart-html.tsx +0 -0
- /package/src/{components → charts}/private/chart-composition/chart-svg.tsx +0 -0
- /package/src/{components → charts}/private/chart-composition/index.ts +0 -0
- /package/src/{components → charts}/private/chart-composition/test/use-chart-children.test.tsx +0 -0
- /package/src/{components → charts}/private/chart-composition/use-chart-children.ts +0 -0
- /package/src/{components → charts}/private/default-glyph/default-glyph.tsx +0 -0
- /package/src/{components → charts}/private/default-glyph/index.ts +0 -0
- /package/src/{components → charts}/private/grid-control/grid-control.module.scss +0 -0
- /package/src/{components → charts}/private/grid-control/grid-control.tsx +0 -0
- /package/src/{components → charts}/private/grid-control/index.ts +0 -0
- /package/src/{components → charts}/private/grid-control/test/grid-control.test.tsx +0 -0
- /package/src/{components → charts}/private/radial-wipe-animation/index.ts +0 -0
- /package/src/{components → charts}/private/radial-wipe-animation/radial-wipe-animation.tsx +0 -0
- /package/src/{components → charts}/private/single-chart-context/index.ts +0 -0
- /package/src/{components → charts}/private/single-chart-context/single-chart-context.tsx +0 -0
- /package/src/{components → charts}/private/single-chart-context/use-single-chart-context.ts +0 -0
- /package/src/{components → charts}/private/with-responsive/index.ts +0 -0
- /package/src/{components → charts}/private/with-responsive/test/with-responsive.test.tsx +0 -0
- /package/src/{components → charts}/private/with-responsive/with-responsive.tsx +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.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": {
|
|
@@ -24,53 +24,58 @@
|
|
|
24
24
|
"require": "./dist/index.cjs"
|
|
25
25
|
},
|
|
26
26
|
"./bar-chart": {
|
|
27
|
-
"import": "./dist/
|
|
28
|
-
"require": "./dist/
|
|
27
|
+
"import": "./dist/charts/bar-chart/index.js",
|
|
28
|
+
"require": "./dist/charts/bar-chart/index.cjs"
|
|
29
29
|
},
|
|
30
|
-
"./bar-chart/style.css": "./dist/
|
|
30
|
+
"./bar-chart/style.css": "./dist/charts/bar-chart/index.css",
|
|
31
31
|
"./bar-list-chart": {
|
|
32
|
-
"import": "./dist/
|
|
33
|
-
"require": "./dist/
|
|
32
|
+
"import": "./dist/charts/bar-list-chart/index.js",
|
|
33
|
+
"require": "./dist/charts/bar-list-chart/index.cjs"
|
|
34
34
|
},
|
|
35
|
-
"./bar-list-chart/style.css": "./dist/
|
|
35
|
+
"./bar-list-chart/style.css": "./dist/charts/bar-list-chart/index.css",
|
|
36
36
|
"./conversion-funnel-chart": {
|
|
37
|
-
"import": "./dist/
|
|
38
|
-
"require": "./dist/
|
|
37
|
+
"import": "./dist/charts/conversion-funnel-chart/index.js",
|
|
38
|
+
"require": "./dist/charts/conversion-funnel-chart/index.cjs"
|
|
39
39
|
},
|
|
40
|
-
"./conversion-funnel-chart/style.css": "./dist/
|
|
40
|
+
"./conversion-funnel-chart/style.css": "./dist/charts/conversion-funnel-chart/index.css",
|
|
41
41
|
"./hooks": {
|
|
42
42
|
"import": "./dist/hooks/index.js",
|
|
43
43
|
"require": "./dist/hooks/index.cjs"
|
|
44
44
|
},
|
|
45
45
|
"./leaderboard-chart": {
|
|
46
|
-
"import": "./dist/
|
|
47
|
-
"require": "./dist/
|
|
46
|
+
"import": "./dist/charts/leaderboard-chart/index.js",
|
|
47
|
+
"require": "./dist/charts/leaderboard-chart/index.cjs"
|
|
48
48
|
},
|
|
49
|
-
"./leaderboard-chart/style.css": "./dist/
|
|
49
|
+
"./leaderboard-chart/style.css": "./dist/charts/leaderboard-chart/index.css",
|
|
50
50
|
"./legend": {
|
|
51
51
|
"import": "./dist/components/legend/index.js",
|
|
52
52
|
"require": "./dist/components/legend/index.cjs"
|
|
53
53
|
},
|
|
54
54
|
"./legend/style.css": "./dist/components/legend/index.css",
|
|
55
55
|
"./line-chart": {
|
|
56
|
-
"import": "./dist/
|
|
57
|
-
"require": "./dist/
|
|
56
|
+
"import": "./dist/charts/line-chart/index.js",
|
|
57
|
+
"require": "./dist/charts/line-chart/index.cjs"
|
|
58
58
|
},
|
|
59
|
-
"./line-chart/style.css": "./dist/
|
|
59
|
+
"./line-chart/style.css": "./dist/charts/line-chart/index.css",
|
|
60
60
|
"./pie-chart": {
|
|
61
|
-
"import": "./dist/
|
|
62
|
-
"require": "./dist/
|
|
61
|
+
"import": "./dist/charts/pie-chart/index.js",
|
|
62
|
+
"require": "./dist/charts/pie-chart/index.cjs"
|
|
63
63
|
},
|
|
64
|
-
"./pie-chart/style.css": "./dist/
|
|
64
|
+
"./pie-chart/style.css": "./dist/charts/pie-chart/index.css",
|
|
65
65
|
"./pie-semi-circle-chart": {
|
|
66
|
-
"import": "./dist/
|
|
67
|
-
"require": "./dist/
|
|
66
|
+
"import": "./dist/charts/pie-semi-circle-chart/index.js",
|
|
67
|
+
"require": "./dist/charts/pie-semi-circle-chart/index.cjs"
|
|
68
68
|
},
|
|
69
|
-
"./pie-semi-circle-chart/style.css": "./dist/
|
|
69
|
+
"./pie-semi-circle-chart/style.css": "./dist/charts/pie-semi-circle-chart/index.css",
|
|
70
70
|
"./providers": {
|
|
71
71
|
"import": "./dist/providers/index.js",
|
|
72
72
|
"require": "./dist/providers/index.cjs"
|
|
73
73
|
},
|
|
74
|
+
"./sparkline": {
|
|
75
|
+
"import": "./dist/components/sparkline/index.js",
|
|
76
|
+
"require": "./dist/components/sparkline/index.cjs"
|
|
77
|
+
},
|
|
78
|
+
"./sparkline/style.css": "./dist/components/sparkline/index.css",
|
|
74
79
|
"./style.css": "./dist/index.css",
|
|
75
80
|
"./tooltip": {
|
|
76
81
|
"import": "./dist/components/tooltip/index.js",
|
|
@@ -102,25 +107,25 @@
|
|
|
102
107
|
"./dist/index.d.ts"
|
|
103
108
|
],
|
|
104
109
|
"line-chart": [
|
|
105
|
-
"./dist/
|
|
110
|
+
"./dist/charts/line-chart/index.d.ts"
|
|
106
111
|
],
|
|
107
112
|
"bar-chart": [
|
|
108
|
-
"./dist/
|
|
113
|
+
"./dist/charts/bar-chart/index.d.ts"
|
|
109
114
|
],
|
|
110
115
|
"pie-chart": [
|
|
111
|
-
"./dist/
|
|
116
|
+
"./dist/charts/pie-chart/index.d.ts"
|
|
112
117
|
],
|
|
113
118
|
"pie-semi-circle-chart": [
|
|
114
|
-
"./dist/
|
|
119
|
+
"./dist/charts/pie-semi-circle-chart/index.d.ts"
|
|
115
120
|
],
|
|
116
121
|
"bar-list-chart": [
|
|
117
|
-
"./dist/
|
|
122
|
+
"./dist/charts/bar-list-chart/index.d.ts"
|
|
118
123
|
],
|
|
119
124
|
"leaderboard-chart": [
|
|
120
|
-
"./dist/
|
|
125
|
+
"./dist/charts/leaderboard-chart/index.d.ts"
|
|
121
126
|
],
|
|
122
127
|
"conversion-funnel-chart": [
|
|
123
|
-
"./dist/
|
|
128
|
+
"./dist/charts/conversion-funnel-chart/index.d.ts"
|
|
124
129
|
],
|
|
125
130
|
"tooltip": [
|
|
126
131
|
"./dist/components/tooltip/index.d.ts"
|
|
@@ -128,6 +133,9 @@
|
|
|
128
133
|
"legend": [
|
|
129
134
|
"./dist/components/legend/index.d.ts"
|
|
130
135
|
],
|
|
136
|
+
"sparkline": [
|
|
137
|
+
"./dist/components/sparkline/index.d.ts"
|
|
138
|
+
],
|
|
131
139
|
"hooks": [
|
|
132
140
|
"./dist/hooks/index.d.ts"
|
|
133
141
|
],
|
|
@@ -203,7 +211,7 @@
|
|
|
203
211
|
"esbuild-sass-plugin": "^3.1.0",
|
|
204
212
|
"jest": "30.2.0",
|
|
205
213
|
"jest-environment-jsdom": "30.2.0",
|
|
206
|
-
"jest-extended": "
|
|
214
|
+
"jest-extended": "7.0.0",
|
|
207
215
|
"postcss": "8.5.6",
|
|
208
216
|
"postcss-modules": "6.0.1",
|
|
209
217
|
"react": "18.3.1",
|
|
@@ -4,6 +4,8 @@ import { Axis, BarSeries, BarGroup, Grid, XYChart } from '@visx/xychart';
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { useCallback, useContext, useState, useRef, useMemo } from 'react';
|
|
7
|
+
import { Legend, useChartLegendItems } from '../../components/legend';
|
|
8
|
+
import { AccessibleTooltip, useKeyboardNavigation } from '../../components/tooltip';
|
|
7
9
|
import {
|
|
8
10
|
useXYChartTheme,
|
|
9
11
|
useChartDataTransform,
|
|
@@ -21,10 +23,8 @@ import {
|
|
|
21
23
|
GlobalChartsContext,
|
|
22
24
|
} from '../../providers';
|
|
23
25
|
import { attachSubComponents } from '../../utils';
|
|
24
|
-
import { Legend, useChartLegendItems } from '../legend';
|
|
25
26
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
26
27
|
import { withResponsive } from '../private/with-responsive';
|
|
27
|
-
import { AccessibleTooltip, useKeyboardNavigation } from '../tooltip';
|
|
28
28
|
import styles from './bar-chart.module.scss';
|
|
29
29
|
import { useBarChartOptions } from './private';
|
|
30
30
|
import type { BaseChartProps, DataPointDate, SeriesData, Optional } from '../../types';
|
package/src/{components → charts}/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx
RENAMED
|
@@ -310,7 +310,6 @@ describe( 'ConversionFunnelChart', () => {
|
|
|
310
310
|
renderWithoutTheme( <ConversionFunnelChart { ...defaultProps } changeIndicator="+5.2%" /> );
|
|
311
311
|
|
|
312
312
|
const changeElement = screen.getByText( '+5.2%' );
|
|
313
|
-
// Note: The exact color value depends on the theme (Woo theme colors)
|
|
314
313
|
// Color is applied via CSS variable, so check that element exists
|
|
315
314
|
expect( changeElement ).toBeInTheDocument();
|
|
316
315
|
} );
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './bar-chart';
|
|
2
|
+
export * from './bar-list-chart';
|
|
3
|
+
export * from './conversion-funnel-chart';
|
|
4
|
+
export * from './leaderboard-chart';
|
|
5
|
+
export * from './line-chart';
|
|
6
|
+
export * from './pie-chart';
|
|
7
|
+
export * from './pie-semi-circle-chart';
|
|
8
|
+
export * from './sparkline';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useGlobalChartsTheme, useGlobalChartsContext } from '../../../providers';
|
|
4
|
+
import type { BaseLegendItem } from '../../../components/legend';
|
|
4
5
|
import type { LeaderboardEntry } from '../../../types';
|
|
5
|
-
import type { BaseLegendItem } from '../../legend';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Hook to create legend items from leaderboard data
|
|
@@ -8,6 +8,7 @@ import { Fragment } from '@wordpress/element';
|
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import { useContext, useMemo, type FC } from 'react';
|
|
11
|
+
import { Legend } from '../../components/legend';
|
|
11
12
|
import { usePrefersReducedMotion } from '../../hooks';
|
|
12
13
|
import {
|
|
13
14
|
GlobalChartsContext,
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
useGlobalChartsTheme,
|
|
19
20
|
} from '../../providers';
|
|
20
21
|
import { formatMetricValue, attachSubComponents } from '../../utils';
|
|
21
|
-
import { Legend } from '../legend';
|
|
22
22
|
import { useChartChildren } from '../private/chart-composition';
|
|
23
23
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
24
24
|
import { withResponsive } from '../private/with-responsive';
|
|
@@ -7,6 +7,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { differenceInHours, differenceInYears } from 'date-fns';
|
|
9
9
|
import { useMemo, useContext, forwardRef, useImperativeHandle, useState, useRef } from 'react';
|
|
10
|
+
import { Legend, useChartLegendItems } from '../../components/legend';
|
|
11
|
+
import { AccessibleTooltip, useKeyboardNavigation } from '../../components/tooltip';
|
|
10
12
|
import {
|
|
11
13
|
useXYChartTheme,
|
|
12
14
|
useChartDataTransform,
|
|
@@ -23,11 +25,9 @@ import {
|
|
|
23
25
|
useGlobalChartsTheme,
|
|
24
26
|
} from '../../providers';
|
|
25
27
|
import { attachSubComponents } from '../../utils';
|
|
26
|
-
import { Legend, useChartLegendItems } from '../legend';
|
|
27
28
|
import { DefaultGlyph } from '../private/default-glyph';
|
|
28
29
|
import { SingleChartContext, type SingleChartRef } from '../private/single-chart-context';
|
|
29
30
|
import { withResponsive } from '../private/with-responsive';
|
|
30
|
-
import { AccessibleTooltip, useKeyboardNavigation } from '../tooltip';
|
|
31
31
|
import styles from './line-chart.module.scss';
|
|
32
32
|
import { LineChartAnnotation, LineChartAnnotationsOverlay, LineChartGlyph } from './private';
|
|
33
33
|
import type { CurveType, RenderLineGlyphProps, LineChartProps, TooltipDatum } from './types';
|
|
@@ -278,6 +278,7 @@ const LineChartInternal = forwardRef< SingleChartRef, LineChartProps >(
|
|
|
278
278
|
onPointerMove = undefined,
|
|
279
279
|
onPointerOut = undefined,
|
|
280
280
|
children,
|
|
281
|
+
gridVisibility,
|
|
281
282
|
},
|
|
282
283
|
ref
|
|
283
284
|
) => {
|
|
@@ -340,12 +341,14 @@ const LineChartInternal = forwardRef< SingleChartRef, LineChartProps >(
|
|
|
340
341
|
orientation: 'bottom' as const,
|
|
341
342
|
numTicks: guessOptimalNumTicks( dataSorted, width, formatter ),
|
|
342
343
|
tickFormat: formatter,
|
|
344
|
+
display: true,
|
|
343
345
|
...options?.axis?.x,
|
|
344
346
|
},
|
|
345
347
|
y: {
|
|
346
348
|
orientation: 'left' as const,
|
|
347
349
|
numTicks: 4,
|
|
348
350
|
tickFormat: formatNumberCompact as TickFormatter< number >,
|
|
351
|
+
display: true,
|
|
349
352
|
...options?.axis?.y,
|
|
350
353
|
},
|
|
351
354
|
},
|
|
@@ -488,9 +491,9 @@ const LineChartInternal = forwardRef< SingleChartRef, LineChartProps >(
|
|
|
488
491
|
onPointerOut={ onPointerOut }
|
|
489
492
|
pointerEventsDataKey="nearest"
|
|
490
493
|
>
|
|
491
|
-
<Grid columns={ false } numTicks={ 4 } />
|
|
492
|
-
<Axis { ...chartOptions.axis.x } />
|
|
493
|
-
<Axis { ...chartOptions.axis.y } />
|
|
494
|
+
{ gridVisibility !== 'none' && <Grid columns={ false } numTicks={ 4 } /> }
|
|
495
|
+
{ chartOptions.axis.x.display && <Axis { ...chartOptions.axis.x } /> }
|
|
496
|
+
{ chartOptions.axis.y.display && <Axis { ...chartOptions.axis.y } /> }
|
|
494
497
|
|
|
495
498
|
{ allSeriesHidden ? (
|
|
496
499
|
<text
|
|
@@ -7,12 +7,12 @@ import { render, screen, waitFor } from '@testing-library/react';
|
|
|
7
7
|
import userEvent from '@testing-library/user-event';
|
|
8
8
|
import { GlyphDiamond } from '@visx/glyph';
|
|
9
9
|
import { createElement, createRef } from 'react';
|
|
10
|
-
import { GlobalChartsProvider,
|
|
10
|
+
import { GlobalChartsProvider, defaultTheme } from '../../../providers';
|
|
11
11
|
import LineChart, { LineChartUnresponsive } from '../line-chart';
|
|
12
12
|
import type { SingleChartRef } from '../../private/single-chart-context';
|
|
13
13
|
|
|
14
14
|
const customTheme = {
|
|
15
|
-
...
|
|
15
|
+
...defaultTheme,
|
|
16
16
|
glyphs: [
|
|
17
17
|
props =>
|
|
18
18
|
createElement(
|
|
@@ -31,8 +31,6 @@ const customTheme = {
|
|
|
31
31
|
|
|
32
32
|
const THEME_MAP = {
|
|
33
33
|
default: undefined,
|
|
34
|
-
jetpack: jetpackTheme,
|
|
35
|
-
woo: wooTheme,
|
|
36
34
|
custom: customTheme,
|
|
37
35
|
};
|
|
38
36
|
|
|
@@ -52,7 +50,7 @@ describe( 'LineChart', () => {
|
|
|
52
50
|
],
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
const renderWithTheme = ( props = {}, themeName = '
|
|
53
|
+
const renderWithTheme = ( props = {}, themeName = 'default' ) => {
|
|
56
54
|
const theme = THEME_MAP[ themeName ];
|
|
57
55
|
|
|
58
56
|
return render(
|
|
@@ -63,7 +61,7 @@ describe( 'LineChart', () => {
|
|
|
63
61
|
);
|
|
64
62
|
};
|
|
65
63
|
|
|
66
|
-
const renderUnwrappedWithTheme = ( props = {}, themeName = '
|
|
64
|
+
const renderUnwrappedWithTheme = ( props = {}, themeName = 'default', ref = undefined ) => {
|
|
67
65
|
const theme = THEME_MAP[ themeName ];
|
|
68
66
|
|
|
69
67
|
return render(
|
|
@@ -815,7 +813,7 @@ describe( 'LineChart', () => {
|
|
|
815
813
|
describe( 'Chart Ref Interface', () => {
|
|
816
814
|
test( 'exposes getScales method via ref', () => {
|
|
817
815
|
const ref = createRef< SingleChartRef >();
|
|
818
|
-
renderUnwrappedWithTheme( {}, '
|
|
816
|
+
renderUnwrappedWithTheme( {}, 'default', ref );
|
|
819
817
|
|
|
820
818
|
expect( ref.current?.getScales() ).toBeDefined();
|
|
821
819
|
expect( ref.current?.getScales()?.xScale ).toBeDefined();
|
|
@@ -824,7 +822,7 @@ describe( 'LineChart', () => {
|
|
|
824
822
|
|
|
825
823
|
test( 'exposes getChartDimensions method via ref', () => {
|
|
826
824
|
const ref = createRef< SingleChartRef >();
|
|
827
|
-
renderUnwrappedWithTheme( { width: 800, height: 400 }, '
|
|
825
|
+
renderUnwrappedWithTheme( { width: 800, height: 400 }, 'default', ref );
|
|
828
826
|
|
|
829
827
|
const dimensions = ref.current?.getChartDimensions();
|
|
830
828
|
expect( dimensions?.width ).toBe( 800 );
|
|
@@ -836,7 +834,7 @@ describe( 'LineChart', () => {
|
|
|
836
834
|
const renderWithAnnotations = (
|
|
837
835
|
children: React.ReactNode,
|
|
838
836
|
props = {},
|
|
839
|
-
themeName = '
|
|
837
|
+
themeName = 'default'
|
|
840
838
|
) => {
|
|
841
839
|
const theme = THEME_MAP[ themeName ];
|
|
842
840
|
|
|
@@ -5,6 +5,8 @@ import { useTooltip, useTooltipInPortal } from '@visx/tooltip';
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { useCallback, useContext, useMemo } from 'react';
|
|
8
|
+
import { Legend, useChartLegendItems } from '../../components/legend';
|
|
9
|
+
import { BaseTooltip } from '../../components/tooltip';
|
|
8
10
|
import { useElementHeight, useInteractiveLegendData, usePrefersReducedMotion } from '../../hooks';
|
|
9
11
|
import {
|
|
10
12
|
GlobalChartsProvider,
|
|
@@ -16,15 +18,13 @@ import {
|
|
|
16
18
|
} from '../../providers';
|
|
17
19
|
import { attachSubComponents } from '../../utils';
|
|
18
20
|
import { getStringWidth } from '../../visx/text';
|
|
19
|
-
import { Legend, useChartLegendItems } from '../legend';
|
|
20
21
|
import { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';
|
|
21
22
|
import { RadialWipeAnimation } from '../private/radial-wipe-animation/';
|
|
22
23
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
23
24
|
import { withResponsive, ResponsiveConfig } from '../private/with-responsive';
|
|
24
|
-
import { BaseTooltip } from '../tooltip';
|
|
25
25
|
import styles from './pie-chart.module.scss';
|
|
26
|
+
import type { LegendValueDisplay } from '../../components/legend';
|
|
26
27
|
import type { BaseChartProps, DataPointPercentage, Optional } from '../../types';
|
|
27
|
-
import type { LegendValueDisplay } from '../legend';
|
|
28
28
|
import type { ChartComponentWithComposition } from '../private/chart-composition';
|
|
29
29
|
import type { SVGProps, MouseEvent, ReactNode, FC } from 'react';
|
|
30
30
|
|
|
@@ -6,6 +6,8 @@ import { useTooltip, useTooltipInPortal } from '@visx/tooltip';
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { useCallback, useContext, useMemo } from 'react';
|
|
9
|
+
import { Legend, useChartLegendItems } from '../../components/legend';
|
|
10
|
+
import { BaseTooltip } from '../../components/tooltip';
|
|
9
11
|
import { useElementHeight, useInteractiveLegendData, usePrefersReducedMotion } from '../../hooks';
|
|
10
12
|
import {
|
|
11
13
|
GlobalChartsProvider,
|
|
@@ -15,15 +17,13 @@ import {
|
|
|
15
17
|
GlobalChartsContext,
|
|
16
18
|
} from '../../providers';
|
|
17
19
|
import { attachSubComponents } from '../../utils';
|
|
18
|
-
import { Legend, useChartLegendItems } from '../legend';
|
|
19
20
|
import { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';
|
|
20
21
|
import { RadialWipeAnimation } from '../private/radial-wipe-animation';
|
|
21
22
|
import { SingleChartContext } from '../private/single-chart-context';
|
|
22
23
|
import { withResponsive } from '../private/with-responsive';
|
|
23
|
-
import { BaseTooltip } from '../tooltip';
|
|
24
24
|
import styles from './pie-semi-circle-chart.module.scss';
|
|
25
|
+
import type { LegendValueDisplay } from '../../components/legend';
|
|
25
26
|
import type { BaseChartProps, DataPointPercentage, Optional } from '../../types';
|
|
26
|
-
import type { LegendValueDisplay } from '../legend';
|
|
27
27
|
import type { ChartComponentWithComposition } from '../private/chart-composition';
|
|
28
28
|
import type { ResponsiveConfig } from '../private/with-responsive';
|
|
29
29
|
import type { PieArcDatum } from '@visx/shape/lib/shapes/Pie';
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useMemo, forwardRef } from 'react';
|
|
3
|
+
import { useGlobalChartsTheme } from '../../providers';
|
|
4
|
+
import { LineChartUnresponsive } from '../line-chart';
|
|
5
|
+
import { withResponsive } from '../private/with-responsive';
|
|
6
|
+
import styles from './sparkline.module.scss';
|
|
7
|
+
import type { SparklineProps } from './types';
|
|
8
|
+
import type { SeriesData } from '../../types';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_WIDTH = 100;
|
|
11
|
+
const DEFAULT_HEIGHT = 40;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Transforms a simple number array into SeriesData format for LineChart.
|
|
15
|
+
* Uses index-based dates to create a linear x-axis.
|
|
16
|
+
*
|
|
17
|
+
* @param data - Array of numeric values to plot
|
|
18
|
+
* @param color - Optional color for the line stroke
|
|
19
|
+
* @param strokeWidth - Optional stroke width for the line
|
|
20
|
+
* @return SeriesData array suitable for LineChart
|
|
21
|
+
*/
|
|
22
|
+
const transformToSeriesData = (
|
|
23
|
+
data: number[],
|
|
24
|
+
color?: string,
|
|
25
|
+
strokeWidth?: number
|
|
26
|
+
): SeriesData[] => {
|
|
27
|
+
// Use a fixed base date and increment by index to create linear spacing
|
|
28
|
+
const baseDate = new Date( 2000, 0, 1 );
|
|
29
|
+
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
label: 'sparkline',
|
|
33
|
+
data: data.map( ( value, index ) => ( {
|
|
34
|
+
date: new Date( baseDate.getTime() + index * 86400000 ), // Add days
|
|
35
|
+
value,
|
|
36
|
+
} ) ),
|
|
37
|
+
options: {
|
|
38
|
+
stroke: color,
|
|
39
|
+
seriesLineStyle: strokeWidth ? { strokeWidth } : undefined,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const SparklineComponent = forwardRef< HTMLDivElement, SparklineProps >(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
data,
|
|
49
|
+
width = DEFAULT_WIDTH,
|
|
50
|
+
height = DEFAULT_HEIGHT,
|
|
51
|
+
color,
|
|
52
|
+
strokeWidth: strokeWidthProp,
|
|
53
|
+
withGradientFill = true,
|
|
54
|
+
gradient,
|
|
55
|
+
className,
|
|
56
|
+
chartId,
|
|
57
|
+
margin: marginProp,
|
|
58
|
+
},
|
|
59
|
+
ref
|
|
60
|
+
) => {
|
|
61
|
+
const theme = useGlobalChartsTheme();
|
|
62
|
+
|
|
63
|
+
// Get theme defaults for sparkline
|
|
64
|
+
const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
|
|
65
|
+
|
|
66
|
+
// Use prop values or fall back to theme defaults
|
|
67
|
+
const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
|
|
68
|
+
|
|
69
|
+
// Transform number[] to SeriesData[] for LineChart
|
|
70
|
+
const seriesData = useMemo( () => {
|
|
71
|
+
if ( ! data || data.length === 0 ) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
return transformToSeriesData( data, color, strokeWidth );
|
|
75
|
+
}, [ data, color, strokeWidth ] );
|
|
76
|
+
|
|
77
|
+
// Merge margins with theme defaults
|
|
78
|
+
const finalMargin = useMemo( () => {
|
|
79
|
+
const themeMargin = theme.sparkline?.margin ?? { top: 2, right: 2, bottom: 2, left: 2 };
|
|
80
|
+
const margin = marginProp ?? themeMargin;
|
|
81
|
+
return {
|
|
82
|
+
...themeMargin,
|
|
83
|
+
...margin,
|
|
84
|
+
};
|
|
85
|
+
}, [ marginProp, theme.sparkline?.margin ] );
|
|
86
|
+
|
|
87
|
+
// Build gradient options for the series if custom gradient is provided
|
|
88
|
+
// Note: This must be called before any early returns to follow React hooks rules
|
|
89
|
+
const seriesWithGradient = useMemo( () => {
|
|
90
|
+
if ( ! gradient || seriesData.length === 0 ) {
|
|
91
|
+
return seriesData;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return seriesData.map( series => ( {
|
|
95
|
+
...series,
|
|
96
|
+
options: {
|
|
97
|
+
...series.options,
|
|
98
|
+
gradient: {
|
|
99
|
+
from: gradient.from || color || '#000000',
|
|
100
|
+
to: gradient.to || '#ffffff',
|
|
101
|
+
fromOpacity: gradient.fromOpacity ?? 0.5,
|
|
102
|
+
toOpacity: gradient.toOpacity ?? 0.0,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
} ) );
|
|
106
|
+
}, [ seriesData, gradient, color ] );
|
|
107
|
+
|
|
108
|
+
// Handle empty data
|
|
109
|
+
if ( ! data || data.length === 0 ) {
|
|
110
|
+
return (
|
|
111
|
+
<div
|
|
112
|
+
ref={ ref }
|
|
113
|
+
className={ clsx(
|
|
114
|
+
'sparkline',
|
|
115
|
+
styles.sparkline,
|
|
116
|
+
styles[ 'sparkline--empty' ],
|
|
117
|
+
className
|
|
118
|
+
) }
|
|
119
|
+
style={ { width, height } }
|
|
120
|
+
data-testid="sparkline-empty"
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Handle single data point - render a simple dot
|
|
126
|
+
if ( data.length === 1 ) {
|
|
127
|
+
const cx = width / 2;
|
|
128
|
+
const cy = height / 2;
|
|
129
|
+
const resolvedColor = color || '#000000';
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div
|
|
133
|
+
ref={ ref }
|
|
134
|
+
className={ clsx(
|
|
135
|
+
'sparkline',
|
|
136
|
+
styles.sparkline,
|
|
137
|
+
styles[ 'sparkline--single-point' ],
|
|
138
|
+
className
|
|
139
|
+
) }
|
|
140
|
+
style={ { width, height } }
|
|
141
|
+
data-testid="sparkline-single-point"
|
|
142
|
+
>
|
|
143
|
+
<svg width={ width } height={ height } aria-hidden="true">
|
|
144
|
+
<circle cx={ cx } cy={ cy } r={ strokeWidth * 1.5 } fill={ resolvedColor } />
|
|
145
|
+
</svg>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
ref={ ref }
|
|
153
|
+
className={ clsx( 'sparkline', styles.sparkline, className ) }
|
|
154
|
+
data-testid="sparkline"
|
|
155
|
+
>
|
|
156
|
+
<LineChartUnresponsive
|
|
157
|
+
data={ seriesWithGradient }
|
|
158
|
+
width={ width }
|
|
159
|
+
height={ height }
|
|
160
|
+
margin={ finalMargin }
|
|
161
|
+
chartId={ chartId }
|
|
162
|
+
withGradientFill={ withGradientFill }
|
|
163
|
+
withTooltips={ false }
|
|
164
|
+
showLegend={ false }
|
|
165
|
+
gridVisibility="none"
|
|
166
|
+
options={ {
|
|
167
|
+
axis: {
|
|
168
|
+
x: { display: false },
|
|
169
|
+
y: { display: false },
|
|
170
|
+
},
|
|
171
|
+
} }
|
|
172
|
+
curveType="monotone"
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
SparklineComponent.displayName = 'SparklineComponent';
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Sparkline - A minimal line chart for inline data visualization.
|
|
183
|
+
*
|
|
184
|
+
* Sparklines are compact charts designed to be embedded inline with text or
|
|
185
|
+
* displayed in small spaces like table cells or dashboards. They show trends
|
|
186
|
+
* without axes, labels, or other chart chrome.
|
|
187
|
+
*
|
|
188
|
+
* This component is built on top of LineChart with preconfigured settings
|
|
189
|
+
* for minimal display (no axes, grid, tooltips, or legend).
|
|
190
|
+
*/
|
|
191
|
+
const SparklineUnresponsive = SparklineComponent;
|
|
192
|
+
|
|
193
|
+
SparklineUnresponsive.displayName = 'SparklineUnresponsive';
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Responsive Sparkline chart component
|
|
197
|
+
*/
|
|
198
|
+
const Sparkline = withResponsive< SparklineProps >( SparklineUnresponsive );
|
|
199
|
+
|
|
200
|
+
export { Sparkline as default, SparklineUnresponsive };
|