@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
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
import { r as formatNumber } from "./format-it1kepFG.js";
|
|
2
|
+
import { i as insets, n as estimateTextWidth, r as innerRect, s as round, t as LINE_HEIGHT } from "./layout-DqAte3H8.js";
|
|
3
|
+
import { a as isRecord, d as text, i as finite, s as list, u as records } from "./clean-CkoQobGv.js";
|
|
4
|
+
import { n as toChartPoint } from "./interaction-En1KlwFO.js";
|
|
5
|
+
import { t as h } from "./vnode-_EMUqysL.js";
|
|
6
|
+
import { n as heatScale, t as EMPTY } from "./heat-Bsqq4zw9.js";
|
|
7
|
+
// src/charts/map-view.ts
|
|
8
|
+
/**
|
|
9
|
+
* A view kept inside the zoom range and the map itself, so the map can never
|
|
10
|
+
* be dragged out of sight; along a side where all of the map fits, it is centered.
|
|
11
|
+
*/
|
|
12
|
+
function fitView(view, layout) {
|
|
13
|
+
const scale = Math.min(layout.max, Math.max(1, finite(view?.scale) ?? 1));
|
|
14
|
+
const unit = layout.k * scale;
|
|
15
|
+
const fit = (at, size, room) => {
|
|
16
|
+
const span = room / unit;
|
|
17
|
+
return span >= size ? (size - span) / 2 : Math.min(size - span, Math.max(0, at ?? 0));
|
|
18
|
+
};
|
|
19
|
+
return unit > 0 ? {
|
|
20
|
+
x: fit(finite(view?.x), layout.mapWidth, layout.width),
|
|
21
|
+
y: fit(finite(view?.y), layout.mapHeight, layout.height),
|
|
22
|
+
scale
|
|
23
|
+
} : {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0,
|
|
26
|
+
scale
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// src/plugins/map.ts
|
|
30
|
+
/** One step of a button, a key or a double click. */
|
|
31
|
+
const ZOOM_STEP = 2;
|
|
32
|
+
const ZOOM_DURATION = 200;
|
|
33
|
+
/**
|
|
34
|
+
* How much one unit of wheel movement magnifies. A pinch on a trackpad comes
|
|
35
|
+
* as a wheel event with `ctrlKey` and much smaller numbers.
|
|
36
|
+
*/
|
|
37
|
+
const WHEEL_SPEED = .002;
|
|
38
|
+
const WHEEL_SPEED_PINCH = .01;
|
|
39
|
+
/** How far a pointer has to move, in pixels, before a press becomes a drag and stops being a click. */
|
|
40
|
+
const DRAG_THRESHOLD = 4;
|
|
41
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
42
|
+
const ICONS = ["M12 5v14M5 12h14", "M5 12h14"];
|
|
43
|
+
/**
|
|
44
|
+
* What makes a map more than a picture: with `zoom` it is magnified with its
|
|
45
|
+
* buttons, the wheel, a double click, a pinch or the `+`, `-` and `0` keys,
|
|
46
|
+
* and dragged around; with `select` a click (or Enter) selects a region. The
|
|
47
|
+
* `map` chart type brings it along, so it needs no import of its own; it
|
|
48
|
+
* keeps no state, the view and the selection live in the options.
|
|
49
|
+
*/
|
|
50
|
+
function mapInteraction() {
|
|
51
|
+
return {
|
|
52
|
+
name: "map",
|
|
53
|
+
install(chart) {
|
|
54
|
+
const host = chart.element;
|
|
55
|
+
if (typeof host.addEventListener !== "function") return {};
|
|
56
|
+
const doc = host.ownerDocument;
|
|
57
|
+
const win = doc.defaultView;
|
|
58
|
+
const options = () => chart.config;
|
|
59
|
+
const isMap = () => chart.config.type.name === "map";
|
|
60
|
+
const zoomOn = () => isMap() && !!options().zoom;
|
|
61
|
+
const layout = () => chart.interaction?.map;
|
|
62
|
+
const svg = () => host.querySelector(":scope > svg.tc-chart");
|
|
63
|
+
/** Whether an event happened on the drawing, not on a control over it. */
|
|
64
|
+
const onMap = (event) => event.target?.closest?.("svg.tc-chart") === svg() && !!svg();
|
|
65
|
+
let frame = 0;
|
|
66
|
+
/** Pointers that are down on the map, with where each was last seen. */
|
|
67
|
+
const pointers = /* @__PURE__ */ new Map();
|
|
68
|
+
/** Whether the pointers that are down have moved the map: the click that ends a drag selects nothing. */
|
|
69
|
+
let dragged = false;
|
|
70
|
+
let controls;
|
|
71
|
+
const addedClass = !host.classList.contains("tc-container");
|
|
72
|
+
const stop = () => win?.cancelAnimationFrame(frame);
|
|
73
|
+
const current = () => {
|
|
74
|
+
const l = layout();
|
|
75
|
+
return l && fitView(options().view, l);
|
|
76
|
+
};
|
|
77
|
+
const setView = (view) => {
|
|
78
|
+
const l = layout();
|
|
79
|
+
if (l) chart.update({ view: fitView(view, l) });
|
|
80
|
+
};
|
|
81
|
+
/** A point of the screen in chart pixels. */
|
|
82
|
+
const toChart = (x, y) => {
|
|
83
|
+
const el = svg();
|
|
84
|
+
const { width, height } = chart.size;
|
|
85
|
+
const p = el ? toChartPoint(el, x, y, width, height) : {
|
|
86
|
+
x: 0,
|
|
87
|
+
y: 0
|
|
88
|
+
};
|
|
89
|
+
return [p.x, p.y];
|
|
90
|
+
};
|
|
91
|
+
/** A point of the screen in the coordinates of the map. */
|
|
92
|
+
const toMapPoint = (x, y) => {
|
|
93
|
+
const l = layout();
|
|
94
|
+
const view = current();
|
|
95
|
+
if (!l || !view) return null;
|
|
96
|
+
const unit = l.k * view.scale;
|
|
97
|
+
const [cx, cy] = toChart(x, y);
|
|
98
|
+
return [view.x + (cx - l.x) / unit, view.y + (cy - l.y) / unit];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Moves to a view over a few frames. The corner and the size of the
|
|
102
|
+
* view change at the same pace, which keeps the point being zoomed at in place.
|
|
103
|
+
*/
|
|
104
|
+
const animateTo = (to) => {
|
|
105
|
+
stop();
|
|
106
|
+
const l = layout();
|
|
107
|
+
const from = current();
|
|
108
|
+
if (!l || !from) return;
|
|
109
|
+
const target = fitView(to, l);
|
|
110
|
+
if (options().animate === false || !win?.requestAnimationFrame || win.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
111
|
+
setView(target);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const start = performance.now();
|
|
115
|
+
const step = (now) => {
|
|
116
|
+
const t = Math.min((now - start) / ZOOM_DURATION, 1);
|
|
117
|
+
const eased = 1 - (1 - t) ** 3;
|
|
118
|
+
const at = (a, b) => a + (b - a) * eased;
|
|
119
|
+
setView({
|
|
120
|
+
x: at(from.x, target.x),
|
|
121
|
+
y: at(from.y, target.y),
|
|
122
|
+
scale: 1 / at(1 / from.scale, 1 / target.scale)
|
|
123
|
+
});
|
|
124
|
+
if (t < 1) frame = win.requestAnimationFrame(step);
|
|
125
|
+
};
|
|
126
|
+
frame = win.requestAnimationFrame(step);
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Magnifies by a factor around a point of the map, which stays where it
|
|
130
|
+
* is on the screen. Without a point, around the middle of the view.
|
|
131
|
+
*/
|
|
132
|
+
const zoomBy = (factor, anchor, animate = false) => {
|
|
133
|
+
const l = layout();
|
|
134
|
+
const view = current();
|
|
135
|
+
if (!l || !view || !(l.k > 0)) return;
|
|
136
|
+
const next = Math.min(l.max, Math.max(1, view.scale * factor));
|
|
137
|
+
const unit = l.k * view.scale;
|
|
138
|
+
const [ax, ay] = anchor ?? [view.x + l.width / unit / 2, view.y + l.height / unit / 2];
|
|
139
|
+
const target = {
|
|
140
|
+
x: ax - (ax - view.x) * view.scale / next,
|
|
141
|
+
y: ay - (ay - view.y) * view.scale / next,
|
|
142
|
+
scale: next
|
|
143
|
+
};
|
|
144
|
+
if (animate) animateTo(target);
|
|
145
|
+
else {
|
|
146
|
+
stop();
|
|
147
|
+
setView(target);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
/** Selects the region of a hit, or takes it out when it is selected. */
|
|
151
|
+
const select = (hit) => {
|
|
152
|
+
const o = options();
|
|
153
|
+
const code = hit?.region;
|
|
154
|
+
if (!isMap() || !o.select || !code) return;
|
|
155
|
+
const selected = [...o.selected ?? []];
|
|
156
|
+
const rest = selected.filter((other) => other !== code);
|
|
157
|
+
const next = rest.length < selected.length ? rest : o.select === "multiple" ? [...selected, code] : [code];
|
|
158
|
+
chart.update({ selected: next });
|
|
159
|
+
o.onSelect?.(next, code);
|
|
160
|
+
};
|
|
161
|
+
const onPointerEnd = (event) => {
|
|
162
|
+
pointers.delete(event.pointerId);
|
|
163
|
+
if (pointers.size === 0) {
|
|
164
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
165
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
166
|
+
if (dragged) chart.update({});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const onPointerDown = (event) => {
|
|
170
|
+
if (!zoomOn() || !onMap(event) || event.pointerType === "mouse" && event.button !== 0) return;
|
|
171
|
+
if (pointers.size === 0) dragged = false;
|
|
172
|
+
pointers.set(event.pointerId, [event.clientX, event.clientY]);
|
|
173
|
+
stop();
|
|
174
|
+
doc.addEventListener("pointerup", onPointerEnd);
|
|
175
|
+
doc.addEventListener("pointercancel", onPointerEnd);
|
|
176
|
+
};
|
|
177
|
+
/** One pointer drags the map, two pinch it. */
|
|
178
|
+
const onPointerMove = (event) => {
|
|
179
|
+
const previous = pointers.get(event.pointerId);
|
|
180
|
+
const view = current();
|
|
181
|
+
const l = layout();
|
|
182
|
+
if (!previous || !view || !l) return;
|
|
183
|
+
const now = [event.clientX, event.clientY];
|
|
184
|
+
if (!dragged) {
|
|
185
|
+
if (pointers.size === 1 && Math.hypot(now[0] - previous[0], now[1] - previous[1]) < DRAG_THRESHOLD) return;
|
|
186
|
+
dragged = true;
|
|
187
|
+
try {
|
|
188
|
+
svg()?.setPointerCapture(event.pointerId);
|
|
189
|
+
} catch {}
|
|
190
|
+
}
|
|
191
|
+
event.stopPropagation();
|
|
192
|
+
chart.clearHighlight();
|
|
193
|
+
pointers.set(event.pointerId, now);
|
|
194
|
+
if (pointers.size === 1) {
|
|
195
|
+
const unit = l.k * view.scale;
|
|
196
|
+
const [x0, y0] = toChart(previous[0], previous[1]);
|
|
197
|
+
const [x1, y1] = toChart(now[0], now[1]);
|
|
198
|
+
setView({
|
|
199
|
+
x: view.x - (x1 - x0) / unit,
|
|
200
|
+
y: view.y - (y1 - y0) / unit,
|
|
201
|
+
scale: view.scale
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const other = [...pointers].find(([id]) => id !== event.pointerId)?.[1];
|
|
206
|
+
if (!other) return;
|
|
207
|
+
const before = Math.hypot(previous[0] - other[0], previous[1] - other[1]);
|
|
208
|
+
const after = Math.hypot(now[0] - other[0], now[1] - other[1]);
|
|
209
|
+
if (before > 0 && after > 0) zoomBy(after / before, toMapPoint((now[0] + other[0]) / 2, (now[1] + other[1]) / 2));
|
|
210
|
+
};
|
|
211
|
+
const onWheel = (event) => {
|
|
212
|
+
const { zoom } = options();
|
|
213
|
+
if (!zoomOn() || typeof zoom === "object" && zoom.wheel === false || !onMap(event)) return;
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
zoomBy(Math.exp(-event.deltaY * (event.ctrlKey ? WHEEL_SPEED_PINCH : WHEEL_SPEED)), toMapPoint(event.clientX, event.clientY));
|
|
216
|
+
};
|
|
217
|
+
const onDoubleClick = (event) => {
|
|
218
|
+
if (zoomOn() && onMap(event)) zoomBy(ZOOM_STEP, toMapPoint(event.clientX, event.clientY), true);
|
|
219
|
+
};
|
|
220
|
+
/** The click that ends a drag is not a click on the map. */
|
|
221
|
+
const onClickCapture = (event) => {
|
|
222
|
+
if (dragged) event.stopPropagation();
|
|
223
|
+
dragged = false;
|
|
224
|
+
};
|
|
225
|
+
const onKey = (event) => {
|
|
226
|
+
if (event.target !== svg() || !isMap()) return;
|
|
227
|
+
const { key } = event;
|
|
228
|
+
if (zoomOn() && (key === "+" || key === "=")) zoomBy(ZOOM_STEP, null, true);
|
|
229
|
+
else if (zoomOn() && key === "-") zoomBy(1 / ZOOM_STEP, null, true);
|
|
230
|
+
else if (zoomOn() && key === "0") animateTo({
|
|
231
|
+
x: 0,
|
|
232
|
+
y: 0,
|
|
233
|
+
scale: 1
|
|
234
|
+
});
|
|
235
|
+
else if (options().select && (key === "Enter" || key === " ") && chart.active) select(chart.active);
|
|
236
|
+
else return;
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
};
|
|
239
|
+
const onControl = (event) => {
|
|
240
|
+
const button = event.target.closest("button");
|
|
241
|
+
if (button) zoomBy(button.value === "in" ? ZOOM_STEP : 1 / ZOOM_STEP, null, true);
|
|
242
|
+
};
|
|
243
|
+
host.addEventListener("pointermove", onPointerMove, true);
|
|
244
|
+
host.addEventListener("click", onClickCapture, true);
|
|
245
|
+
host.addEventListener("pointerdown", onPointerDown);
|
|
246
|
+
host.addEventListener("wheel", onWheel, { passive: false });
|
|
247
|
+
host.addEventListener("dblclick", onDoubleClick);
|
|
248
|
+
host.addEventListener("keydown", onKey);
|
|
249
|
+
const off = chart.on("click", ({ hit }) => select(hit));
|
|
250
|
+
/** The zoom buttons, laid over a corner of the map. */
|
|
251
|
+
const renderControls = () => {
|
|
252
|
+
if (!zoomOn()) {
|
|
253
|
+
controls?.remove();
|
|
254
|
+
controls = void 0;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (!controls) {
|
|
258
|
+
controls = doc.createElement("div");
|
|
259
|
+
controls.className = "tc-map-zoom";
|
|
260
|
+
for (const [i, d] of ICONS.entries()) {
|
|
261
|
+
const button = doc.createElement("button");
|
|
262
|
+
button.type = "button";
|
|
263
|
+
button.className = "tc-download-toggle";
|
|
264
|
+
button.value = i ? "out" : "in";
|
|
265
|
+
const icon = doc.createElementNS(SVG_NS, "svg");
|
|
266
|
+
icon.setAttribute("viewBox", "0 0 24 24");
|
|
267
|
+
icon.setAttribute("width", "16");
|
|
268
|
+
icon.setAttribute("height", "16");
|
|
269
|
+
icon.setAttribute("aria-hidden", "true");
|
|
270
|
+
const path = doc.createElementNS(SVG_NS, "path");
|
|
271
|
+
path.setAttribute("d", d);
|
|
272
|
+
icon.append(path);
|
|
273
|
+
button.append(icon);
|
|
274
|
+
controls.append(button);
|
|
275
|
+
}
|
|
276
|
+
controls.addEventListener("click", onControl);
|
|
277
|
+
host.classList.add("tc-container");
|
|
278
|
+
}
|
|
279
|
+
if (!controls.isConnected) host.append(controls);
|
|
280
|
+
const { zoom } = options();
|
|
281
|
+
const labels = typeof zoom === "object" ? zoom.labels : void 0;
|
|
282
|
+
const view = current();
|
|
283
|
+
const max = layout()?.max ?? 1;
|
|
284
|
+
const [zoomIn, zoomOut] = controls.querySelectorAll("button");
|
|
285
|
+
if (zoomIn && zoomOut && view) {
|
|
286
|
+
zoomIn.setAttribute("aria-label", labels?.in ?? "Zoom in");
|
|
287
|
+
zoomOut.setAttribute("aria-label", labels?.out ?? "Zoom out");
|
|
288
|
+
zoomIn.disabled = view.scale >= max;
|
|
289
|
+
zoomOut.disabled = view.scale <= 1;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
return {
|
|
293
|
+
svgAttrs: () => zoomOn() ? { "data-zoom": dragged && pointers.size ? "drag" : "" } : void 0,
|
|
294
|
+
afterRender: renderControls,
|
|
295
|
+
destroy() {
|
|
296
|
+
stop();
|
|
297
|
+
off();
|
|
298
|
+
host.removeEventListener("pointermove", onPointerMove, true);
|
|
299
|
+
host.removeEventListener("click", onClickCapture, true);
|
|
300
|
+
host.removeEventListener("pointerdown", onPointerDown);
|
|
301
|
+
host.removeEventListener("wheel", onWheel);
|
|
302
|
+
host.removeEventListener("dblclick", onDoubleClick);
|
|
303
|
+
host.removeEventListener("keydown", onKey);
|
|
304
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
305
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
306
|
+
controls?.remove();
|
|
307
|
+
if (controls && addedClass) host.classList.remove("tc-container");
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// src/charts/map.ts
|
|
314
|
+
/** The selected regions of the options that are allowed: one when only one can be selected. */
|
|
315
|
+
const selectedOf = (options) => options.select === "multiple" ? options.selected ?? [] : options.select === "single" ? (options.selected ?? []).slice(0, 1) : [];
|
|
316
|
+
/** Share of the full color at the minimum, so the lowest value still stands out from a region without one. */
|
|
317
|
+
const FLOOR = .1;
|
|
318
|
+
const MARKER = "var(--tc-map-marker-color,var(--tc-color-1))";
|
|
319
|
+
/** Slices of the scale's bar: enough to read as one smooth gradient. */
|
|
320
|
+
const SCALE_STEPS = 24;
|
|
321
|
+
const SCALE_STEP = 5;
|
|
322
|
+
const SCALE_HEIGHT = 8;
|
|
323
|
+
/** How far a line bends away from the straight one, as a share of its length. */
|
|
324
|
+
const LINE_CURVE = .2;
|
|
325
|
+
const RADIANS = Math.PI / 180;
|
|
326
|
+
const maps = {};
|
|
327
|
+
/** Register a map under a name, so `map: 'world'` finds it (configs from JSON, `<tabler-chart>`, the data API). */
|
|
328
|
+
function addMap(name, data) {
|
|
329
|
+
maps[name] = data;
|
|
330
|
+
}
|
|
331
|
+
const isMap = (v) => isRecord(v) && isRecord(v.regions) && (finite(v.width) ?? 0) > 0 && (finite(v.height) ?? 0) > 0;
|
|
332
|
+
/** Rings of path data made of moves and straight lines. */
|
|
333
|
+
function parsePath(d) {
|
|
334
|
+
const rings = [];
|
|
335
|
+
let ring = [];
|
|
336
|
+
let x = 0;
|
|
337
|
+
let y = 0;
|
|
338
|
+
for (const [, command = "", args = ""] of d.matchAll(/([MLHVZ])([^MLHVZ]*)/gi)) {
|
|
339
|
+
const n = (args.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi) ?? []).map(Number);
|
|
340
|
+
const relative = command >= "a";
|
|
341
|
+
const type = command.toUpperCase();
|
|
342
|
+
if (type === "Z") {
|
|
343
|
+
if (ring.length) {
|
|
344
|
+
x = ring[0];
|
|
345
|
+
y = ring[1];
|
|
346
|
+
}
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const step = type === "H" || type === "V" ? 1 : 2;
|
|
350
|
+
for (let i = 0; i + step <= n.length; i += step) {
|
|
351
|
+
const a = n[i];
|
|
352
|
+
const b = n[i + 1];
|
|
353
|
+
if (type === "H") x = relative ? x + a : a;
|
|
354
|
+
else if (type === "V") y = relative ? y + a : a;
|
|
355
|
+
else {
|
|
356
|
+
x = relative ? x + a : a;
|
|
357
|
+
y = relative ? y + b : b;
|
|
358
|
+
}
|
|
359
|
+
if (type === "M" && i === 0) {
|
|
360
|
+
ring = [];
|
|
361
|
+
rings.push(ring);
|
|
362
|
+
}
|
|
363
|
+
ring.push(x, y);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return rings;
|
|
367
|
+
}
|
|
368
|
+
const parsed = /* @__PURE__ */ new WeakMap();
|
|
369
|
+
/** The regions of a map, parsed once per map file. */
|
|
370
|
+
function shapesOf(map) {
|
|
371
|
+
let shapes = parsed.get(map);
|
|
372
|
+
if (shapes) return shapes;
|
|
373
|
+
shapes = /* @__PURE__ */ new Map();
|
|
374
|
+
for (const [code, region] of Object.entries(map.regions)) {
|
|
375
|
+
if (!isRecord(region) || typeof region.path !== "string") continue;
|
|
376
|
+
const rings = parsePath(region.path).filter((ring) => ring.every(Number.isFinite));
|
|
377
|
+
const box = [
|
|
378
|
+
Number.POSITIVE_INFINITY,
|
|
379
|
+
Number.POSITIVE_INFINITY,
|
|
380
|
+
Number.NEGATIVE_INFINITY,
|
|
381
|
+
Number.NEGATIVE_INFINITY
|
|
382
|
+
];
|
|
383
|
+
let x = 0;
|
|
384
|
+
let y = 0;
|
|
385
|
+
let largest = -1;
|
|
386
|
+
for (const ring of rings) {
|
|
387
|
+
let x0 = Number.POSITIVE_INFINITY;
|
|
388
|
+
let y0 = Number.POSITIVE_INFINITY;
|
|
389
|
+
let x1 = Number.NEGATIVE_INFINITY;
|
|
390
|
+
let y1 = Number.NEGATIVE_INFINITY;
|
|
391
|
+
for (let i = 0; i < ring.length; i += 2) {
|
|
392
|
+
x0 = Math.min(x0, ring[i]);
|
|
393
|
+
x1 = Math.max(x1, ring[i]);
|
|
394
|
+
y0 = Math.min(y0, ring[i + 1]);
|
|
395
|
+
y1 = Math.max(y1, ring[i + 1]);
|
|
396
|
+
}
|
|
397
|
+
box[0] = Math.min(box[0], x0);
|
|
398
|
+
box[1] = Math.min(box[1], y0);
|
|
399
|
+
box[2] = Math.max(box[2], x1);
|
|
400
|
+
box[3] = Math.max(box[3], y1);
|
|
401
|
+
const size = (x1 - x0) * (y1 - y0);
|
|
402
|
+
if (size > largest) {
|
|
403
|
+
largest = size;
|
|
404
|
+
x = (x0 + x1) / 2;
|
|
405
|
+
y = (y0 + y1) / 2;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (largest < 0) continue;
|
|
409
|
+
shapes.set(code, {
|
|
410
|
+
code,
|
|
411
|
+
name: text(region.name) || code,
|
|
412
|
+
path: region.path,
|
|
413
|
+
point: region.point === true,
|
|
414
|
+
rings,
|
|
415
|
+
box,
|
|
416
|
+
x,
|
|
417
|
+
y
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
parsed.set(map, shapes);
|
|
421
|
+
return shapes;
|
|
422
|
+
}
|
|
423
|
+
/** Whether a point lies inside the rings (even-odd, so a hole is outside). */
|
|
424
|
+
function inside(rings, x, y) {
|
|
425
|
+
let hit = false;
|
|
426
|
+
for (const ring of rings) for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {
|
|
427
|
+
const xi = ring[i];
|
|
428
|
+
const yi = ring[i + 1];
|
|
429
|
+
const xj = ring[j];
|
|
430
|
+
const yj = ring[j + 1];
|
|
431
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) hit = !hit;
|
|
432
|
+
}
|
|
433
|
+
return hit;
|
|
434
|
+
}
|
|
435
|
+
/** Path of a circle, for the ring around a hovered dot. */
|
|
436
|
+
const circlePath = (x, y, r) => `M${round(x - r)} ${round(y)}a${r} ${r} 0 1 0 ${r * 2} 0a${r} ${r} 0 1 0 ${-r * 2} 0Z`;
|
|
437
|
+
function renderMap(options, ctx) {
|
|
438
|
+
const { width, height, fontSize, locale } = ctx;
|
|
439
|
+
if (typeof options.map === "string" && !maps[options.map]) throw new Error(`[tabler-charts] Map "${options.map}" is not registered. Import it (e.g. from '@tabler/charts/maps/world') and call addMap('${options.map}', data).`);
|
|
440
|
+
const map = typeof options.map === "string" ? maps[options.map] : options.map;
|
|
441
|
+
if (!isMap(map)) return { content: null };
|
|
442
|
+
const shapes = shapesOf(map);
|
|
443
|
+
const data = options.data ?? {};
|
|
444
|
+
const value = formatNumber(options.format, locale);
|
|
445
|
+
const radius = Math.max(0, finite(options.markerRadius) ?? 4);
|
|
446
|
+
const entries = [];
|
|
447
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
448
|
+
let dataMin = Number.POSITIVE_INFINITY;
|
|
449
|
+
let dataMax = Number.NEGATIVE_INFINITY;
|
|
450
|
+
for (const code of Object.keys(data)) {
|
|
451
|
+
const shape = shapes.get(code);
|
|
452
|
+
const v = finite(data[code]);
|
|
453
|
+
if (!shape || v === null) continue;
|
|
454
|
+
indexOf.set(shape, entries.length);
|
|
455
|
+
entries.push({
|
|
456
|
+
shape,
|
|
457
|
+
value: v
|
|
458
|
+
});
|
|
459
|
+
if (v < dataMin) dataMin = v;
|
|
460
|
+
if (v > dataMax) dataMax = v;
|
|
461
|
+
}
|
|
462
|
+
const valued = entries.length;
|
|
463
|
+
const lo = finite(options.min) ?? (valued ? Math.min(0, dataMin) : 0);
|
|
464
|
+
const hi = finite(options.max) ?? (valued ? dataMax : 1);
|
|
465
|
+
const stops = options.colors && options.colors.length >= 2 ? options.colors : void 0;
|
|
466
|
+
const mid = finite(options.mid);
|
|
467
|
+
const { position, paint } = heatScale(lo, hi, mid, stops, FLOOR);
|
|
468
|
+
const pad = insets(options.padding, 0);
|
|
469
|
+
const scale = options.scale !== false && valued > 0;
|
|
470
|
+
const scaleHeight = scale ? Math.ceil(fontSize * LINE_HEIGHT) + 8 : 0;
|
|
471
|
+
const area = innerRect(width, height, {
|
|
472
|
+
...pad,
|
|
473
|
+
bottom: pad.bottom + scaleHeight
|
|
474
|
+
});
|
|
475
|
+
const zoom = typeof options.zoom === "object" ? options.zoom : {};
|
|
476
|
+
const layout = {
|
|
477
|
+
...area,
|
|
478
|
+
k: Math.max(0, Math.min(area.width / map.width, area.height / map.height)),
|
|
479
|
+
mapWidth: map.width,
|
|
480
|
+
mapHeight: map.height,
|
|
481
|
+
max: Math.max(1, finite(zoom.max) ?? 8)
|
|
482
|
+
};
|
|
483
|
+
const view = fitView(options.view, layout);
|
|
484
|
+
const k = Math.round(layout.k * view.scale * 1e4) / 1e4;
|
|
485
|
+
const tx = round(area.x - view.x * k);
|
|
486
|
+
const ty = round(area.y - view.y * k);
|
|
487
|
+
const px = (x) => tx + x * k;
|
|
488
|
+
const py = (y) => ty + y * k;
|
|
489
|
+
const clipped = view.scale > 1;
|
|
490
|
+
const selected = new Set(selectedOf(options));
|
|
491
|
+
const { projection } = map;
|
|
492
|
+
const project = isRecord(projection) && finite(projection.scale) !== null && Array.isArray(projection.translate) && projection.translate.slice(0, 2).every((n) => finite(n) !== null) ? (lng, lat) => [px(lng * RADIANS * projection.scale + projection.translate[0]), py(projection.translate[1] - 1.25 * Math.log(Math.tan(Math.PI / 4 + .4 * lat * RADIANS)) * projection.scale)] : void 0;
|
|
493
|
+
const markers = [];
|
|
494
|
+
if (project && k > 0) for (const marker of options.markers ?? []) {
|
|
495
|
+
const [x, y] = project(marker.lng, marker.lat);
|
|
496
|
+
if (Number.isFinite(x) && Number.isFinite(y)) markers.push({
|
|
497
|
+
name: marker.name ?? "",
|
|
498
|
+
x,
|
|
499
|
+
y
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const firstMarker = entries.length;
|
|
503
|
+
for (const marker of markers) entries.push({
|
|
504
|
+
marker,
|
|
505
|
+
value: null
|
|
506
|
+
});
|
|
507
|
+
const count = entries.length;
|
|
508
|
+
for (const shape of shapes.values()) {
|
|
509
|
+
if (shape.point || indexOf.has(shape)) continue;
|
|
510
|
+
indexOf.set(shape, entries.length);
|
|
511
|
+
entries.push({
|
|
512
|
+
shape,
|
|
513
|
+
value: null
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
const hitAt = (i) => {
|
|
517
|
+
const entry = entries[i];
|
|
518
|
+
if (!entry) return null;
|
|
519
|
+
const { shape, marker } = entry;
|
|
520
|
+
const dot = marker ?? (shape?.point ? {
|
|
521
|
+
x: px(shape.x),
|
|
522
|
+
y: py(shape.y)
|
|
523
|
+
} : void 0);
|
|
524
|
+
const x = dot?.x ?? px(shape?.x ?? 0);
|
|
525
|
+
const y = dot?.y ?? py(shape?.y ?? 0);
|
|
526
|
+
const name = marker?.name ?? shape?.name ?? "";
|
|
527
|
+
const v = entry.value;
|
|
528
|
+
return {
|
|
529
|
+
index: i,
|
|
530
|
+
label: shape?.code ?? name,
|
|
531
|
+
...shape ? { region: shape.code } : { marker: name },
|
|
532
|
+
title: "",
|
|
533
|
+
x,
|
|
534
|
+
area,
|
|
535
|
+
items: [{
|
|
536
|
+
name,
|
|
537
|
+
seriesIndex: 0,
|
|
538
|
+
value: v,
|
|
539
|
+
text: v === null ? "" : value(v),
|
|
540
|
+
x,
|
|
541
|
+
y,
|
|
542
|
+
color: marker ? MARKER : v === null ? EMPTY : paint(position(v)).color
|
|
543
|
+
}],
|
|
544
|
+
highlight: {
|
|
545
|
+
kind: "halo",
|
|
546
|
+
d: dot ? circlePath(dot.x, dot.y, radius + 3) : (shape?.rings ?? []).map((ring) => {
|
|
547
|
+
let d = "";
|
|
548
|
+
for (let p = 0; p < ring.length; p += 2) d += `${p ? "L" : "M"}${Math.round(px(ring[p]) * 10) / 10} ${Math.round(py(ring[p + 1]) * 10) / 10}`;
|
|
549
|
+
return `${d}Z`;
|
|
550
|
+
}).join("")
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
const interaction = {
|
|
555
|
+
count,
|
|
556
|
+
map: layout,
|
|
557
|
+
hitIndex: hitAt,
|
|
558
|
+
hitTest(x, y) {
|
|
559
|
+
if (!(k > 0)) return null;
|
|
560
|
+
if (x < area.x || x > area.x + area.width || y < area.y || y > area.y + area.height) return null;
|
|
561
|
+
const near = (dot) => Math.hypot(dot.x - x, dot.y - y) <= radius + 4;
|
|
562
|
+
for (let i = count - 1; i >= firstMarker; i--) if (near(entries[i]?.marker)) return hitAt(i);
|
|
563
|
+
for (let i = 0; i < valued; i++) {
|
|
564
|
+
const shape = entries[i]?.shape;
|
|
565
|
+
if (shape.point && near({
|
|
566
|
+
x: px(shape.x),
|
|
567
|
+
y: py(shape.y)
|
|
568
|
+
})) return hitAt(i);
|
|
569
|
+
}
|
|
570
|
+
const mx = (x - tx) / k;
|
|
571
|
+
const my = (y - ty) / k;
|
|
572
|
+
for (const [shape, i] of indexOf) {
|
|
573
|
+
const [x0, y0, x1, y1] = shape.box;
|
|
574
|
+
if (shape.point || mx < x0 || mx > x1 || my < y0 || my > y1) continue;
|
|
575
|
+
if (inside(shape.rings, mx, my)) return hitAt(i);
|
|
576
|
+
}
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const regions = [];
|
|
581
|
+
const raised = [];
|
|
582
|
+
const points = [];
|
|
583
|
+
for (const shape of shapes.values()) {
|
|
584
|
+
const i = indexOf.get(shape);
|
|
585
|
+
const v = i === void 0 ? null : entries[i]?.value ?? null;
|
|
586
|
+
const style = v === null ? void 0 : paint(position(v)).style;
|
|
587
|
+
const chosen = selected.has(shape.code) && "tc-region-selected";
|
|
588
|
+
if (!shape.point) (chosen ? raised : regions).push(h("path", {
|
|
589
|
+
key: shape.code,
|
|
590
|
+
class: [
|
|
591
|
+
"tc-region",
|
|
592
|
+
v === null ? "tc-region-empty" : "tc-cell",
|
|
593
|
+
chosen
|
|
594
|
+
],
|
|
595
|
+
"data-region": shape.code,
|
|
596
|
+
d: shape.path,
|
|
597
|
+
style
|
|
598
|
+
}));
|
|
599
|
+
else if (v !== null) points.push(h("circle", {
|
|
600
|
+
key: shape.code,
|
|
601
|
+
class: ["tc-region tc-region-point tc-cell", chosen],
|
|
602
|
+
"data-region": shape.code,
|
|
603
|
+
cx: round(px(shape.x)),
|
|
604
|
+
cy: round(py(shape.y)),
|
|
605
|
+
r: radius,
|
|
606
|
+
style
|
|
607
|
+
}));
|
|
608
|
+
}
|
|
609
|
+
const byName = new Map(markers.map((marker) => [marker.name, marker]));
|
|
610
|
+
const lines = (options.lines ?? []).flatMap((line, i) => {
|
|
611
|
+
const from = byName.get(line.from);
|
|
612
|
+
const to = byName.get(line.to);
|
|
613
|
+
if (!from || !to) return [];
|
|
614
|
+
const cx = (from.x + to.x) / 2 + (to.y - from.y) * LINE_CURVE;
|
|
615
|
+
const cy = (from.y + to.y) / 2 - (to.x - from.x) * LINE_CURVE;
|
|
616
|
+
return h("path", {
|
|
617
|
+
key: `${line.from}›${line.to}›${i}`,
|
|
618
|
+
class: "tc-map-line",
|
|
619
|
+
d: `M${round(from.x)} ${round(from.y)}Q${round(cx)} ${round(cy)} ${round(to.x)} ${round(to.y)}`
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
const scaleText = typeof options.scale === "object" ? options.scale : {};
|
|
623
|
+
const low = scaleText.low ?? value(lo);
|
|
624
|
+
const high = scaleText.high ?? value(hi);
|
|
625
|
+
const lowWidth = estimateTextWidth(low, fontSize);
|
|
626
|
+
const barWidth = 120;
|
|
627
|
+
const scaleWidth = lowWidth + 8 + barWidth + 8 + estimateTextWidth(high, fontSize);
|
|
628
|
+
const scaleX = Math.round(area.x + Math.max(0, (area.width - scaleWidth) / 2));
|
|
629
|
+
const barX = Math.round(scaleX + lowWidth + 8);
|
|
630
|
+
const scaleY = area.y + area.height + 8 + (scaleHeight - 8) / 2;
|
|
631
|
+
const selectable = options.select === "single" || options.select === "multiple";
|
|
632
|
+
const clip = `${ctx.id}-map`;
|
|
633
|
+
return {
|
|
634
|
+
content: [
|
|
635
|
+
clipped && h("clipPath", {
|
|
636
|
+
key: "clip",
|
|
637
|
+
id: clip
|
|
638
|
+
}, h("rect", {
|
|
639
|
+
x: area.x,
|
|
640
|
+
y: area.y,
|
|
641
|
+
width: area.width,
|
|
642
|
+
height: area.height
|
|
643
|
+
})),
|
|
644
|
+
h("g", {
|
|
645
|
+
key: "map",
|
|
646
|
+
class: ["tc-map", selectable && "tc-map-selectable"],
|
|
647
|
+
"clip-path": clipped ? `url(#${clip})` : void 0
|
|
648
|
+
}, k > 0 && h("g", {
|
|
649
|
+
key: "regions",
|
|
650
|
+
class: "tc-map-regions",
|
|
651
|
+
transform: `translate(${tx} ${ty}) scale(${k})`
|
|
652
|
+
}, regions, raised), h("g", {
|
|
653
|
+
key: "points",
|
|
654
|
+
class: "tc-map-points"
|
|
655
|
+
}, points), h("g", {
|
|
656
|
+
key: "lines",
|
|
657
|
+
class: "tc-map-lines"
|
|
658
|
+
}, lines), h("g", {
|
|
659
|
+
key: "markers",
|
|
660
|
+
class: "tc-map-markers"
|
|
661
|
+
}, markers.map((marker, i) => h("circle", {
|
|
662
|
+
key: `${marker.name}›${i}`,
|
|
663
|
+
class: "tc-map-marker",
|
|
664
|
+
"data-marker": marker.name,
|
|
665
|
+
cx: round(marker.x),
|
|
666
|
+
cy: round(marker.y),
|
|
667
|
+
r: radius
|
|
668
|
+
})))),
|
|
669
|
+
scale && h("g", {
|
|
670
|
+
key: "scale",
|
|
671
|
+
class: "tc-map-scale",
|
|
672
|
+
"aria-hidden": "true",
|
|
673
|
+
"shape-rendering": "crispEdges"
|
|
674
|
+
}, h("text", {
|
|
675
|
+
class: "tc-tick-label",
|
|
676
|
+
x: scaleX,
|
|
677
|
+
y: round(scaleY),
|
|
678
|
+
dy: "0.32em"
|
|
679
|
+
}, low), Array.from({ length: SCALE_STEPS }, (_, s) => h("rect", {
|
|
680
|
+
key: s,
|
|
681
|
+
class: "tc-cell",
|
|
682
|
+
x: barX + s * SCALE_STEP,
|
|
683
|
+
y: round(scaleY - SCALE_HEIGHT / 2),
|
|
684
|
+
width: SCALE_STEP,
|
|
685
|
+
height: SCALE_HEIGHT,
|
|
686
|
+
style: paint(s / 23).style
|
|
687
|
+
})), h("text", {
|
|
688
|
+
class: "tc-tick-label",
|
|
689
|
+
x: barX + barWidth + 8,
|
|
690
|
+
y: round(scaleY),
|
|
691
|
+
dy: "0.32em"
|
|
692
|
+
}, high))
|
|
693
|
+
],
|
|
694
|
+
interaction
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
/** Table: one row per region with a value, in the order of the data. */
|
|
698
|
+
function mapTable(options, ctx, limit) {
|
|
699
|
+
const map = typeof options.map === "string" ? maps[options.map] : options.map;
|
|
700
|
+
const shapes = isMap(map) ? shapesOf(map) : void 0;
|
|
701
|
+
const value = formatNumber(options.format, ctx.locale);
|
|
702
|
+
const rows = [];
|
|
703
|
+
for (const [code, raw] of Object.entries(options.data ?? {})) {
|
|
704
|
+
const v = finite(raw);
|
|
705
|
+
const shape = shapes?.get(code);
|
|
706
|
+
if (shape && v !== null) rows.push([shape.name, value(v)]);
|
|
707
|
+
}
|
|
708
|
+
return {
|
|
709
|
+
columns: ["", "Value"],
|
|
710
|
+
total: rows.length,
|
|
711
|
+
rows: rows.slice(0, limit)
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
/** Width to height of the map with its scale at a usual size, so the map fills the chart. */
|
|
715
|
+
function ratioOf(options) {
|
|
716
|
+
const map = typeof options.map === "string" ? maps[options.map] : options.map;
|
|
717
|
+
if (!isMap(map)) return void 0;
|
|
718
|
+
const scale = options.scale !== false && Object.keys(options.data ?? {}).length > 0;
|
|
719
|
+
return round(600 / (600 * map.height / map.width + (scale ? 23 : 0)));
|
|
720
|
+
}
|
|
721
|
+
/** Values that are finite numbers, markers with real coordinates, lines and colors that are text. */
|
|
722
|
+
const cleanMap = (options) => {
|
|
723
|
+
const o = options;
|
|
724
|
+
const data = {};
|
|
725
|
+
if (isRecord(o.data)) for (const [code, v] of Object.entries(o.data)) {
|
|
726
|
+
const n = finite(v);
|
|
727
|
+
if (n !== null) data[code] = n;
|
|
728
|
+
}
|
|
729
|
+
return {
|
|
730
|
+
...options,
|
|
731
|
+
map: typeof o.map === "string" || isMap(o.map) ? o.map : void 0,
|
|
732
|
+
data,
|
|
733
|
+
colors: list(o.colors).filter((c) => typeof c === "string" && c.trim() !== ""),
|
|
734
|
+
markers: records(o.markers, (m) => ({
|
|
735
|
+
lat: finite(m.lat),
|
|
736
|
+
lng: finite(m.lng),
|
|
737
|
+
...typeof m.name === "string" ? { name: m.name } : {}
|
|
738
|
+
})).filter((m) => m.lat !== null && m.lng !== null),
|
|
739
|
+
lines: records(o.lines, (l) => ({
|
|
740
|
+
from: text(l.from),
|
|
741
|
+
to: text(l.to)
|
|
742
|
+
})),
|
|
743
|
+
select: o.select === "single" || o.select === "multiple" ? o.select : void 0,
|
|
744
|
+
selected: list(o.selected).filter((code) => typeof code === "string"),
|
|
745
|
+
view: isRecord(o.view) ? o.view : void 0,
|
|
746
|
+
onSelect: typeof o.onSelect === "function" ? o.onSelect : void 0
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Map: the regions of a map file as SVG shapes, shaded by value from the
|
|
751
|
+
* empty shade to the full color (`--tc-heat-color`, the cells of the
|
|
752
|
+
* heatmap) or through a scale of `colors`, with markers placed by their
|
|
753
|
+
* coordinates, lines between them and a bar of the scale. The shapes come
|
|
754
|
+
* projected from the map file, so no geo library ships to the browser.
|
|
755
|
+
*
|
|
756
|
+
* ```ts
|
|
757
|
+
* import { world } from '@tabler/charts/maps/world'
|
|
758
|
+
*
|
|
759
|
+
* new Chart('#el', {
|
|
760
|
+
* type: map,
|
|
761
|
+
* map: world,
|
|
762
|
+
* data: { PL: 80, DE: 45, US: 100 },
|
|
763
|
+
* })
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
const map = {
|
|
767
|
+
name: "map",
|
|
768
|
+
clean: (options) => {
|
|
769
|
+
const config = cleanMap(options);
|
|
770
|
+
if (config.aspectRatio !== void 0 && config.aspectRatio !== config.autoRatio) return config;
|
|
771
|
+
const autoRatio = ratioOf(config);
|
|
772
|
+
return {
|
|
773
|
+
...config,
|
|
774
|
+
aspectRatio: autoRatio,
|
|
775
|
+
autoRatio
|
|
776
|
+
};
|
|
777
|
+
},
|
|
778
|
+
render: renderMap,
|
|
779
|
+
table: mapTable,
|
|
780
|
+
plugins: [mapInteraction()]
|
|
781
|
+
};
|
|
782
|
+
export { map as n, addMap as t };
|
|
783
|
+
|
|
784
|
+
//# sourceMappingURL=map-CYp6x-uS.js.map
|