@automattic/charts 0.56.7 → 0.58.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/AGENTS.md +28 -98
- package/CHANGELOG.md +30 -0
- package/dist/charts/bar-chart/index.cjs +7 -6
- package/dist/charts/bar-chart/index.cjs.map +1 -1
- package/dist/charts/bar-chart/index.css +12 -24
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.d.cts +3 -4
- package/dist/charts/bar-chart/index.d.ts +3 -4
- package/dist/charts/bar-chart/index.js +6 -5
- package/dist/charts/bar-list-chart/index.cjs +8 -7
- package/dist/charts/bar-list-chart/index.cjs.map +1 -1
- package/dist/charts/bar-list-chart/index.css +12 -24
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.d.cts +3 -3
- package/dist/charts/bar-list-chart/index.d.ts +3 -3
- package/dist/charts/bar-list-chart/index.js +7 -6
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -6
- package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.css +0 -94
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.ts +1 -1
- package/dist/charts/conversion-funnel-chart/index.js +4 -5
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +0 -94
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.d.cts +1 -1
- package/dist/charts/geo-chart/index.d.ts +1 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +7 -6
- package/dist/charts/leaderboard-chart/index.cjs.map +1 -1
- package/dist/charts/leaderboard-chart/index.css +20 -33
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.d.cts +3 -3
- package/dist/charts/leaderboard-chart/index.d.ts +3 -3
- package/dist/charts/leaderboard-chart/index.js +6 -5
- package/dist/charts/line-chart/index.cjs +7 -6
- package/dist/charts/line-chart/index.cjs.map +1 -1
- package/dist/charts/line-chart/index.css +12 -24
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.d.cts +3 -4
- package/dist/charts/line-chart/index.d.ts +3 -4
- package/dist/charts/line-chart/index.js +6 -5
- package/dist/charts/pie-chart/index.cjs +7 -7
- package/dist/charts/pie-chart/index.css +12 -24
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.d.cts +7 -13
- package/dist/charts/pie-chart/index.d.ts +7 -13
- package/dist/charts/pie-chart/index.js +6 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs +7 -7
- package/dist/charts/pie-semi-circle-chart/index.css +12 -24
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.d.ts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.js +6 -6
- package/dist/charts/sparkline/index.cjs +8 -7
- package/dist/charts/sparkline/index.cjs.map +1 -1
- package/dist/charts/sparkline/index.css +12 -24
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +7 -6
- package/dist/{chunk-RFSHE3HL.js → chunk-2I67QUIV.js} +84 -431
- package/dist/chunk-2I67QUIV.js.map +1 -0
- package/dist/{chunk-OMS5QIJN.js → chunk-2ICEEQOC.js} +31 -25
- package/dist/chunk-2ICEEQOC.js.map +1 -0
- package/dist/{chunk-GWBS65VC.js → chunk-4B7BL2DD.js} +3 -3
- package/dist/{chunk-7FDQGBY7.js → chunk-4OXMTKAL.js} +24 -24
- package/dist/chunk-4OXMTKAL.js.map +1 -0
- package/dist/{chunk-SSFFCBCF.js → chunk-B6NLZFRW.js} +32 -26
- package/dist/chunk-B6NLZFRW.js.map +1 -0
- package/dist/{chunk-3EXJP67N.cjs → chunk-BBAUQOW6.cjs} +9 -9
- package/dist/{chunk-3EXJP67N.cjs.map → chunk-BBAUQOW6.cjs.map} +1 -1
- package/dist/{chunk-NQJE2CC7.cjs → chunk-CMMHCTBX.cjs} +45 -45
- package/dist/chunk-CMMHCTBX.cjs.map +1 -0
- package/dist/{chunk-O2JIANHK.cjs → chunk-CPPXJATQ.cjs} +51 -45
- package/dist/chunk-CPPXJATQ.cjs.map +1 -0
- package/dist/{chunk-MDRCAGKZ.js → chunk-DKU775VC.js} +3 -3
- package/dist/{chunk-BXFD7JIG.cjs → chunk-GRA7Y2ZG.cjs} +46 -46
- package/dist/chunk-GRA7Y2ZG.cjs.map +1 -0
- package/dist/{chunk-TE63Y5PX.js → chunk-JJIMABHT.js} +10 -3
- package/dist/chunk-JJIMABHT.js.map +1 -0
- package/dist/{chunk-KHQPN77E.js → chunk-KJHWXOCZ.js} +4 -4
- package/dist/{chunk-6CCZL2JJ.js → chunk-KRWGSOJ2.js} +30 -2
- package/dist/chunk-KRWGSOJ2.js.map +1 -0
- package/dist/{chunk-VPAEBI2F.js → chunk-LTFH7SEG.js} +24 -24
- package/dist/chunk-LTFH7SEG.js.map +1 -0
- package/dist/{chunk-E62LCBGD.js → chunk-MUNOKLLE.js} +3 -3
- package/dist/{chunk-ZVGEDXDP.cjs → chunk-MXGLYWVP.cjs} +10 -3
- package/dist/chunk-MXGLYWVP.cjs.map +1 -0
- package/dist/{chunk-55ZCOYDF.cjs → chunk-OYC34VTO.cjs} +252 -827
- package/dist/chunk-OYC34VTO.cjs.map +1 -0
- package/dist/{chunk-CAFJRZPZ.cjs → chunk-PQL5I3F6.cjs} +17 -17
- package/dist/{chunk-CAFJRZPZ.cjs.map → chunk-PQL5I3F6.cjs.map} +1 -1
- package/dist/{chunk-UFRBUT2D.cjs → chunk-REZTQ4PH.cjs} +87 -24
- package/dist/chunk-REZTQ4PH.cjs.map +1 -0
- package/dist/{chunk-RCY6XLGU.cjs → chunk-TZRUHQOH.cjs} +36 -8
- package/dist/chunk-TZRUHQOH.cjs.map +1 -0
- package/dist/{chunk-XD2HV7M5.js → chunk-UTYVIOWZ.js} +226 -801
- package/dist/chunk-UTYVIOWZ.js.map +1 -0
- package/dist/{chunk-YAXY5L7I.cjs → chunk-W2LDIX26.cjs} +5 -5
- package/dist/{chunk-YAXY5L7I.cjs.map → chunk-W2LDIX26.cjs.map} +1 -1
- package/dist/{chunk-K6TGILHX.cjs → chunk-WSG64BVN.cjs} +6 -6
- package/dist/{chunk-K6TGILHX.cjs.map → chunk-WSG64BVN.cjs.map} +1 -1
- package/dist/chunk-WTQYGUNF.js +400 -0
- package/dist/chunk-WTQYGUNF.js.map +1 -0
- package/dist/{chunk-YDVHT7GS.cjs → chunk-WYK7EL5R.cjs} +100 -447
- package/dist/chunk-WYK7EL5R.cjs.map +1 -0
- package/dist/{chunk-X7JL2NYJ.cjs → chunk-XC4KHJYX.cjs} +51 -45
- package/dist/chunk-XC4KHJYX.cjs.map +1 -0
- package/dist/chunk-XVBH5XHE.cjs +400 -0
- package/dist/chunk-XVBH5XHE.cjs.map +1 -0
- package/dist/{chunk-IS5YYLTV.js → chunk-YAFQVVDI.js} +85 -22
- package/dist/chunk-YAFQVVDI.js.map +1 -0
- package/dist/components/legend/index.cjs +4 -3
- package/dist/components/legend/index.cjs.map +1 -1
- package/dist/components/legend/index.css +12 -24
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.d.cts +4 -4
- package/dist/components/legend/index.d.ts +4 -4
- package/dist/components/legend/index.js +3 -2
- package/dist/components/tooltip/index.d.cts +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/hooks/index.cjs +3 -5
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +0 -94
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +9 -13
- package/dist/hooks/index.d.ts +9 -13
- package/dist/hooks/index.js +2 -4
- package/dist/index.cjs +18 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -33
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +17 -16
- package/dist/{leaderboard-chart-COtgamhe.d.cts → leaderboard-chart-BSbg0ufV.d.cts} +3 -11
- package/dist/{leaderboard-chart-BSgEw_Um.d.ts → leaderboard-chart-odEYxxEC.d.ts} +3 -11
- package/dist/{legend-C9ahiwOt.d.cts → legend-DFkosEvC.d.cts} +1 -1
- package/dist/{legend-jjMmhSg3.d.ts → legend-DLswHhOk.d.ts} +1 -1
- package/dist/providers/index.cjs +3 -3
- package/dist/providers/index.css +0 -94
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +2 -2
- package/dist/{themes-CVR5rmIs.d.cts → themes-D0qc5JaW.d.cts} +2 -2
- package/dist/{themes-DQzmaSze.d.ts → themes-itO4Ht5g.d.ts} +2 -2
- package/dist/{types-BBwg4Evw.d.cts → types-B5f6XQ7Q.d.cts} +1 -1
- package/dist/{types-DQNnq5Fr.d.ts → types-BsHooDbM.d.ts} +1 -1
- package/dist/{types-C05PdDJa.d.cts → types-BuSrRM4p.d.ts} +15 -23
- package/dist/{types-CzdN7rUe.d.cts → types-ChOUI9-N.d.cts} +90 -46
- package/dist/{types-CzdN7rUe.d.ts → types-ChOUI9-N.d.ts} +90 -46
- package/dist/{types-C05PdDJa.d.ts → types-Dfw9VOKI.d.cts} +15 -23
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +10 -8
- package/src/charts/bar-chart/bar-chart.tsx +19 -19
- package/src/charts/bar-chart/test/bar-chart.test.tsx +78 -31
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +2 -2
- package/src/charts/leaderboard-chart/hooks/use-leaderboard-legend-items.ts +0 -2
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +9 -10
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +124 -102
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +61 -33
- package/src/charts/leaderboard-chart/test/use-leaderboard-legend-items.test.tsx +2 -5
- package/src/charts/leaderboard-chart/types.ts +2 -15
- package/src/charts/line-chart/line-chart.tsx +18 -17
- 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.tsx +23 -23
- package/src/charts/pie-chart/test/composition-api.test.tsx +41 -0
- package/src/charts/pie-chart/test/pie-chart.test.tsx +9 -9
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +21 -24
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +33 -5
- 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/components/legend/private/base-legend.module.scss +19 -37
- package/src/components/legend/private/base-legend.tsx +32 -24
- package/src/components/legend/test/legend.test.tsx +148 -52
- package/src/components/legend/types.ts +23 -24
- package/src/hooks/index.ts +0 -1
- package/src/hooks/test/use-zero-value-display.test.tsx +206 -0
- package/src/hooks/use-zero-value-display.ts +52 -23
- package/src/providers/chart-context/test/chart-context.test.tsx +12 -6
- package/src/providers/chart-context/themes.ts +6 -4
- package/src/types.ts +93 -44
- package/src/utils/date-parsing.ts +10 -1
- package/src/utils/get-styles.ts +1 -1
- package/src/utils/test/date-parsing.test.ts +12 -0
- package/src/utils/test/get-styles.test.ts +12 -10
- package/src/utils/test/resolve-css-var.test.ts +2 -2
- package/tsup.config.ts +1 -1
- package/dist/chunk-55ZCOYDF.cjs.map +0 -1
- package/dist/chunk-6CCZL2JJ.js.map +0 -1
- package/dist/chunk-7FDQGBY7.js.map +0 -1
- package/dist/chunk-BXFD7JIG.cjs.map +0 -1
- package/dist/chunk-IS5YYLTV.js.map +0 -1
- package/dist/chunk-KNIMXN6Z.js +0 -51
- package/dist/chunk-KNIMXN6Z.js.map +0 -1
- package/dist/chunk-NQJE2CC7.cjs.map +0 -1
- package/dist/chunk-O2JIANHK.cjs.map +0 -1
- package/dist/chunk-OMS5QIJN.js.map +0 -1
- package/dist/chunk-RCY6XLGU.cjs.map +0 -1
- package/dist/chunk-RFSHE3HL.js.map +0 -1
- package/dist/chunk-SSFFCBCF.js.map +0 -1
- package/dist/chunk-SUDERBUA.cjs +0 -51
- package/dist/chunk-SUDERBUA.cjs.map +0 -1
- package/dist/chunk-TE63Y5PX.js.map +0 -1
- package/dist/chunk-UFRBUT2D.cjs.map +0 -1
- package/dist/chunk-VPAEBI2F.js.map +0 -1
- package/dist/chunk-X7JL2NYJ.cjs.map +0 -1
- package/dist/chunk-XD2HV7M5.js.map +0 -1
- package/dist/chunk-YDVHT7GS.cjs.map +0 -1
- package/dist/chunk-ZVGEDXDP.cjs.map +0 -1
- package/src/hooks/use-has-legend-child.ts +0 -22
- /package/dist/{chunk-GWBS65VC.js.map → chunk-4B7BL2DD.js.map} +0 -0
- /package/dist/{chunk-MDRCAGKZ.js.map → chunk-DKU775VC.js.map} +0 -0
- /package/dist/{chunk-KHQPN77E.js.map → chunk-KJHWXOCZ.js.map} +0 -0
- /package/dist/{chunk-E62LCBGD.js.map → chunk-MUNOKLLE.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["esbuild-sass-plugin:css-chunk:src/hooks/use-tooltip-portal-relocator.module.scss","esbuild-sass-plugin:css-chunk:src/components/legend/private/base-legend.module.scss","esbuild-sass-plugin:css-chunk:src/components/tooltip/base-tooltip.module.scss","esbuild-sass-plugin:css-chunk:src/charts/private/with-responsive/with-responsive.module.scss","esbuild-sass-plugin:css-chunk:src/charts/line-chart/line-chart.module.scss","esbuild-sass-plugin:css-chunk:src/charts/sparkline/sparkline.module.scss"],"sourcesContent":[".a8ccharts-jCw5dQ {\n position: fixed;\n inset: 0;\n overflow: visible;\n z-index: 1;\n pointer-events: none;\n}",".a8ccharts-
|
|
1
|
+
{"version":3,"sources":["esbuild-sass-plugin:css-chunk:src/hooks/use-tooltip-portal-relocator.module.scss","esbuild-sass-plugin:css-chunk:src/components/legend/private/base-legend.module.scss","esbuild-sass-plugin:css-chunk:src/components/tooltip/base-tooltip.module.scss","esbuild-sass-plugin:css-chunk:src/charts/private/with-responsive/with-responsive.module.scss","esbuild-sass-plugin:css-chunk:src/charts/line-chart/line-chart.module.scss","esbuild-sass-plugin:css-chunk:src/charts/sparkline/sparkline.module.scss"],"sourcesContent":[".a8ccharts-jCw5dQ {\n position: fixed;\n inset: 0;\n overflow: visible;\n z-index: 1;\n pointer-events: none;\n}",".a8ccharts-89ApsU {\n align-self: stretch;\n}\n.a8ccharts-AELBvX {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 16px;\n}\n.a8ccharts-fX8uQe {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.a8ccharts-DEe0wg {\n justify-content: flex-start;\n}\n.a8ccharts-WBKF9I {\n justify-content: center;\n}\n.a8ccharts-JfwMng {\n justify-content: flex-end;\n}\n.a8ccharts-fX8uQe.a8ccharts-DEe0wg {\n align-items: flex-start;\n}\n.a8ccharts-fX8uQe.a8ccharts-WBKF9I {\n align-items: center;\n}\n.a8ccharts-fX8uQe.a8ccharts-JfwMng {\n align-items: flex-end;\n}\n\n.a8ccharts-Vflwq8 {\n display: flex;\n align-items: center;\n font-size: 0.875rem;\n}\n.a8ccharts-qGsavM {\n cursor: pointer;\n user-select: none;\n transition: opacity 0.2s ease;\n}\n.a8ccharts-qGsavM:hover {\n opacity: 0.8;\n}\n.a8ccharts-qGsavM:focus {\n outline: 2px solid currentColor;\n outline-offset: 2px;\n border-radius: 4px;\n}\n.a8ccharts-qGsavM:focus:not(:focus-visible) {\n outline: none;\n}\n.a8ccharts-ZtDY-Q {\n opacity: 0.4;\n}\n.a8ccharts-ZtDY-Q .a8ccharts-2H65Kr {\n text-decoration: line-through;\n}\n\n.a8ccharts-2H65Kr {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n /* Text wrapping is handled at the text level, not the label container */\n}\n\n.a8ccharts-faSDBI {\n overflow-wrap: break-word;\n white-space: normal;\n hyphens: auto;\n}\n.a8ccharts-FISUIO {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 1;\n min-width: 0;\n}\n\n.a8ccharts-DTZlT- {\n font-weight: 500;\n flex-shrink: 0;\n}",".a8ccharts-OfX6nd {\n padding: 0.5rem;\n background-color: rgba(0, 0, 0, 0.85);\n color: #fff;\n border-radius: 4px;\n font-size: 14px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n position: absolute;\n pointer-events: none;\n transform: translate(-50%, -100%);\n}",".a8ccharts-GSKfBD {\n min-width: 0;\n min-height: 0;\n}",".a8ccharts-v-oO8E {\n position: relative;\n}\n.a8ccharts-cpMNjj {\n flex: 1;\n min-height: 0;\n}\n.a8ccharts-QrkuTW path {\n transform-origin: 0 95%;\n transform: scaleY(0);\n animation: a8ccharts--rxDU3 1s ease-out forwards;\n}\n.a8ccharts-v-oO8E svg {\n overflow: visible;\n}\n.a8ccharts-Tu0rR-, .a8ccharts--RSWXi {\n background: #fff;\n padding: 0.5rem;\n}\n.a8ccharts-Q-b5A1 {\n font-weight: 700;\n padding-bottom: 10px;\n}\n.a8ccharts-19N7T9 {\n display: flex;\n align-items: center;\n padding: 4px 0;\n justify-content: space-between;\n}\n.a8ccharts-HOAXrD {\n font-weight: 500;\n padding-right: 1rem;\n}\n.a8ccharts-rQiY8O {\n position: absolute;\n left: 0;\n top: 0;\n overflow: visible;\n pointer-events: none;\n}\n.a8ccharts-8AKWOe {\n pointer-events: auto;\n}\n.a8ccharts-7mh3Cl {\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: auto;\n cursor: pointer;\n border: none;\n background: none;\n padding: 0;\n}\n.a8ccharts--RSWXi {\n min-width: 125px;\n background: #fff;\n border: none;\n border-radius: 4px;\n font-size: 14px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n position: fixed;\n margin: 0.5rem;\n visibility: hidden;\n}\n.a8ccharts-VAeVuJ {\n visibility: visible;\n}\n.a8ccharts-TEe-iV {\n position: initial;\n margin: auto;\n}\n.a8ccharts-LAUpx7 {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: start;\n}\n.a8ccharts-b76gEu {\n padding: 0.5rem;\n}\n.a8ccharts-LIpFoS {\n background: none;\n border: none;\n cursor: pointer;\n width: 44px;\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n}\n\n.visx-tooltip-glyph svg {\n width: 10px;\n height: 10px;\n}\n\n@keyframes a8ccharts--rxDU3 {\n to {\n transform: scaleY(1);\n }\n}",".a8ccharts-o-3Z8B {\n display: inline-block;\n vertical-align: middle;\n line-height: 1;\n}\n.a8ccharts-o-3Z8B svg {\n display: block;\n overflow: visible;\n}\n.a8ccharts-o-3Z8B path {\n vector-effect: non-scaling-stroke;\n}\n.a8ccharts-CbLbcd {\n display: inline-block;\n}"],"mappings":"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","names":[]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Sparkline,
|
|
3
3
|
SparklineUnresponsive
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-MUNOKLLE.js";
|
|
5
|
+
import "../../chunk-2ICEEQOC.js";
|
|
6
|
+
import "../../chunk-KRWGSOJ2.js";
|
|
7
|
+
import "../../chunk-WTQYGUNF.js";
|
|
6
8
|
import "../../chunk-BPYKWMI7.js";
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-KNIMXN6Z.js";
|
|
9
|
+
import "../../chunk-YAFQVVDI.js";
|
|
9
10
|
import "../../chunk-OP6PHB2U.js";
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-2I67QUIV.js";
|
|
12
|
+
import "../../chunk-JJIMABHT.js";
|
|
12
13
|
import "../../chunk-G3PMV62Z.js";
|
|
13
14
|
export {
|
|
14
15
|
Sparkline,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
formatPercentage,
|
|
3
2
|
getColorDistance,
|
|
4
3
|
getItemShapeStyles,
|
|
5
4
|
getLongestTickWidth,
|
|
@@ -8,14 +7,53 @@ import {
|
|
|
8
7
|
normalizeColorToHex,
|
|
9
8
|
parseAsLocalDate,
|
|
10
9
|
resolveCssVariable
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JJIMABHT.js";
|
|
11
|
+
import {
|
|
12
|
+
__commonJS,
|
|
13
|
+
__toESM
|
|
14
|
+
} from "./chunk-G3PMV62Z.js";
|
|
15
|
+
|
|
16
|
+
// ../../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
17
|
+
var require_fast_deep_equal = __commonJS({
|
|
18
|
+
"../../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
19
|
+
"use strict";
|
|
20
|
+
module.exports = function equal(a, b) {
|
|
21
|
+
if (a === b) return true;
|
|
22
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
23
|
+
if (a.constructor !== b.constructor) return false;
|
|
24
|
+
var length, i, keys;
|
|
25
|
+
if (Array.isArray(a)) {
|
|
26
|
+
length = a.length;
|
|
27
|
+
if (length != b.length) return false;
|
|
28
|
+
for (i = length; i-- !== 0; )
|
|
29
|
+
if (!equal(a[i], b[i])) return false;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
33
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
34
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
35
|
+
keys = Object.keys(a);
|
|
36
|
+
length = keys.length;
|
|
37
|
+
if (length !== Object.keys(b).length) return false;
|
|
38
|
+
for (i = length; i-- !== 0; )
|
|
39
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
40
|
+
for (i = length; i-- !== 0; ) {
|
|
41
|
+
var key = keys[i];
|
|
42
|
+
if (!equal(a[key], b[key])) return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return a !== a && b !== b;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
12
50
|
|
|
13
51
|
// src/hooks/use-deep-memo.ts
|
|
14
|
-
|
|
52
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
|
|
15
53
|
import { useRef } from "react";
|
|
16
54
|
var useDeepMemo = (value) => {
|
|
17
55
|
const ref = useRef(value);
|
|
18
|
-
if (!
|
|
56
|
+
if (!(0, import_fast_deep_equal.default)(ref.current, value)) {
|
|
19
57
|
ref.current = value;
|
|
20
58
|
}
|
|
21
59
|
return ref.current;
|
|
@@ -266,12 +304,14 @@ var defaultTheme = {
|
|
|
266
304
|
gridColorDark: "",
|
|
267
305
|
xTickLineStyles: { stroke: "black" },
|
|
268
306
|
xAxisLineStyles: { stroke: "#DCDCDE", strokeWidth: 1 },
|
|
269
|
-
|
|
270
|
-
|
|
307
|
+
legend: {
|
|
308
|
+
labelStyles: {
|
|
309
|
+
color: "var(--jp-gray-80, #2c3338)"
|
|
310
|
+
},
|
|
311
|
+
containerStyles: {},
|
|
312
|
+
shapeStyles: []
|
|
271
313
|
},
|
|
272
|
-
legendContainerStyles: {},
|
|
273
314
|
seriesLineStyles: [],
|
|
274
|
-
legendShapeStyles: [],
|
|
275
315
|
glyphs: [],
|
|
276
316
|
svgLabelSmall: { fill: "var(--jp-gray-80, #2c3338)" },
|
|
277
317
|
annotationStyles: {
|
|
@@ -693,407 +733,12 @@ function useElementSize({
|
|
|
693
733
|
return [refCallback, width, height];
|
|
694
734
|
}
|
|
695
735
|
|
|
696
|
-
// src/hooks/use-has-legend-child.ts
|
|
697
|
-
import { Children, isValidElement, useMemo as useMemo8 } from "react";
|
|
698
|
-
|
|
699
|
-
// src/components/legend/legend.tsx
|
|
700
|
-
import { useContext as useContext5, useMemo as useMemo6, forwardRef as forwardRef2 } from "react";
|
|
701
|
-
|
|
702
|
-
// src/charts/private/single-chart-context/single-chart-context.tsx
|
|
703
|
-
import { createContext as createContext2 } from "react";
|
|
704
|
-
var ChartInstanceContext = /* @__PURE__ */ createContext2(null);
|
|
705
|
-
var SingleChartContext = ChartInstanceContext;
|
|
706
|
-
|
|
707
|
-
// src/charts/private/single-chart-context/use-single-chart-context.ts
|
|
708
|
-
import { useContext as useContext3 } from "react";
|
|
709
|
-
var useChartInstanceContext = () => {
|
|
710
|
-
const context = useContext3(ChartInstanceContext);
|
|
711
|
-
if (!context) {
|
|
712
|
-
throw new Error("useChartInstanceContext must be used within a Chart component");
|
|
713
|
-
}
|
|
714
|
-
return context;
|
|
715
|
-
};
|
|
716
|
-
var useSingleChartContext = useChartInstanceContext;
|
|
717
|
-
|
|
718
|
-
// src/components/legend/private/base-legend.tsx
|
|
719
|
-
import { Group } from "@visx/group";
|
|
720
|
-
import { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from "@visx/legend";
|
|
721
|
-
import { scaleOrdinal } from "@visx/scale";
|
|
722
|
-
import clsx from "clsx";
|
|
723
|
-
import { forwardRef, useCallback as useCallback4, useContext as useContext4 } from "react";
|
|
724
|
-
|
|
725
|
-
// src/components/legend/utils/value-or-identity.ts
|
|
726
|
-
function valueOrIdentity(_) {
|
|
727
|
-
if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
|
|
728
|
-
return _.value;
|
|
729
|
-
return _;
|
|
730
|
-
}
|
|
731
|
-
function valueOrIdentityString(_) {
|
|
732
|
-
return String(valueOrIdentity(_));
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// src/components/legend/utils/label-transform-factory.ts
|
|
736
|
-
function labelTransformFactory({
|
|
737
|
-
scale,
|
|
738
|
-
labelFormat
|
|
739
|
-
}) {
|
|
740
|
-
return (d, i) => ({
|
|
741
|
-
datum: d,
|
|
742
|
-
index: i,
|
|
743
|
-
text: `${labelFormat(d, i)}`,
|
|
744
|
-
value: scale(d)
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
// src/components/legend/private/base-legend.module.scss
|
|
749
|
-
var base_legend_module_default = {
|
|
750
|
-
"legend--horizontal": "a8ccharts-AELBvX",
|
|
751
|
-
"legend--vertical": "a8ccharts-fX8uQe",
|
|
752
|
-
"legend--alignment-start": "a8ccharts-DEe0wg",
|
|
753
|
-
"legend--alignment-center": "a8ccharts-WBKF9I",
|
|
754
|
-
"legend--alignment-end": "a8ccharts-JfwMng",
|
|
755
|
-
"legend--position-top": "a8ccharts-8Y73Kh",
|
|
756
|
-
"legend--position-bottom": "a8ccharts-TVM-IY",
|
|
757
|
-
"legend-item": "a8ccharts-Vflwq8",
|
|
758
|
-
"legend-item--interactive": "a8ccharts-qGsavM",
|
|
759
|
-
"legend-item--inactive": "a8ccharts-ZtDY-Q",
|
|
760
|
-
"legend-item-label": "a8ccharts-2H65Kr",
|
|
761
|
-
"legend-item-text--wrap": "a8ccharts-faSDBI",
|
|
762
|
-
"legend-item-text--ellipsis": "a8ccharts-FISUIO",
|
|
763
|
-
"legend-item-value": "a8ccharts-DTZlT-"
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// src/components/legend/private/base-legend.tsx
|
|
767
|
-
import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
|
|
768
|
-
var orientationToFlexDirection = {
|
|
769
|
-
horizontal: "row",
|
|
770
|
-
vertical: "column"
|
|
771
|
-
};
|
|
772
|
-
var LegendText = ({
|
|
773
|
-
text,
|
|
774
|
-
textOverflow,
|
|
775
|
-
maxWidth
|
|
776
|
-
}) => {
|
|
777
|
-
const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
|
|
778
|
-
const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
|
|
779
|
-
return /* @__PURE__ */ _jsx2("span", {
|
|
780
|
-
ref: textRef,
|
|
781
|
-
className: clsx(base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
|
|
782
|
-
style: {
|
|
783
|
-
...maxWidth != null && {
|
|
784
|
-
maxWidth,
|
|
785
|
-
minWidth: 0
|
|
786
|
-
}
|
|
787
|
-
},
|
|
788
|
-
title: isEllipsis && isTruncated ? text : void 0,
|
|
789
|
-
children: text
|
|
790
|
-
});
|
|
791
|
-
};
|
|
792
|
-
var BaseLegend = /* @__PURE__ */ forwardRef(({
|
|
793
|
-
items,
|
|
794
|
-
className,
|
|
795
|
-
orientation = "horizontal",
|
|
796
|
-
position = "bottom",
|
|
797
|
-
alignment = "center",
|
|
798
|
-
maxWidth,
|
|
799
|
-
textOverflow = "wrap",
|
|
800
|
-
shape = "rect",
|
|
801
|
-
fill = valueOrIdentityString,
|
|
802
|
-
size = valueOrIdentityString,
|
|
803
|
-
labelFormat = valueOrIdentity,
|
|
804
|
-
labelTransform = labelTransformFactory,
|
|
805
|
-
shapeWidth = 16,
|
|
806
|
-
shapeHeight = 16,
|
|
807
|
-
shapeMargin = "2px 4px 2px 0",
|
|
808
|
-
labelAlign = "left",
|
|
809
|
-
labelFlex = "0 0 auto",
|
|
810
|
-
// Use natural width instead of expanding to fill space
|
|
811
|
-
labelMargin = "0 4px",
|
|
812
|
-
itemMargin = "0",
|
|
813
|
-
itemDirection = "row",
|
|
814
|
-
legendLabelProps,
|
|
815
|
-
legendItemClassName,
|
|
816
|
-
render,
|
|
817
|
-
interactive = false,
|
|
818
|
-
chartId,
|
|
819
|
-
...legendItemProps
|
|
820
|
-
}, ref) => {
|
|
821
|
-
const theme = useGlobalChartsTheme();
|
|
822
|
-
const context = useContext4(GlobalChartsContext);
|
|
823
|
-
const legendScale = scaleOrdinal({
|
|
824
|
-
domain: items.map((item) => item.label),
|
|
825
|
-
range: items.map((item) => item.color)
|
|
826
|
-
});
|
|
827
|
-
const domain = legendScale.domain();
|
|
828
|
-
const getShapeStyle = useCallback4(({
|
|
829
|
-
index
|
|
830
|
-
}) => items[index]?.shapeStyle, [items]);
|
|
831
|
-
const handleLegendClick = useCallback4((seriesLabel) => {
|
|
832
|
-
if (interactive && chartId && context) {
|
|
833
|
-
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
834
|
-
}
|
|
835
|
-
}, [interactive, chartId, context]);
|
|
836
|
-
const isSeriesVisible = useCallback4((seriesLabel) => {
|
|
837
|
-
if (!interactive || !chartId || !context) {
|
|
838
|
-
return true;
|
|
839
|
-
}
|
|
840
|
-
return context.isSeriesVisible(chartId, seriesLabel);
|
|
841
|
-
}, [interactive, chartId, context]);
|
|
842
|
-
const createClickHandler = useCallback4((labelText) => {
|
|
843
|
-
if (!interactive) {
|
|
844
|
-
return void 0;
|
|
845
|
-
}
|
|
846
|
-
return () => handleLegendClick(labelText);
|
|
847
|
-
}, [interactive, handleLegendClick]);
|
|
848
|
-
const createKeyDownHandler = useCallback4((labelText) => {
|
|
849
|
-
if (!interactive) {
|
|
850
|
-
return void 0;
|
|
851
|
-
}
|
|
852
|
-
return (event) => {
|
|
853
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
854
|
-
event.preventDefault();
|
|
855
|
-
handleLegendClick(labelText);
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
}, [interactive, handleLegendClick]);
|
|
859
|
-
return render ? render(items) : /* @__PURE__ */ _jsx2(LegendOrdinal, {
|
|
860
|
-
scale: legendScale,
|
|
861
|
-
labelFormat,
|
|
862
|
-
labelTransform,
|
|
863
|
-
children: (labels) => /* @__PURE__ */ _jsx2("div", {
|
|
864
|
-
ref,
|
|
865
|
-
role: "list",
|
|
866
|
-
className: clsx(base_legend_module_default.legend, base_legend_module_default[`legend--${orientation}`], base_legend_module_default[`legend--alignment-${alignment}`], base_legend_module_default[`legend--position-${position}`], className),
|
|
867
|
-
style: {
|
|
868
|
-
flexDirection: orientationToFlexDirection[orientation],
|
|
869
|
-
...theme.legendContainerStyles
|
|
870
|
-
},
|
|
871
|
-
children: labels.map((label, i) => {
|
|
872
|
-
const visible = isSeriesVisible(label.text);
|
|
873
|
-
const handleClick = createClickHandler(label.text);
|
|
874
|
-
const handleKeyDown = createKeyDownHandler(label.text);
|
|
875
|
-
return /* @__PURE__ */ _jsxs(LegendItem, {
|
|
876
|
-
className: clsx("visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], legendItemClassName),
|
|
877
|
-
margin: itemMargin,
|
|
878
|
-
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
879
|
-
onClick: handleClick,
|
|
880
|
-
onKeyDown: handleKeyDown,
|
|
881
|
-
role: interactive ? "button" : void 0,
|
|
882
|
-
tabIndex: interactive ? 0 : void 0,
|
|
883
|
-
"aria-pressed": interactive ? visible : void 0,
|
|
884
|
-
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
885
|
-
...legendItemProps,
|
|
886
|
-
children: [items[i]?.renderGlyph ? /* @__PURE__ */ _jsx2("svg", {
|
|
887
|
-
width: items[i]?.glyphSize * 2,
|
|
888
|
-
height: items[i]?.glyphSize * 2,
|
|
889
|
-
children: /* @__PURE__ */ _jsx2(Group, {
|
|
890
|
-
children: items[i]?.renderGlyph({
|
|
891
|
-
key: `legend-glyph-${label.text}`,
|
|
892
|
-
datum: {},
|
|
893
|
-
index: i,
|
|
894
|
-
color: fill(label),
|
|
895
|
-
size: items[i]?.glyphSize,
|
|
896
|
-
x: items[i]?.glyphSize,
|
|
897
|
-
y: items[i]?.glyphSize
|
|
898
|
-
})
|
|
899
|
-
})
|
|
900
|
-
}) : /* @__PURE__ */ _jsx2(LegendShape, {
|
|
901
|
-
shape,
|
|
902
|
-
height: shapeHeight,
|
|
903
|
-
width: shapeWidth,
|
|
904
|
-
margin: shapeMargin,
|
|
905
|
-
item: domain[i],
|
|
906
|
-
itemIndex: i,
|
|
907
|
-
label,
|
|
908
|
-
fill,
|
|
909
|
-
size,
|
|
910
|
-
shapeStyle: getShapeStyle
|
|
911
|
-
}), /* @__PURE__ */ _jsxs(LegendLabel, {
|
|
912
|
-
className: clsx("visx-legend-label", base_legend_module_default["legend-item-label"]),
|
|
913
|
-
style: {
|
|
914
|
-
justifyContent: labelAlign,
|
|
915
|
-
flex: labelFlex,
|
|
916
|
-
margin: labelMargin,
|
|
917
|
-
...theme.legendLabelStyles
|
|
918
|
-
},
|
|
919
|
-
...legendLabelProps,
|
|
920
|
-
children: [/* @__PURE__ */ _jsx2(LegendText, {
|
|
921
|
-
text: label.text,
|
|
922
|
-
textOverflow,
|
|
923
|
-
maxWidth
|
|
924
|
-
}), items.find((item) => item.label === label.text)?.value && /* @__PURE__ */ _jsxs("span", {
|
|
925
|
-
className: base_legend_module_default["legend-item-value"],
|
|
926
|
-
children: ["\xA0", items.find((item) => item.label === label.text)?.value]
|
|
927
|
-
})]
|
|
928
|
-
})]
|
|
929
|
-
}, `legend-${label.text}-${i}`);
|
|
930
|
-
})
|
|
931
|
-
})
|
|
932
|
-
});
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
// src/components/legend/legend.tsx
|
|
936
|
-
import { jsx as _jsx3 } from "react/jsx-runtime";
|
|
937
|
-
var Legend = /* @__PURE__ */ forwardRef2(({
|
|
938
|
-
chartId,
|
|
939
|
-
items,
|
|
940
|
-
...props
|
|
941
|
-
}, ref) => {
|
|
942
|
-
const context = useContext5(GlobalChartsContext);
|
|
943
|
-
const singleChartContext = useContext5(SingleChartContext);
|
|
944
|
-
const contextChartId = chartId ?? singleChartContext?.chartId;
|
|
945
|
-
const contextItems = useMemo6(() => {
|
|
946
|
-
return contextChartId && context ? context.getChartData(contextChartId)?.legendItems : void 0;
|
|
947
|
-
}, [contextChartId, context]);
|
|
948
|
-
const legendItems = items || contextItems;
|
|
949
|
-
if (!legendItems) {
|
|
950
|
-
return null;
|
|
951
|
-
}
|
|
952
|
-
return /* @__PURE__ */ _jsx3(BaseLegend, {
|
|
953
|
-
ref,
|
|
954
|
-
items: legendItems,
|
|
955
|
-
...props,
|
|
956
|
-
chartId: contextChartId
|
|
957
|
-
});
|
|
958
|
-
});
|
|
959
|
-
|
|
960
|
-
// src/components/legend/hooks/use-chart-legend-items.ts
|
|
961
|
-
import { formatNumber } from "@automattic/number-formatters";
|
|
962
|
-
import { useMemo as useMemo7 } from "react";
|
|
963
|
-
function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
|
|
964
|
-
if (!showValues || legendValueDisplay === "none") {
|
|
965
|
-
return "";
|
|
966
|
-
}
|
|
967
|
-
if ("percentage" in point) {
|
|
968
|
-
const percentagePoint = point;
|
|
969
|
-
switch (legendValueDisplay) {
|
|
970
|
-
case "percentage":
|
|
971
|
-
return formatPercentage(percentagePoint.percentage);
|
|
972
|
-
case "value":
|
|
973
|
-
return formatNumber(percentagePoint.value);
|
|
974
|
-
case "valueDisplay":
|
|
975
|
-
return percentagePoint.valueDisplay || formatNumber(percentagePoint.value);
|
|
976
|
-
default:
|
|
977
|
-
return "";
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
if ("value" in point) {
|
|
981
|
-
return point.value !== null ? formatNumber(point.value) : "";
|
|
982
|
-
}
|
|
983
|
-
return "";
|
|
984
|
-
}
|
|
985
|
-
function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
|
|
986
|
-
if (withGlyph) {
|
|
987
|
-
const glyphToUse = glyph || renderGlyph;
|
|
988
|
-
if (glyphToUse) {
|
|
989
|
-
return {
|
|
990
|
-
...baseItem,
|
|
991
|
-
glyphSize,
|
|
992
|
-
renderGlyph: glyphToUse
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
return baseItem;
|
|
997
|
-
}
|
|
998
|
-
function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
999
|
-
const mapper = (series, index) => {
|
|
1000
|
-
const { color, glyph, shapeStyles } = getElementStyles({
|
|
1001
|
-
data: series,
|
|
1002
|
-
index,
|
|
1003
|
-
legendShape
|
|
1004
|
-
});
|
|
1005
|
-
const baseItem = {
|
|
1006
|
-
label: series.label,
|
|
1007
|
-
value: showValues ? series.data?.length?.toString() || "0" : "",
|
|
1008
|
-
color,
|
|
1009
|
-
shapeStyle: shapeStyles
|
|
1010
|
-
};
|
|
1011
|
-
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
1012
|
-
};
|
|
1013
|
-
return seriesData.map(mapper);
|
|
1014
|
-
}
|
|
1015
|
-
function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
1016
|
-
const mapper = (point, index) => {
|
|
1017
|
-
const { color, glyph, shapeStyles } = getElementStyles({
|
|
1018
|
-
data: point,
|
|
1019
|
-
index,
|
|
1020
|
-
legendShape
|
|
1021
|
-
});
|
|
1022
|
-
const baseItem = {
|
|
1023
|
-
label: point.label,
|
|
1024
|
-
value: formatPointValue(point, showValues, legendValueDisplay),
|
|
1025
|
-
color,
|
|
1026
|
-
shapeStyle: shapeStyles
|
|
1027
|
-
};
|
|
1028
|
-
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
1029
|
-
};
|
|
1030
|
-
return pointData.map(mapper);
|
|
1031
|
-
}
|
|
1032
|
-
function useChartLegendItems(data, options = {}, legendShape) {
|
|
1033
|
-
const {
|
|
1034
|
-
showValues = false,
|
|
1035
|
-
legendValueDisplay = "percentage",
|
|
1036
|
-
withGlyph = false,
|
|
1037
|
-
glyphSize = 8,
|
|
1038
|
-
renderGlyph
|
|
1039
|
-
} = options;
|
|
1040
|
-
const { getElementStyles } = useGlobalChartsContext();
|
|
1041
|
-
return useMemo7(() => {
|
|
1042
|
-
if (!data || !Array.isArray(data) || data.length === 0) {
|
|
1043
|
-
return [];
|
|
1044
|
-
}
|
|
1045
|
-
if ("data" in data[0]) {
|
|
1046
|
-
return processSeriesData(
|
|
1047
|
-
data,
|
|
1048
|
-
getElementStyles,
|
|
1049
|
-
showValues,
|
|
1050
|
-
withGlyph,
|
|
1051
|
-
glyphSize,
|
|
1052
|
-
renderGlyph,
|
|
1053
|
-
legendShape
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
|
-
return processPointData(
|
|
1057
|
-
data,
|
|
1058
|
-
getElementStyles,
|
|
1059
|
-
showValues,
|
|
1060
|
-
legendValueDisplay,
|
|
1061
|
-
withGlyph,
|
|
1062
|
-
glyphSize,
|
|
1063
|
-
renderGlyph,
|
|
1064
|
-
legendShape
|
|
1065
|
-
);
|
|
1066
|
-
}, [
|
|
1067
|
-
data,
|
|
1068
|
-
getElementStyles,
|
|
1069
|
-
showValues,
|
|
1070
|
-
legendValueDisplay,
|
|
1071
|
-
withGlyph,
|
|
1072
|
-
glyphSize,
|
|
1073
|
-
renderGlyph,
|
|
1074
|
-
legendShape
|
|
1075
|
-
]);
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// src/hooks/use-has-legend-child.ts
|
|
1079
|
-
function useHasLegendChild(children) {
|
|
1080
|
-
return useMemo8(() => {
|
|
1081
|
-
let found = false;
|
|
1082
|
-
Children.forEach(children, (child) => {
|
|
1083
|
-
if (isValidElement(child) && child.type === Legend) {
|
|
1084
|
-
found = true;
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
return found;
|
|
1088
|
-
}, [children]);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
736
|
// src/hooks/use-text-truncation.ts
|
|
1092
|
-
import { useCallback as
|
|
737
|
+
import { useCallback as useCallback4, useRef as useRef4, useState as useState3 } from "react";
|
|
1093
738
|
function useTextTruncation(enabled = true) {
|
|
1094
739
|
const [isTruncated, setIsTruncated] = useState3(false);
|
|
1095
740
|
const observerRef = useRef4(null);
|
|
1096
|
-
const refCallback =
|
|
741
|
+
const refCallback = useCallback4(
|
|
1097
742
|
(node) => {
|
|
1098
743
|
if (observerRef.current) {
|
|
1099
744
|
observerRef.current.disconnect();
|
|
@@ -1118,26 +763,29 @@ function useTextTruncation(enabled = true) {
|
|
|
1118
763
|
}
|
|
1119
764
|
|
|
1120
765
|
// src/hooks/use-zero-value-display.ts
|
|
1121
|
-
import { useMemo as
|
|
766
|
+
import { useMemo as useMemo6 } from "react";
|
|
767
|
+
var MIN_PIXEL_SIZE = 3;
|
|
768
|
+
var ZERO_PIXEL_SIZE = MIN_PIXEL_SIZE - 1;
|
|
1122
769
|
var useZeroValueDisplay = (data, options = { enabled: false }) => {
|
|
1123
|
-
const { enabled,
|
|
1124
|
-
return
|
|
1125
|
-
if (!enabled) return data;
|
|
1126
|
-
|
|
770
|
+
const { enabled, valueAxisLength } = options;
|
|
771
|
+
return useMemo6(() => {
|
|
772
|
+
if (!enabled || !valueAxisLength || valueAxisLength <= 0) return data;
|
|
773
|
+
let maxAbsoluteValue = 0;
|
|
1127
774
|
for (const series of data) {
|
|
1128
775
|
for (const point of series.data) {
|
|
1129
776
|
if (point.value !== null && point.value !== 0) {
|
|
1130
|
-
|
|
777
|
+
maxAbsoluteValue = Math.max(maxAbsoluteValue, Math.abs(point.value));
|
|
1131
778
|
}
|
|
1132
779
|
}
|
|
1133
780
|
}
|
|
1134
|
-
if (
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
781
|
+
if (maxAbsoluteValue === 0) return data;
|
|
782
|
+
const minNonZeroValue = Math.min(
|
|
783
|
+
MIN_PIXEL_SIZE / valueAxisLength * maxAbsoluteValue,
|
|
784
|
+
maxAbsoluteValue
|
|
785
|
+
);
|
|
786
|
+
const zeroVisualValue = Math.min(
|
|
787
|
+
ZERO_PIXEL_SIZE / valueAxisLength * maxAbsoluteValue,
|
|
788
|
+
maxAbsoluteValue
|
|
1141
789
|
);
|
|
1142
790
|
return data.map((series) => ({
|
|
1143
791
|
...series,
|
|
@@ -1145,24 +793,34 @@ var useZeroValueDisplay = (data, options = { enabled: false }) => {
|
|
|
1145
793
|
if (point.value === 0) {
|
|
1146
794
|
return {
|
|
1147
795
|
...point,
|
|
1148
|
-
visualValue:
|
|
796
|
+
visualValue: zeroVisualValue
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
if (point.value === null) {
|
|
800
|
+
return point;
|
|
801
|
+
}
|
|
802
|
+
const absValue = Math.abs(point.value);
|
|
803
|
+
if (absValue < minNonZeroValue) {
|
|
804
|
+
return {
|
|
805
|
+
...point,
|
|
806
|
+
visualValue: Math.sign(point.value) * minNonZeroValue
|
|
1149
807
|
};
|
|
1150
808
|
}
|
|
1151
809
|
return point;
|
|
1152
810
|
})
|
|
1153
811
|
}));
|
|
1154
|
-
}, [data, enabled,
|
|
812
|
+
}, [data, enabled, valueAxisLength]);
|
|
1155
813
|
};
|
|
1156
814
|
|
|
1157
815
|
// src/hooks/use-interactive-legend-data.ts
|
|
1158
|
-
import { useMemo as
|
|
816
|
+
import { useMemo as useMemo7 } from "react";
|
|
1159
817
|
var useInteractiveLegendData = ({
|
|
1160
818
|
data,
|
|
1161
819
|
chartId,
|
|
1162
820
|
legendInteractive,
|
|
1163
821
|
isSeriesVisible
|
|
1164
822
|
}) => {
|
|
1165
|
-
const visibleData =
|
|
823
|
+
const visibleData = useMemo7(() => {
|
|
1166
824
|
if (!chartId || !legendInteractive) {
|
|
1167
825
|
return data;
|
|
1168
826
|
}
|
|
@@ -1176,10 +834,10 @@ var useInteractiveLegendData = ({
|
|
|
1176
834
|
percentage: totalValue > 0 ? segment.value / totalValue * 100 : 0
|
|
1177
835
|
}));
|
|
1178
836
|
}, [data, chartId, isSeriesVisible, legendInteractive]);
|
|
1179
|
-
const allSegmentsHidden =
|
|
837
|
+
const allSegmentsHidden = useMemo7(() => {
|
|
1180
838
|
return legendInteractive && visibleData.length === 0;
|
|
1181
839
|
}, [legendInteractive, visibleData]);
|
|
1182
|
-
const legendData =
|
|
840
|
+
const legendData = useMemo7(() => {
|
|
1183
841
|
if (!legendInteractive || !chartId) {
|
|
1184
842
|
return data;
|
|
1185
843
|
}
|
|
@@ -1215,8 +873,6 @@ function usePrefersReducedMotion() {
|
|
|
1215
873
|
}
|
|
1216
874
|
|
|
1217
875
|
export {
|
|
1218
|
-
SingleChartContext,
|
|
1219
|
-
useSingleChartContext,
|
|
1220
876
|
useTooltipPortalRelocator,
|
|
1221
877
|
defaultTheme,
|
|
1222
878
|
GlobalChartsContext,
|
|
@@ -1229,14 +885,11 @@ export {
|
|
|
1229
885
|
useChartDataTransform,
|
|
1230
886
|
useChartMargin,
|
|
1231
887
|
useElementSize,
|
|
1232
|
-
useHasLegendChild,
|
|
1233
888
|
useTextTruncation,
|
|
1234
889
|
useZeroValueDisplay,
|
|
1235
890
|
useInteractiveLegendData,
|
|
1236
891
|
usePrefersReducedMotion,
|
|
1237
892
|
useChartRegistration,
|
|
1238
|
-
useGlobalChartsTheme
|
|
1239
|
-
Legend,
|
|
1240
|
-
useChartLegendItems
|
|
893
|
+
useGlobalChartsTheme
|
|
1241
894
|
};
|
|
1242
|
-
//# sourceMappingURL=chunk-
|
|
895
|
+
//# sourceMappingURL=chunk-2I67QUIV.js.map
|