@tabler/charts 0.2.0 → 0.4.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/README.md +165 -17
- package/dist/{annotations-DdRdeBUB.cjs → annotations--m-HzMBM.cjs} +87 -11
- package/dist/annotations--m-HzMBM.cjs.map +1 -0
- package/dist/{annotations-B02GR_KU.d.ts → annotations-CCDUC1lW.d.ts} +16 -30
- package/dist/{annotations-CHafaGd4.d.cts → annotations-CqZM1z9R.d.cts} +16 -30
- package/dist/{annotations-D0YQ0IoA.js → annotations-DGITy6th.js} +87 -11
- package/dist/annotations-DGITy6th.js.map +1 -0
- package/dist/annotations.cjs +2 -2
- package/dist/annotations.d.cts +1 -1
- package/dist/annotations.d.ts +1 -1
- package/dist/annotations.js +2 -2
- package/dist/{area-0-L1bG9B.js → area-BN0uE9R0.js} +4 -3
- package/dist/area-BN0uE9R0.js.map +1 -0
- package/dist/{area-CJX9219z.d.cts → area-D6LNLk3r.d.cts} +2 -2
- package/dist/{area-d11XePuw.d.ts → area-DEFL-Yun.d.ts} +2 -2
- package/dist/{area-4eRs3c0K.cjs → area-D_N8b4Ng.cjs} +4 -3
- package/dist/area-D_N8b4Ng.cjs.map +1 -0
- package/dist/area.cjs +1 -1
- package/dist/area.d.cts +1 -1
- package/dist/area.d.ts +1 -1
- package/dist/area.js +1 -1
- package/dist/axis-BzBkkC5X.cjs +305 -0
- package/dist/axis-BzBkkC5X.cjs.map +1 -0
- package/dist/axis-C5obgdJt.js +240 -0
- package/dist/axis-C5obgdJt.js.map +1 -0
- package/dist/{bar-Da6dE_nI.cjs → bar-BrmfXugT.cjs} +77 -58
- package/dist/bar-BrmfXugT.cjs.map +1 -0
- package/dist/{bar-XwzM6Pb0.d.ts → bar-Bs_rPqgR.d.ts} +1 -1
- package/dist/{bar-BDLR4p9c.d.cts → bar-CEt8YRxf.d.cts} +2 -2
- package/dist/{bar-B5n2oq9-.js → bar-CgpC2EpX.js} +2 -2
- package/dist/{bar-B5n2oq9-.js.map → bar-CgpC2EpX.js.map} +1 -1
- package/dist/{bar-BNZ3GhIw.js → bar-D_KKd2fL.js} +75 -56
- package/dist/bar-D_KKd2fL.js.map +1 -0
- package/dist/{bar-LYIF8MEz.cjs → bar-wVykm1us.cjs} +2 -2
- package/dist/{bar-LYIF8MEz.cjs.map → bar-wVykm1us.cjs.map} +1 -1
- package/dist/bar.cjs +1 -1
- package/dist/bar.d.cts +1 -1
- package/dist/bar.d.ts +1 -1
- package/dist/bar.js +1 -1
- package/dist/calendar-B7843sQu.d.cts +106 -0
- package/dist/calendar-BG_q_NC_.cjs +507 -0
- package/dist/calendar-BG_q_NC_.cjs.map +1 -0
- package/dist/calendar-CF3gfDQk.js +502 -0
- package/dist/calendar-CF3gfDQk.js.map +1 -0
- package/dist/calendar-D10_ki1S.d.ts +106 -0
- package/dist/calendar.cjs +3 -0
- package/dist/calendar.d.cts +3 -0
- package/dist/calendar.d.ts +3 -0
- package/dist/calendar.js +1 -0
- package/dist/{candlestick-BHQkQfxH.js → candlestick-B1onjo1o.js} +17 -14
- package/dist/candlestick-B1onjo1o.js.map +1 -0
- package/dist/{candlestick-Dq7qp-F0.d.cts → candlestick-B7YXUVVh.d.cts} +4 -3
- package/dist/{candlestick-CYCQXgky.cjs → candlestick-BwrFKak_.cjs} +17 -14
- package/dist/candlestick-BwrFKak_.cjs.map +1 -0
- package/dist/{candlestick-D0xKkdqd.d.ts → candlestick-XpqJvarq.d.ts} +4 -3
- package/dist/candlestick.cjs +3 -3
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +3 -3
- package/dist/{cartesian-DV02PsBe.cjs → cartesian-B9CrasFJ.cjs} +190 -310
- package/dist/cartesian-B9CrasFJ.cjs.map +1 -0
- package/dist/{cartesian-CI2x6N7N.js → cartesian-COglz544.js} +161 -251
- package/dist/cartesian-COglz544.js.map +1 -0
- package/dist/{chart-DWn9v6qw.js → chart-B97FBRCd.js} +114 -72
- package/dist/chart-B97FBRCd.js.map +1 -0
- package/dist/{chart-QilhWP8Z.d.ts → chart-CE9EVbfV.d.ts} +427 -112
- package/dist/{chart-kqFMEwDo.d.cts → chart-Dz4geQZy.d.cts} +427 -112
- package/dist/{chart-e2VqomCI.cjs → chart-GUmmjJ7S.cjs} +132 -78
- package/dist/chart-GUmmjJ7S.cjs.map +1 -0
- package/dist/{core-BKRQvPAT.js → core-7fgM3su0.js} +188 -73
- package/dist/core-7fgM3su0.js.map +1 -0
- package/dist/{core-DRUCk67j.d.ts → core-BUQzLsRJ.d.ts} +26 -10
- package/dist/{core-DIOC61up.cjs → core-BZTrsPxc.cjs} +200 -73
- package/dist/core-BZTrsPxc.cjs.map +1 -0
- package/dist/{core-PAX5ogLk.d.cts → core-Ck5uHcW8.d.cts} +45 -24
- package/dist/core.cjs +45 -31
- package/dist/core.d.cts +23 -18
- package/dist/core.d.ts +23 -18
- package/dist/core.js +28 -23
- package/dist/{dates-DurEr9WT.cjs → dates-0YNY49KQ.cjs} +2 -2
- package/dist/{dates-DurEr9WT.cjs.map → dates-0YNY49KQ.cjs.map} +1 -1
- package/dist/{dates-C2RzY3rE.js → dates-CKDRgpin.js} +2 -2
- package/dist/{dates-C2RzY3rE.js.map → dates-CKDRgpin.js.map} +1 -1
- package/dist/decimate.cjs +1 -1
- package/dist/decimate.js +1 -1
- package/dist/{dom-D_g13XWY.cjs → dom-C33zvtPo.cjs} +3 -7
- package/dist/dom-C33zvtPo.cjs.map +1 -0
- package/dist/{dom-CuceR8gt.js → dom-CTse6Rvd.js} +3 -7
- package/dist/dom-CTse6Rvd.js.map +1 -0
- package/dist/end-labels-B3oRvjxw.js +114 -0
- package/dist/end-labels-B3oRvjxw.js.map +1 -0
- package/dist/end-labels-CS-fnpp-.cjs +119 -0
- package/dist/end-labels-CS-fnpp-.cjs.map +1 -0
- package/dist/end-labels.cjs +11 -0
- package/dist/end-labels.cjs.map +1 -0
- package/dist/end-labels.d.cts +6 -0
- package/dist/end-labels.d.ts +6 -0
- package/dist/end-labels.js +11 -0
- package/dist/end-labels.js.map +1 -0
- package/dist/{export-chart-83UYH48t.js → export-chart-BOH_nfcH.js} +92 -15
- package/dist/export-chart-BOH_nfcH.js.map +1 -0
- package/dist/{export-chart-mYgEfK-L.cjs → export-chart-Be4T9J3m.cjs} +97 -14
- package/dist/export-chart-Be4T9J3m.cjs.map +1 -0
- package/dist/export.cjs +5 -3
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +4 -3
- package/dist/export.d.ts +4 -3
- package/dist/export.js +5 -4
- package/dist/export.js.map +1 -1
- package/dist/{fade-GGxcBdss.js → fade-CDrQjnDz.js} +56 -78
- package/dist/fade-CDrQjnDz.js.map +1 -0
- package/dist/{fade-DVTkhrFU.cjs → fade-CRqcKMWY.cjs} +56 -78
- package/dist/fade-CRqcKMWY.cjs.map +1 -0
- package/dist/{features-BMxkqCyS.js → features-B55rwpQC.js} +4 -2
- package/dist/features-B55rwpQC.js.map +1 -0
- package/dist/{features-DCXEvoya.cjs → features-DEDP5CEQ.cjs} +9 -1
- package/dist/features-DEDP5CEQ.cjs.map +1 -0
- package/dist/fit-BPyPRnsK.js +16 -0
- package/dist/fit-BPyPRnsK.js.map +1 -0
- package/dist/fit-D4MIIQQz.cjs +21 -0
- package/dist/fit-D4MIIQQz.cjs.map +1 -0
- package/dist/funnel-B9ridzNx.d.cts +50 -0
- package/dist/funnel-CFEEulw_.cjs +244 -0
- package/dist/funnel-CFEEulw_.cjs.map +1 -0
- package/dist/funnel-CYCv8cq2.js +239 -0
- package/dist/funnel-CYCv8cq2.js.map +1 -0
- package/dist/funnel-FogM8flk.d.ts +50 -0
- package/dist/funnel.cjs +3 -0
- package/dist/funnel.d.cts +3 -0
- package/dist/funnel.d.ts +3 -0
- package/dist/funnel.js +1 -0
- package/dist/{gauge-DXkjXNCD.cjs → gauge-6HfDcLMJ.cjs} +28 -28
- package/dist/gauge-6HfDcLMJ.cjs.map +1 -0
- package/dist/{gauge-BSist7My.d.cts → gauge-BScJ7U6O.d.cts} +2 -2
- package/dist/{gauge-0VJuAHWF.d.ts → gauge-D78oq1Lx.d.ts} +2 -2
- package/dist/{gauge-ts0kqN1-.js → gauge-DiTk5aWO.js} +28 -28
- package/dist/gauge-DiTk5aWO.js.map +1 -0
- package/dist/gauge.cjs +1 -1
- package/dist/gauge.d.cts +1 -1
- package/dist/gauge.d.ts +1 -1
- package/dist/gauge.js +1 -1
- package/dist/heat-Bsqq4zw9.js +38 -0
- package/dist/heat-Bsqq4zw9.js.map +1 -0
- package/dist/heat-DYsivvDq.cjs +49 -0
- package/dist/heat-DYsivvDq.cjs.map +1 -0
- package/dist/{heatmap-CXhlrLTl.cjs → heatmap-Dyzrd4Fd.cjs} +39 -37
- package/dist/heatmap-Dyzrd4Fd.cjs.map +1 -0
- package/dist/{heatmap-19BGJTKF.js → heatmap-J7fxG7MM.js} +35 -33
- package/dist/heatmap-J7fxG7MM.js.map +1 -0
- package/dist/{heatmap-Dp_oyEe0.d.cts → heatmap-Jvwo7iFW.d.cts} +2 -2
- package/dist/{heatmap-59lmClj9.d.ts → heatmap-mFCnP6aB.d.ts} +2 -2
- package/dist/heatmap.cjs +1 -1
- package/dist/heatmap.d.cts +1 -1
- package/dist/heatmap.d.ts +1 -1
- package/dist/heatmap.js +1 -1
- package/dist/{hydrate-OA6R2_Pn.js → hydrate-BB3MlR36.js} +2 -2
- package/dist/{hydrate-OA6R2_Pn.js.map → hydrate-BB3MlR36.js.map} +1 -1
- package/dist/{hydrate-CmN1k8Mo.cjs → hydrate-m0I5m6ue.cjs} +2 -2
- package/dist/{hydrate-CmN1k8Mo.cjs.map → hydrate-m0I5m6ue.cjs.map} +1 -1
- package/dist/hydrate.cjs +2 -2
- package/dist/hydrate.js +2 -2
- package/dist/index.cjs +69 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -19
- package/dist/index.d.ts +24 -19
- package/dist/index.js +51 -37
- package/dist/index.js.map +1 -1
- package/dist/interaction-DXYSjgnP.cjs +32 -0
- package/dist/interaction-DXYSjgnP.cjs.map +1 -0
- package/dist/interaction-En1KlwFO.js +21 -0
- package/dist/interaction-En1KlwFO.js.map +1 -0
- package/dist/layout-CYerDebD.d.cts +29 -0
- package/dist/layout-CYerDebD.d.ts +29 -0
- package/dist/{layout-JY2aR-yE.cjs → layout-Cfg9x1k2.cjs} +32 -1
- package/dist/layout-Cfg9x1k2.cjs.map +1 -0
- package/dist/{layout-DmrrLjwN.js → layout-DqAte3H8.js} +27 -2
- package/dist/layout-DqAte3H8.js.map +1 -0
- package/dist/{line-DO66LtwH.js → line-CXH0L10d.js} +84 -37
- package/dist/line-CXH0L10d.js.map +1 -0
- package/dist/{line-_rNdeKmS.d.cts → line-Cu9ctpbv.d.cts} +9 -3
- package/dist/{line-Dbt6KFRK.cjs → line-DHbYCQy4.cjs} +84 -37
- package/dist/line-DHbYCQy4.cjs.map +1 -0
- package/dist/{line-DtSh7HQU.d.ts → line-TkzA7wMK.d.ts} +8 -1
- package/dist/line.cjs +3 -3
- package/dist/line.d.cts +1 -1
- package/dist/line.d.ts +1 -1
- package/dist/line.js +3 -3
- package/dist/log.cjs +1 -1
- package/dist/log.js +1 -1
- package/dist/map-BirylCmT.d.cts +156 -0
- package/dist/map-CYp6x-uS.js +784 -0
- package/dist/map-CYp6x-uS.js.map +1 -0
- package/dist/map-ChwSgooH.cjs +795 -0
- package/dist/map-ChwSgooH.cjs.map +1 -0
- package/dist/map-DNqog2Xs.d.ts +156 -0
- package/dist/map.cjs +4 -0
- package/dist/map.d.cts +3 -0
- package/dist/map.d.ts +3 -0
- package/dist/map.js +1 -0
- package/dist/maps/world.cjs +875 -0
- package/dist/maps/world.cjs.map +1 -0
- package/dist/maps/world.d.cts +2 -0
- package/dist/maps/world.d.ts +2 -0
- package/dist/maps/world.js +874 -0
- package/dist/maps/world.js.map +1 -0
- package/dist/{morph-9_LJL0ra.cjs → morph-3I1Nf_tR.cjs} +2 -2
- package/dist/{morph-9_LJL0ra.cjs.map → morph-3I1Nf_tR.cjs.map} +1 -1
- package/dist/{morph-DnRxuwR-.js → morph-GfBab-b3.js} +2 -2
- package/dist/{morph-DnRxuwR-.js.map → morph-GfBab-b3.js.map} +1 -1
- package/dist/morph.cjs +2 -2
- package/dist/morph.js +2 -2
- package/dist/others-CuNdpvjd.d.cts +31 -0
- package/dist/{others-J7NCAMA0.js → others-DBIGE6jr.js} +11 -3
- package/dist/others-DBIGE6jr.js.map +1 -0
- package/dist/others-DBO4Kjwl.d.ts +29 -0
- package/dist/{others-DWdK7vKp.cjs → others-WfjCsjqT.cjs} +14 -6
- package/dist/others-WfjCsjqT.cjs.map +1 -0
- package/dist/{parliament-Cru4IcuM.js → parliament-BKN6ikBJ.js} +30 -29
- package/dist/parliament-BKN6ikBJ.js.map +1 -0
- package/dist/{parliament-CLCI7tUO.d.ts → parliament-CHdf13XU.d.ts} +2 -2
- package/dist/{parliament-CgsVnWEe.d.cts → parliament-CsYgh4N2.d.cts} +2 -2
- package/dist/{parliament-x5hcFaQ3.cjs → parliament-DhxAaIZ3.cjs} +30 -29
- package/dist/parliament-DhxAaIZ3.cjs.map +1 -0
- package/dist/parliament.cjs +1 -1
- package/dist/parliament.d.cts +1 -1
- package/dist/parliament.d.ts +1 -1
- package/dist/parliament.js +1 -1
- package/dist/{patterns-D3-wQagb.cjs → patterns-BPN1c9qe.cjs} +2 -2
- package/dist/{patterns-D3-wQagb.cjs.map → patterns-BPN1c9qe.cjs.map} +1 -1
- package/dist/{patterns-CufKZYhm.js → patterns-CVrLrJXg.js} +2 -2
- package/dist/{patterns-CufKZYhm.js.map → patterns-CVrLrJXg.js.map} +1 -1
- package/dist/patterns.cjs +2 -2
- package/dist/patterns.d.cts +1 -1
- package/dist/patterns.d.ts +1 -1
- package/dist/patterns.js +2 -2
- package/dist/{percentage-bar-ybNS3goo.cjs → percentage-bar-BChkTRoz.cjs} +37 -35
- package/dist/percentage-bar-BChkTRoz.cjs.map +1 -0
- package/dist/{percentage-bar-nhTeakD_.d.ts → percentage-bar-CSAbzDOn.d.ts} +11 -15
- package/dist/{percentage-bar-B6tNOqNn.js → percentage-bar-CaInxrL8.js} +37 -35
- package/dist/percentage-bar-CaInxrL8.js.map +1 -0
- package/dist/{percentage-bar-tepMr7Hd.d.cts → percentage-bar-UZHCRvlK.d.cts} +11 -15
- package/dist/percentage-bar.cjs +1 -1
- package/dist/percentage-bar.d.cts +1 -1
- package/dist/percentage-bar.d.ts +1 -1
- package/dist/percentage-bar.js +1 -1
- package/dist/{pie-BXg2gNpb.d.cts → pie-AFedsDcF.d.cts} +17 -14
- package/dist/{pie-CVsc-6qD.js → pie-Ch6Bx0ih.js} +68 -52
- package/dist/pie-Ch6Bx0ih.js.map +1 -0
- package/dist/{pie-BpjvSPnz.cjs → pie-Cll1OrVZ.cjs} +68 -52
- package/dist/pie-Cll1OrVZ.cjs.map +1 -0
- package/dist/{pie-CFptILSm.d.ts → pie-Cn2H3pz8.d.ts} +17 -14
- package/dist/pie.cjs +1 -1
- package/dist/pie.d.cts +1 -1
- package/dist/pie.d.ts +1 -1
- package/dist/pie.js +1 -1
- package/dist/{point-shapes--_gmdTyK.cjs → point-shapes-BRawRM78.cjs} +23 -22
- package/dist/point-shapes-BRawRM78.cjs.map +1 -0
- package/dist/{point-shapes-DD2Ektzm.js → point-shapes-DI6GhcI7.js} +18 -23
- package/dist/point-shapes-DI6GhcI7.js.map +1 -0
- package/dist/point-shapes.cjs +6 -4
- package/dist/point-shapes.cjs.map +1 -1
- package/dist/point-shapes.d.cts +2 -2
- package/dist/point-shapes.d.ts +2 -2
- package/dist/point-shapes.js +7 -5
- package/dist/point-shapes.js.map +1 -1
- package/dist/{radar-BR-mumDd.js → radar-Bg-IiIWB.js} +21 -22
- package/dist/radar-Bg-IiIWB.js.map +1 -0
- package/dist/{radar-BC9Skgpj.d.ts → radar-DEer2jjd.d.ts} +2 -2
- package/dist/{radar-D1-lItDy.d.cts → radar-DxmjXhMc.d.cts} +2 -2
- package/dist/{radar-HPDrIdzc.cjs → radar-wDyX17S3.cjs} +22 -23
- package/dist/radar-wDyX17S3.cjs.map +1 -0
- package/dist/radar.cjs +1 -1
- package/dist/radar.d.cts +1 -1
- package/dist/radar.d.ts +1 -1
- package/dist/radar.js +1 -1
- package/dist/range-bar-BnKjJP89.cjs +348 -0
- package/dist/range-bar-BnKjJP89.cjs.map +1 -0
- package/dist/range-bar-C4cRaaQE.d.ts +123 -0
- package/dist/range-bar-D32dIQOY.d.cts +123 -0
- package/dist/range-bar-Dx6ce0J1.js +343 -0
- package/dist/range-bar-Dx6ce0J1.js.map +1 -0
- package/dist/range-bar.cjs +3 -0
- package/dist/range-bar.d.cts +3 -0
- package/dist/range-bar.d.ts +3 -0
- package/dist/range-bar.js +1 -0
- package/dist/{rect-DSVmUZrD.js → rect-CZTNvMlf.js} +2 -2
- package/dist/{rect-DSVmUZrD.js.map → rect-CZTNvMlf.js.map} +1 -1
- package/dist/{rect-D6VhynBM.cjs → rect-DPr9QRxl.cjs} +2 -2
- package/dist/{rect-D6VhynBM.cjs.map → rect-DPr9QRxl.cjs.map} +1 -1
- package/dist/{sankey-fCoo1cpz.cjs → sankey-0CSp_Er9.cjs} +72 -71
- package/dist/sankey-0CSp_Er9.cjs.map +1 -0
- package/dist/{sankey-Dk7jUt8x.d.cts → sankey-D-8ATwBT.d.cts} +2 -2
- package/dist/{sankey-D6JeZfK5.js → sankey-Dp4CuLVe.js} +72 -71
- package/dist/sankey-Dp4CuLVe.js.map +1 -0
- package/dist/{sankey-D_v7KxnJ.d.ts → sankey-DpYJsOI4.d.ts} +2 -2
- package/dist/sankey.cjs +1 -1
- package/dist/sankey.d.cts +1 -1
- package/dist/sankey.d.ts +1 -1
- package/dist/sankey.js +1 -1
- package/dist/{scatter-C0TWjFpW.js → scatter-0Z7K_YUz.js} +94 -46
- package/dist/scatter-0Z7K_YUz.js.map +1 -0
- package/dist/{scatter-CXEsioOJ.d.ts → scatter-BAL5K9_4.d.ts} +28 -9
- package/dist/{scatter-DZeEIfyo.d.cts → scatter-BUGbnRzM.d.cts} +28 -9
- package/dist/{scatter-DVqB_fP9.cjs → scatter-CZ8do3Up.cjs} +95 -47
- package/dist/scatter-CZ8do3Up.cjs.map +1 -0
- package/dist/scatter.cjs +1 -1
- package/dist/scatter.d.cts +2 -2
- package/dist/scatter.d.ts +2 -2
- package/dist/scatter.js +1 -1
- package/dist/slice-labels-1TBq7p3q.d.cts +28 -0
- package/dist/slice-labels-C9ucsBVW.js +88 -0
- package/dist/slice-labels-C9ucsBVW.js.map +1 -0
- package/dist/slice-labels-CbFiy46l.cjs +93 -0
- package/dist/slice-labels-CbFiy46l.cjs.map +1 -0
- package/dist/slice-labels-Cm5CyV7B.d.ts +28 -0
- package/dist/slice-labels.cjs +11 -0
- package/dist/slice-labels.cjs.map +1 -0
- package/dist/slice-labels.d.cts +6 -0
- package/dist/slice-labels.d.ts +6 -0
- package/dist/slice-labels.js +11 -0
- package/dist/slice-labels.js.map +1 -0
- package/dist/{sparkline-cbvRkWqS.d.ts → sparkline-CtoBJe-a.d.ts} +2 -2
- package/dist/{sparkline-B39NA0Mi.cjs → sparkline-DjR-V6BI.cjs} +13 -15
- package/dist/sparkline-DjR-V6BI.cjs.map +1 -0
- package/dist/{sparkline-DAP6jtzw.d.cts → sparkline-DwHJfeZz.d.cts} +2 -2
- package/dist/{sparkline-XO_TqCNP.js → sparkline-_dxwtdli.js} +13 -15
- package/dist/sparkline-_dxwtdli.js.map +1 -0
- package/dist/sparkline.cjs +1 -1
- package/dist/sparkline.d.cts +1 -1
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.js +1 -1
- package/dist/{stack-Dagxq7l2.d.cts → stack-CcmyALx0.d.cts} +1 -1
- package/dist/{stack-2H2Gfs1Q.js → stack-CyVlS7Fr.js} +2 -2
- package/dist/{stack-2H2Gfs1Q.js.map → stack-CyVlS7Fr.js.map} +1 -1
- package/dist/{stack-BgPzoQmv.cjs → stack-DBhmYNat.cjs} +2 -2
- package/dist/{stack-BgPzoQmv.cjs.map → stack-DBhmYNat.cjs.map} +1 -1
- package/dist/style.css +1 -1
- package/dist/{time-axis-BjZ1bYTK.cjs → time-axis-CVKjQKSS.cjs} +4 -3
- package/dist/{time-axis-BjZ1bYTK.cjs.map → time-axis-CVKjQKSS.cjs.map} +1 -1
- package/dist/{time-axis-FLONo54E.js → time-axis-CkmbAw4Z.js} +3 -2
- package/dist/{time-axis-FLONo54E.js.map → time-axis-CkmbAw4Z.js.map} +1 -1
- package/dist/time.cjs +3 -3
- package/dist/time.js +3 -3
- package/dist/{treemap-BAkhmVQc.d.cts → treemap-C2maqerU.d.cts} +37 -5
- package/dist/{treemap-BNpxFBao.d.ts → treemap-D_zbubo3.d.ts} +37 -5
- package/dist/{treemap-BWpEUlDh.cjs → treemap-PulGXZv0.cjs} +58 -33
- package/dist/treemap-PulGXZv0.cjs.map +1 -0
- package/dist/{treemap-CQdavQ9u.js → treemap-lbYxb-7h.js} +57 -32
- package/dist/treemap-lbYxb-7h.js.map +1 -0
- package/dist/treemap.cjs +1 -1
- package/dist/treemap.d.cts +1 -1
- package/dist/treemap.d.ts +1 -1
- package/dist/treemap.js +1 -1
- package/dist/{value-labels-BBuSi4i0.js → value-labels-B0VeheyE.js} +29 -8
- package/dist/value-labels-B0VeheyE.js.map +1 -0
- package/dist/{value-labels-BV9keAuL.cjs → value-labels-Dcyk3GIY.cjs} +29 -8
- package/dist/value-labels-Dcyk3GIY.cjs.map +1 -0
- package/dist/value-labels.cjs +2 -2
- package/dist/value-labels.d.cts +1 -1
- package/dist/value-labels.d.ts +1 -1
- package/dist/value-labels.js +2 -2
- package/dist/zoom.cjs +810 -0
- package/dist/zoom.cjs.map +1 -0
- package/dist/zoom.d.cts +34 -0
- package/dist/zoom.d.ts +34 -0
- package/dist/zoom.js +806 -0
- package/dist/zoom.js.map +1 -0
- package/package.json +120 -235
- package/dist/annotations-D0YQ0IoA.js.map +0 -1
- package/dist/annotations-DdRdeBUB.cjs.map +0 -1
- package/dist/area-0-L1bG9B.js.map +0 -1
- package/dist/area-4eRs3c0K.cjs.map +0 -1
- package/dist/bar-BNZ3GhIw.js.map +0 -1
- package/dist/bar-Da6dE_nI.cjs.map +0 -1
- package/dist/candlestick-BHQkQfxH.js.map +0 -1
- package/dist/candlestick-CYCQXgky.cjs.map +0 -1
- package/dist/cartesian-CI2x6N7N.js.map +0 -1
- package/dist/cartesian-DV02PsBe.cjs.map +0 -1
- package/dist/chart-DWn9v6qw.js.map +0 -1
- package/dist/chart-e2VqomCI.cjs.map +0 -1
- package/dist/core-BKRQvPAT.js.map +0 -1
- package/dist/core-DIOC61up.cjs.map +0 -1
- package/dist/dom-CuceR8gt.js.map +0 -1
- package/dist/dom-D_g13XWY.cjs.map +0 -1
- package/dist/export-chart-83UYH48t.js.map +0 -1
- package/dist/export-chart-mYgEfK-L.cjs.map +0 -1
- package/dist/fade-DVTkhrFU.cjs.map +0 -1
- package/dist/fade-GGxcBdss.js.map +0 -1
- package/dist/features-BMxkqCyS.js.map +0 -1
- package/dist/features-DCXEvoya.cjs.map +0 -1
- package/dist/gauge-DXkjXNCD.cjs.map +0 -1
- package/dist/gauge-ts0kqN1-.js.map +0 -1
- package/dist/heatmap-19BGJTKF.js.map +0 -1
- package/dist/heatmap-CXhlrLTl.cjs.map +0 -1
- package/dist/layout-DmrrLjwN.js.map +0 -1
- package/dist/layout-JY2aR-yE.cjs.map +0 -1
- package/dist/line-DO66LtwH.js.map +0 -1
- package/dist/line-Dbt6KFRK.cjs.map +0 -1
- package/dist/others-DWdK7vKp.cjs.map +0 -1
- package/dist/others-J7NCAMA0.js.map +0 -1
- package/dist/parliament-Cru4IcuM.js.map +0 -1
- package/dist/parliament-x5hcFaQ3.cjs.map +0 -1
- package/dist/percentage-bar-B6tNOqNn.js.map +0 -1
- package/dist/percentage-bar-ybNS3goo.cjs.map +0 -1
- package/dist/pie-BpjvSPnz.cjs.map +0 -1
- package/dist/pie-CVsc-6qD.js.map +0 -1
- package/dist/point-shapes--_gmdTyK.cjs.map +0 -1
- package/dist/point-shapes-DD2Ektzm.js.map +0 -1
- package/dist/radar-BR-mumDd.js.map +0 -1
- package/dist/radar-HPDrIdzc.cjs.map +0 -1
- package/dist/sankey-D6JeZfK5.js.map +0 -1
- package/dist/sankey-fCoo1cpz.cjs.map +0 -1
- package/dist/scatter-C0TWjFpW.js.map +0 -1
- package/dist/scatter-DVqB_fP9.cjs.map +0 -1
- package/dist/sparkline-B39NA0Mi.cjs.map +0 -1
- package/dist/sparkline-XO_TqCNP.js.map +0 -1
- package/dist/treemap-BWpEUlDh.cjs.map +0 -1
- package/dist/treemap-CQdavQ9u.js.map +0 -1
- package/dist/value-labels-BBuSi4i0.js.map +0 -1
- package/dist/value-labels-BV9keAuL.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-DIOC61up.cjs","names":["feature","render","h","h","round","toChartPoint","markerShape","h","render","legendContent","run","flushHooks","render","renderContext","getNumberFormat","h","render","schedule"],"sources":["../src/plugins/download.ts","../src/components/hover.ts","../src/plugins/pointer.ts","../src/plugins/highlight.ts","../src/a11y.ts","../src/plugins/keyboard.ts","../src/plugins/legend.ts","../src/plugins/sync.ts","../src/idle.ts","../src/plugins/table.ts","../src/tooltip.ts","../src/plugins/tooltip.ts","../src/plugins/index.ts","../package.json","../src/core.ts"],"sourcesContent":["import { feature } from '../features.ts'\nimport type { ChartPlugin } from '../plugin.ts'\nimport { render } from '../render/dom.ts'\nimport { h } from '../vnode.ts'\n\n/** A file format of the download menu. */\nexport type DownloadFormat = 'png' | 'svg' | 'jpeg' | 'webp'\n\n/** The `download` option as an object. */\nexport interface DownloadMenuOptions {\n /** Formats offered, in this order. Defaults to `['png', 'svg']`. */\n formats?: readonly DownloadFormat[]\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** Accessible name of the menu button. Defaults to `'Download'`. */\n label?: string\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the file. Defaults to `true`. */\n legend?: boolean\n /** Pixels per chart pixel in images. Defaults to `2`. */\n scale?: number\n}\n\n/** The `download` option: on, a list of formats, or the options. */\nexport type DownloadOption = boolean | readonly DownloadFormat[] | DownloadMenuOptions\n\nconst NAMES: Record<DownloadFormat, string> = { png: 'PNG', svg: 'SVG', jpeg: 'JPEG', webp: 'WebP' }\nconst DEFAULT_FORMATS: readonly DownloadFormat[] = ['png', 'svg']\n\nfunction resolve(option: DownloadOption): DownloadMenuOptions {\n return option === true\n ? {}\n : Array.isArray(option)\n ? { formats: option }\n : (option as DownloadMenuOptions)\n}\n\n/**\n * A download menu in the chart's corner (`.tc-download`): a button that opens\n * a list of file formats, PNG and SVG by default. Shown with the `download`\n * option. The files come from `@tabler/charts/export`, which must be imported\n * (the chart says so otherwise): that way charts without a download never\n * carry the export code.\n */\nexport function download(): ChartPlugin {\n return {\n name: 'download',\n install(chart) {\n const host = chart.element\n const doc = host.ownerDocument\n let el: HTMLElement | undefined\n let options: DownloadMenuOptions = {}\n // The menu overlays the chart: the container is the positioning context.\n const addedClass = !host.classList.contains('tc-container')\n\n const toggle = () => el?.querySelector<HTMLElement>('.tc-download-toggle')\n const menu = () => el?.querySelector<HTMLElement>('.tc-download-menu')\n const items = () => Array.from(el?.querySelectorAll<HTMLElement>('.tc-download-item') ?? [])\n\n const setOpen = (open: boolean) => {\n const list = menu()\n if (!list) return\n list.hidden = !open\n toggle()?.setAttribute('aria-expanded', String(open))\n if (open) doc.addEventListener('pointerdown', onOutside, true)\n else doc.removeEventListener('pointerdown', onOutside, true)\n }\n const isOpen = () => menu()?.hidden === false\n\n const onOutside = (event: Event) => {\n if (!el?.contains(event.target as Node)) setOpen(false)\n }\n\n const onClick = (event: Event) => {\n const target = event.target as Element\n if (target.closest('.tc-download-toggle')) {\n setOpen(!isOpen())\n if (isOpen()) items()[0]?.focus()\n return\n }\n const format = target.closest('.tc-download-item')?.getAttribute('data-format')\n if (!format) return\n setOpen(false)\n toggle()?.focus()\n void feature('export')(chart, { ...options, format: format as DownloadFormat })\n }\n\n const onKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && isOpen()) {\n event.preventDefault()\n setOpen(false)\n toggle()?.focus()\n return\n }\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return\n const list = items()\n if (!list.length) return\n event.preventDefault()\n if (!isOpen()) setOpen(true)\n const at = list.indexOf(doc.activeElement as HTMLElement)\n const step = event.key === 'ArrowDown' ? 1 : -1\n list[(at + step + list.length) % list.length]?.focus()\n }\n\n // Tabbing out of the menu closes it.\n const onBlur = (event: FocusEvent) => {\n if (!el?.contains(event.relatedTarget as Node)) setOpen(false)\n }\n\n const remove = () => {\n if (!el) return\n setOpen(false)\n render(el, null)\n el.remove()\n el = undefined\n if (addedClass) host.classList.remove('tc-container')\n }\n\n return {\n afterRender({ config, changed }) {\n const option = config.download\n if (!option || typeof document === 'undefined') {\n remove()\n return\n }\n // Resizing and hovering change nothing in the menu.\n if (!changed && el?.isConnected) return\n // Fail early, at render, when the export entry is not imported.\n feature('export')\n options = resolve(option)\n const formats = options.formats?.length ? options.formats : DEFAULT_FORMATS\n if (!el) {\n el = doc.createElement('div')\n el.className = 'tc-download'\n el.addEventListener('click', onClick)\n el.addEventListener('keydown', onKey)\n el.addEventListener('focusout', onBlur)\n }\n render(\n el,\n h(\n 'div',\n { class: 'tc-download-box' },\n h(\n 'button',\n {\n type: 'button',\n class: 'tc-download-toggle',\n 'aria-label': options.label ?? 'Download',\n 'aria-haspopup': 'menu',\n 'aria-expanded': 'false',\n },\n h(\n 'svg',\n {\n viewBox: '0 0 24 24',\n width: '16',\n height: '16',\n 'aria-hidden': 'true',\n fill: 'none',\n stroke: 'currentColor',\n 'stroke-width': '2',\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n },\n h('path', {\n d: 'M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2M7 11l5 5 5-5M12 4v12',\n }),\n ),\n ),\n h(\n 'div',\n { class: 'tc-download-menu', role: 'menu', hidden: '' },\n formats.map((format) =>\n h(\n 'button',\n {\n key: format,\n type: 'button',\n role: 'menuitem',\n class: 'tc-download-item',\n 'data-format': format,\n },\n NAMES[format] ?? format,\n ),\n ),\n ),\n ),\n )\n // In the corner the chart starts from: the left one, right to left.\n el.dir = chart.rtl ? 'rtl' : ''\n host.classList.add('tc-container')\n if (!el.isConnected) host.appendChild(el)\n },\n destroy: remove,\n }\n },\n }\n}\n","import type { Hit } from '../interaction.ts'\nimport { round } from '../layout.ts'\nimport { h, type VNode } from '../vnode.ts'\n\n/** Series wrapper so hover marks pick up the series color from CSS. */\nfunction seriesGroup(seriesIndex: number, color: string | undefined, child: VNode): VNode {\n return h(\n 'g',\n {\n key: seriesIndex,\n class: ['tc-series', `tc-series-${seriesIndex + 1}`],\n style: { '--tc-series-color': color },\n },\n child,\n )\n}\n\n/**\n * Hover marks drawn below the series: a band behind the hovered category of\n * band charts (bars), or a vertical crosshair for point charts (lines).\n */\nexport function hoverUnderlay(hit: Hit, crosshair = true): VNode {\n const { area } = hit\n return h(\n 'g',\n { class: 'tc-hover', 'aria-hidden': 'true' },\n hit.mark\n ? null\n : hit.band\n ? h('rect', {\n class: 'tc-hover-band',\n x: round(hit.band.x),\n y: round(hit.band.y),\n width: round(hit.band.width),\n height: round(hit.band.height),\n })\n : crosshair &&\n h(\n 'line',\n hit.guide\n ? {\n class: 'tc-crosshair',\n x1: round(hit.guide.x1),\n x2: round(hit.guide.x2),\n y1: round(hit.guide.y1),\n y2: round(hit.guide.y2),\n }\n : {\n class: 'tc-crosshair',\n x1: round(hit.x),\n x2: round(hit.x),\n y1: round(area.y),\n y2: round(area.y + area.height),\n },\n ),\n )\n}\n\n/**\n * Hover marks drawn above the series: the hit's own mark (pie slices), or\n * an active dot on every point of point charts (of the series' `shape`, if given).\n */\nexport function hoverOverlay(\n hit: Hit,\n radius = 4,\n shape?: (slot: number, x: number, y: number, r: number) => string,\n): VNode {\n const { mark } = hit\n if (mark) {\n const item = hit.items.find((i) => i.seriesIndex === hit.seriesIndex) ?? hit.items[0]\n return h(\n 'g',\n { class: 'tc-hover', 'aria-hidden': 'true' },\n item &&\n seriesGroup(\n item.seriesIndex,\n item.color,\n h('path', {\n class: 'tc-hover-mark',\n d: mark.d,\n style: `transform:translate(${round(mark.x)}px,${round(mark.y)}px)`,\n }),\n ),\n )\n }\n return h(\n 'g',\n { class: 'tc-hover', 'aria-hidden': 'true' },\n !hit.band &&\n hit.items.map(\n (item) =>\n item.y !== null &&\n seriesGroup(\n item.seriesIndex,\n item.color,\n shape\n ? h('path', {\n class: 'tc-point tc-point-active tc-marker',\n d: shape(item.seriesIndex, item.x, item.y, radius),\n })\n : h('circle', {\n class: 'tc-point tc-point-active',\n cx: round(item.x),\n cy: round(item.y),\n r: radius,\n }),\n ),\n ),\n )\n}\n","import type { Chart } from '../chart.ts'\nimport { toChartPoint } from '../interaction.ts'\nimport type { ChartPlugin } from '../plugin.ts'\n\nconst listening = /* @__PURE__ */ new WeakSet<object>()\n\n/**\n * Turn pointer input on the chart's element into highlights and `hover` /\n * `click` events (once per chart, however many plugins ask). Returns the\n * function that stops listening, or nothing when already listening.\n */\nexport function listenPointer(chart: Chart<object>): (() => void) | undefined {\n const el = chart.element\n if (listening.has(chart) || typeof el.addEventListener !== 'function') return undefined\n listening.add(chart)\n const local = (event: MouseEvent) => {\n const svg = el.querySelector('svg.tc-chart')\n if (!svg) return undefined\n const { width, height } = chart.size\n return toChartPoint(svg, event.clientX, event.clientY, width, height)\n }\n // Controls laid over the chart (the download menu) are not the chart:\n // hovering them clears the highlight, so the tooltip never covers them.\n const overControl = (event: Event) =>\n !!(event.target as Element | null)?.closest?.('.tc-download')\n const onLeave = (event: PointerEvent) => {\n // On touch, keep the last highlight after the finger lifts.\n if (event.pointerType !== 'touch' && chart.highlightSource === 'pointer') {\n chart.clearHighlight(event)\n }\n }\n const onMove = (event: PointerEvent) => {\n if (overControl(event)) {\n onLeave(event)\n return\n }\n const point = local(event)\n if (point) chart.highlightAt(point.x, point.y, event)\n }\n const onClick = (event: MouseEvent) => {\n if (overControl(event)) return\n const point = local(event)\n const hit = point ? chart.hitTest(point.x, point.y) : null\n if (hit) chart.emit('click', { hit, event })\n }\n el.addEventListener('pointermove', onMove as EventListener)\n el.addEventListener('pointerdown', onMove as EventListener)\n el.addEventListener('pointerleave', onLeave as EventListener)\n el.addEventListener('click', onClick as EventListener)\n return () => {\n listening.delete(chart)\n el.removeEventListener('pointermove', onMove as EventListener)\n el.removeEventListener('pointerdown', onMove as EventListener)\n el.removeEventListener('pointerleave', onLeave as EventListener)\n el.removeEventListener('click', onClick as EventListener)\n }\n}\n\n/**\n * Pointer input: hovering highlights what is under the pointer and emits\n * `hover`, clicking emits `click`. The highlight and tooltip plugins turn it\n * on themselves; add it to a bare `Chart` that only needs the events.\n */\nexport function pointer(): ChartPlugin {\n return {\n name: 'pointer',\n install(chart) {\n const stop = listenPointer(chart)\n return stop ? { destroy: stop } : {}\n },\n }\n}\n","import { markerShape } from '../charts/cartesian.ts'\nimport { hoverOverlay, hoverUnderlay } from '../components/hover.ts'\nimport type { ChartPlugin } from '../plugin.ts'\nimport { listenPointer } from './pointer.ts'\n\n/**\n * Draws the highlighted category: a crosshair (or a band behind bars) under\n * the series and active dots above them. `crosshair: false` keeps the dots.\n */\nexport function highlight(): ChartPlugin {\n return {\n name: 'highlight',\n install(chart) {\n const stop = listenPointer(chart)\n return {\n layers: (hit, config) => ({\n under: hoverUnderlay(hit, config.crosshair !== false),\n over: hoverOverlay(hit, 4, markerShape(config)),\n }),\n ...(stop ? { destroy: stop } : {}),\n }\n },\n }\n}\n","import type { Hit } from './interaction.ts'\nimport { h, type VNode } from './vnode.ts'\n\n/** The data behind a chart as text: header cells and one row per category. */\nexport interface DataTable {\n /** Column headers; the first one labels the row headers (may be empty). */\n columns: string[]\n /** Rows of display text; the first cell of each row is its header. */\n rows: string[][]\n /** Total number of rows when `rows` was cut to a limit. */\n total?: number\n}\n\n/**\n * An HTML table of the chart data, for screen readers (visually hidden by\n * default) or as a visible fallback. Every cell is text, escaped by the renderer.\n */\nexport function tableContent(table: DataTable, caption?: string): VNode {\n const [corner = '', ...headers] = table.columns\n return h(\n 'table',\n { class: 'tc-table' },\n caption && h('caption', null, caption),\n h(\n 'thead',\n null,\n h(\n 'tr',\n null,\n h('th', { scope: 'col' }, corner),\n headers.map((name, i) => h('th', { key: i, scope: 'col' }, name)),\n ),\n ),\n h(\n 'tbody',\n null,\n table.rows.map(([head = '', ...cells], i) =>\n h(\n 'tr',\n { key: i },\n h('th', { scope: 'row' }, head),\n cells.map((cell, j) => h('td', { key: j }, cell)),\n ),\n ),\n ),\n )\n}\n\n/** Short sentence describing a hit, announced during keyboard navigation. */\nexport function describeHit(hit: Hit): string {\n const items =\n hit.seriesIndex === undefined\n ? hit.items\n : hit.items.filter((item) => item.seriesIndex === hit.seriesIndex)\n const values = items.map((item) => `${item.name} ${item.text}`).join(', ')\n return hit.title ? `${hit.title}: ${values}` : values\n}\n","import { describeHit } from '../a11y.ts'\nimport type { ChartPlugin } from '../plugin.ts'\n\n/**\n * Keyboard navigation: the SVG becomes focusable; arrow keys walk\n * categories, Up/Down walk series, Home/End jump, Escape (or leaving)\n * clears. Every step is announced through a polite live region.\n */\n/** The config's `keyboard` option, else the chart type's default, else on. */\nconst enabled = (config: { keyboard?: boolean; type: { keyboard?: boolean } }): boolean =>\n config.keyboard ?? config.type.keyboard ?? true\n\nexport function keyboard(): ChartPlugin {\n return {\n name: 'keyboard',\n install(chart) {\n const host = chart.element\n let live: HTMLElement | undefined\n\n /**\n * The live region, added when the chart takes focus: screen readers only\n * announce changes of a region that was already there, so one created\n * with its first message would stay silent for that message.\n */\n const region = (): HTMLElement => {\n if (!live) {\n live = host.ownerDocument.createElement('div')\n live.className = 'tc-sr-only'\n live.setAttribute('aria-live', 'polite')\n live.setAttribute('aria-atomic', 'true')\n host.appendChild(live)\n }\n return live\n }\n const announce = (text: string) => {\n region().textContent = text\n }\n\n const go = (index: number, seriesIndex?: number) => {\n const hit = chart.highlightIndex(index, seriesIndex)\n if (hit) announce(describeHit(hit))\n }\n\n /** Returns whether the key was handled. */\n const handle = (key: string): boolean => {\n const interaction = chart.interaction\n if (!interaction || interaction.count === 0) return false\n // Arrows follow the screen: categories from the right swap them.\n if (interaction.reversed && /^Arrow(L|R)/.test(key))\n key = key === 'ArrowLeft' ? 'ArrowRight' : 'ArrowLeft'\n const current = chart.highlightSource === 'index' ? chart.active : null\n const last = interaction.count - 1\n const index = current?.index\n const focused = current?.seriesIndex\n const series = current?.items.map((item) => item.seriesIndex) ?? []\n const at = focused === undefined ? -1 : series.indexOf(focused)\n\n switch (key) {\n case 'ArrowRight':\n go(index === undefined ? 0 : Math.min(last, index + 1), focused)\n return true\n case 'ArrowLeft':\n go(index === undefined ? last : Math.max(0, index - 1), focused)\n return true\n case 'Home':\n go(0, focused)\n return true\n case 'End':\n go(last, focused)\n return true\n case 'ArrowDown':\n case 'ArrowUp': {\n if (index === undefined || series.length === 0) {\n go(0)\n return true\n }\n const step = key === 'ArrowDown' ? 1 : -1\n const next = at === -1 ? (step > 0 ? 0 : series.length - 1) : at + step\n go(index, next < 0 || next >= series.length ? undefined : series[next])\n return true\n }\n case 'Escape':\n if (!current) return false\n chart.clearHighlight()\n return true\n default:\n return false\n }\n }\n\n const isChart = (target: EventTarget | null) =>\n (target as Element | null)?.matches?.('svg.tc-chart') === true\n const onKey = (event: Event) => {\n const { key } = event as KeyboardEvent\n if (!enabled(chart.config) || !isChart(event.target)) return\n if (handle(key)) event.preventDefault()\n }\n const onBlur = (event: Event) => {\n if (isChart(event.target) && chart.highlightSource === 'index') chart.clearHighlight()\n }\n const onFocus = (event: Event) => {\n if (enabled(chart.config) && isChart(event.target)) region()\n }\n host.addEventListener('keydown', onKey)\n host.addEventListener('focusin', onFocus)\n host.addEventListener('focusout', onBlur)\n\n return {\n svgAttrs: (config) => (enabled(config) ? { tabindex: 0 } : undefined),\n destroy() {\n host.removeEventListener('keydown', onKey)\n host.removeEventListener('focusin', onFocus)\n host.removeEventListener('focusout', onBlur)\n live?.remove()\n },\n }\n },\n }\n}\n","import { legendContent } from '../legend.ts'\nimport type { ChartPlugin } from '../plugin.ts'\nimport { render } from '../render/dom.ts'\n\n/**\n * An HTML legend (`.tc-legend`) with toggle buttons, above or below the SVG.\n * Shown for two or more entries unless the `legend` option says otherwise.\n */\nexport function legend(): ChartPlugin {\n return {\n name: 'legend',\n install(chart) {\n const host = chart.element\n // Take over a server-rendered legend instead of adding a second one.\n let el = host.querySelector<HTMLElement>(':scope > .tc-legend') ?? undefined\n let adopt = el?.firstElementChild ?? null\n let bound = false\n const onClick = (event: Event) => {\n const button = (event.target as Element).closest?.('.tc-legend-item')\n const key = button?.getAttribute('data-key')\n if (key != null) chart.toggleSeries(key)\n }\n\n const remove = () => {\n if (!el) return\n render(el, null)\n el.removeEventListener('click', onClick)\n bound = false\n el.remove()\n el = undefined\n }\n\n /** Keep the legend right before or after the SVG, whatever else lives in the container. */\n const place = () => {\n if (!el) return\n const svg = host.querySelector(':scope > svg.tc-chart')\n if (el.dataset.position === 'bottom') {\n if (!svg) {\n if (!el.isConnected) host.appendChild(el)\n } else if (svg.nextElementSibling !== el) {\n svg.after(el)\n }\n } else if (!el.isConnected || el.nextElementSibling !== svg) {\n host.insertBefore(el, svg ?? host.firstChild)\n }\n }\n\n return {\n beforeRender({ legend, hidden }) {\n if (!legend.show || typeof document === 'undefined') {\n remove()\n return\n }\n if (!el) {\n el = host.ownerDocument.createElement('div')\n el.className = 'tc-legend'\n }\n if (!bound) {\n el.addEventListener('click', onClick)\n bound = true\n }\n el.dataset.position = legend.position\n // A right-to-left chart reads right to left, whatever the page around it.\n el.dir = chart.rtl ? 'rtl' : ''\n render(el, legendContent(legend.items, hidden), adopt)\n adopt = null\n place()\n },\n // With its margin: the gap to the chart is taken from the container too.\n reservedHeight() {\n if (!el?.isConnected) return 0\n const { marginTop, marginBottom } = getComputedStyle(el)\n return (\n el.offsetHeight +\n (Number.parseFloat(marginTop) || 0) +\n (Number.parseFloat(marginBottom) || 0)\n )\n },\n afterRender: place,\n destroy: remove,\n }\n },\n }\n}\n","import type { Chart } from '../chart.ts'\nimport type { Interaction } from '../interaction.ts'\nimport type { ChartPlugin } from '../plugin.ts'\n\n/** Charts by `sync` group, held weakly: a chart taken out without destroy() is let go. */\nconst groups = /* @__PURE__ */ new Map<string, Set<WeakRef<Chart<object>>>>()\n\n/** The index of each category label, per render of a chart. */\nconst indexes = /* @__PURE__ */ new WeakMap<Interaction, Map<string | number, number>>()\n\n/** Set while a highlight is passed on, so the charts it reaches do not pass it on again. */\nlet passing = false\n\n/** The index of the category with `label` in a chart's current render, if it has one. */\nfunction indexOf(interaction: Interaction, label: string | number): number | undefined {\n let index = indexes.get(interaction)\n if (!index) {\n index = new Map()\n for (let i = 0; i < interaction.count; i++) {\n const hit = interaction.hitIndex(i)\n if (hit && !index.has(hit.label)) index.set(hit.label, i)\n }\n indexes.set(interaction, index)\n }\n return index.get(label)\n}\n\n/**\n * Shared hover across charts: charts with the same `sync` group highlight\n * the category under the pointer in any of them (with its crosshair and\n * tooltip), matched by label, and clear together when it leaves. Keyboard\n * highlights stay in their own chart.\n */\nexport function sync(): ChartPlugin {\n return {\n name: 'sync',\n install(chart) {\n const self = new WeakRef(chart)\n let group: Set<WeakRef<Chart<object>>> | undefined\n /** The name of the group joined: the config may have moved on before the next render. */\n let joined: string | undefined\n /** Leave the group, and take it off the list when it is empty. */\n const leave = () => {\n group?.delete(self)\n if (joined && group?.size === 0 && groups.get(joined) === group) groups.delete(joined)\n }\n /** Join the group of the current config, leaving the one before. */\n const join = () => {\n const name = chart.config.sync\n const next = name ? (groups.get(name) ?? new Set()) : undefined\n if (next === group) return\n leave()\n if (name && next) {\n next.add(self)\n groups.set(name, next)\n }\n group = next\n joined = name\n }\n join()\n const off = chart.on('hover', ({ hit }) => {\n // Only the pointer leads; keyboard highlights and highlights passed on do not.\n if (passing || !group || (hit && chart.highlightSource !== 'pointer')) return\n passing = true\n try {\n for (const ref of group) {\n const other = ref.deref()\n if (!other) group.delete(ref)\n if (!other || other === chart) continue\n const index = hit && other.interaction && indexOf(other.interaction, hit.label)\n if (index === undefined || index === null) other.clearHighlight()\n else other.highlightIndex(index)\n }\n } finally {\n passing = false\n }\n })\n return {\n afterRender: join,\n destroy() {\n off()\n leave()\n },\n }\n },\n }\n}\n","/**\n * Work that can wait until the browser is idle, such as hidden data tables:\n * it runs in an idle callback (within a second at the latest), or with\n * `flush()`. A module of its own, so charts without such work do not ship it.\n */\nimport { flushHooks, run } from './scheduler.ts'\n\nconst idle = /* @__PURE__ */ new Map<object, () => void>()\nlet pending = false\n\nfunction drain(): number {\n pending = false\n let count = 0\n while (idle.size > 0) {\n const tasks = Array.from(idle.values())\n idle.clear()\n for (const task of tasks) {\n run(task)\n count++\n }\n }\n return count\n}\n\n/** Run `task` once the browser is idle, replacing any idle task already queued for `key`. */\nexport function scheduleIdle(key: object, task: () => void): void {\n flushHooks.idle = drain\n idle.set(key, task)\n if (pending) return\n pending = true\n if (typeof requestIdleCallback === 'function') requestIdleCallback(drain, { timeout: 1000 })\n else setTimeout(drain, 100)\n}\n\n/** Drop the idle task queued for `key`, if any. */\nexport function cancelIdle(key: object): void {\n idle.delete(key)\n}\n","import { tableContent } from '../a11y.ts'\nimport { type ChartConfig, renderContext, type Size } from '../chart.ts'\nimport { getNumberFormat } from '../format.ts'\nimport { cancelIdle, scheduleIdle } from '../idle.ts'\nimport type { ChartPlugin } from '../plugin.ts'\nimport { render } from '../render/dom.ts'\n\n/**\n * The chart data as an HTML table next to the SVG: visually hidden for\n * screen readers by default, visible with `table: 'visible'`.\n */\nconst DEFAULT_MAX_ROWS = 1000\n\nexport function dataTable(): ChartPlugin {\n return {\n name: 'table',\n install(chart) {\n const host = chart.element\n // Take over a server-rendered table instead of adding a second one.\n let el = host.querySelector<HTMLElement>(':scope > .tc-table-wrap') ?? undefined\n let adopt = el?.firstElementChild ?? null\n\n /** The table option of the last table, to tell its changes from new data. */\n let shown: unknown\n const key = {}\n\n const remove = () => {\n cancelIdle(key)\n if (!el) return\n render(el, null)\n el.remove()\n el = undefined\n }\n\n const update = (config: ChartConfig<object>, size: Size, hidden: ReadonlySet<string>) => {\n const option = config.table ?? true\n const maxRows =\n typeof option === 'object' && option.maxRows ? option.maxRows : DEFAULT_MAX_ROWS\n const table =\n option !== false && typeof document !== 'undefined'\n ? config.type.table?.(\n config,\n renderContext(config, size, chart.id, () => {}, hidden, chart.fontSize),\n maxRows,\n )\n : undefined\n if (!table) {\n remove()\n return\n }\n const visible =\n option === 'visible' || (typeof option === 'object' && option.visible === true)\n // Huge tables help nobody and cost real time to build; keep the first rows.\n let caption = config.title\n const total = table.total ?? table.rows.length\n const rows =\n table.rows.length > maxRows\n ? { columns: table.columns, rows: table.rows.slice(0, maxRows) }\n : table\n if (total > rows.rows.length) {\n const n = getNumberFormat(config.locale)\n const note = `${n.format(rows.rows.length)} of ${n.format(total)} rows`\n caption = caption ? `${caption} (${note})` : note\n }\n if (!el) el = host.ownerDocument.createElement('div')\n el.className = visible ? 'tc-table-wrap' : 'tc-table-wrap tc-sr-only'\n render(el, tableContent(rows, caption), adopt)\n adopt = null\n const svg = host.querySelector(':scope > svg.tc-chart')\n const bottomLegend = host.querySelector(':scope > .tc-legend[data-position=\"bottom\"]')\n const after = bottomLegend ?? svg\n if (after && after.nextElementSibling !== el) after.after(el)\n else if (!el.isConnected) host.appendChild(el)\n }\n\n return {\n afterRender({ config, size, hidden, changed }) {\n // Resizing changes nothing in the table.\n if (!changed && el?.isConnected) return\n const option = config.table ?? true\n const same = shown === option\n shown = option\n // A hidden table only serves screen readers: rebuilding thousands of\n // cells for new data can wait until the browser is idle instead of\n // delaying the frame that animates the chart. The first table, visible\n // ones and changes of the table option itself are built right away.\n if (same && el?.isConnected && el.classList.contains('tc-sr-only')) {\n scheduleIdle(key, () => update(config, size, hidden))\n } else {\n cancelIdle(key)\n update(config, size, hidden)\n }\n },\n destroy: remove,\n }\n },\n }\n}\n","import type { Hit } from './interaction.ts'\nimport { type ChildInput, h, type VNode } from './vnode.ts'\n\n/**\n * Where a tooltip for `hit` belongs, in chart pixels: the pointer when it\n * drives the highlight, otherwise the focused value (keyboard).\n */\nexport function hitAnchor(hit: Hit, pointer?: { x: number; y: number }): { x: number; y: number } {\n if (pointer) return pointer\n const item = hit.items.find((i) => i.seriesIndex === hit.seriesIndex) ?? hit.items[0]\n if (hit.guide && item?.y != null) return { x: item.x, y: item.y }\n if (hit.axis === 'y') return { x: item?.x ?? hit.x, y: hit.y ?? hit.area.y }\n return { x: hit.x, y: item?.y ?? hit.area.y + hit.area.height / 2 }\n}\n\nexport interface TooltipOptions {\n /**\n * Colors of the tooltip: `'dark'` (the default) is a dark box with light\n * text, `'light'` a white one with dark text. Both keep their colors in\n * dark mode; the `--tc-tooltip-*` tokens tune them.\n */\n theme?: 'dark' | 'light'\n /**\n * Custom content for a hit: VNodes built with `h()` or plain text.\n * Rendered safely (no HTML parsing), inside `.tc-tooltip`.\n */\n format?: (hit: Hit) => ChildInput\n /** Extra content below the default rows (e.g. a total), in `.tc-tooltip-footer`. */\n footer?: (hit: Hit) => ChildInput\n}\n\n/** Default tooltip content: the category title and one row per series. */\nexport function tooltipContent(hit: Hit, options: TooltipOptions = {}): VNode {\n const body: ChildInput = options.format\n ? options.format(hit)\n : [\n hit.title && h('div', { class: 'tc-tooltip-title' }, hit.title),\n hit.items.map((item) =>\n h(\n 'div',\n {\n key: item.seriesIndex,\n class: [\n 'tc-tooltip-item',\n 'tc-series',\n `tc-series-${item.seriesIndex + 1}`,\n hit.seriesIndex === item.seriesIndex && 'tc-tooltip-item-active',\n ],\n style: { '--tc-series-color': item.color },\n },\n h('span', { class: 'tc-tooltip-swatch' }),\n h('span', { class: 'tc-tooltip-name' }, item.name),\n h('span', { class: 'tc-tooltip-value' }, item.text),\n ),\n ),\n options.footer && h('div', { class: 'tc-tooltip-footer' }, options.footer(hit)),\n ]\n return h('div', { class: 'tc-tooltip-content' }, body)\n}\n\nexport interface TooltipPlacement {\n x: number\n y: number\n side: 'left' | 'right'\n}\n\n/**\n * Place a `width × height` tooltip next to an anchor within `bounds` (from\n * `bounds.x`, `bounds.y`, 0 by default): right of the anchor, or left when it\n * would overflow (the other way round with `rtl`), vertically centered on the\n * pointer and clamped.\n */\nexport function placeTooltip(\n anchor: { x: number; y: number },\n size: { width: number; height: number },\n bounds: { x?: number; y?: number; width: number; height: number },\n offset = 12,\n rtl = false,\n): TooltipPlacement {\n const { x: left = 0, y: top = 0 } = bounds\n const fitsRight = anchor.x + offset + size.width <= left + bounds.width\n const fitsLeft = anchor.x - offset - size.width >= left\n // The side read first, unless only the other one has room.\n const side = (rtl ? fitsLeft || !fitsRight : fitsLeft && !fitsRight) ? 'left' : 'right'\n const rawX = side === 'right' ? anchor.x + offset : anchor.x - offset - size.width\n const x = Math.max(left, Math.min(rawX, left + bounds.width - size.width))\n const y = Math.max(top, Math.min(anchor.y - size.height / 2, top + bounds.height - size.height))\n return { x: Math.round(x), y: Math.round(y), side }\n}\n","import type { ChartPlugin } from '../plugin.ts'\nimport { render } from '../render/dom.ts'\nimport { schedule } from '../scheduler.ts'\nimport { hitAnchor, placeTooltip, tooltipContent } from '../tooltip.ts'\nimport { listenPointer } from './pointer.ts'\n\n/**\n * Where a tooltip in `el` can show without being cut off: the box of the\n * nearest element that clips its overflow (`el` itself, an ancestor, across\n * shadow roots), within the viewport.\n */\nfunction room(el: Element): { left: number; top: number; right: number; bottom: number } {\n let left = 0\n let top = 0\n let right = innerWidth\n let bottom = innerHeight\n for (let node: Element | null = el; node; ) {\n const style = getComputedStyle(node)\n if (style.overflowX !== 'visible' || style.overflowY !== 'visible') {\n const box = node.getBoundingClientRect()\n left = Math.max(left, box.left)\n top = Math.max(top, box.top)\n right = Math.min(right, box.right)\n bottom = Math.min(bottom, box.bottom)\n break\n }\n node = node.parentElement ?? ((node.getRootNode() as ShadowRoot).host || null)\n }\n return { left, top, right, bottom }\n}\n\n/** Tooltips to place: each measures where it goes, and returns what moves it there. */\nconst waiting: (() => (() => void) | undefined)[] = []\n\n/**\n * Place the waiting tooltips, in the frame that rendered their charts: all\n * are measured before any is moved, so the page is laid out once for the\n * frame. Measured and moved one by one, twelve charts sharing a hover laid\n * the page out twelve times.\n */\nfunction placeAll(): void {\n for (const move of waiting.splice(0).map((measure) => measure())) move?.()\n}\n\n/**\n * An HTML tooltip (`.tc-tooltip`) for the highlighted category, placed next\n * to it inside the chart element. Configure it with the `tooltip` option;\n * `theme: 'light'` adds `.tc-tooltip-light` for the white variant.\n */\nexport function tooltip(): ChartPlugin {\n return {\n name: 'tooltip',\n install(chart) {\n const stop = listenPointer(chart)\n const el = chart.element as HTMLElement\n // Positioning context for the tooltip (zero specificity in CSS, so page styles win).\n const addedClass = !el.classList.contains('tc-container')\n el.classList.add('tc-container')\n let tip: HTMLElement | undefined\n /** Counts the renders, so a placement still waiting knows when it is out of date. */\n let turns = 0\n\n return {\n afterRender() {\n const option = chart.config.tooltip\n const hit = chart.active\n const anchor = hit && hitAnchor(hit, chart.pointer)\n if (\n option === false ||\n typeof document === 'undefined' ||\n !hit ||\n !anchor ||\n !Number.isFinite(anchor.x) ||\n !Number.isFinite(anchor.y)\n ) {\n turns++\n tip?.removeAttribute('data-visible')\n return\n }\n if (!tip) {\n tip = el.ownerDocument.createElement('div')\n tip.className = 'tc-tooltip'\n tip.setAttribute('aria-hidden', 'true')\n el.appendChild(tip)\n }\n const options = typeof option === 'object' ? option : undefined\n tip.classList.toggle('tc-tooltip-light', options?.theme === 'light')\n const { rtl } = chart\n tip.dir = rtl ? 'rtl' : ''\n render(tip, tooltipContent(hit, options))\n\n // Placed with the tooltips of the other charts of this frame (see placeAll).\n const shown = tip\n const turn = ++turns\n waiting.push(() => {\n const svg = el.querySelector('svg.tc-chart')\n // A later render of this chart, or its end, overtook this one.\n if (!svg || turn !== turns) return undefined\n const { width, height } = chart.size\n const box = el.getBoundingClientRect()\n const rect = svg.getBoundingClientRect()\n // Screen pixels per pixel of the container (transformed or zoomed ancestors).\n const k = box.width > 0 && el.offsetWidth > 0 ? box.width / el.offsetWidth : 1\n const sx = rect.width > 0 ? rect.width / width / k : 1\n const sy = rect.height > 0 ? rect.height / height / k : 1\n const origin = {\n x: (rect.left - box.left) / k - el.clientLeft,\n y: (rect.top - box.top) / k - el.clientTop,\n }\n // Snap to the category, follow the pointer along the values\n // (a radar spoke runs both ways, so there it follows the pointer).\n const ax = hit.axis === 'y' || hit.guide ? anchor.x : hit.x\n const ay = hit.axis === 'y' ? (hit.y ?? anchor.y) : anchor.y\n // The tooltip may leave the container, up to what would cut it off.\n const clip = room(el)\n const place = placeTooltip(\n { x: origin.x + ax * sx, y: origin.y + ay * sy },\n { width: shown.offsetWidth, height: shown.offsetHeight },\n {\n x: (clip.left - box.left) / k - el.clientLeft,\n y: (clip.top - box.top) / k - el.clientTop,\n width: (clip.right - clip.left) / k,\n height: (clip.bottom - clip.top) / k,\n },\n 12,\n rtl,\n )\n return () => {\n shown.style.transform = `translate(${place.x}px, ${place.y}px)`\n shown.dataset.side = place.side\n if (!shown.hasAttribute('data-visible')) {\n // Commit the position before becoming visible, so it does not glide in from the old spot.\n void getComputedStyle(shown).transform\n shown.setAttribute('data-visible', '')\n }\n }\n })\n schedule(waiting, placeAll)\n },\n destroy() {\n turns++\n if (tip) {\n render(tip, null)\n tip.remove()\n }\n if (addedClass) el.classList.remove('tc-container')\n stop?.()\n },\n }\n },\n }\n}\n","import type { ChartPlugin } from '../plugin.ts'\nimport { download } from './download.ts'\nimport { highlight } from './highlight.ts'\nimport { keyboard } from './keyboard.ts'\nimport { legend } from './legend.ts'\nimport { pointer } from './pointer.ts'\nimport { sync } from './sync.ts'\nimport { dataTable } from './table.ts'\nimport { tooltip } from './tooltip.ts'\n\nexport { dataTable, download, highlight, keyboard, legend, pointer, sync, tooltip }\n\n/** The built-in plugins installed by the default `Chart` from `@tabler/charts`. */\nexport function defaultPlugins(): ChartPlugin[] {\n return [highlight(), legend(), tooltip(), dataTable(), keyboard(), sync(), download()]\n}\n","","import { version } from '../package.json'\n\n/** Version of the `@tabler/charts` package. */\nexport const VERSION: string = version\n\nexport type { DataTable } from './a11y.ts'\nexport { describeHit, tableContent } from './a11y.ts'\nexport type {\n BaseOptions,\n ChartConfig,\n ChartEvents,\n ChartType,\n RenderContext,\n ResolvedLegend,\n Size,\n} from './chart.ts'\nexport {\n buildChart,\n Chart,\n chartEvents,\n chartLabel,\n chartToString,\n renderContext,\n resolveLegend,\n resolveSize,\n} from './chart.ts'\nexport type { Annotation } from './charts/annotations.ts'\nexport type { AreaOptions } from './charts/area.ts'\nexport { area } from './charts/area.ts'\nexport type { BarOptions } from './charts/bar.ts'\nexport { bar } from './charts/bar.ts'\nexport type { Candle, CandlestickOptions } from './charts/candlestick.ts'\nexport { candlestick } from './charts/candlestick.ts'\nexport type {\n CartesianData,\n CartesianOptions,\n CategoryAxisOptions,\n Label,\n Series,\n ValueAxisOptions,\n} from './charts/cartesian.ts'\nexport {\n categoryInteraction,\n domainOf,\n seriesKey,\n seriesLegend,\n seriesTable,\n} from './charts/cartesian.ts'\nexport type { GaugeOptions, GaugeRing } from './charts/gauge.ts'\nexport { gauge } from './charts/gauge.ts'\nexport type { HeatmapOptions, HeatmapRange } from './charts/heatmap.ts'\nexport { heatmap } from './charts/heatmap.ts'\nexport type { LineOptions } from './charts/line.ts'\nexport { line } from './charts/line.ts'\nexport type { ParliamentOptions, ParliamentParty } from './charts/parliament.ts'\nexport { parliament } from './charts/parliament.ts'\nexport type { PercentageBarOptions, PercentageBarSegment } from './charts/percentage-bar.ts'\nexport { percentageBar } from './charts/percentage-bar.ts'\nexport type { PieOptions, PieSlice } from './charts/pie.ts'\nexport { donut, pie } from './charts/pie.ts'\nexport type { RadarOptions, RadialAxisOptions } from './charts/radar.ts'\nexport { radar } from './charts/radar.ts'\nexport type { SankeyData, SankeyLink, SankeyNode, SankeyOptions } from './charts/sankey.ts'\nexport { sankey } from './charts/sankey.ts'\nexport type { ScatterOptions, ScatterPoint, ScatterSeries } from './charts/scatter.ts'\nexport { scatter } from './charts/scatter.ts'\nexport type { SparklineOptions } from './charts/sparkline.ts'\nexport { sparkline } from './charts/sparkline.ts'\nexport type { TreemapNode, TreemapOptions } from './charts/treemap.ts'\nexport { treemap } from './charts/treemap.ts'\nexport type { AxisOptions, AxisPosition, LinearTicksOptions, Tick } from './components/axis.ts'\nexport { axis, axisSize, bandTicks, linearTicks, thinTicks } from './components/axis.ts'\nexport type { GridOptions } from './components/grid.ts'\nexport { grid } from './components/grid.ts'\nexport { hoverOverlay, hoverUnderlay } from './components/hover.ts'\nexport type { Features } from './features.ts'\nexport { feature, features, register } from './features.ts'\nexport type { DateFormat, Locale, NumberFormat, NumberFormatOptions } from './format.ts'\nexport {\n formatDate,\n formatDetail,\n formatNumber,\n formatTicks,\n getDateFormat,\n getNumberFormat,\n stepPrecision,\n} from './format.ts'\nexport type { Hit, HitItem, HitTester, Interaction } from './interaction.ts'\nexport type { Insets, InsetsInput, Rect } from './layout.ts'\nexport { estimateTextWidth, innerRect, insets, LINE_HEIGHT } from './layout.ts'\nexport type { LegendItem, LegendOptions } from './legend.ts'\nexport { defaultHidden, legendContent } from './legend.ts'\nexport type {\n AfterRenderState,\n BeforeRenderState,\n ChartPlugin,\n PluginInstance,\n} from './plugin.ts'\nexport type { DownloadFormat, DownloadMenuOptions, DownloadOption } from './plugins/download.ts'\nexport {\n dataTable,\n defaultPlugins,\n download,\n highlight,\n keyboard,\n legend,\n pointer,\n sync,\n tooltip,\n} from './plugins/index.ts'\nexport { render } from './render/dom.ts'\nexport type { RenderToStringOptions } from './render/string.ts'\nexport { escapeAttr, escapeText, renderToString } from './render/string.ts'\nexport type { BandKey, BandScale, BandScaleOptions } from './scales/band.ts'\nexport { band, point } from './scales/band.ts'\nexport { extent } from './scales/extent.ts'\nexport type { LinearScale, LinearScaleOptions } from './scales/linear.ts'\nexport { linear } from './scales/linear.ts'\nexport { niceDomain, tickIncrement, tickStep, ticks } from './scales/ticks.ts'\nexport { cancel, flush, schedule } from './scheduler.ts'\nexport type { ArcOptions } from './shapes/arc.ts'\nexport { arcCentroid, arcPathStable, padAngleForGap } from './shapes/arc.ts'\nexport { barPath, hbarPath } from './shapes/bar.ts'\nexport type { Curve, PathOptions, Point } from './shapes/path.ts'\nexport { areaPath, linePath } from './shapes/path.ts'\nexport type { TooltipOptions, TooltipPlacement } from './tooltip.ts'\nexport { hitAnchor, placeTooltip, tooltipContent } from './tooltip.ts'\nexport type {\n Attrs,\n AttrValue,\n Child,\n ChildInput,\n ClassValue,\n Key,\n Props,\n StyleValue,\n VNode,\n} from './vnode.ts'\nexport { h, normalizeClass, normalizeStyle } from './vnode.ts'\n"],"mappings":";;;;;;;;AA8BA,MAAM,QAAwC;CAAE,KAAK;CAAO,KAAK;CAAO,MAAM;CAAQ,MAAM;AAAO;AACnG,MAAM,kBAA6C,CAAC,OAAO,KAAK;AAEhE,SAAS,QAAQ,QAA6C;CAC5D,OAAO,WAAW,OACd,CAAC,IACD,MAAM,QAAQ,MAAM,IAClB,EAAE,SAAS,OAAO,IACjB;AACT;;;;;;;;AASA,SAAgB,WAAwB;CACtC,OAAO;EACL,MAAM;EACN,QAAQ,OAAO;GACb,MAAM,OAAO,MAAM;GACnB,MAAM,MAAM,KAAK;GACjB,IAAI;GACJ,IAAI,UAA+B,CAAC;GAEpC,MAAM,aAAa,CAAC,KAAK,UAAU,SAAS,cAAc;GAE1D,MAAM,eAAe,IAAI,cAA2B,qBAAqB;GACzE,MAAM,aAAa,IAAI,cAA2B,mBAAmB;GACrE,MAAM,cAAc,MAAM,KAAK,IAAI,iBAA8B,mBAAmB,KAAK,CAAC,CAAC;GAE3F,MAAM,WAAW,SAAkB;IACjC,MAAM,OAAO,KAAK;IAClB,IAAI,CAAC,MAAM;IACX,KAAK,SAAS,CAAC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E,MAAM,MAAM,EAAE;OAC3D,MAAM,QAAQ,OAAO,MAAM;OAC3B,IAAI,CAAC,MAAM,aAAa,cAAc,GAAG;QAElC,iBAAiB,KAAK,CAAC,CAAC;QAC7B,MAAM,aAAa,gBAAgB,EAAE;OACvC;MACF;KACF,CAAC;KACDC,cAAAA,SAAS,SAAS,QAAQ;IAC5B;IACA,UAAU;KACR;KACA,IAAI,KAAK;MACPD,YAAAA,OAAO,KAAK,IAAI;MAChB,IAAI,OAAO;KACb;KACA,IAAI,YAAY,GAAG,UAAU,OAAO,cAAc;KAClD,OAAO;IACT;GACF;EACF;CACF;AACF;;;AC1IA,SAAgB,iBAAgC;CAC9C,OAAO;EAAC,UAAU;EAAG,OAAO;EAAG,QAAQ;EAAG,UAAU;EAAG,SAAS;EAAG,KAAK;EAAG,SAAS;CAAC;AACvF;;;AEZA,MAAa,UAAkB"}
|
package/dist/dom-CuceR8gt.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom-CuceR8gt.js","names":[],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== anchor) {\n parent.insertBefore(node, anchor)\n }\n anchor = node\n }\n}\n"],"mappings":";;;AACA,MAAM,UAAU;;AAGhB,MAAM,WAAW;;AAGjB,SAAgB,WAAW,MAAuB;CAChD,OAAO,QAAQ,KAAK,IAAI;AAC1B;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,QAAQ,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;AAClD;;ACVA,MAAa,SAAS;AACtB,MAAM,UAAU;;AAGhB,MAAa,2BAAiD,IAAI,QAAqB;;AAGvF,MAAM,wBAAwB,IAAI,QAA0B;;;;;;;;;;;;;;;;AAiB5D,SAAgB,OACd,WACA,OACA,SACgB;CAChB,MAAM,OA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AI,GAAG,OAAO,YAAY,IAAI;CAI9C,MAAM,KAAK,eAAe,MAAM;CAChC,MAAM,MAAM,OAAO;CACnB,IAAI,SAAsB;CAC1B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom-D_g13XWY.cjs","names":["features"],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== anchor) {\n parent.insertBefore(node, anchor)\n }\n anchor = node\n }\n}\n"],"mappings":";;;AACA,MAAM,UAAU;;AAGhB,MAAM,WAAW;;AAGjB,SAAgB,WAAW,MAAuB;CAChD,OAAO,QAAQ,KAAK,IAAI;AAC1B;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,QAAQ,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;AAClD;;ACVA,MAAa,SAAS;AACtB,MAAM,UAAU;;AAGhB,MAAa,2BAAiD,IAAI,QAAqB;;AAGvF,MAAM,wBAAwB,IAAI,QAA0B;;;;;;;;;;;;;;;;AAiB5D,SAAgB,OACd,WACA,OACA,SACgB;CAChB,MAAM,OAAO,MAAM,IAAI,SAAS,MAAM,SAAS,eAAe,YAAY,UAAU,KAAA;CAEpF,IAAI,UAAU,QAAQ,CAAC,WAAW,MAAM,GAAG,GAAG;EAC5C,IAAI,MAAM;GACR,KAAK,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AAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-chart-83UYH48t.js","names":[],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,mBAAmB;CACnB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;AACA,MAAM,OAA+B;CACnC,GAAG;CACH,eAAe;CACf,aAAa;CACb,eAAe;CACf,cAAc;CACd,wBAAwB;CACxB,kBAAkB;AACpB;AACA,MAAM,OAA+B;CAAE,cAAc;CAAI,gBAAgB;AAAI;AAC7E,MAAM,QAAgC,EAAE,SAAS,IAAI;AACrD,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAU;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBAAuB;CAClF,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,8CAA8C;CACxE,OAAO;AACT;;AAGA,SAAS,YAAY,OAAgD;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Q;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-chart-mYgEfK-L.cjs","names":["round"],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,mBAAmB;CACnB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;AACA,MAAM,OAA+B;CACnC,GAAG;CACH,eAAe;CACf,aAAa;CACb,eAAe;CACf,cAAc;CACd,wBAAwB;CACxB,kBAAkB;AACpB;AACA,MAAM,OAA+B;CAAE,cAAc;CAAI,gBAAgB;AAAI;AAC7E,MAAM,QAAgC,EAAE,SAAS,IAAI;AACrD,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAU;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBAAuB;CAClF,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,8CAA8C;CACxE,OAAO;AACT;;AAGA,SAAS,YAAY,OAAgD;CACnE,MAAM,QAAQ,MAAM;CACpB,IAAI,CAAC,SAAS,UAAU,QAAQ,OAAO,KAAA;CAEvC,MAAM,MAAM,MAAM,QAAQ,OAAO,EAAE;CACnC,IAAI,IAAI,WAAW,WAAW,GAAG,OAAO;CACxC,MAAM,CAAC,KAAK,GAAG,KAAK,MAAM,MAAM,mBAAmB,MAA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path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACK;CAET,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAE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K;AACd;;;;;;AAOA,SAAgB,SACd,QACA,UACA,UAAuB,CAAC,GAChB;CACR,MAAM,EAAE,QAAQ,UAAU,YAAY,MAAM;CAC5C,MAAM,OAAO,IAAI,YAAY,SAAS;CACtC,MAAM,UAAU,MACd,OAAO,aAAa,WAAW,WAAY,SAAS,MAAM;CAE5D,KAAK,MAAM,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAOA,cAAAA,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5CA,cAAAA,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnDA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/CA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACAA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fade-GGxcBdss.js","names":[],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACK;CAET,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,QAAQ,IAAY,IAAY,IAAY,IAAY,GAAW,GAAiB;EAClF,KAAK,KAAK,I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AAM,UAAU,MACd,OAAO,aAAa,WAAW,WAAY,SAAS,MAAM;CAE5D,KAAK,MAAM,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAO,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5C,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnD,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/C,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features-BMxkqCyS.js","names":[],"sources":["../src/features.ts"],"sourcesContent":["import type { ChartConfig, RenderContext } from './chart.ts'\nimport type { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport type { dateLabels } from './charts/dates.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features-DCXEvoya.cjs","names":[],"sources":["../src/features.ts"],"sourcesContent":["import type { ChartConfig, RenderContext } from './chart.ts'\nimport type { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport type { dateLabels } from './charts/dates.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gauge-DXkjXNCD.cjs","names":["keyOf","insets","innerRect","DEG","formatNumber","getNumberFormat","arcCentroid","arcPathStable","h","groupAttrs","arcNode","cleanData","cleanItems","isRecord","features","sweepArcs","legendItems"],"sources":["../src/charts/gauge.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { features } from '../features.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets } from '../layout.ts'\nimport { arcNode, sweep as sweepArcs } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO } from '../shapes/arc.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems, isRecord } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** One ring of a gauge. */\nexport interface GaugeRing {\n name: string\n /** Current value, clamped to `0…max`. */\n value: number\n /** Full-ring value of this ring; overrides `GaugeOptions.max`. */\n max?: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the ring group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface GaugeOptions {\n /** A single value, one ring, or concentric rings (outermost first). */\n data: number | GaugeRing | readonly GaugeRing[]\n /** Full-ring value. Defaults to `100`. */\n max?: number\n /** Where the arc starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Degrees the full ring spans, `0…360`. Defaults to `360`; use e.g. `270` for a dial. */\n angle?: number\n /** Ring thickness in pixels. Defaults to `12`. */\n thickness?: number\n /** Space between rings in pixels. Defaults to `4`. */\n gap?: number\n /** Corner radius of the arcs. Defaults to half the thickness (round caps). */\n cornerRadius?: number\n /** Format of the values (tooltip, table). */\n format?: NumberFormat\n /**\n * Text in the middle: the first ring's share of `max` and its name by\n * default; `false` hides it, or give your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the gauge, in pixels. */\n padding?: InsetsInput\n}\n\n/** Space kept around the gauge for the hover halo. */\nconst HALF_PI = Math.PI / 2\n\ninterface Ring {\n data: GaugeRing\n index: number\n value: number\n max: number\n /** Slot among the visible rings, from the outside in. */\n position: number\n}\n\nfunction ringsOf(options: GaugeOptions): GaugeRing[] {\n const { data } = options\n if (typeof data === 'number') return [{ name: '', value: data }]\n return Array.isArray(data) ? (data as GaugeRing[]) : [data as GaugeRing]\n}\n\n/** The visible rings with clamped values. */\nfunction layoutRings(options: GaugeOptions, hidden: ReadonlySet<string>): Ring[] {\n const max = options.max ?? 100\n return ringsOf(options)\n .map((data, index) => ({ data, index, max: data.max ?? max }))\n .filter((ring) => !hidden.has(keyOf(ring.data)))\n .map((ring, position) => ({\n ...ring,\n position,\n value: Math.min(ring.max, Math.max(0, ring.data.value || 0)),\n }))\n}\n\n/**\n * Radius and center that fit the swept ring (plus the text in the middle)\n * into `area`: a dial or half ring is centered by its own outline, not by\n * the full circle it is cut from.\n */\nfunction fitGauge(\n area: { x: number; y: number; width: number; height: number },\n start: number,\n sweep: number,\n textTop: number,\n textBottom: number,\n): { outer: number; cx: number; cy: number } {\n // Points of the outline, in units of the outer radius: both ends of the arc\n // and every axis extreme it passes; the origin covers the inner edge.\n const unit: [number, number][] = [[0, 0]]\n const end = start + sweep\n unit.push([Math.sin(start), -Math.cos(start)], [Math.sin(end), -Math.cos(end)])\n // (At most a full turn of them: a huge start angle is beyond what adding a quarter turn changes.)\n for (let a = Math.ceil(start / HALF_PI) * HALF_PI, n = 0; n < 5 && a <= end + 1e-9; n++) {\n unit.push([Math.sin(a), -Math.cos(a)])\n a += HALF_PI\n }\n let outer = Math.min(area.width, area.height) / 2\n let box = { x0: 0, y0: 0, x1: 0, y1: 0 }\n // The text does not scale with the radius, so converge in a few rounds.\n for (let i = 0; i < 4; i++) {\n box = { x0: 0, y0: textTop, x1: 0, y1: textBottom }\n for (const [x, y] of unit) {\n box.x0 = Math.min(box.x0, x * outer)\n box.x1 = Math.max(box.x1, x * outer)\n box.y0 = Math.min(box.y0, y * outer)\n box.y1 = Math.max(box.y1, y * outer)\n }\n const scale = Math.min(area.width / (box.x1 - box.x0), area.height / (box.y1 - box.y0))\n if (Math.abs(scale - 1) < 1e-3) break\n outer = Math.max(0, outer * scale)\n }\n return {\n outer,\n cx: area.x + (area.width - (box.x1 - box.x0)) / 2 - box.x0,\n cy: area.y + (area.height - (box.y1 - box.y0)) / 2 - box.y0,\n }\n}\n\nfunction renderGauge(options: GaugeOptions, ctx: RenderContext): ChildInput {\n const { width, height, locale } = ctx\n const thickness = Math.max(1, options.thickness ?? 12)\n const gap = Math.max(0, options.gap ?? 4)\n const cornerRadius = options.cornerRadius ?? thickness / 2\n const pad = insets(options.padding, 0)\n const area = innerRect(width, height, {\n top: pad.top + HALO,\n right: pad.right + HALO,\n bottom: pad.bottom + HALO,\n left: pad.left + HALO,\n })\n const start = (options.startAngle ?? 0) * DEG\n const sweep = Math.min(360, Math.max(0, options.angle ?? 360)) * DEG\n const rings = layoutRings(options, ctx.hidden)\n const center = options.center\n const first = rings[0]\n const showCenter = center !== false && first !== undefined\n const centerLabel = showCenter ? (center?.label ?? (first.data.name || undefined)) : undefined\n const { outer, cx, cy } = fitGauge(\n area,\n start,\n sweep,\n showCenter ? -1.4 * ctx.fontSize : 0,\n showCenter ? (centerLabel ? 2 : 0.7) * ctx.fontSize : 0,\n )\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const radii = (ring: Ring, grow = 0) => {\n const r1 = Math.max(0, outer - ring.position * (thickness + gap))\n return { innerRadius: Math.max(0, r1 - thickness - grow), outerRadius: r1 + grow }\n }\n const fraction = (ring: Ring) => (ring.max > 0 ? ring.value / ring.max : 0)\n const geometry = (ring: Ring, grow = 0) => ({\n ...radii(ring, grow),\n startAngle: start,\n endAngle: start + sweep * fraction(ring),\n cornerRadius,\n })\n\n const hitFor = (ring: Ring): Hit => {\n const [x, y] = arcCentroid(geometry(ring))\n const item: HitItem = {\n name: ring.data.name,\n seriesIndex: ring.index,\n value: ring.value,\n text: `${value(ring.value)} (${share.format(fraction(ring))})`,\n x: cx + x,\n y: cy + y,\n }\n if (ring.data.color) item.color = ring.data.color\n return {\n index: ring.position,\n label: ring.data.name,\n title: '',\n x: cx + x,\n area: { x: cx - outer, y: cy - outer, width: outer * 2, height: outer * 2 },\n items: [item],\n seriesIndex: ring.index,\n // The value arc, slightly enlarged.\n mark: { d: arcPathStable(geometry(ring, 2)), x: cx, y: cy },\n }\n }\n\n const interaction: Interaction = {\n count: rings.length,\n hitIndex: (position) => {\n const ring = rings[position]\n return ring ? hitFor(ring) : null\n },\n hitTest(px, py) {\n const r = Math.hypot(px - cx, py - cy)\n const ring = rings.find((ring) => {\n const { innerRadius, outerRadius } = radii(ring, 2)\n return r >= innerRadius && r <= outerRadius\n })\n return ring ? hitFor(ring) : null\n },\n }\n ctx.onHitTest(interaction)\n\n const groups = rings.map((ring) =>\n h(\n 'g',\n groupAttrs(ring.data, ring.index),\n // Each path keeps its arc, so a new value (or a new shape of the gauge)\n // sweeps it around the center (see `sweep`).\n arcNode('tc-gauge-track', { ...geometry(ring), endAngle: start + sweep }),\n arcNode('tc-gauge-arc', geometry(ring)),\n ),\n )\n\n const centerValue = showCenter ? (center?.value ?? share.format(fraction(first))) : ''\n\n return [\n // Rings sit in their own group: the entrance animation transforms it, not the translated parent.\n h(\n 'g',\n { class: 'tc-gauge', style: `transform:translate(${cx}px,${cy}px)` },\n h('g', { class: 'tc-gauge-rings' }, groups),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-gauge-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-gauge-value',\n x: cx,\n y: cy,\n dy: centerLabel ? '0' : '0.35em',\n 'text-anchor': 'middle',\n },\n centerValue,\n ),\n centerLabel &&\n h(\n 'text',\n { class: 'tc-gauge-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n}\n\nfunction gaugeTable(options: GaugeOptions, ctx: RenderContext): DataTable {\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: layoutRings(options, ctx.hidden).map((ring) => [\n ring.data.name,\n value(ring.value),\n share.format(ring.max > 0 ? ring.value / ring.max : 0),\n ]),\n }\n}\n\n/**\n * Gauge (radial bar): progress towards a maximum as an arc on a track, with\n * the share in the middle. Several rings nest from the outside in.\n *\n * ```ts\n * new Chart('#el', { type: gauge, data: 58 })\n * new Chart('#el', { type: gauge, data: { name: 'completed', value: 1392, max: 2400 } })\n * ```\n */\nexport const gauge: ChartType<GaugeOptions> = {\n name: 'gauge',\n clean: cleanData((data) =>\n cleanItems(\n typeof data === 'number' ? [{ name: '', value: data }] : isRecord(data) ? [data] : data,\n ),\n ),\n render: (options, ctx): ChildInput => {\n // Set here, not as the module loads (see pie).\n features.sweep = sweepArcs\n return renderGauge(options, ctx)\n },\n legend: (options) => legendItems(ringsOf(options)),\n table: gaugeTable,\n}\n"],"mappings":";;;;;;;;;;AA2DA,MAAM,UAAU,KAAK,KAAK;AAW1B,SAAS,QAAQ,SAAoC;CACnD,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU,OAAO,CAAC;EAAE,MAAM;EAAI,OAAO;CAAK,CAAC;CAC/D,OAAO,MAAM,QAAQ,IAAI,IAAK,OAAuB,CAAC,IAAiB;AACzE;;AAGA,SAAS,YAAY,SAAuB,QAAqC;CAC/E,MAAM,MAAM,QAAQ,OAAO;CAC3B,OAAO,QAAQ,OAAO,CAAC,CACpB,KAAK,MAAM,WAAW;EAAE;EAAM;EAAO,KAAK,KAAK,OAAO;CAAI,EAAE,CAAC,CAC7D,QAAQ,SAAS,CAAC,OAAO,IAAIA,cAAAA,MAAM,KAAK,IAAI,CAAC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Q;EAAE,OAAO;EAAW,uBAAuB;CAAE,CAAC;CACxF,OAAO;EACL,SAAS;GAAC;GAAI;GAAS;EAAO;EAC9B,MAAM,YAAY,SAAS,IAAI,MAAM,CAAC,CAAC,KAAK,SAAS;GACnD,KAAK,KAAK;GACV,MAAM,KAAK,KAAK;GAChB,MAAM,OAAO,KAAK,MAAM,IAAI,KAAK,QAAQ,KAAK,MAAM,CAAC;EACvD,CAAC;CACH;AACF;;;;;;;;;;AAWA,MAAa,QAAiC;CAC5C,MAAM;CACN,OAAOM,cAAAA,WAAW,SAChBC,cAAAA,WACE,OAAO,SAAS,WAAW,CAAC;EAAE,MAAM;EAAI,OAAO;CAAK,CAAC,IAAIC,cAAAA,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,IACrF,CACF;CACA,SAAS,SAAS,QAAoB;EAEpCC,iBAAAA,SAAS,QAAQC,cAAAA;EACjB,OAAO,YAAY,SAAS,GAAG;CACjC;CACA,SAAS,YAAYC,cAAAA,YAAY,QAAQ,OAAO,CAAC;CACjD,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gauge-ts0kqN1-.js","names":["sweepArcs"],"sources":["../src/charts/gauge.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { features } from '../features.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets } from '../layout.ts'\nimport { arcNode, sweep as sweepArcs } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO } from '../shapes/arc.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems, isRecord } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** One ring of a gauge. */\nexport interface GaugeRing {\n name: string\n /** Current value, clamped to `0…max`. */\n value: number\n /** Full-ring value of this ring; overrides `GaugeOptions.max`. */\n max?: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the ring group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface GaugeOptions {\n /** A single value, one ring, or concentric rings (outermost first). */\n data: number | GaugeRing | readonly GaugeRing[]\n /** Full-ring value. Defaults to `100`. */\n max?: number\n /** Where the arc starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Degrees the full ring spans, `0…360`. Defaults to `360`; use e.g. `270` for a dial. */\n angle?: number\n /** Ring thickness in pixels. Defaults to `12`. */\n thickness?: number\n /** Space between rings in pixels. Defaults to `4`. */\n gap?: number\n /** Corner radius of the arcs. Defaults to half the thickness (round caps). */\n cornerRadius?: number\n /** Format of the values (tooltip, table). */\n format?: NumberFormat\n /**\n * Text in the middle: the first ring's share of `max` and its name by\n * default; `false` hides it, or give your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the gauge, in pixels. */\n padding?: InsetsInput\n}\n\n/** Space kept around the gauge for the hover halo. */\nconst HALF_PI = Math.PI / 2\n\ninterface Ring {\n data: GaugeRing\n index: number\n value: number\n max: number\n /** Slot among the visible rings, from the outside in. */\n position: number\n}\n\nfunction ringsOf(options: GaugeOptions): GaugeRing[] {\n const { data } = options\n if (typeof data === 'number') return [{ name: '', value: data }]\n return Array.isArray(data) ? (data as GaugeRing[]) : [data as GaugeRing]\n}\n\n/** The visible rings with clamped values. */\nfunction layoutRings(options: GaugeOptions, hidden: ReadonlySet<string>): Ring[] {\n const max = options.max ?? 100\n return ringsOf(options)\n .map((data, index) => ({ data, index, max: data.max ?? max }))\n .filter((ring) => !hidden.has(keyOf(ring.data)))\n .map((ring, position) => ({\n ...ring,\n position,\n value: Math.min(ring.max, Math.max(0, ring.data.value || 0)),\n }))\n}\n\n/**\n * Radius and center that fit the swept ring (plus the text in the middle)\n * into `area`: a dial or half ring is centered by its own outline, not by\n * the full circle it is cut from.\n */\nfunction fitGauge(\n area: { x: number; y: number; width: number; height: number },\n start: number,\n sweep: number,\n textTop: number,\n textBottom: number,\n): { outer: number; cx: number; cy: number } {\n // Points of the outline, in units of the outer radius: both ends of the arc\n // and every axis extreme it passes; the origin covers the inner edge.\n const unit: [number, number][] = [[0, 0]]\n const end = start + sweep\n unit.push([Math.sin(start), -Math.cos(start)], [Math.sin(end), -Math.cos(end)])\n // (At most a full turn of them: a huge start angle is beyond what adding a quarter turn changes.)\n for (let a = Math.ceil(start / HALF_PI) * HALF_PI, n = 0; n < 5 && a <= end + 1e-9; n++) {\n unit.push([Math.sin(a), -Math.cos(a)])\n a += HALF_PI\n }\n let outer = Math.min(area.width, area.height) / 2\n let box = { x0: 0, y0: 0, x1: 0, y1: 0 }\n // The text does not scale with the radius, so converge in a few rounds.\n for (let i = 0; i < 4; i++) {\n box = { x0: 0, y0: textTop, x1: 0, y1: textBottom }\n for (const [x, y] of unit) {\n box.x0 = Math.min(box.x0, x * outer)\n box.x1 = Math.max(box.x1, x * outer)\n box.y0 = Math.min(box.y0, y * outer)\n box.y1 = Math.max(box.y1, y * outer)\n }\n const scale = Math.min(area.width / (box.x1 - box.x0), area.height / (box.y1 - box.y0))\n if (Math.abs(scale - 1) < 1e-3) break\n outer = Math.max(0, outer * scale)\n }\n return {\n outer,\n cx: area.x + (area.width - (box.x1 - box.x0)) / 2 - box.x0,\n cy: area.y + (area.height - (box.y1 - box.y0)) / 2 - box.y0,\n }\n}\n\nfunction renderGauge(options: GaugeOptions, ctx: RenderContext): ChildInput {\n const { width, height, locale } = ctx\n const thickness = Math.max(1, options.thickness ?? 12)\n const gap = Math.max(0, options.gap ?? 4)\n const cornerRadius = options.cornerRadius ?? thickness / 2\n const pad = insets(options.padding, 0)\n const area = innerRect(width, height, {\n top: pad.top + HALO,\n right: pad.right + HALO,\n bottom: pad.bottom + HALO,\n left: pad.left + HALO,\n })\n const start = (options.startAngle ?? 0) * DEG\n const sweep = Math.min(360, Math.max(0, options.angle ?? 360)) * DEG\n const rings = layoutRings(options, ctx.hidden)\n const center = options.center\n const first = rings[0]\n const showCenter = center !== false && first !== undefined\n const centerLabel = showCenter ? (center?.label ?? (first.data.name || undefined)) : undefined\n const { outer, cx, cy } = fitGauge(\n area,\n start,\n sweep,\n showCenter ? -1.4 * ctx.fontSize : 0,\n showCenter ? (centerLabel ? 2 : 0.7) * ctx.fontSize : 0,\n )\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const radii = (ring: Ring, grow = 0) => {\n const r1 = Math.max(0, outer - ring.position * (thickness + gap))\n return { innerRadius: Math.max(0, r1 - thickness - grow), outerRadius: r1 + grow }\n }\n const fraction = (ring: Ring) => (ring.max > 0 ? ring.value / ring.max : 0)\n const geometry = (ring: Ring, grow = 0) => ({\n ...radii(ring, grow),\n startAngle: start,\n endAngle: start + sweep * fraction(ring),\n cornerRadius,\n })\n\n const hitFor = (ring: Ring): Hit => {\n const [x, y] = arcCentroid(geometry(ring))\n const item: HitItem = {\n name: ring.data.name,\n seriesIndex: ring.index,\n value: ring.value,\n text: `${value(ring.value)} (${share.format(fraction(ring))})`,\n x: cx + x,\n y: cy + y,\n }\n if (ring.data.color) item.color = ring.data.color\n return {\n index: ring.position,\n label: ring.data.name,\n title: '',\n x: cx + x,\n area: { x: cx - outer, y: cy - outer, width: outer * 2, height: outer * 2 },\n items: [item],\n seriesIndex: ring.index,\n // The value arc, slightly enlarged.\n mark: { d: arcPathStable(geometry(ring, 2)), x: cx, y: cy },\n }\n }\n\n const interaction: Interaction = {\n count: rings.length,\n hitIndex: (position) => {\n const ring = rings[position]\n return ring ? hitFor(ring) : null\n },\n hitTest(px, py) {\n const r = Math.hypot(px - cx, py - cy)\n const ring = rings.find((ring) => {\n const { innerRadius, outerRadius } = radii(ring, 2)\n return r >= innerRadius && r <= outerRadius\n })\n return ring ? hitFor(ring) : null\n },\n }\n ctx.onHitTest(interaction)\n\n const groups = rings.map((ring) =>\n h(\n 'g',\n groupAttrs(ring.data, ring.index),\n // Each path keeps its arc, so a new value (or a new shape of the gauge)\n // sweeps it around the center (see `sweep`).\n arcNode('tc-gauge-track', { ...geometry(ring), endAngle: start + sweep }),\n arcNode('tc-gauge-arc', geometry(ring)),\n ),\n )\n\n const centerValue = showCenter ? (center?.value ?? share.format(fraction(first))) : ''\n\n return [\n // Rings sit in their own group: the entrance animation transforms it, not the translated parent.\n h(\n 'g',\n { class: 'tc-gauge', style: `transform:translate(${cx}px,${cy}px)` },\n h('g', { class: 'tc-gauge-rings' }, groups),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-gauge-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-gauge-value',\n x: cx,\n y: cy,\n dy: centerLabel ? '0' : '0.35em',\n 'text-anchor': 'middle',\n },\n centerValue,\n ),\n centerLabel &&\n h(\n 'text',\n { class: 'tc-gauge-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n}\n\nfunction gaugeTable(options: GaugeOptions, ctx: RenderContext): DataTable {\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: layoutRings(options, ctx.hidden).map((ring) => [\n ring.data.name,\n value(ring.value),\n share.format(ring.max > 0 ? ring.value / ring.max : 0),\n ]),\n }\n}\n\n/**\n * Gauge (radial bar): progress towards a maximum as an arc on a track, with\n * the share in the middle. Several rings nest from the outside in.\n *\n * ```ts\n * new Chart('#el', { type: gauge, data: 58 })\n * new Chart('#el', { type: gauge, data: { name: 'completed', value: 1392, max: 2400 } })\n * ```\n */\nexport const gauge: ChartType<GaugeOptions> = {\n name: 'gauge',\n clean: cleanData((data) =>\n cleanItems(\n typeof data === 'number' ? [{ name: '', value: data }] : isRecord(data) ? [data] : data,\n ),\n ),\n render: (options, ctx): ChildInput => {\n // Set here, not as the module loads (see pie).\n features.sweep = sweepArcs\n return renderGauge(options, ctx)\n },\n legend: (options) => legendItems(ringsOf(options)),\n table: gaugeTable,\n}\n"],"mappings":";;;;;;;;;;AA2DA,MAAM,UAAU,KAAK,KAAK;AAW1B,SAAS,QAAQ,SAAoC;CACnD,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU,OAAO,CAAC;EAAE,MAAM;EAAI,OAAO;CAAK,CAAC;CAC/D,OAAO,MAAM,QAAQ,IAAI,IAAK,OAAuB,CAAC,IAAiB;AACzE;;AAGA,SAAS,YAAY,SAAuB,QAAqC;CAC/E,MAAM,MAAM,QAAQ,OAAO;CAC3B,OAAO,QAAQ,OAAO,CAAC,CACpB,KAAK,MAAM,WAAW;EAAE;EAAM;EAAO,KAAK,KAAK,OAAO;CAAI,EAAE,CAAC,CAC7D,QAAQ,SAAS,CAAC,OAAO,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAC/C,KAAK,MAAM,cAAc;EACxB,GAAG;EACH;EACA,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC;CAC7D,EAAE;AACN;;;;;;AAOA,SAAS,SACP,MACA,OACA,OACA,SACA,YAC2C;CAG3C,MAAM,OAA2B,CAAC,CAAC,GAAG,CAAC,CAAC;CACxC,MAAM,MAAM,QAAQ;CACpB,KAAK,KAAK,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;CAE9E,KAAK,IAAI,IAAI,KAAK,KAAK,QAAQ,OAAO,IAAI,SAAS,IAAI,GAAG,IAAI,KAAK,KAAK,MAAM,M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charts/heatmap.ts"],"sourcesContent":["import type { ChartType, LegendItem, RenderContext } from '../chart.ts'\nimport { axis, axisSize, bandTicks, thinTicks } from '../components/axis.ts'\nimport { formatNumber, type Locale, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n innerRect,\n insets,\n mirrorSides,\n round,\n} from '../layout.ts'\nimport { band } from '../scales/band.ts'\nimport { extent } from '../scales/extent.ts'\nimport { rectPath } from '../shapes/rect.ts'\nimport { h, type StyleValue } from '../vnode.ts'\nimport {\n type CartesianData,\n type Label,\n labelKey,\n resolveLabels,\n type Series,\n seriesKey,\n seriesLegend,\n seriesTable,\n} from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\n\n/** A band of values drawn in one color, with its own legend entry. */\nexport interface HeatmapRange {\n /** Lowest value in the band (inclusive). Leave it out for \"everything below `to`\". */\n from?: number\n /** Value where the band ends (exclusive). Leave it out on the last band. */\n to?: number\n /**\n * Any CSS color, including `var(--tc-color-3)`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color: string\n /** Legend and tooltip name, e.g. `'High'`. Defaults to the range, e.g. `10–30`. */\n name?: string\n}\n\nexport interface HeatmapOptions {\n /** Columns are the labels, rows are the series (first series on top). */\n data: CartesianData\n /** Value shown with the lightest shade (or the first color). Defaults to the smaller of `0` and the data minimum. */\n min?: number\n /** Value shown with the full color (or the last color). Defaults to the data maximum. */\n max?: number\n /**\n * Discrete bands of values, each in its own color and legend entry (which\n * also hides the band's cells). Takes precedence over `colors` and `colorBy`.\n */\n ranges?: readonly HeatmapRange[]\n /**\n * A continuous scale through two or more colors (any CSS color, including\n * `var(--tc-…)`), from `min` to `max`. For values around a reference\n * point, use two hues with a neutral middle, e.g.\n * `['var(--tc-color-1)', 'var(--tc-grid-color)', 'var(--tc-color-8)']`.\n * Values that could inject CSS are ignored, as for series colors.\n */\n colors?: readonly string[]\n /** Value placed on the middle color of `colors` (e.g. `0` for changes). Defaults to halfway. */\n mid?: number\n /**\n * `'series'` shades every row in its own palette color (with a legend of\n * the rows); `'value'` (the default) uses one hue, `--tc-heat-color`.\n */\n colorBy?: 'value' | 'series'\n /** Space between cells in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the cells. Defaults to `3`. */\n radius?: number\n /** Format of the values (tooltip, table). */\n format?: NumberFormat\n /** Column labels along the bottom. */\n x?: { show?: boolean; format?: (label: Label, index: number) => string }\n /** Row names on the left. */\n y?: { show?: boolean }\n /** Extra space around the grid, in pixels. */\n padding?: InsetsInput\n}\n\n/** Share of the full color at the minimum, so zero still reads as a value, not a gap. */\nconst FLOOR = 0.08\n\nconst EMPTY = 'var(--tc-heat-empty,var(--tc-grid-color))'\n\n/** Cell color at `share` (0…1) of the way from the empty shade to `color`. */\nconst shade = (share: number, color = 'var(--tc-heat-color,var(--tc-color-1))'): string =>\n `color-mix(in oklab,${color} ${round(share * 100)}%,${EMPTY})`\n\n/** Legend key of a range. */\nconst rangeKey = (range: HeatmapRange, index: number): string => range.name ?? `range-${index + 1}`\n\n/** The first range containing `v` (`from` inclusive, `to` exclusive). */\nconst rangeOf = (ranges: readonly HeatmapRange[], v: number): number =>\n ranges.findIndex((r) => (r.from === undefined || v >= r.from) && (r.to === undefined || v < r.to))\n\n/** Color of a palette slot by series index, as the CSS classes would pick it. */\nconst slotColor = (series: Series, index: number): string =>\n series.color ?? (index < 8 ? `var(--tc-color-${index + 1})` : 'var(--tc-color-other)')\n\n/** How one cell is painted: inline style, the tooltip swatch, and whether it is drawn empty. */\ninterface Paint {\n style?: StyleValue\n color: string\n empty?: boolean\n}\n\nfunction renderHeatmap(options: HeatmapOptions, ctx: RenderContext) {\n const { width, height, fontSize, locale } = ctx\n const { gap = 2, radius = 3 } = options\n const labels = resolveLabels(options.data)\n const formatLabel = options.x?.format ?? ((label: Label) => String(label))\n const value = formatNumber(options.format, locale)\n\n // Color domain.\n const all = options.data.series.flatMap((s) => s.values)\n const [dataMin, dataMax] = extent(all) ?? [0, 1]\n const lo = options.min ?? Math.min(0, dataMin)\n const hi = options.max ?? dataMax\n /** Position of a value in the domain, 0…1 (through `mid` for a scale with a middle). */\n const position = (v: number) => {\n const { mid } = options\n let t: number\n if (mid !== undefined && options.colors && lo < mid && mid < hi) {\n t = v <= mid ? ((v - lo) / (mid - lo)) * 0.5 : 0.5 + ((v - mid) / (hi - mid)) * 0.5\n } else {\n t = hi > lo ? (v - lo) / (hi - lo) : v > lo ? 1 : 0\n }\n return Math.min(1, Math.max(0, t))\n }\n const share = (v: number) => FLOOR + (1 - FLOOR) * position(v)\n\n const ranges = options.ranges?.length ? options.ranges : undefined\n const stops = !ranges && options.colors && options.colors.length >= 2 ? options.colors : undefined\n const bySeries = !ranges && !stops && options.colorBy === 'series'\n // Rows hidden from the legend (rows are legend entries when colored by series).\n const rows = bySeries\n ? options.data.series.filter((s) => !ctx.hidden.has(seriesKey(s)))\n : options.data.series\n const slot = (row: Series) => options.data.series.indexOf(row)\n\n /** How the cell of `row` with value `v` is painted in the active color mode. */\n const paint = (v: number, row: Series): Paint => {\n if (ranges) {\n const index = rangeOf(ranges, v)\n const range = ranges[index]\n if (!range || ctx.hidden.has(rangeKey(range, index))) return { color: EMPTY, empty: true }\n return { style: { '--tc-cell-fill': range.color }, color: range.color }\n }\n if (stops) {\n const at = position(v) * (stops.length - 1)\n const k = Math.min(stops.length - 2, Math.floor(at))\n const u = round((at - k) * 100)\n const from = stops[k] as string\n const color =\n u <= 0\n ? from\n : u >= 100\n ? (stops[k + 1] as string)\n : `color-mix(in oklab,${stops[k + 1]} ${u}%,${from})`\n return { style: { '--tc-cell-fill': color }, color }\n }\n const pct = share(v)\n return {\n style: `--tc-heat:${round(pct * 100)}%`,\n color: bySeries ? shade(pct, slotColor(row, slot(row))) : shade(pct),\n }\n }\n\n // Margins for the labels, then one band per column and per row.\n // Right to left, the sides are worked out as their mirror image, then swapped.\n const { rtl } = ctx\n const pad = mirrorSides(insets(options.padding, 0), rtl)\n const showX = options.x?.show !== false && labels.length > 0\n const showY = options.y?.show !== false && rows.length > 0\n const rowTicks = rows.map((s, i) => ({ value: i, position: 0, label: s.name }))\n const left = showY ? axisSize('left', rowTicks, fontSize) : 0\n const bottom = showX ? axisSize('bottom', [{ value: 0, position: 0, label: 'M' }], fontSize) : 0\n // The last column label is centered on its column: what is wider than half a\n // column needs room on the right.\n const lastLabel = showX\n ? estimateTextWidth(\n formatLabel(labels[labels.length - 1] as Label, labels.length - 1),\n fontSize,\n )\n : 0\n const halfColumn = (width - pad.left - pad.right - left) / Math.max(1, labels.length) / 2\n const area = innerRect(\n width,\n height,\n mirrorSides(\n {\n top: pad.top,\n right: pad.right + Math.max(0, Math.ceil(lastLabel / 2 - halfColumn)),\n bottom: pad.bottom + bottom,\n left: pad.left + left,\n },\n rtl,\n ),\n )\n const end = area.x + area.width\n const x = band(\n labels.map((_, i) => i),\n rtl ? [end, area.x] : [area.x, end],\n )\n const y = band(\n rows.map((_, i) => i),\n [area.y, area.y + area.height],\n )\n const cellW = Math.max(0, x.bandwidth - gap)\n const cellH = Math.max(0, y.bandwidth - gap)\n const cellX = (i: number) => x.at(i) + gap / 2\n const cellY = (j: number) => y.at(j) + gap / 2\n const valueAt = (i: number, j: number) => {\n const v = rows[j]?.values[i]\n return v != null && Number.isFinite(v) ? v : null\n }\n\n // One hit per column; every row is an item, the hovered row is active.\n const hitAt = (i: number, row = 0): Hit | null => {\n if (i < 0 || i >= labels.length || rows.length === 0) return null\n const j = Math.max(0, Math.min(rows.length - 1, row))\n const items: HitItem[] = rows.map((s, r) => {\n const v = valueAt(i, r)\n const range = ranges && v !== null ? ranges[rangeOf(ranges, v)] : undefined\n return {\n name: s.name,\n seriesIndex: r,\n value: v,\n // With ranges, the band's name says what the value means.\n text: v === null ? '–' : range?.name ? `${value(v)} · ${range.name}` : value(v),\n x: cellX(i) + cellW / 2,\n y: cellY(r) + cellH / 2,\n box: { x: cellX(i), y: cellY(r), width: cellW, height: cellH },\n color: v === null ? 'var(--tc-grid-color)' : paint(v, s).color,\n }\n })\n return {\n index: i,\n label: labelKey(labels[i] as Label),\n title: formatLabel(labels[i] as Label, i),\n x: cellX(i) + cellW / 2,\n area,\n items,\n seriesIndex: j,\n // A ring just outside the hovered cell.\n mark: {\n d: rectPath(cellX(i) - 2, cellY(j) - 2, cellW + 4, cellH + 4, radius + 2),\n x: 0,\n y: 0,\n },\n }\n }\n\n const interaction: Interaction = {\n count: labels.length,\n reversed: rtl === true,\n hitIndex: (i, row) => hitAt(i, row),\n hitTest(px, py) {\n if (px < area.x || px > area.x + area.width || py < area.y || py > area.y + area.height) {\n return null\n }\n const column = Math.min(labels.length - 1, Math.floor((px - area.x) / (x.step || 1)))\n const i = rtl ? labels.length - 1 - column : column\n const j = Math.min(rows.length - 1, Math.floor((py - area.y) / (y.step || 1)))\n return hitAt(i, j)\n },\n }\n ctx.onHitTest(interaction)\n\n const cells = rows.map((s, j) =>\n h(\n 'g',\n {\n key: seriesKey(s),\n // Colored by series, a row takes its palette slot like any series.\n class: ['tc-heatmap-row', bySeries && ['tc-series', `tc-series-${slot(s) + 1}`]],\n 'data-series': s.name,\n style: bySeries ? { '--tc-series-color': s.color } : undefined,\n },\n labels.map((label, i) => {\n const v = valueAt(i, j)\n const painted = v === null ? undefined : paint(v, s)\n return h('rect', {\n key: labelKey(label),\n class: ['tc-cell', (v === null || painted?.empty) && 'tc-cell-empty'],\n x: round(cellX(i)),\n y: round(cellY(j)),\n width: round(cellW),\n height: round(cellH),\n rx: round(Math.min(radius, cellW / 2, cellH / 2)),\n style: painted?.style,\n })\n }),\n ),\n )\n\n const xTicks = showX\n ? thinTicks(\n bandTicks(x, (_, i) => formatLabel(labels[i] as Label, i)),\n 'bottom',\n fontSize,\n )\n : []\n const yTicks = showY ? bandTicks(y, (_, j) => rows[j]?.name ?? '') : []\n\n return [\n h('g', { class: 'tc-heatmap-cells' }, cells),\n showX && axis({ position: 'bottom', ticks: xTicks, area }),\n showY && axis({ position: rtl ? 'right' : 'left', ticks: yTicks, area }),\n ]\n}\n\n/** Legend: the ranges, or the rows when colored by series; none for a single scale. */\nfunction heatmapLegend(options: HeatmapOptions): LegendItem[] {\n const { ranges } = options\n if (ranges?.length) {\n // The legend is asked with the whole config, so the names follow its locale.\n const value = formatNumber(options.format, (options as { locale?: Locale }).locale)\n return ranges.map((range, index) => ({\n key: rangeKey(range, index),\n name:\n range.name ??\n (range.from === undefined\n ? `< ${value(range.to ?? 0)}`\n : range.to === undefined\n ? `≥ ${value(range.from)}`\n : `${value(range.from)}–${value(range.to)}`),\n index,\n color: range.color,\n }))\n }\n if (options.colors && options.colors.length >= 2) return []\n return options.colorBy === 'series' ? seriesLegend(options.data) : []\n}\n\n/**\n * Heatmap: a grid of cells, one row per series and one column per label,\n * shaded from light to the full color by value (a single hue, so it reads\n * as magnitude). Set the hue with `--tc-heat-color`, or color the cells by\n * `ranges` of values, a `colors` scale (with a `mid` for diverging data),\n * or one palette color per row with `colorBy: 'series'`.\n *\n * ```ts\n * new Chart('#el', {\n * type: heatmap,\n * data: { labels: ['W1', 'W2', 'W3'], series: [{ name: 'Mon', values: [2, 4, 0] }] },\n * })\n * ```\n */\nexport const heatmap: ChartType<HeatmapOptions> = {\n name: 'heatmap',\n clean: cleanData(cleanSeries),\n render: renderHeatmap,\n legend: heatmapLegend,\n valueLabels: { marks: 'cell', format: (options) => options.format },\n // Cells are formatted as in the tooltip: `format` is the value format here, not `y.format`.\n table: (options, ctx, limit) =>\n seriesTable(\n { data: options.data, ...(options.x ? { x: options.x } : {}), y: { format: options.format } },\n ctx,\n limit,\n ),\n}\n"],"mappings":";;;;;;;;;AAqFA,MAAM,QAAQ;AAEd,MAAM,QAAQ;;AAGd,MAAM,SAAS,OAAe,QAAQ,6CACpC,sBAAsB,MAAM,GAAG,MAAM,QAAQ,GAAG,EAAE,IAAI,MAAM;;AAG9D,MAAM,YAAY,OAAqB,UAA0B,MAAM,QAAQ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