@tabler/charts 0.3.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 +94 -16
- package/dist/{annotations-CpCWA29b.cjs → annotations--m-HzMBM.cjs} +86 -10
- 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-BQ8l-qHs.js → annotations-DGITy6th.js} +86 -10
- package/dist/annotations-DGITy6th.js.map +1 -0
- package/dist/annotations.cjs +1 -1
- package/dist/annotations.d.cts +1 -1
- package/dist/annotations.d.ts +1 -1
- package/dist/annotations.js +1 -1
- package/dist/{area-WdtfqvhX.js → area-BN0uE9R0.js} +4 -3
- package/dist/area-BN0uE9R0.js.map +1 -0
- package/dist/{area-h_FvieFb.d.cts → area-D6LNLk3r.d.cts} +2 -2
- package/dist/{area-DEFQm_SQ.d.ts → area-DEFL-Yun.d.ts} +2 -2
- package/dist/{area-DYdQ_sMV.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-YfAerNBA.cjs → axis-BzBkkC5X.cjs} +12 -7
- package/dist/axis-BzBkkC5X.cjs.map +1 -0
- package/dist/{axis-MMaVoSWB.js → axis-C5obgdJt.js} +12 -7
- package/dist/axis-C5obgdJt.js.map +1 -0
- package/dist/{bar-CVkOJ7WA.cjs → bar-BrmfXugT.cjs} +5 -4
- package/dist/bar-BrmfXugT.cjs.map +1 -0
- package/dist/{bar-D9B_arKf.d.ts → bar-Bs_rPqgR.d.ts} +1 -1
- package/dist/{bar-DZCQ-kyf.d.cts → bar-CEt8YRxf.d.cts} +2 -2
- package/dist/{bar-BOcRcArc.js → bar-D_KKd2fL.js} +5 -4
- package/dist/bar-D_KKd2fL.js.map +1 -0
- 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-BSvO8nRb.d.cts → calendar-B7843sQu.d.cts} +2 -2
- package/dist/{calendar-DAFXjV99.cjs → calendar-BG_q_NC_.cjs} +2 -2
- package/dist/{calendar-DAFXjV99.cjs.map → calendar-BG_q_NC_.cjs.map} +1 -1
- package/dist/{calendar-BXgIX5H1.js → calendar-CF3gfDQk.js} +2 -2
- package/dist/{calendar-BXgIX5H1.js.map → calendar-CF3gfDQk.js.map} +1 -1
- package/dist/{calendar-Bq3vFzPl.d.ts → calendar-D10_ki1S.d.ts} +2 -2
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.cts +1 -1
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{candlestick-BtT9glp9.js → candlestick-B1onjo1o.js} +3 -2
- package/dist/candlestick-B1onjo1o.js.map +1 -0
- package/dist/{candlestick-BcomxeVG.d.cts → candlestick-B7YXUVVh.d.cts} +4 -3
- package/dist/{candlestick-CSmRuZ4v.cjs → candlestick-BwrFKak_.cjs} +3 -2
- package/dist/candlestick-BwrFKak_.cjs.map +1 -0
- package/dist/{candlestick-B3WcLzph.d.ts → candlestick-XpqJvarq.d.ts} +4 -3
- package/dist/candlestick.cjs +2 -2
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +2 -2
- package/dist/{cartesian-DRSXHxWe.cjs → cartesian-B9CrasFJ.cjs} +49 -7
- package/dist/cartesian-B9CrasFJ.cjs.map +1 -0
- package/dist/{cartesian-BrPqb5Qn.js → cartesian-COglz544.js} +45 -9
- package/dist/cartesian-COglz544.js.map +1 -0
- package/dist/{chart-B6TTY4Kr.js → chart-B97FBRCd.js} +22 -12
- package/dist/chart-B97FBRCd.js.map +1 -0
- package/dist/{chart-CYrrUCi3.d.ts → chart-CE9EVbfV.d.ts} +240 -62
- package/dist/{chart-CbPzP5Dp.d.cts → chart-Dz4geQZy.d.cts} +240 -62
- package/dist/{chart-D_lyOy-M.cjs → chart-GUmmjJ7S.cjs} +27 -11
- package/dist/chart-GUmmjJ7S.cjs.map +1 -0
- package/dist/{core-CQ0FaJ4G.js → core-7fgM3su0.js} +84 -16
- package/dist/core-7fgM3su0.js.map +1 -0
- package/dist/{core-C3qEppSm.d.ts → core-BUQzLsRJ.d.ts} +21 -6
- package/dist/{core-D2PSked3.cjs → core-BZTrsPxc.cjs} +93 -13
- package/dist/core-BZTrsPxc.cjs.map +1 -0
- package/dist/{core-9BnLEW4K.d.cts → core-Ck5uHcW8.d.cts} +40 -23
- package/dist/core.cjs +20 -16
- package/dist/core.d.cts +23 -21
- package/dist/core.d.ts +23 -21
- package/dist/core.js +18 -17
- package/dist/{dates-DerXTb1J.cjs → dates-0YNY49KQ.cjs} +2 -2
- package/dist/{dates-DerXTb1J.cjs.map → dates-0YNY49KQ.cjs.map} +1 -1
- package/dist/{dates-DLe2Ww64.js → dates-CKDRgpin.js} +2 -2
- package/dist/{dates-DLe2Ww64.js.map → dates-CKDRgpin.js.map} +1 -1
- 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-DoeiAyR2.js → export-chart-BOH_nfcH.js} +76 -4
- package/dist/export-chart-BOH_nfcH.js.map +1 -0
- package/dist/{export-chart-CPtXmZvi.cjs → export-chart-Be4T9J3m.cjs} +81 -3
- package/dist/export-chart-Be4T9J3m.cjs.map +1 -0
- package/dist/export.cjs +4 -2
- 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 +4 -3
- package/dist/export.js.map +1 -1
- package/dist/features-B55rwpQC.js.map +1 -1
- package/dist/features-DEDP5CEQ.cjs.map +1 -1
- package/dist/{funnel-CarOh8w_.d.cts → funnel-B9ridzNx.d.cts} +2 -2
- package/dist/{funnel-BdcfUkb5.d.ts → funnel-FogM8flk.d.ts} +2 -2
- package/dist/funnel.d.cts +1 -1
- package/dist/funnel.d.ts +1 -1
- package/dist/{gauge-Ds9k1UV2.d.cts → gauge-BScJ7U6O.d.cts} +2 -2
- package/dist/{gauge-Zy25jfps.d.ts → gauge-D78oq1Lx.d.ts} +2 -2
- package/dist/gauge.d.cts +1 -1
- package/dist/gauge.d.ts +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-Dcc_bsoQ.cjs → heatmap-Dyzrd4Fd.cjs} +3 -3
- package/dist/{heatmap-Dcc_bsoQ.cjs.map → heatmap-Dyzrd4Fd.cjs.map} +1 -1
- package/dist/{heatmap-C1v8bwpq.js → heatmap-J7fxG7MM.js} +3 -3
- package/dist/{heatmap-C1v8bwpq.js.map → heatmap-J7fxG7MM.js.map} +1 -1
- package/dist/{heatmap-CJ-0dfhJ.d.cts → heatmap-Jvwo7iFW.d.cts} +2 -2
- package/dist/{heatmap-Jp5sHRTo.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/index.cjs +37 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -21
- package/dist/index.d.ts +23 -21
- package/dist/index.js +34 -27
- package/dist/index.js.map +1 -1
- package/dist/interaction-DXYSjgnP.cjs.map +1 -1
- package/dist/interaction-En1KlwFO.js.map +1 -1
- package/dist/layout-CYerDebD.d.cts +29 -0
- package/dist/layout-CYerDebD.d.ts +29 -0
- package/dist/{line-CxR4tg1Q.js → line-CXH0L10d.js} +43 -8
- package/dist/line-CXH0L10d.js.map +1 -0
- package/dist/{line-vyWO030v.d.cts → line-Cu9ctpbv.d.cts} +9 -2
- package/dist/{line-YiCuhVMI.cjs → line-DHbYCQy4.cjs} +43 -8
- package/dist/line-DHbYCQy4.cjs.map +1 -0
- package/dist/{line-Bpr5uVLQ.d.ts → line-TkzA7wMK.d.ts} +8 -1
- package/dist/line.cjs +1 -1
- package/dist/line.d.cts +1 -1
- package/dist/line.d.ts +1 -1
- package/dist/line.js +1 -1
- package/dist/{map-49FcfdmJ.d.cts → map-BirylCmT.d.cts} +2 -2
- package/dist/{map-C15NC7kW.js → map-CYp6x-uS.js} +3 -26
- package/dist/map-CYp6x-uS.js.map +1 -0
- package/dist/{map-BqrZ80vT.cjs → map-ChwSgooH.cjs} +4 -27
- package/dist/map-ChwSgooH.cjs.map +1 -0
- package/dist/{map-BMC61J-P.d.ts → map-DNqog2Xs.d.ts} +2 -2
- package/dist/map.cjs +1 -1
- package/dist/map.d.cts +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +1 -1
- package/dist/maps/world.d.cts +1 -1
- package/dist/maps/world.d.ts +1 -1
- package/dist/{others-ls5eKtZ4.d.cts → others-CuNdpvjd.d.cts} +1 -1
- package/dist/{parliament-Cz9n_DoK.d.ts → parliament-CHdf13XU.d.ts} +2 -2
- package/dist/{parliament-C7V8UJj1.d.cts → parliament-CsYgh4N2.d.cts} +2 -2
- package/dist/parliament.d.cts +1 -1
- package/dist/parliament.d.ts +1 -1
- package/dist/{patterns-Dw7OMD_2.cjs → patterns-BPN1c9qe.cjs} +2 -2
- package/dist/{patterns-Dw7OMD_2.cjs.map → patterns-BPN1c9qe.cjs.map} +1 -1
- package/dist/{patterns-BMUINoka.js → patterns-CVrLrJXg.js} +2 -2
- package/dist/{patterns-BMUINoka.js.map → patterns-CVrLrJXg.js.map} +1 -1
- package/dist/patterns.cjs +1 -1
- package/dist/patterns.d.cts +1 -1
- package/dist/patterns.d.ts +1 -1
- package/dist/patterns.js +1 -1
- package/dist/{percentage-bar-cSeiLdwU.d.ts → percentage-bar-CSAbzDOn.d.ts} +2 -2
- package/dist/{percentage-bar-R1--2grK.d.cts → percentage-bar-UZHCRvlK.d.cts} +3 -3
- package/dist/percentage-bar.d.cts +1 -1
- package/dist/percentage-bar.d.ts +1 -1
- package/dist/{pie-vD5-g8je.d.cts → pie-AFedsDcF.d.cts} +12 -3
- package/dist/{pie-Bd8wyrtY.js → pie-Ch6Bx0ih.js} +54 -39
- package/dist/pie-Ch6Bx0ih.js.map +1 -0
- package/dist/{pie-BseZlCgP.cjs → pie-Cll1OrVZ.cjs} +54 -39
- package/dist/pie-Cll1OrVZ.cjs.map +1 -0
- package/dist/{pie-BQQkvy1N.d.ts → pie-Cn2H3pz8.d.ts} +11 -2
- 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.d.cts +1 -1
- package/dist/point-shapes.d.ts +1 -1
- package/dist/{radar-D6XqkFWQ.js → radar-Bg-IiIWB.js} +3 -3
- package/dist/{radar-D6XqkFWQ.js.map → radar-Bg-IiIWB.js.map} +1 -1
- package/dist/{radar-vLxilcr4.d.ts → radar-DEer2jjd.d.ts} +2 -2
- package/dist/{radar-7I6hsY_h.d.cts → radar-DxmjXhMc.d.cts} +2 -2
- package/dist/{radar-DjISDnSf.cjs → radar-wDyX17S3.cjs} +3 -3
- package/dist/{radar-DjISDnSf.cjs.map → radar-wDyX17S3.cjs.map} +1 -1
- 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/{sankey-DqiuxUx7.d.cts → sankey-D-8ATwBT.d.cts} +2 -2
- package/dist/{sankey-7As41Fo4.d.ts → sankey-DpYJsOI4.d.ts} +2 -2
- package/dist/sankey.d.cts +1 -1
- package/dist/sankey.d.ts +1 -1
- package/dist/{scatter-DCMAtt5L.js → scatter-0Z7K_YUz.js} +65 -19
- package/dist/scatter-0Z7K_YUz.js.map +1 -0
- package/dist/{scatter-BXkXGgM_.d.ts → scatter-BAL5K9_4.d.ts} +22 -9
- package/dist/{scatter-DL0zAV09.d.cts → scatter-BUGbnRzM.d.cts} +22 -9
- package/dist/{scatter-Bwkblr4L.cjs → scatter-CZ8do3Up.cjs} +65 -19
- 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-BElUSd0r.d.ts → sparkline-CtoBJe-a.d.ts} +2 -2
- package/dist/{sparkline-BMSuEPHP.cjs → sparkline-DjR-V6BI.cjs} +2 -2
- package/dist/{sparkline-BMSuEPHP.cjs.map → sparkline-DjR-V6BI.cjs.map} +1 -1
- package/dist/{sparkline-RYly7bR0.d.cts → sparkline-DwHJfeZz.d.cts} +2 -2
- package/dist/{sparkline-NDmq90kP.js → sparkline-_dxwtdli.js} +2 -2
- package/dist/{sparkline-NDmq90kP.js.map → sparkline-_dxwtdli.js.map} +1 -1
- 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-BTWYIwLO.d.cts → stack-CcmyALx0.d.cts} +1 -1
- package/dist/{stack-jVKvg2x_.js → stack-CyVlS7Fr.js} +2 -2
- package/dist/{stack-jVKvg2x_.js.map → stack-CyVlS7Fr.js.map} +1 -1
- package/dist/{stack-BO4624CY.cjs → stack-DBhmYNat.cjs} +2 -2
- package/dist/{stack-BO4624CY.cjs.map → stack-DBhmYNat.cjs.map} +1 -1
- package/dist/style.css +1 -1
- package/dist/{time-axis-B3VekUfX.cjs → time-axis-CVKjQKSS.cjs} +3 -3
- package/dist/{time-axis-B3VekUfX.cjs.map → time-axis-CVKjQKSS.cjs.map} +1 -1
- package/dist/{time-axis-CLjqOakA.js → time-axis-CkmbAw4Z.js} +3 -3
- package/dist/{time-axis-CLjqOakA.js.map → time-axis-CkmbAw4Z.js.map} +1 -1
- package/dist/time.cjs +2 -2
- package/dist/time.js +2 -2
- package/dist/{treemap-25vHO_UK.d.cts → treemap-C2maqerU.d.cts} +26 -4
- package/dist/{treemap-BCXUbixd.d.ts → treemap-D_zbubo3.d.ts} +26 -4
- package/dist/{treemap-CZk8kKFD.cjs → treemap-PulGXZv0.cjs} +38 -8
- package/dist/treemap-PulGXZv0.cjs.map +1 -0
- package/dist/{treemap-C4glsx-g.js → treemap-lbYxb-7h.js} +38 -8
- 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-C7GrhOXJ.js → value-labels-B0VeheyE.js} +5 -4
- package/dist/value-labels-B0VeheyE.js.map +1 -0
- package/dist/{value-labels-DzaKIWKp.cjs → value-labels-Dcyk3GIY.cjs} +5 -4
- package/dist/value-labels-Dcyk3GIY.cjs.map +1 -0
- package/dist/value-labels.cjs +1 -1
- package/dist/value-labels.d.cts +1 -1
- package/dist/value-labels.d.ts +1 -1
- package/dist/value-labels.js +1 -1
- 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 +27 -2
- package/dist/annotations-BQ8l-qHs.js.map +0 -1
- package/dist/annotations-CpCWA29b.cjs.map +0 -1
- package/dist/area-DYdQ_sMV.cjs.map +0 -1
- package/dist/area-WdtfqvhX.js.map +0 -1
- package/dist/axis-MMaVoSWB.js.map +0 -1
- package/dist/axis-YfAerNBA.cjs.map +0 -1
- package/dist/bar-BOcRcArc.js.map +0 -1
- package/dist/bar-CVkOJ7WA.cjs.map +0 -1
- package/dist/candlestick-BtT9glp9.js.map +0 -1
- package/dist/candlestick-CSmRuZ4v.cjs.map +0 -1
- package/dist/cartesian-BrPqb5Qn.js.map +0 -1
- package/dist/cartesian-DRSXHxWe.cjs.map +0 -1
- package/dist/chart-B6TTY4Kr.js.map +0 -1
- package/dist/chart-D_lyOy-M.cjs.map +0 -1
- package/dist/core-CQ0FaJ4G.js.map +0 -1
- package/dist/core-D2PSked3.cjs.map +0 -1
- package/dist/export-chart-CPtXmZvi.cjs.map +0 -1
- package/dist/export-chart-DoeiAyR2.js.map +0 -1
- package/dist/line-CxR4tg1Q.js.map +0 -1
- package/dist/line-YiCuhVMI.cjs.map +0 -1
- package/dist/map-BqrZ80vT.cjs.map +0 -1
- package/dist/map-C15NC7kW.js.map +0 -1
- package/dist/pie-Bd8wyrtY.js.map +0 -1
- package/dist/pie-BseZlCgP.cjs.map +0 -1
- package/dist/scatter-Bwkblr4L.cjs.map +0 -1
- package/dist/scatter-DCMAtt5L.js.map +0 -1
- package/dist/treemap-C4glsx-g.js.map +0 -1
- package/dist/treemap-CZk8kKFD.cjs.map +0 -1
- package/dist/value-labels-C7GrhOXJ.js.map +0 -1
- package/dist/value-labels-DzaKIWKp.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-BqrZ80vT.cjs","names":["finite","toChartPoint","isRecord","finite","text","round","formatNumber","insets","LINE_HEIGHT","innerRect","h","estimateTextWidth","list","records"],"sources":["../src/charts/map-view.ts","../src/plugins/map.ts","../src/charts/map.ts"],"sourcesContent":["import { finite } from './clean.ts'\n\n/** The part of a map in sight. */\nexport interface MapView {\n /** The top left corner, in the coordinates of the map file. */\n x: number\n y: number\n /** How many times the map is magnified; `1` shows all of it. */\n scale: number\n}\n\n/** Where the last render put the map, for the zoom to work from. */\nexport interface MapLayout {\n /** The room of the map in chart pixels. */\n x: number\n y: number\n width: number\n height: number\n /** Pixels per unit of the map when all of it is in sight. */\n k: number\n /** Size of the map file. */\n mapWidth: number\n mapHeight: number\n /** The most the map can be magnified. */\n max: number\n}\n\n/**\n * A view kept inside the zoom range and the map itself, so the map can never\n * be dragged out of sight; along a side where all of the map fits, it is centered.\n */\nexport function fitView(view: Partial<MapView> | undefined, layout: MapLayout): MapView {\n const scale = Math.min(layout.max, Math.max(1, finite(view?.scale) ?? 1))\n const unit = layout.k * scale\n const fit = (at: number | null, size: number, room: number): number => {\n const span = room / unit\n return span >= size ? (size - span) / 2 : Math.min(size - span, Math.max(0, at ?? 0))\n }\n return unit > 0\n ? {\n x: fit(finite(view?.x), layout.mapWidth, layout.width),\n y: fit(finite(view?.y), layout.mapHeight, layout.height),\n scale,\n }\n : { x: 0, y: 0, scale }\n}\n","import type { MapHit, MapInteraction, MapOptions } from '../charts/map.ts'\nimport { fitView, type MapView } from '../charts/map-view.ts'\nimport { toChartPoint } from '../interaction.ts'\nimport type { ChartPlugin } from '../plugin.ts'\n\ntype Point = [number, number]\n\n/** One step of a button, a key or a double click. */\nconst ZOOM_STEP = 2\nconst ZOOM_DURATION = 200\n/**\n * How much one unit of wheel movement magnifies. A pinch on a trackpad comes\n * as a wheel event with `ctrlKey` and much smaller numbers.\n */\nconst WHEEL_SPEED = 0.002\nconst WHEEL_SPEED_PINCH = 0.01\n/** How far a pointer has to move, in pixels, before a press becomes a drag and stops being a click. */\nconst DRAG_THRESHOLD = 4\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst ICONS = ['M12 5v14M5 12h14', 'M5 12h14']\n\n/**\n * What makes a map more than a picture: with `zoom` it is magnified with its\n * buttons, the wheel, a double click, a pinch or the `+`, `-` and `0` keys,\n * and dragged around; with `select` a click (or Enter) selects a region. The\n * `map` chart type brings it along, so it needs no import of its own; it\n * keeps no state, the view and the selection live in the options.\n */\nexport function mapInteraction(): ChartPlugin {\n return {\n name: 'map',\n install(chart) {\n const host = chart.element\n if (typeof host.addEventListener !== 'function') return {}\n const doc = host.ownerDocument\n const win = doc.defaultView\n const options = () => chart.config as unknown as MapOptions & { animate?: boolean }\n const isMap = () => chart.config.type.name === 'map'\n const zoomOn = () => isMap() && !!options().zoom\n const layout = () => (chart.interaction as Partial<MapInteraction> | undefined)?.map\n const svg = () => host.querySelector(':scope > svg.tc-chart')\n /** Whether an event happened on the drawing, not on a control over it. */\n const onMap = (event: Event) =>\n (event.target as Element | null)?.closest?.('svg.tc-chart') === svg() && !!svg()\n\n let frame = 0\n /** Pointers that are down on the map, with where each was last seen. */\n const pointers = new Map<number, Point>()\n /** Whether the pointers that are down have moved the map: the click that ends a drag selects nothing. */\n let dragged = false\n let controls: HTMLElement | undefined\n const addedClass = !host.classList.contains('tc-container')\n\n const stop = () => win?.cancelAnimationFrame(frame)\n const current = (): MapView | undefined => {\n const l = layout()\n return l && fitView(options().view, l)\n }\n const setView = (view: MapView) => {\n const l = layout()\n if (l) chart.update({ view: fitView(view, l) } as never)\n }\n\n /** A point of the screen in chart pixels. */\n const toChart = (x: number, y: number): Point => {\n const el = svg()\n const { width, height } = chart.size\n const p = el ? toChartPoint(el, x, y, width, height) : { x: 0, y: 0 }\n return [p.x, p.y]\n }\n /** A point of the screen in the coordinates of the map. */\n const toMapPoint = (x: number, y: number): Point | null => {\n const l = layout()\n const view = current()\n if (!l || !view) return null\n const unit = l.k * view.scale\n const [cx, cy] = toChart(x, y)\n return [view.x + (cx - l.x) / unit, view.y + (cy - l.y) / unit]\n }\n\n /**\n * Moves to a view over a few frames. The corner and the size of the\n * view change at the same pace, which keeps the point being zoomed at in place.\n */\n const animateTo = (to: MapView) => {\n stop()\n const l = layout()\n const from = current()\n if (!l || !from) return\n const target = fitView(to, l)\n const still =\n options().animate === false ||\n !win?.requestAnimationFrame ||\n win.matchMedia?.('(prefers-reduced-motion: reduce)').matches\n if (still) {\n setView(target)\n return\n }\n const start = performance.now()\n const step = (now: number) => {\n const t = Math.min((now - start) / ZOOM_DURATION, 1)\n const eased = 1 - (1 - t) ** 3\n const at = (a: number, b: number) => a + (b - a) * eased\n setView({\n x: at(from.x, target.x),\n y: at(from.y, target.y),\n scale: 1 / at(1 / from.scale, 1 / target.scale),\n })\n if (t < 1) frame = win.requestAnimationFrame(step)\n }\n frame = win.requestAnimationFrame(step)\n }\n\n /**\n * Magnifies by a factor around a point of the map, which stays where it\n * is on the screen. Without a point, around the middle of the view.\n */\n const zoomBy = (factor: number, anchor: Point | null, animate = false) => {\n const l = layout()\n const view = current()\n if (!l || !view || !(l.k > 0)) return\n const next = Math.min(l.max, Math.max(1, view.scale * factor))\n const unit = l.k * view.scale\n const [ax, ay] = anchor ?? [view.x + l.width / unit / 2, view.y + l.height / unit / 2]\n const target = {\n x: ax - ((ax - view.x) * view.scale) / next,\n y: ay - ((ay - view.y) * view.scale) / next,\n scale: next,\n }\n if (animate) animateTo(target)\n else {\n stop()\n setView(target)\n }\n }\n\n /** Selects the region of a hit, or takes it out when it is selected. */\n const select = (hit: MapHit | null) => {\n const o = options()\n const code = hit?.region\n if (!isMap() || !o.select || !code) return\n const selected = [...(o.selected ?? [])]\n const rest = selected.filter((other) => other !== code)\n const next =\n rest.length < selected.length\n ? rest\n : o.select === 'multiple'\n ? [...selected, code]\n : [code]\n chart.update({ selected: next } as never)\n o.onSelect?.(next, code)\n }\n\n const onPointerEnd = (event: PointerEvent) => {\n pointers.delete(event.pointerId)\n if (pointers.size === 0) {\n doc.removeEventListener('pointerup', onPointerEnd)\n doc.removeEventListener('pointercancel', onPointerEnd)\n // The cursor of a drag goes with the next render.\n if (dragged) chart.update({})\n }\n }\n const onPointerDown = (event: PointerEvent) => {\n if (!zoomOn() || !onMap(event) || (event.pointerType === 'mouse' && event.button !== 0))\n return\n if (pointers.size === 0) dragged = false\n pointers.set(event.pointerId, [event.clientX, event.clientY])\n stop()\n doc.addEventListener('pointerup', onPointerEnd)\n doc.addEventListener('pointercancel', onPointerEnd)\n }\n /** One pointer drags the map, two pinch it. */\n const onPointerMove = (event: PointerEvent) => {\n const previous = pointers.get(event.pointerId)\n const view = current()\n const l = layout()\n if (!previous || !view || !l) return\n const now: Point = [event.clientX, event.clientY]\n // A press that barely moves is a click, not a drag: until the pointer\n // has moved far enough the map stays put, and the click reaches the region.\n if (!dragged) {\n if (\n pointers.size === 1 &&\n Math.hypot(now[0] - previous[0], now[1] - previous[1]) < DRAG_THRESHOLD\n )\n return\n dragged = true\n // The map keeps getting the moves of this pointer when it leaves the\n // map. Capturing throws for a pointer the browser does not know,\n // which is what an event made in a script has.\n try {\n svg()?.setPointerCapture(event.pointerId)\n } catch {\n // The drag still works while the pointer stays over the map.\n }\n }\n // The highlight and the tooltip stay out of a drag.\n event.stopPropagation()\n chart.clearHighlight()\n pointers.set(event.pointerId, now)\n if (pointers.size === 1) {\n const unit = l.k * view.scale\n const [x0, y0] = toChart(previous[0], previous[1])\n const [x1, y1] = toChart(now[0], now[1])\n setView({ x: view.x - (x1 - x0) / unit, y: view.y - (y1 - y0) / unit, scale: view.scale })\n return\n }\n const other = [...pointers].find(([id]) => id !== event.pointerId)?.[1]\n if (!other) return\n const before = Math.hypot(previous[0] - other[0], previous[1] - other[1])\n const after = Math.hypot(now[0] - other[0], now[1] - other[1])\n if (before > 0 && after > 0)\n zoomBy(after / before, toMapPoint((now[0] + other[0]) / 2, (now[1] + other[1]) / 2))\n }\n const onWheel = (event: WheelEvent) => {\n const { zoom } = options()\n if (!zoomOn() || (typeof zoom === 'object' && zoom.wheel === false) || !onMap(event)) return\n // The page must not scroll while the wheel zooms the map.\n event.preventDefault()\n zoomBy(\n Math.exp(-event.deltaY * (event.ctrlKey ? WHEEL_SPEED_PINCH : WHEEL_SPEED)),\n toMapPoint(event.clientX, event.clientY),\n )\n }\n const onDoubleClick = (event: MouseEvent) => {\n if (zoomOn() && onMap(event))\n zoomBy(ZOOM_STEP, toMapPoint(event.clientX, event.clientY), true)\n }\n /** The click that ends a drag is not a click on the map. */\n const onClickCapture = (event: MouseEvent) => {\n if (dragged) event.stopPropagation()\n dragged = false\n }\n const onKey = (event: KeyboardEvent) => {\n if (event.target !== svg() || !isMap()) return\n const { key } = event\n if (zoomOn() && (key === '+' || key === '=')) zoomBy(ZOOM_STEP, null, true)\n else if (zoomOn() && key === '-') zoomBy(1 / ZOOM_STEP, null, true)\n else if (zoomOn() && key === '0') animateTo({ x: 0, y: 0, scale: 1 })\n else if (options().select && (key === 'Enter' || key === ' ') && chart.active)\n select(chart.active)\n else return\n event.preventDefault()\n }\n const onControl = (event: MouseEvent) => {\n const button = (event.target as Element).closest('button')\n if (button) zoomBy(button.value === 'in' ? ZOOM_STEP : 1 / ZOOM_STEP, null, true)\n }\n\n // Moves are taken on their way down, so a drag never reaches the highlight.\n host.addEventListener('pointermove', onPointerMove, true)\n host.addEventListener('click', onClickCapture, true)\n host.addEventListener('pointerdown', onPointerDown)\n // (Not passive: the wheel must be kept from scrolling the page.)\n host.addEventListener('wheel', onWheel, { passive: false })\n host.addEventListener('dblclick', onDoubleClick)\n host.addEventListener('keydown', onKey)\n const off = chart.on('click', ({ hit }) => select(hit))\n\n /** The zoom buttons, laid over a corner of the map. */\n const renderControls = () => {\n if (!zoomOn()) {\n controls?.remove()\n controls = undefined\n return\n }\n if (!controls) {\n controls = doc.createElement('div')\n controls.className = 'tc-map-zoom'\n for (const [i, d] of ICONS.entries()) {\n const button = doc.createElement('button')\n button.type = 'button'\n button.className = 'tc-download-toggle'\n button.value = i ? 'out' : 'in'\n const icon = doc.createElementNS(SVG_NS, 'svg')\n icon.setAttribute('viewBox', '0 0 24 24')\n icon.setAttribute('width', '16')\n icon.setAttribute('height', '16')\n icon.setAttribute('aria-hidden', 'true')\n const path = doc.createElementNS(SVG_NS, 'path')\n path.setAttribute('d', d)\n icon.append(path)\n button.append(icon)\n controls.append(button)\n }\n controls.addEventListener('click', onControl)\n host.classList.add('tc-container')\n }\n if (!controls.isConnected) host.append(controls)\n const { zoom } = options()\n const labels = typeof zoom === 'object' ? zoom.labels : undefined\n const view = current()\n const max = layout()?.max ?? 1\n const [zoomIn, zoomOut] = controls.querySelectorAll('button')\n if (zoomIn && zoomOut && view) {\n zoomIn.setAttribute('aria-label', labels?.in ?? 'Zoom in')\n zoomOut.setAttribute('aria-label', labels?.out ?? 'Zoom out')\n zoomIn.disabled = view.scale >= max\n zoomOut.disabled = view.scale <= 1\n }\n }\n\n return {\n // The stylesheet takes drags and pinches for a map that can be\n // magnified, so the page does not scroll or zoom under the finger.\n svgAttrs: () =>\n zoomOn() ? { 'data-zoom': dragged && pointers.size ? 'drag' : '' } : undefined,\n afterRender: renderControls,\n destroy() {\n stop()\n off()\n host.removeEventListener('pointermove', onPointerMove, true)\n host.removeEventListener('click', onClickCapture, true)\n host.removeEventListener('pointerdown', onPointerDown)\n host.removeEventListener('wheel', onWheel)\n host.removeEventListener('dblclick', onDoubleClick)\n host.removeEventListener('keydown', onKey)\n doc.removeEventListener('pointerup', onPointerEnd)\n doc.removeEventListener('pointercancel', onPointerEnd)\n controls?.remove()\n if (controls && addedClass) host.classList.remove('tc-container')\n },\n }\n },\n }\n}\n","import type { ChartType, DataTable, RenderContext, RenderResult, TableContext } from '../chart.ts'\nimport { formatNumber, type NumberFormat } from '../format.ts'\nimport type { Hit, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n innerRect,\n insets,\n LINE_HEIGHT,\n round,\n} from '../layout.ts'\nimport { mapInteraction } from '../plugins/map.ts'\nimport { h, type StyleValue, type VNode } from '../vnode.ts'\nimport { finite, isRecord, list, records, text } from './clean.ts'\nimport { fitView, type MapLayout, type MapView } from './map-view.ts'\n\nexport type { MapLayout, MapView }\n\n/** One region of a map (a country, a state …). */\nexport interface MapRegion {\n name: string\n /**\n * SVG path data in the coordinates of the map (`M`, `L`, `H`, `V` and `Z`,\n * absolute or relative; curves are drawn but not hit by the pointer).\n */\n path: string\n /** Too small for a shape at the scale of the map: `path` is a single point, drawn as a dot when it has a value. */\n point?: boolean\n}\n\n/** A map: shapes already projected into a `width` × `height` box, as the files in `@tabler/charts/maps/*` are. */\nexport interface MapData {\n width: number\n height: number\n /** How the shapes were projected, to place a marker by its coordinates. */\n projection?: { type: 'miller'; scale: number; translate: readonly number[] }\n /** Regions by their code, e.g. ISO 3166-1 alpha-2 for countries. */\n regions: Readonly<Record<string, MapRegion>>\n}\n\n/** A place on the map, by its coordinates. */\nexport interface MapMarker {\n /** Shown in the tooltip, and what a line refers to. */\n name?: string\n /** Latitude and longitude in degrees. */\n lat: number\n lng: number\n}\n\n/** A curve between two markers, by their names. */\nexport interface MapLine {\n from: string\n to: string\n}\n\nexport interface MapOptions {\n /** The map: a map file (`import { world } from '@tabler/charts/maps/world'`), or the name it was given with `addMap()`. */\n map: MapData | string\n /** A value per region code, e.g. `{ PL: 80, DE: 45 }`. Regions without one keep the empty shade. */\n data: Readonly<Record<string, number | null>>\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 * A continuous scale through two or more colors (any CSS color, including\n * `var(--tc-…)`), from `min` to `max`, instead of one hue (`--tc-heat-color`).\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 /** Places drawn as dots over the map. */\n markers?: readonly MapMarker[]\n /** Dashed curves between markers. */\n lines?: readonly MapLine[]\n /** Radius of the markers and of the regions drawn as a dot, in pixels. Defaults to `4`. */\n markerRadius?: number\n /** Format of the values (tooltip, scale, table). */\n format?: NumberFormat\n /**\n * The bar below the map with the lowest and the highest value: `false`\n * hides it, an object names its ends instead of the values.\n */\n scale?: boolean | { low?: string; high?: string }\n /** Extra space around the map, in pixels. */\n padding?: InsetsInput\n /**\n * Let the map be magnified with its buttons, the wheel, a double click, a\n * pinch or the `+` and `-` keys, and dragged around. An object sets the\n * most it magnifies (`max`, `8` by default), turns the wheel off\n * (`wheel: false`) and names the buttons (`labels`).\n */\n zoom?: boolean | { max?: number; wheel?: boolean; labels?: { in?: string; out?: string } }\n /**\n * The part of the map in sight. Zooming and dragging write it; set it\n * yourself to start on a part of the map, leave it out for the whole map.\n */\n view?: Partial<MapView>\n /**\n * Let regions be selected with a click (or Enter on the region the\n * keyboard is on): one at a time, or any number of them. A click on a\n * selected region takes it out again.\n */\n select?: 'single' | 'multiple'\n /** Codes of the selected regions. Selecting writes it; `onSelect` hears of it. */\n selected?: readonly string[]\n /** Called when a click or a key changes the selection, with the codes now selected and the one that changed. */\n onSelect?: (selected: string[], code: string) => void\n}\n\n/** A hit of a map: what it is on. */\nexport interface MapHit extends Hit {\n /** Code of the region, for a hit on a region. */\n region?: string\n /** Name of the marker, for a hit on a marker. */\n marker?: string\n}\n\n/** The interaction of a map, with where the map was drawn. */\nexport interface MapInteraction extends Interaction {\n map: MapLayout\n}\n\n/** The selected regions of the options that are allowed: one when only one can be selected. */\nexport const selectedOf = (options: MapOptions): readonly string[] =>\n options.select === 'multiple'\n ? (options.selected ?? [])\n : options.select === 'single'\n ? (options.selected ?? []).slice(0, 1)\n : []\n\n/** Share of the full color at the minimum, so the lowest value still stands out from a region without one. */\nconst FLOOR = 0.1\nconst EMPTY = 'var(--tc-heat-empty,var(--tc-grid-color))'\nconst MARKER = 'var(--tc-map-marker-color,var(--tc-color-1))'\n/** Slices of the scale's bar: enough to read as one smooth gradient. */\nconst SCALE_STEPS = 24\nconst SCALE_STEP = 5\nconst SCALE_HEIGHT = 8\n/** How far a line bends away from the straight one, as a share of its length. */\nconst LINE_CURVE = 0.2\nconst RADIANS = Math.PI / 180\n\nconst maps: Record<string, MapData> = {}\n\n/** Register a map under a name, so `map: 'world'` finds it (configs from JSON, `<tabler-chart>`, the data API). */\nexport function addMap(name: string, data: MapData): void {\n maps[name] = data\n}\n\nconst isMap = (v: unknown): v is MapData =>\n isRecord(v) && isRecord(v.regions) && (finite(v.width) ?? 0) > 0 && (finite(v.height) ?? 0) > 0\n\n/** A region ready to draw and to hit: its rings as flat `x, y` lists in map coordinates. */\ninterface Shape {\n code: string\n name: string\n path: string\n point: boolean\n rings: number[][]\n /** Bounds of the shape: left, top, right, bottom. */\n box: [number, number, number, number]\n /** Middle of the largest ring (the mainland), where the keyboard's tooltip sits. */\n x: number\n y: number\n}\n\n/** Rings of path data made of moves and straight lines. */\nfunction parsePath(d: string): number[][] {\n const rings: number[][] = []\n let ring: number[] = []\n let x = 0\n let y = 0\n for (const [, command = '', args = ''] of d.matchAll(/([MLHVZ])([^MLHVZ]*)/gi)) {\n const n = (args.match(/-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi) ?? []).map(Number)\n const relative = command >= 'a'\n const type = command.toUpperCase()\n if (type === 'Z') {\n if (ring.length) {\n x = ring[0] as number\n y = ring[1] as number\n }\n continue\n }\n const step = type === 'H' || type === 'V' ? 1 : 2\n for (let i = 0; i + step <= n.length; i += step) {\n const a = n[i] as number\n const b = n[i + 1] as number\n if (type === 'H') x = relative ? x + a : a\n else if (type === 'V') y = relative ? y + a : a\n else {\n x = relative ? x + a : a\n y = relative ? y + b : b\n }\n // A move starts a ring; the pairs after its first are lines.\n if (type === 'M' && i === 0) {\n ring = []\n rings.push(ring)\n }\n ring.push(x, y)\n }\n }\n return rings\n}\n\nconst parsed = new WeakMap<MapData, Map<string, Shape>>()\n\n/** The regions of a map, parsed once per map file. */\nfunction shapesOf(map: MapData): Map<string, Shape> {\n let shapes = parsed.get(map)\n if (shapes) return shapes\n shapes = new Map()\n for (const [code, region] of Object.entries(map.regions)) {\n if (!isRecord(region) || typeof region.path !== 'string') continue\n const rings = parsePath(region.path).filter((ring) => ring.every(Number.isFinite))\n const box: Shape['box'] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ]\n let x = 0\n let y = 0\n let largest = -1\n for (const ring of rings) {\n let x0 = Number.POSITIVE_INFINITY\n let y0 = Number.POSITIVE_INFINITY\n let x1 = Number.NEGATIVE_INFINITY\n let y1 = Number.NEGATIVE_INFINITY\n for (let i = 0; i < ring.length; i += 2) {\n x0 = Math.min(x0, ring[i] as number)\n x1 = Math.max(x1, ring[i] as number)\n y0 = Math.min(y0, ring[i + 1] as number)\n y1 = Math.max(y1, ring[i + 1] as number)\n }\n box[0] = Math.min(box[0], x0)\n box[1] = Math.min(box[1], y0)\n box[2] = Math.max(box[2], x1)\n box[3] = Math.max(box[3], y1)\n const size = (x1 - x0) * (y1 - y0)\n if (size > largest) {\n largest = size\n x = (x0 + x1) / 2\n y = (y0 + y1) / 2\n }\n }\n if (largest < 0) continue\n shapes.set(code, {\n code,\n name: text(region.name) || code,\n path: region.path,\n point: region.point === true,\n rings,\n box,\n x,\n y,\n })\n }\n parsed.set(map, shapes)\n return shapes\n}\n\n/** Whether a point lies inside the rings (even-odd, so a hole is outside). */\nfunction inside(rings: readonly number[][], x: number, y: number): boolean {\n let hit = false\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {\n const xi = ring[i] as number\n const yi = ring[i + 1] as number\n const xj = ring[j] as number\n const yj = ring[j + 1] as number\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) hit = !hit\n }\n }\n return hit\n}\n\n/** Path of a circle, for the ring around a hovered dot. */\nconst circlePath = (x: number, y: number, r: number): string =>\n `M${round(x - r)} ${round(y)}a${r} ${r} 0 1 0 ${r * 2} 0a${r} ${r} 0 1 0 ${-r * 2} 0Z`\n\n/** What the pointer and the keyboard can land on. */\ninterface Entry {\n shape?: Shape\n marker?: { name: string; x: number; y: number }\n value: number | null\n}\n\nfunction renderMap(options: MapOptions, ctx: RenderContext): RenderResult {\n const { width, height, fontSize, locale } = ctx\n if (typeof options.map === 'string' && !maps[options.map]) {\n throw new Error(\n `[tabler-charts] Map \"${options.map}\" is not registered. Import it (e.g. from '@tabler/charts/maps/world') and call addMap('${options.map}', data).`,\n )\n }\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n if (!isMap(map)) return { content: null }\n const shapes = shapesOf(map)\n const data = options.data ?? {}\n const value = formatNumber(options.format, locale)\n const radius = Math.max(0, finite(options.markerRadius) ?? 4)\n\n // Regions with a value, in the order of the data (the order the keyboard walks).\n const entries: Entry[] = []\n const indexOf = new Map<Shape, number>()\n let dataMin = Number.POSITIVE_INFINITY\n let dataMax = Number.NEGATIVE_INFINITY\n for (const code of Object.keys(data)) {\n const shape = shapes.get(code)\n const v = finite(data[code])\n if (!shape || v === null) continue\n indexOf.set(shape, entries.length)\n entries.push({ shape, value: v })\n if (v < dataMin) dataMin = v\n if (v > dataMax) dataMax = v\n }\n const valued = entries.length\n\n // Color domain and the scale of colors.\n const lo = finite(options.min) ?? (valued ? Math.min(0, dataMin) : 0)\n const hi = finite(options.max) ?? (valued ? dataMax : 1)\n const stops = options.colors && options.colors.length >= 2 ? options.colors : undefined\n const mid = finite(options.mid)\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 t =\n stops && mid !== null && lo < mid && mid < hi\n ? v <= mid\n ? ((v - lo) / (mid - lo)) * 0.5\n : 0.5 + ((v - mid) / (hi - mid)) * 0.5\n : hi > lo\n ? (v - lo) / (hi - lo)\n : v > lo\n ? 1\n : 0\n return Math.min(1, Math.max(0, t))\n }\n /** How a region at position `t` of the scale is painted: its style and the tooltip swatch. */\n const paint = (t: number): { style: StyleValue; color: string } => {\n if (stops) {\n const at = t * (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 = round((FLOOR + (1 - FLOOR) * t) * 100)\n return {\n style: `--tc-heat:${pct}%`,\n color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`,\n }\n }\n\n // The map keeps its proportions, centered in the room above the scale.\n const pad = insets(options.padding, 0)\n const scale = options.scale !== false && valued > 0\n const scaleHeight = scale ? Math.ceil(fontSize * LINE_HEIGHT) + 8 : 0\n const area = innerRect(width, height, { ...pad, bottom: pad.bottom + scaleHeight })\n const zoom = typeof options.zoom === 'object' ? options.zoom : {}\n const layout: MapLayout = {\n ...area,\n k: Math.max(0, Math.min(area.width / map.width, area.height / map.height)),\n mapWidth: map.width,\n mapHeight: map.height,\n max: Math.max(1, finite(zoom.max) ?? 8),\n }\n const view = fitView(options.view, layout)\n // (`k` is pixels per unit of the map as it is drawn, magnified by the view.)\n const k = Math.round(layout.k * view.scale * 1e4) / 1e4\n const tx = round(area.x - view.x * k)\n const ty = round(area.y - view.y * k)\n const px = (x: number) => tx + x * k\n const py = (y: number) => ty + y * k\n // A magnified map is cut at the edges of its room.\n const clipped = view.scale > 1\n const selected = new Set(selectedOf(options))\n\n // Markers, placed with the projection the map file was made with.\n const { projection } = map\n const project =\n isRecord(projection) &&\n finite(projection.scale) !== null &&\n Array.isArray(projection.translate) &&\n projection.translate.slice(0, 2).every((n) => finite(n) !== null)\n ? (lng: number, lat: number): [number, number] => [\n px(lng * RADIANS * projection.scale + (projection.translate[0] as number)),\n py(\n (projection.translate[1] as number) -\n 1.25 * Math.log(Math.tan(Math.PI / 4 + 0.4 * lat * RADIANS)) * projection.scale,\n ),\n ]\n : undefined\n const markers: NonNullable<Entry['marker']>[] = []\n if (project && k > 0) {\n for (const marker of options.markers ?? []) {\n const [x, y] = project(marker.lng, marker.lat)\n if (Number.isFinite(x) && Number.isFinite(y)) markers.push({ name: marker.name ?? '', x, y })\n }\n }\n const firstMarker = entries.length\n for (const marker of markers) entries.push({ marker, value: null })\n // Regions without a value are not walked by the keyboard, but still name themselves on hover.\n const count = entries.length\n for (const shape of shapes.values()) {\n if (shape.point || indexOf.has(shape)) continue\n indexOf.set(shape, entries.length)\n entries.push({ shape, value: null })\n }\n\n const hitAt = (i: number): MapHit | null => {\n const entry = entries[i]\n if (!entry) return null\n const { shape, marker } = entry\n const dot = marker ?? (shape?.point ? { x: px(shape.x), y: py(shape.y) } : undefined)\n const x = dot?.x ?? px(shape?.x ?? 0)\n const y = dot?.y ?? py(shape?.y ?? 0)\n const name = marker?.name ?? shape?.name ?? ''\n const v = entry.value\n return {\n index: i,\n label: shape?.code ?? name,\n ...(shape ? { region: shape.code } : { marker: name }),\n // One row, \"■ Poland 80\": a region without a value and a marker only name themselves.\n title: '',\n x,\n area,\n items: [\n {\n name,\n seriesIndex: 0,\n value: v,\n text: v === null ? '' : value(v),\n x,\n y,\n color: marker ? MARKER : v === null ? EMPTY : paint(position(v)).color,\n },\n ],\n highlight: {\n kind: 'halo',\n d: dot\n ? circlePath(dot.x, dot.y, radius + 3)\n : (shape?.rings ?? [])\n .map((ring) => {\n let d = ''\n for (let p = 0; p < ring.length; p += 2)\n d += `${p ? 'L' : 'M'}${Math.round(px(ring[p] as number) * 10) / 10} ${Math.round(py(ring[p + 1] as number) * 10) / 10}`\n return `${d}Z`\n })\n .join(''),\n },\n }\n }\n\n const interaction: MapInteraction = {\n count,\n map: layout,\n hitIndex: hitAt,\n hitTest(x, y) {\n if (!(k > 0)) return null\n if (x < area.x || x > area.x + area.width || y < area.y || y > area.y + area.height)\n return null\n const near = (dot: { x: number; y: number }) => Math.hypot(dot.x - x, dot.y - y) <= radius + 4\n // What is drawn on top is hit first: markers, then dots, then shapes.\n for (let i = count - 1; i >= firstMarker; i--)\n if (near(entries[i]?.marker as { x: number; y: number })) return hitAt(i)\n for (let i = 0; i < valued; i++) {\n const shape = entries[i]?.shape as Shape\n if (shape.point && near({ x: px(shape.x), y: py(shape.y) })) return hitAt(i)\n }\n const mx = (x - tx) / k\n const my = (y - ty) / k\n for (const [shape, i] of indexOf) {\n const [x0, y0, x1, y1] = shape.box\n if (shape.point || mx < x0 || mx > x1 || my < y0 || my > y1) continue\n if (inside(shape.rings, mx, my)) return hitAt(i)\n }\n return null\n },\n }\n const regions: VNode[] = []\n // A selected shape goes in after the others, where nothing covers its outline.\n const raised: VNode[] = []\n const points: VNode[] = []\n for (const shape of shapes.values()) {\n const i = indexOf.get(shape)\n const v = i === undefined ? null : (entries[i]?.value ?? null)\n const style = v === null ? undefined : paint(position(v)).style\n const chosen = selected.has(shape.code) && 'tc-region-selected'\n if (!shape.point) {\n ;(chosen ? raised : regions).push(\n h('path', {\n key: shape.code,\n class: ['tc-region', v === null ? 'tc-region-empty' : 'tc-cell', chosen],\n 'data-region': shape.code,\n d: shape.path,\n style,\n }),\n )\n } else if (v !== null) {\n // A country too small for a shape says nothing without a value, so only then is it drawn.\n points.push(\n h('circle', {\n key: shape.code,\n class: ['tc-region tc-region-point tc-cell', chosen],\n 'data-region': shape.code,\n cx: round(px(shape.x)),\n cy: round(py(shape.y)),\n r: radius,\n style,\n }),\n )\n }\n }\n\n // Lines go in before the markers, so the markers sit on top of their ends.\n const byName = new Map(markers.map((marker) => [marker.name, marker]))\n const lines = (options.lines ?? []).flatMap((line, i) => {\n const from = byName.get(line.from)\n const to = byName.get(line.to)\n if (!from || !to) return []\n // A curve through a point pushed sideways from the middle of the line.\n const cx = (from.x + to.x) / 2 + (to.y - from.y) * LINE_CURVE\n const cy = (from.y + to.y) / 2 - (to.x - from.x) * LINE_CURVE\n return h('path', {\n key: `${line.from}›${line.to}›${i}`,\n class: 'tc-map-line',\n d: `M${round(from.x)} ${round(from.y)}Q${round(cx)} ${round(cy)} ${round(to.x)} ${round(to.y)}`,\n })\n })\n\n // The scale, centered below the map: the lowest value, a bar of the colors, the highest.\n const scaleText = typeof options.scale === 'object' ? options.scale : {}\n const low = scaleText.low ?? value(lo)\n const high = scaleText.high ?? value(hi)\n const lowWidth = estimateTextWidth(low, fontSize)\n const barWidth = SCALE_STEPS * SCALE_STEP\n const scaleWidth = lowWidth + 8 + barWidth + 8 + estimateTextWidth(high, fontSize)\n const scaleX = Math.round(area.x + Math.max(0, (area.width - scaleWidth) / 2))\n const barX = Math.round(scaleX + lowWidth + 8)\n const scaleY = area.y + area.height + 8 + (scaleHeight - 8) / 2\n\n const selectable = options.select === 'single' || options.select === 'multiple'\n const clip = `${ctx.id}-map`\n\n const content = [\n clipped &&\n h(\n 'clipPath',\n { key: 'clip', id: clip },\n h('rect', { x: area.x, y: area.y, width: area.width, height: area.height }),\n ),\n h(\n 'g',\n {\n key: 'map',\n class: ['tc-map', selectable && 'tc-map-selectable'],\n 'clip-path': clipped ? `url(#${clip})` : undefined,\n },\n k > 0 &&\n h(\n 'g',\n {\n key: 'regions',\n class: 'tc-map-regions',\n transform: `translate(${tx} ${ty}) scale(${k})`,\n },\n regions,\n raised,\n ),\n h('g', { key: 'points', class: 'tc-map-points' }, points),\n h('g', { key: 'lines', class: 'tc-map-lines' }, lines),\n h(\n 'g',\n { key: 'markers', class: 'tc-map-markers' },\n markers.map((marker, i) =>\n h('circle', {\n key: `${marker.name}›${i}`,\n class: 'tc-map-marker',\n 'data-marker': marker.name,\n cx: round(marker.x),\n cy: round(marker.y),\n r: radius,\n }),\n ),\n ),\n ),\n scale &&\n h(\n 'g',\n // (Crisp edges: the slices of the bar meet without a seam.)\n {\n key: 'scale',\n class: 'tc-map-scale',\n 'aria-hidden': 'true',\n 'shape-rendering': 'crispEdges',\n },\n h('text', { class: 'tc-tick-label', x: scaleX, y: round(scaleY), dy: '0.32em' }, low),\n Array.from({ length: SCALE_STEPS }, (_, s) =>\n h('rect', {\n key: s,\n class: 'tc-cell',\n x: barX + s * SCALE_STEP,\n y: round(scaleY - SCALE_HEIGHT / 2),\n width: SCALE_STEP,\n height: SCALE_HEIGHT,\n style: paint(s / (SCALE_STEPS - 1)).style,\n }),\n ),\n h(\n 'text',\n { class: 'tc-tick-label', x: barX + barWidth + 8, y: round(scaleY), dy: '0.32em' },\n high,\n ),\n ),\n ]\n return { content, interaction }\n}\n\n/** Table: one row per region with a value, in the order of the data. */\nfunction mapTable(options: MapOptions, ctx: TableContext, limit: number): DataTable {\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n const shapes = isMap(map) ? shapesOf(map) : undefined\n const value = formatNumber(options.format, ctx.locale)\n const rows: string[][] = []\n for (const [code, raw] of Object.entries(options.data ?? {})) {\n const v = finite(raw)\n const shape = shapes?.get(code)\n if (shape && v !== null) rows.push([shape.name, value(v)])\n }\n return { columns: ['', 'Value'], total: rows.length, rows: rows.slice(0, limit) }\n}\n\n/** Width to height of the map with its scale at a usual size, so the map fills the chart. */\nfunction ratioOf(options: MapOptions): number | undefined {\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n if (!isMap(map)) return undefined\n const scale = options.scale !== false && Object.keys(options.data ?? {}).length > 0\n return round(600 / ((600 * map.height) / map.width + (scale ? 23 : 0)))\n}\n\n/** Values that are finite numbers, markers with real coordinates, lines and colors that are text. */\nconst cleanMap = (options: MapOptions): MapOptions => {\n const o = options as unknown as Record<string, unknown>\n const data: Record<string, number> = {}\n if (isRecord(o.data))\n for (const [code, v] of Object.entries(o.data)) {\n const n = finite(v)\n if (n !== null) data[code] = n\n }\n return {\n ...options,\n map: typeof o.map === 'string' || isMap(o.map) ? o.map : (undefined as never),\n data,\n colors: list(o.colors).filter((c): c is string => typeof c === 'string' && c.trim() !== ''),\n markers: records(o.markers, (m) => ({\n lat: finite(m.lat) as number,\n lng: finite(m.lng) as number,\n ...(typeof m.name === 'string' ? { name: m.name } : {}),\n })).filter((m) => m.lat !== null && m.lng !== null),\n lines: records(o.lines, (l) => ({ from: text(l.from), to: text(l.to) })),\n select: o.select === 'single' || o.select === 'multiple' ? o.select : undefined,\n selected: list(o.selected).filter((code): code is string => typeof code === 'string'),\n view: isRecord(o.view) ? (o.view as Partial<MapView>) : undefined,\n onSelect: typeof o.onSelect === 'function' ? (o.onSelect as MapOptions['onSelect']) : undefined,\n }\n}\n\n/**\n * Map: the regions of a map file as SVG shapes, shaded by value from the\n * empty shade to the full color (`--tc-heat-color`, the cells of the\n * heatmap) or through a scale of `colors`, with markers placed by their\n * coordinates, lines between them and a bar of the scale. The shapes come\n * projected from the map file, so no geo library ships to the browser.\n *\n * ```ts\n * import { world } from '@tabler/charts/maps/world'\n *\n * new Chart('#el', {\n * type: map,\n * map: world,\n * data: { PL: 80, DE: 45, US: 100 },\n * })\n * ```\n */\nexport const map: ChartType<MapOptions> = {\n name: 'map',\n // (The options come with the whole config: its proportions are defaulted here.)\n clean: (options) => {\n const config = cleanMap(options) as MapOptions & {\n aspectRatio?: number\n autoRatio?: number\n }\n // The ratio set here follows the map; one of your own is kept.\n if (config.aspectRatio !== undefined && config.aspectRatio !== config.autoRatio) return config\n const autoRatio = ratioOf(config)\n return { ...config, aspectRatio: autoRatio, autoRatio }\n },\n render: renderMap,\n table: mapTable,\n // Zoom, drag and selection: at work only with `zoom` or `select`.\n plugins: [mapInteraction()],\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAAgB,QAAQ,MAAoC,QAA4B;CACtF,MAAM,QAAQ,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,GAAGA,cAAAA,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC;CACxE,MAAM,OAAO,OAAO,IAAI;CACxB,MAAM,OAAO,IAAmB,MAAc,SAAyB;EACrE,MAAM,OAAO,OAAO;EACpB,OAAO,QAAQ,QAAQ,OAAO,QAAQ,IAAI,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC,CAAC;CACtF;CACA,OAAO,OAAO,IACV;EACE,GAAG,IAAIA,cAAAA,OAAO,MAAM,CAAC,GAAG,OAAO,UAAU,OAAO,KAAK;EACrD,GAAG,IAAIA,cAAAA,OAAO,MAAM,CAAC,GAAG,OAAO,WAAW,OAAO,MAAM;EACvD;CACF,IACA;EAAE,GAAG;EAAG,GAAG;EAAG;CAAM;AAC1B;;;ACrCA,MAAM,YAAY;AAClB,MAAM,gBAAgB;;;;;AAKtB,MAAM,cAAc;AACpB,MAAM,oBAAoB;;AAE1B,MAAM,iBAAiB;AACvB,MAAM,SAAS;AACf,MAAM,QAAQ,CAAC,oBAAoB,UAAU;;;;;;;;AAS7C,SAAgB,iBAA8B;CAC5C,OAAO;EACL,MAAM;EACN,QAAQ,OAAO;GACb,MAAM,OAAO,MAAM;GACnB,IAAI,OAAO,KAAK,qBAAqB,YAAY,OAAO,CAAC;GACzD,MAAM,MAAM,KAAK;GACjB,MAAM,MAAM,IAAI;GAChB,MAAM,gBAAgB,MAAM;GAC5B,MAAM,cAAc,MAAM,OAAO,KAAK,SAAS;GAC/C,MAAM,eAAe,MAAM,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;GAC5C,MAAM,eAAgB,MAAM,aAAqD;GACjF,MA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AO;GAAE,GAAG;GAAQ,aAAa;GAAW;EAAU;CACxD;CACA,QAAQ;CACR,OAAO;CAEP,SAAS,CAAC,eAAe,CAAC;AAC5B"}
|
package/dist/map-C15NC7kW.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-C15NC7kW.js","names":[],"sources":["../src/charts/map-view.ts","../src/plugins/map.ts","../src/charts/map.ts"],"sourcesContent":["import { finite } from './clean.ts'\n\n/** The part of a map in sight. */\nexport interface MapView {\n /** The top left corner, in the coordinates of the map file. */\n x: number\n y: number\n /** How many times the map is magnified; `1` shows all of it. */\n scale: number\n}\n\n/** Where the last render put the map, for the zoom to work from. */\nexport interface MapLayout {\n /** The room of the map in chart pixels. */\n x: number\n y: number\n width: number\n height: number\n /** Pixels per unit of the map when all of it is in sight. */\n k: number\n /** Size of the map file. */\n mapWidth: number\n mapHeight: number\n /** The most the map can be magnified. */\n max: number\n}\n\n/**\n * A view kept inside the zoom range and the map itself, so the map can never\n * be dragged out of sight; along a side where all of the map fits, it is centered.\n */\nexport function fitView(view: Partial<MapView> | undefined, layout: MapLayout): MapView {\n const scale = Math.min(layout.max, Math.max(1, finite(view?.scale) ?? 1))\n const unit = layout.k * scale\n const fit = (at: number | null, size: number, room: number): number => {\n const span = room / unit\n return span >= size ? (size - span) / 2 : Math.min(size - span, Math.max(0, at ?? 0))\n }\n return unit > 0\n ? {\n x: fit(finite(view?.x), layout.mapWidth, layout.width),\n y: fit(finite(view?.y), layout.mapHeight, layout.height),\n scale,\n }\n : { x: 0, y: 0, scale }\n}\n","import type { MapHit, MapInteraction, MapOptions } from '../charts/map.ts'\nimport { fitView, type MapView } from '../charts/map-view.ts'\nimport { toChartPoint } from '../interaction.ts'\nimport type { ChartPlugin } from '../plugin.ts'\n\ntype Point = [number, number]\n\n/** One step of a button, a key or a double click. */\nconst ZOOM_STEP = 2\nconst ZOOM_DURATION = 200\n/**\n * How much one unit of wheel movement magnifies. A pinch on a trackpad comes\n * as a wheel event with `ctrlKey` and much smaller numbers.\n */\nconst WHEEL_SPEED = 0.002\nconst WHEEL_SPEED_PINCH = 0.01\n/** How far a pointer has to move, in pixels, before a press becomes a drag and stops being a click. */\nconst DRAG_THRESHOLD = 4\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst ICONS = ['M12 5v14M5 12h14', 'M5 12h14']\n\n/**\n * What makes a map more than a picture: with `zoom` it is magnified with its\n * buttons, the wheel, a double click, a pinch or the `+`, `-` and `0` keys,\n * and dragged around; with `select` a click (or Enter) selects a region. The\n * `map` chart type brings it along, so it needs no import of its own; it\n * keeps no state, the view and the selection live in the options.\n */\nexport function mapInteraction(): ChartPlugin {\n return {\n name: 'map',\n install(chart) {\n const host = chart.element\n if (typeof host.addEventListener !== 'function') return {}\n const doc = host.ownerDocument\n const win = doc.defaultView\n const options = () => chart.config as unknown as MapOptions & { animate?: boolean }\n const isMap = () => chart.config.type.name === 'map'\n const zoomOn = () => isMap() && !!options().zoom\n const layout = () => (chart.interaction as Partial<MapInteraction> | undefined)?.map\n const svg = () => host.querySelector(':scope > svg.tc-chart')\n /** Whether an event happened on the drawing, not on a control over it. */\n const onMap = (event: Event) =>\n (event.target as Element | null)?.closest?.('svg.tc-chart') === svg() && !!svg()\n\n let frame = 0\n /** Pointers that are down on the map, with where each was last seen. */\n const pointers = new Map<number, Point>()\n /** Whether the pointers that are down have moved the map: the click that ends a drag selects nothing. */\n let dragged = false\n let controls: HTMLElement | undefined\n const addedClass = !host.classList.contains('tc-container')\n\n const stop = () => win?.cancelAnimationFrame(frame)\n const current = (): MapView | undefined => {\n const l = layout()\n return l && fitView(options().view, l)\n }\n const setView = (view: MapView) => {\n const l = layout()\n if (l) chart.update({ view: fitView(view, l) } as never)\n }\n\n /** A point of the screen in chart pixels. */\n const toChart = (x: number, y: number): Point => {\n const el = svg()\n const { width, height } = chart.size\n const p = el ? toChartPoint(el, x, y, width, height) : { x: 0, y: 0 }\n return [p.x, p.y]\n }\n /** A point of the screen in the coordinates of the map. */\n const toMapPoint = (x: number, y: number): Point | null => {\n const l = layout()\n const view = current()\n if (!l || !view) return null\n const unit = l.k * view.scale\n const [cx, cy] = toChart(x, y)\n return [view.x + (cx - l.x) / unit, view.y + (cy - l.y) / unit]\n }\n\n /**\n * Moves to a view over a few frames. The corner and the size of the\n * view change at the same pace, which keeps the point being zoomed at in place.\n */\n const animateTo = (to: MapView) => {\n stop()\n const l = layout()\n const from = current()\n if (!l || !from) return\n const target = fitView(to, l)\n const still =\n options().animate === false ||\n !win?.requestAnimationFrame ||\n win.matchMedia?.('(prefers-reduced-motion: reduce)').matches\n if (still) {\n setView(target)\n return\n }\n const start = performance.now()\n const step = (now: number) => {\n const t = Math.min((now - start) / ZOOM_DURATION, 1)\n const eased = 1 - (1 - t) ** 3\n const at = (a: number, b: number) => a + (b - a) * eased\n setView({\n x: at(from.x, target.x),\n y: at(from.y, target.y),\n scale: 1 / at(1 / from.scale, 1 / target.scale),\n })\n if (t < 1) frame = win.requestAnimationFrame(step)\n }\n frame = win.requestAnimationFrame(step)\n }\n\n /**\n * Magnifies by a factor around a point of the map, which stays where it\n * is on the screen. Without a point, around the middle of the view.\n */\n const zoomBy = (factor: number, anchor: Point | null, animate = false) => {\n const l = layout()\n const view = current()\n if (!l || !view || !(l.k > 0)) return\n const next = Math.min(l.max, Math.max(1, view.scale * factor))\n const unit = l.k * view.scale\n const [ax, ay] = anchor ?? [view.x + l.width / unit / 2, view.y + l.height / unit / 2]\n const target = {\n x: ax - ((ax - view.x) * view.scale) / next,\n y: ay - ((ay - view.y) * view.scale) / next,\n scale: next,\n }\n if (animate) animateTo(target)\n else {\n stop()\n setView(target)\n }\n }\n\n /** Selects the region of a hit, or takes it out when it is selected. */\n const select = (hit: MapHit | null) => {\n const o = options()\n const code = hit?.region\n if (!isMap() || !o.select || !code) return\n const selected = [...(o.selected ?? [])]\n const rest = selected.filter((other) => other !== code)\n const next =\n rest.length < selected.length\n ? rest\n : o.select === 'multiple'\n ? [...selected, code]\n : [code]\n chart.update({ selected: next } as never)\n o.onSelect?.(next, code)\n }\n\n const onPointerEnd = (event: PointerEvent) => {\n pointers.delete(event.pointerId)\n if (pointers.size === 0) {\n doc.removeEventListener('pointerup', onPointerEnd)\n doc.removeEventListener('pointercancel', onPointerEnd)\n // The cursor of a drag goes with the next render.\n if (dragged) chart.update({})\n }\n }\n const onPointerDown = (event: PointerEvent) => {\n if (!zoomOn() || !onMap(event) || (event.pointerType === 'mouse' && event.button !== 0))\n return\n if (pointers.size === 0) dragged = false\n pointers.set(event.pointerId, [event.clientX, event.clientY])\n stop()\n doc.addEventListener('pointerup', onPointerEnd)\n doc.addEventListener('pointercancel', onPointerEnd)\n }\n /** One pointer drags the map, two pinch it. */\n const onPointerMove = (event: PointerEvent) => {\n const previous = pointers.get(event.pointerId)\n const view = current()\n const l = layout()\n if (!previous || !view || !l) return\n const now: Point = [event.clientX, event.clientY]\n // A press that barely moves is a click, not a drag: until the pointer\n // has moved far enough the map stays put, and the click reaches the region.\n if (!dragged) {\n if (\n pointers.size === 1 &&\n Math.hypot(now[0] - previous[0], now[1] - previous[1]) < DRAG_THRESHOLD\n )\n return\n dragged = true\n // The map keeps getting the moves of this pointer when it leaves the\n // map. Capturing throws for a pointer the browser does not know,\n // which is what an event made in a script has.\n try {\n svg()?.setPointerCapture(event.pointerId)\n } catch {\n // The drag still works while the pointer stays over the map.\n }\n }\n // The highlight and the tooltip stay out of a drag.\n event.stopPropagation()\n chart.clearHighlight()\n pointers.set(event.pointerId, now)\n if (pointers.size === 1) {\n const unit = l.k * view.scale\n const [x0, y0] = toChart(previous[0], previous[1])\n const [x1, y1] = toChart(now[0], now[1])\n setView({ x: view.x - (x1 - x0) / unit, y: view.y - (y1 - y0) / unit, scale: view.scale })\n return\n }\n const other = [...pointers].find(([id]) => id !== event.pointerId)?.[1]\n if (!other) return\n const before = Math.hypot(previous[0] - other[0], previous[1] - other[1])\n const after = Math.hypot(now[0] - other[0], now[1] - other[1])\n if (before > 0 && after > 0)\n zoomBy(after / before, toMapPoint((now[0] + other[0]) / 2, (now[1] + other[1]) / 2))\n }\n const onWheel = (event: WheelEvent) => {\n const { zoom } = options()\n if (!zoomOn() || (typeof zoom === 'object' && zoom.wheel === false) || !onMap(event)) return\n // The page must not scroll while the wheel zooms the map.\n event.preventDefault()\n zoomBy(\n Math.exp(-event.deltaY * (event.ctrlKey ? WHEEL_SPEED_PINCH : WHEEL_SPEED)),\n toMapPoint(event.clientX, event.clientY),\n )\n }\n const onDoubleClick = (event: MouseEvent) => {\n if (zoomOn() && onMap(event))\n zoomBy(ZOOM_STEP, toMapPoint(event.clientX, event.clientY), true)\n }\n /** The click that ends a drag is not a click on the map. */\n const onClickCapture = (event: MouseEvent) => {\n if (dragged) event.stopPropagation()\n dragged = false\n }\n const onKey = (event: KeyboardEvent) => {\n if (event.target !== svg() || !isMap()) return\n const { key } = event\n if (zoomOn() && (key === '+' || key === '=')) zoomBy(ZOOM_STEP, null, true)\n else if (zoomOn() && key === '-') zoomBy(1 / ZOOM_STEP, null, true)\n else if (zoomOn() && key === '0') animateTo({ x: 0, y: 0, scale: 1 })\n else if (options().select && (key === 'Enter' || key === ' ') && chart.active)\n select(chart.active)\n else return\n event.preventDefault()\n }\n const onControl = (event: MouseEvent) => {\n const button = (event.target as Element).closest('button')\n if (button) zoomBy(button.value === 'in' ? ZOOM_STEP : 1 / ZOOM_STEP, null, true)\n }\n\n // Moves are taken on their way down, so a drag never reaches the highlight.\n host.addEventListener('pointermove', onPointerMove, true)\n host.addEventListener('click', onClickCapture, true)\n host.addEventListener('pointerdown', onPointerDown)\n // (Not passive: the wheel must be kept from scrolling the page.)\n host.addEventListener('wheel', onWheel, { passive: false })\n host.addEventListener('dblclick', onDoubleClick)\n host.addEventListener('keydown', onKey)\n const off = chart.on('click', ({ hit }) => select(hit))\n\n /** The zoom buttons, laid over a corner of the map. */\n const renderControls = () => {\n if (!zoomOn()) {\n controls?.remove()\n controls = undefined\n return\n }\n if (!controls) {\n controls = doc.createElement('div')\n controls.className = 'tc-map-zoom'\n for (const [i, d] of ICONS.entries()) {\n const button = doc.createElement('button')\n button.type = 'button'\n button.className = 'tc-download-toggle'\n button.value = i ? 'out' : 'in'\n const icon = doc.createElementNS(SVG_NS, 'svg')\n icon.setAttribute('viewBox', '0 0 24 24')\n icon.setAttribute('width', '16')\n icon.setAttribute('height', '16')\n icon.setAttribute('aria-hidden', 'true')\n const path = doc.createElementNS(SVG_NS, 'path')\n path.setAttribute('d', d)\n icon.append(path)\n button.append(icon)\n controls.append(button)\n }\n controls.addEventListener('click', onControl)\n host.classList.add('tc-container')\n }\n if (!controls.isConnected) host.append(controls)\n const { zoom } = options()\n const labels = typeof zoom === 'object' ? zoom.labels : undefined\n const view = current()\n const max = layout()?.max ?? 1\n const [zoomIn, zoomOut] = controls.querySelectorAll('button')\n if (zoomIn && zoomOut && view) {\n zoomIn.setAttribute('aria-label', labels?.in ?? 'Zoom in')\n zoomOut.setAttribute('aria-label', labels?.out ?? 'Zoom out')\n zoomIn.disabled = view.scale >= max\n zoomOut.disabled = view.scale <= 1\n }\n }\n\n return {\n // The stylesheet takes drags and pinches for a map that can be\n // magnified, so the page does not scroll or zoom under the finger.\n svgAttrs: () =>\n zoomOn() ? { 'data-zoom': dragged && pointers.size ? 'drag' : '' } : undefined,\n afterRender: renderControls,\n destroy() {\n stop()\n off()\n host.removeEventListener('pointermove', onPointerMove, true)\n host.removeEventListener('click', onClickCapture, true)\n host.removeEventListener('pointerdown', onPointerDown)\n host.removeEventListener('wheel', onWheel)\n host.removeEventListener('dblclick', onDoubleClick)\n host.removeEventListener('keydown', onKey)\n doc.removeEventListener('pointerup', onPointerEnd)\n doc.removeEventListener('pointercancel', onPointerEnd)\n controls?.remove()\n if (controls && addedClass) host.classList.remove('tc-container')\n },\n }\n },\n }\n}\n","import type { ChartType, DataTable, RenderContext, RenderResult, TableContext } from '../chart.ts'\nimport { formatNumber, type NumberFormat } from '../format.ts'\nimport type { Hit, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n innerRect,\n insets,\n LINE_HEIGHT,\n round,\n} from '../layout.ts'\nimport { mapInteraction } from '../plugins/map.ts'\nimport { h, type StyleValue, type VNode } from '../vnode.ts'\nimport { finite, isRecord, list, records, text } from './clean.ts'\nimport { fitView, type MapLayout, type MapView } from './map-view.ts'\n\nexport type { MapLayout, MapView }\n\n/** One region of a map (a country, a state …). */\nexport interface MapRegion {\n name: string\n /**\n * SVG path data in the coordinates of the map (`M`, `L`, `H`, `V` and `Z`,\n * absolute or relative; curves are drawn but not hit by the pointer).\n */\n path: string\n /** Too small for a shape at the scale of the map: `path` is a single point, drawn as a dot when it has a value. */\n point?: boolean\n}\n\n/** A map: shapes already projected into a `width` × `height` box, as the files in `@tabler/charts/maps/*` are. */\nexport interface MapData {\n width: number\n height: number\n /** How the shapes were projected, to place a marker by its coordinates. */\n projection?: { type: 'miller'; scale: number; translate: readonly number[] }\n /** Regions by their code, e.g. ISO 3166-1 alpha-2 for countries. */\n regions: Readonly<Record<string, MapRegion>>\n}\n\n/** A place on the map, by its coordinates. */\nexport interface MapMarker {\n /** Shown in the tooltip, and what a line refers to. */\n name?: string\n /** Latitude and longitude in degrees. */\n lat: number\n lng: number\n}\n\n/** A curve between two markers, by their names. */\nexport interface MapLine {\n from: string\n to: string\n}\n\nexport interface MapOptions {\n /** The map: a map file (`import { world } from '@tabler/charts/maps/world'`), or the name it was given with `addMap()`. */\n map: MapData | string\n /** A value per region code, e.g. `{ PL: 80, DE: 45 }`. Regions without one keep the empty shade. */\n data: Readonly<Record<string, number | null>>\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 * A continuous scale through two or more colors (any CSS color, including\n * `var(--tc-…)`), from `min` to `max`, instead of one hue (`--tc-heat-color`).\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 /** Places drawn as dots over the map. */\n markers?: readonly MapMarker[]\n /** Dashed curves between markers. */\n lines?: readonly MapLine[]\n /** Radius of the markers and of the regions drawn as a dot, in pixels. Defaults to `4`. */\n markerRadius?: number\n /** Format of the values (tooltip, scale, table). */\n format?: NumberFormat\n /**\n * The bar below the map with the lowest and the highest value: `false`\n * hides it, an object names its ends instead of the values.\n */\n scale?: boolean | { low?: string; high?: string }\n /** Extra space around the map, in pixels. */\n padding?: InsetsInput\n /**\n * Let the map be magnified with its buttons, the wheel, a double click, a\n * pinch or the `+` and `-` keys, and dragged around. An object sets the\n * most it magnifies (`max`, `8` by default), turns the wheel off\n * (`wheel: false`) and names the buttons (`labels`).\n */\n zoom?: boolean | { max?: number; wheel?: boolean; labels?: { in?: string; out?: string } }\n /**\n * The part of the map in sight. Zooming and dragging write it; set it\n * yourself to start on a part of the map, leave it out for the whole map.\n */\n view?: Partial<MapView>\n /**\n * Let regions be selected with a click (or Enter on the region the\n * keyboard is on): one at a time, or any number of them. A click on a\n * selected region takes it out again.\n */\n select?: 'single' | 'multiple'\n /** Codes of the selected regions. Selecting writes it; `onSelect` hears of it. */\n selected?: readonly string[]\n /** Called when a click or a key changes the selection, with the codes now selected and the one that changed. */\n onSelect?: (selected: string[], code: string) => void\n}\n\n/** A hit of a map: what it is on. */\nexport interface MapHit extends Hit {\n /** Code of the region, for a hit on a region. */\n region?: string\n /** Name of the marker, for a hit on a marker. */\n marker?: string\n}\n\n/** The interaction of a map, with where the map was drawn. */\nexport interface MapInteraction extends Interaction {\n map: MapLayout\n}\n\n/** The selected regions of the options that are allowed: one when only one can be selected. */\nexport const selectedOf = (options: MapOptions): readonly string[] =>\n options.select === 'multiple'\n ? (options.selected ?? [])\n : options.select === 'single'\n ? (options.selected ?? []).slice(0, 1)\n : []\n\n/** Share of the full color at the minimum, so the lowest value still stands out from a region without one. */\nconst FLOOR = 0.1\nconst EMPTY = 'var(--tc-heat-empty,var(--tc-grid-color))'\nconst MARKER = 'var(--tc-map-marker-color,var(--tc-color-1))'\n/** Slices of the scale's bar: enough to read as one smooth gradient. */\nconst SCALE_STEPS = 24\nconst SCALE_STEP = 5\nconst SCALE_HEIGHT = 8\n/** How far a line bends away from the straight one, as a share of its length. */\nconst LINE_CURVE = 0.2\nconst RADIANS = Math.PI / 180\n\nconst maps: Record<string, MapData> = {}\n\n/** Register a map under a name, so `map: 'world'` finds it (configs from JSON, `<tabler-chart>`, the data API). */\nexport function addMap(name: string, data: MapData): void {\n maps[name] = data\n}\n\nconst isMap = (v: unknown): v is MapData =>\n isRecord(v) && isRecord(v.regions) && (finite(v.width) ?? 0) > 0 && (finite(v.height) ?? 0) > 0\n\n/** A region ready to draw and to hit: its rings as flat `x, y` lists in map coordinates. */\ninterface Shape {\n code: string\n name: string\n path: string\n point: boolean\n rings: number[][]\n /** Bounds of the shape: left, top, right, bottom. */\n box: [number, number, number, number]\n /** Middle of the largest ring (the mainland), where the keyboard's tooltip sits. */\n x: number\n y: number\n}\n\n/** Rings of path data made of moves and straight lines. */\nfunction parsePath(d: string): number[][] {\n const rings: number[][] = []\n let ring: number[] = []\n let x = 0\n let y = 0\n for (const [, command = '', args = ''] of d.matchAll(/([MLHVZ])([^MLHVZ]*)/gi)) {\n const n = (args.match(/-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi) ?? []).map(Number)\n const relative = command >= 'a'\n const type = command.toUpperCase()\n if (type === 'Z') {\n if (ring.length) {\n x = ring[0] as number\n y = ring[1] as number\n }\n continue\n }\n const step = type === 'H' || type === 'V' ? 1 : 2\n for (let i = 0; i + step <= n.length; i += step) {\n const a = n[i] as number\n const b = n[i + 1] as number\n if (type === 'H') x = relative ? x + a : a\n else if (type === 'V') y = relative ? y + a : a\n else {\n x = relative ? x + a : a\n y = relative ? y + b : b\n }\n // A move starts a ring; the pairs after its first are lines.\n if (type === 'M' && i === 0) {\n ring = []\n rings.push(ring)\n }\n ring.push(x, y)\n }\n }\n return rings\n}\n\nconst parsed = new WeakMap<MapData, Map<string, Shape>>()\n\n/** The regions of a map, parsed once per map file. */\nfunction shapesOf(map: MapData): Map<string, Shape> {\n let shapes = parsed.get(map)\n if (shapes) return shapes\n shapes = new Map()\n for (const [code, region] of Object.entries(map.regions)) {\n if (!isRecord(region) || typeof region.path !== 'string') continue\n const rings = parsePath(region.path).filter((ring) => ring.every(Number.isFinite))\n const box: Shape['box'] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ]\n let x = 0\n let y = 0\n let largest = -1\n for (const ring of rings) {\n let x0 = Number.POSITIVE_INFINITY\n let y0 = Number.POSITIVE_INFINITY\n let x1 = Number.NEGATIVE_INFINITY\n let y1 = Number.NEGATIVE_INFINITY\n for (let i = 0; i < ring.length; i += 2) {\n x0 = Math.min(x0, ring[i] as number)\n x1 = Math.max(x1, ring[i] as number)\n y0 = Math.min(y0, ring[i + 1] as number)\n y1 = Math.max(y1, ring[i + 1] as number)\n }\n box[0] = Math.min(box[0], x0)\n box[1] = Math.min(box[1], y0)\n box[2] = Math.max(box[2], x1)\n box[3] = Math.max(box[3], y1)\n const size = (x1 - x0) * (y1 - y0)\n if (size > largest) {\n largest = size\n x = (x0 + x1) / 2\n y = (y0 + y1) / 2\n }\n }\n if (largest < 0) continue\n shapes.set(code, {\n code,\n name: text(region.name) || code,\n path: region.path,\n point: region.point === true,\n rings,\n box,\n x,\n y,\n })\n }\n parsed.set(map, shapes)\n return shapes\n}\n\n/** Whether a point lies inside the rings (even-odd, so a hole is outside). */\nfunction inside(rings: readonly number[][], x: number, y: number): boolean {\n let hit = false\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {\n const xi = ring[i] as number\n const yi = ring[i + 1] as number\n const xj = ring[j] as number\n const yj = ring[j + 1] as number\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) hit = !hit\n }\n }\n return hit\n}\n\n/** Path of a circle, for the ring around a hovered dot. */\nconst circlePath = (x: number, y: number, r: number): string =>\n `M${round(x - r)} ${round(y)}a${r} ${r} 0 1 0 ${r * 2} 0a${r} ${r} 0 1 0 ${-r * 2} 0Z`\n\n/** What the pointer and the keyboard can land on. */\ninterface Entry {\n shape?: Shape\n marker?: { name: string; x: number; y: number }\n value: number | null\n}\n\nfunction renderMap(options: MapOptions, ctx: RenderContext): RenderResult {\n const { width, height, fontSize, locale } = ctx\n if (typeof options.map === 'string' && !maps[options.map]) {\n throw new Error(\n `[tabler-charts] Map \"${options.map}\" is not registered. Import it (e.g. from '@tabler/charts/maps/world') and call addMap('${options.map}', data).`,\n )\n }\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n if (!isMap(map)) return { content: null }\n const shapes = shapesOf(map)\n const data = options.data ?? {}\n const value = formatNumber(options.format, locale)\n const radius = Math.max(0, finite(options.markerRadius) ?? 4)\n\n // Regions with a value, in the order of the data (the order the keyboard walks).\n const entries: Entry[] = []\n const indexOf = new Map<Shape, number>()\n let dataMin = Number.POSITIVE_INFINITY\n let dataMax = Number.NEGATIVE_INFINITY\n for (const code of Object.keys(data)) {\n const shape = shapes.get(code)\n const v = finite(data[code])\n if (!shape || v === null) continue\n indexOf.set(shape, entries.length)\n entries.push({ shape, value: v })\n if (v < dataMin) dataMin = v\n if (v > dataMax) dataMax = v\n }\n const valued = entries.length\n\n // Color domain and the scale of colors.\n const lo = finite(options.min) ?? (valued ? Math.min(0, dataMin) : 0)\n const hi = finite(options.max) ?? (valued ? dataMax : 1)\n const stops = options.colors && options.colors.length >= 2 ? options.colors : undefined\n const mid = finite(options.mid)\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 t =\n stops && mid !== null && lo < mid && mid < hi\n ? v <= mid\n ? ((v - lo) / (mid - lo)) * 0.5\n : 0.5 + ((v - mid) / (hi - mid)) * 0.5\n : hi > lo\n ? (v - lo) / (hi - lo)\n : v > lo\n ? 1\n : 0\n return Math.min(1, Math.max(0, t))\n }\n /** How a region at position `t` of the scale is painted: its style and the tooltip swatch. */\n const paint = (t: number): { style: StyleValue; color: string } => {\n if (stops) {\n const at = t * (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 = round((FLOOR + (1 - FLOOR) * t) * 100)\n return {\n style: `--tc-heat:${pct}%`,\n color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`,\n }\n }\n\n // The map keeps its proportions, centered in the room above the scale.\n const pad = insets(options.padding, 0)\n const scale = options.scale !== false && valued > 0\n const scaleHeight = scale ? Math.ceil(fontSize * LINE_HEIGHT) + 8 : 0\n const area = innerRect(width, height, { ...pad, bottom: pad.bottom + scaleHeight })\n const zoom = typeof options.zoom === 'object' ? options.zoom : {}\n const layout: MapLayout = {\n ...area,\n k: Math.max(0, Math.min(area.width / map.width, area.height / map.height)),\n mapWidth: map.width,\n mapHeight: map.height,\n max: Math.max(1, finite(zoom.max) ?? 8),\n }\n const view = fitView(options.view, layout)\n // (`k` is pixels per unit of the map as it is drawn, magnified by the view.)\n const k = Math.round(layout.k * view.scale * 1e4) / 1e4\n const tx = round(area.x - view.x * k)\n const ty = round(area.y - view.y * k)\n const px = (x: number) => tx + x * k\n const py = (y: number) => ty + y * k\n // A magnified map is cut at the edges of its room.\n const clipped = view.scale > 1\n const selected = new Set(selectedOf(options))\n\n // Markers, placed with the projection the map file was made with.\n const { projection } = map\n const project =\n isRecord(projection) &&\n finite(projection.scale) !== null &&\n Array.isArray(projection.translate) &&\n projection.translate.slice(0, 2).every((n) => finite(n) !== null)\n ? (lng: number, lat: number): [number, number] => [\n px(lng * RADIANS * projection.scale + (projection.translate[0] as number)),\n py(\n (projection.translate[1] as number) -\n 1.25 * Math.log(Math.tan(Math.PI / 4 + 0.4 * lat * RADIANS)) * projection.scale,\n ),\n ]\n : undefined\n const markers: NonNullable<Entry['marker']>[] = []\n if (project && k > 0) {\n for (const marker of options.markers ?? []) {\n const [x, y] = project(marker.lng, marker.lat)\n if (Number.isFinite(x) && Number.isFinite(y)) markers.push({ name: marker.name ?? '', x, y })\n }\n }\n const firstMarker = entries.length\n for (const marker of markers) entries.push({ marker, value: null })\n // Regions without a value are not walked by the keyboard, but still name themselves on hover.\n const count = entries.length\n for (const shape of shapes.values()) {\n if (shape.point || indexOf.has(shape)) continue\n indexOf.set(shape, entries.length)\n entries.push({ shape, value: null })\n }\n\n const hitAt = (i: number): MapHit | null => {\n const entry = entries[i]\n if (!entry) return null\n const { shape, marker } = entry\n const dot = marker ?? (shape?.point ? { x: px(shape.x), y: py(shape.y) } : undefined)\n const x = dot?.x ?? px(shape?.x ?? 0)\n const y = dot?.y ?? py(shape?.y ?? 0)\n const name = marker?.name ?? shape?.name ?? ''\n const v = entry.value\n return {\n index: i,\n label: shape?.code ?? name,\n ...(shape ? { region: shape.code } : { marker: name }),\n // One row, \"■ Poland 80\": a region without a value and a marker only name themselves.\n title: '',\n x,\n area,\n items: [\n {\n name,\n seriesIndex: 0,\n value: v,\n text: v === null ? '' : value(v),\n x,\n y,\n color: marker ? MARKER : v === null ? EMPTY : paint(position(v)).color,\n },\n ],\n highlight: {\n kind: 'halo',\n d: dot\n ? circlePath(dot.x, dot.y, radius + 3)\n : (shape?.rings ?? [])\n .map((ring) => {\n let d = ''\n for (let p = 0; p < ring.length; p += 2)\n d += `${p ? 'L' : 'M'}${Math.round(px(ring[p] as number) * 10) / 10} ${Math.round(py(ring[p + 1] as number) * 10) / 10}`\n return `${d}Z`\n })\n .join(''),\n },\n }\n }\n\n const interaction: MapInteraction = {\n count,\n map: layout,\n hitIndex: hitAt,\n hitTest(x, y) {\n if (!(k > 0)) return null\n if (x < area.x || x > area.x + area.width || y < area.y || y > area.y + area.height)\n return null\n const near = (dot: { x: number; y: number }) => Math.hypot(dot.x - x, dot.y - y) <= radius + 4\n // What is drawn on top is hit first: markers, then dots, then shapes.\n for (let i = count - 1; i >= firstMarker; i--)\n if (near(entries[i]?.marker as { x: number; y: number })) return hitAt(i)\n for (let i = 0; i < valued; i++) {\n const shape = entries[i]?.shape as Shape\n if (shape.point && near({ x: px(shape.x), y: py(shape.y) })) return hitAt(i)\n }\n const mx = (x - tx) / k\n const my = (y - ty) / k\n for (const [shape, i] of indexOf) {\n const [x0, y0, x1, y1] = shape.box\n if (shape.point || mx < x0 || mx > x1 || my < y0 || my > y1) continue\n if (inside(shape.rings, mx, my)) return hitAt(i)\n }\n return null\n },\n }\n const regions: VNode[] = []\n // A selected shape goes in after the others, where nothing covers its outline.\n const raised: VNode[] = []\n const points: VNode[] = []\n for (const shape of shapes.values()) {\n const i = indexOf.get(shape)\n const v = i === undefined ? null : (entries[i]?.value ?? null)\n const style = v === null ? undefined : paint(position(v)).style\n const chosen = selected.has(shape.code) && 'tc-region-selected'\n if (!shape.point) {\n ;(chosen ? raised : regions).push(\n h('path', {\n key: shape.code,\n class: ['tc-region', v === null ? 'tc-region-empty' : 'tc-cell', chosen],\n 'data-region': shape.code,\n d: shape.path,\n style,\n }),\n )\n } else if (v !== null) {\n // A country too small for a shape says nothing without a value, so only then is it drawn.\n points.push(\n h('circle', {\n key: shape.code,\n class: ['tc-region tc-region-point tc-cell', chosen],\n 'data-region': shape.code,\n cx: round(px(shape.x)),\n cy: round(py(shape.y)),\n r: radius,\n style,\n }),\n )\n }\n }\n\n // Lines go in before the markers, so the markers sit on top of their ends.\n const byName = new Map(markers.map((marker) => [marker.name, marker]))\n const lines = (options.lines ?? []).flatMap((line, i) => {\n const from = byName.get(line.from)\n const to = byName.get(line.to)\n if (!from || !to) return []\n // A curve through a point pushed sideways from the middle of the line.\n const cx = (from.x + to.x) / 2 + (to.y - from.y) * LINE_CURVE\n const cy = (from.y + to.y) / 2 - (to.x - from.x) * LINE_CURVE\n return h('path', {\n key: `${line.from}›${line.to}›${i}`,\n class: 'tc-map-line',\n d: `M${round(from.x)} ${round(from.y)}Q${round(cx)} ${round(cy)} ${round(to.x)} ${round(to.y)}`,\n })\n })\n\n // The scale, centered below the map: the lowest value, a bar of the colors, the highest.\n const scaleText = typeof options.scale === 'object' ? options.scale : {}\n const low = scaleText.low ?? value(lo)\n const high = scaleText.high ?? value(hi)\n const lowWidth = estimateTextWidth(low, fontSize)\n const barWidth = SCALE_STEPS * SCALE_STEP\n const scaleWidth = lowWidth + 8 + barWidth + 8 + estimateTextWidth(high, fontSize)\n const scaleX = Math.round(area.x + Math.max(0, (area.width - scaleWidth) / 2))\n const barX = Math.round(scaleX + lowWidth + 8)\n const scaleY = area.y + area.height + 8 + (scaleHeight - 8) / 2\n\n const selectable = options.select === 'single' || options.select === 'multiple'\n const clip = `${ctx.id}-map`\n\n const content = [\n clipped &&\n h(\n 'clipPath',\n { key: 'clip', id: clip },\n h('rect', { x: area.x, y: area.y, width: area.width, height: area.height }),\n ),\n h(\n 'g',\n {\n key: 'map',\n class: ['tc-map', selectable && 'tc-map-selectable'],\n 'clip-path': clipped ? `url(#${clip})` : undefined,\n },\n k > 0 &&\n h(\n 'g',\n {\n key: 'regions',\n class: 'tc-map-regions',\n transform: `translate(${tx} ${ty}) scale(${k})`,\n },\n regions,\n raised,\n ),\n h('g', { key: 'points', class: 'tc-map-points' }, points),\n h('g', { key: 'lines', class: 'tc-map-lines' }, lines),\n h(\n 'g',\n { key: 'markers', class: 'tc-map-markers' },\n markers.map((marker, i) =>\n h('circle', {\n key: `${marker.name}›${i}`,\n class: 'tc-map-marker',\n 'data-marker': marker.name,\n cx: round(marker.x),\n cy: round(marker.y),\n r: radius,\n }),\n ),\n ),\n ),\n scale &&\n h(\n 'g',\n // (Crisp edges: the slices of the bar meet without a seam.)\n {\n key: 'scale',\n class: 'tc-map-scale',\n 'aria-hidden': 'true',\n 'shape-rendering': 'crispEdges',\n },\n h('text', { class: 'tc-tick-label', x: scaleX, y: round(scaleY), dy: '0.32em' }, low),\n Array.from({ length: SCALE_STEPS }, (_, s) =>\n h('rect', {\n key: s,\n class: 'tc-cell',\n x: barX + s * SCALE_STEP,\n y: round(scaleY - SCALE_HEIGHT / 2),\n width: SCALE_STEP,\n height: SCALE_HEIGHT,\n style: paint(s / (SCALE_STEPS - 1)).style,\n }),\n ),\n h(\n 'text',\n { class: 'tc-tick-label', x: barX + barWidth + 8, y: round(scaleY), dy: '0.32em' },\n high,\n ),\n ),\n ]\n return { content, interaction }\n}\n\n/** Table: one row per region with a value, in the order of the data. */\nfunction mapTable(options: MapOptions, ctx: TableContext, limit: number): DataTable {\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n const shapes = isMap(map) ? shapesOf(map) : undefined\n const value = formatNumber(options.format, ctx.locale)\n const rows: string[][] = []\n for (const [code, raw] of Object.entries(options.data ?? {})) {\n const v = finite(raw)\n const shape = shapes?.get(code)\n if (shape && v !== null) rows.push([shape.name, value(v)])\n }\n return { columns: ['', 'Value'], total: rows.length, rows: rows.slice(0, limit) }\n}\n\n/** Width to height of the map with its scale at a usual size, so the map fills the chart. */\nfunction ratioOf(options: MapOptions): number | undefined {\n const map = typeof options.map === 'string' ? maps[options.map] : options.map\n if (!isMap(map)) return undefined\n const scale = options.scale !== false && Object.keys(options.data ?? {}).length > 0\n return round(600 / ((600 * map.height) / map.width + (scale ? 23 : 0)))\n}\n\n/** Values that are finite numbers, markers with real coordinates, lines and colors that are text. */\nconst cleanMap = (options: MapOptions): MapOptions => {\n const o = options as unknown as Record<string, unknown>\n const data: Record<string, number> = {}\n if (isRecord(o.data))\n for (const [code, v] of Object.entries(o.data)) {\n const n = finite(v)\n if (n !== null) data[code] = n\n }\n return {\n ...options,\n map: typeof o.map === 'string' || isMap(o.map) ? o.map : (undefined as never),\n data,\n colors: list(o.colors).filter((c): c is string => typeof c === 'string' && c.trim() !== ''),\n markers: records(o.markers, (m) => ({\n lat: finite(m.lat) as number,\n lng: finite(m.lng) as number,\n ...(typeof m.name === 'string' ? { name: m.name } : {}),\n })).filter((m) => m.lat !== null && m.lng !== null),\n lines: records(o.lines, (l) => ({ from: text(l.from), to: text(l.to) })),\n select: o.select === 'single' || o.select === 'multiple' ? o.select : undefined,\n selected: list(o.selected).filter((code): code is string => typeof code === 'string'),\n view: isRecord(o.view) ? (o.view as Partial<MapView>) : undefined,\n onSelect: typeof o.onSelect === 'function' ? (o.onSelect as MapOptions['onSelect']) : undefined,\n }\n}\n\n/**\n * Map: the regions of a map file as SVG shapes, shaded by value from the\n * empty shade to the full color (`--tc-heat-color`, the cells of the\n * heatmap) or through a scale of `colors`, with markers placed by their\n * coordinates, lines between them and a bar of the scale. The shapes come\n * projected from the map file, so no geo library ships to the browser.\n *\n * ```ts\n * import { world } from '@tabler/charts/maps/world'\n *\n * new Chart('#el', {\n * type: map,\n * map: world,\n * data: { PL: 80, DE: 45, US: 100 },\n * })\n * ```\n */\nexport const map: ChartType<MapOptions> = {\n name: 'map',\n // (The options come with the whole config: its proportions are defaulted here.)\n clean: (options) => {\n const config = cleanMap(options) as MapOptions & {\n aspectRatio?: number\n autoRatio?: number\n }\n // The ratio set here follows the map; one of your own is kept.\n if (config.aspectRatio !== undefined && config.aspectRatio !== config.autoRatio) return config\n const autoRatio = ratioOf(config)\n return { ...config, aspectRatio: autoRatio, autoRatio }\n },\n render: renderMap,\n table: mapTable,\n // Zoom, drag and selection: at work only with `zoom` or `select`.\n plugins: [mapInteraction()],\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAAgB,QAAQ,MAAoC,QAA4B;CACtF,MAAM,QAAQ,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,GAAG,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC;CACxE,MAAM,OAAO,OAAO,IAAI;CACxB,MAAM,OAAO,IAAmB,MAAc,SAAyB;EACrE,MAAM,OAAO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AAA;EACxD,UAAU,OAAO,EAAE,aAAa,aAAc,EAAE,WAAsC,KAAA;CACxF;AACF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,MAA6B;CACxC,MAAM;CAEN,QAAQ,YAAY;EAClB,MAAM,SAAS,SAAS,OAAO;EAK/B,IAAI,OAAO,gBAAgB,KAAA,KAAa,OAAO,gBAAgB,OAAO,WAAW,OAAO;EACxF,MAAM,YAAY,QAAQ,MAAM;EAChC,OAAO;GAAE,GAAG;GAAQ,aAAa;GAAW;EAAU;CACxD;CACA,QAAQ;CACR,OAAO;CAEP,SAAS,CAAC,eAAe,CAAC;AAC5B"}
|
package/dist/pie-Bd8wyrtY.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pie-Bd8wyrtY.js","names":[],"sources":["../src/charts/pie.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext, RenderResult, TableContext } from '../chart.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 } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO, padAngleForGap } from '../shapes/arc.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf } from './named.ts'\nimport { type SliceGrouping, slicesLegend, type WithSlices, withSlices } from './others.ts'\n\n/** One slice of a pie or donut. */\nexport interface PieSlice {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: 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 slice group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PieOptions extends SliceGrouping {\n data: readonly PieSlice[]\n /** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */\n innerRadius?: number\n /** Gap between slices in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */\n cornerRadius?: number\n /** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Format of the values (tooltip, table, donut total). */\n format?: NumberFormat\n /**\n * Text in the donut hole: the total by default; `false` hides it, or give\n * your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the pie, in pixels. */\n padding?: InsetsInput\n}\n\n/** The chart model of a pie: its options, with the slices as drawn (the rest grouped). */\nexport type PieModel = WithSlices<PieOptions>\n\ninterface Slice {\n data: PieSlice\n index: number\n value: number\n startAngle: number\n endAngle: number\n}\n\n/** Angles of the visible slices, clockwise from `startAngle`. */\nfunction layoutSlices(\n model: PieModel,\n hidden: ReadonlySet<string>,\n): { slices: Slice[]; total: number } {\n const visible = model.slices.filter((slice) => !hidden.has(keyOf(slice.data)))\n const total = visible.reduce((sum, slice) => sum + slice.value, 0)\n let angle = (model.startAngle ?? 0) * DEG\n const slices = visible.map((slice) => {\n const sweep = total > 0 ? (slice.value / total) * Math.PI * 2 : 0\n const out: Slice = { ...slice, startAngle: angle, endAngle: angle + sweep }\n angle += sweep\n return out\n })\n return { slices, total }\n}\n\nfunction renderPie(\n options: PieModel,\n ctx: RenderContext,\n defaults: { inner: number; corner: number },\n) {\n const { width, height, locale } = ctx\n const gap = options.gap ?? 2\n const area = innerRect(width, height, insets(options.padding, 0))\n const outer = Math.max(0, Math.min(area.width, area.height) / 2 - HALO)\n const ratio = Math.min(0.95, Math.max(0, options.innerRadius ?? defaults.inner))\n const inner = outer * ratio\n const cornerRadius = options.cornerRadius ?? defaults.corner\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const drawn = slices.filter((slice) => slice.value > 0)\n // A single slice is a full ring: no gap to cut.\n // Rings get a pad angle, which keeps a constant gap width along the whole\n // edge. In a full pie every slice meets at the center, so a pad angle would\n // widen into a wedge: the gap is a surface-colored stroke instead.\n const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0\n const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const geometry = (slice: Slice, r0 = inner, r1 = outer) => ({\n innerRadius: r0,\n outerRadius: r1,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n padAngle,\n cornerRadius,\n })\n\n const hitFor = (slice: Slice, position: number): Hit => {\n const [x, y] = arcCentroid(geometry(slice))\n const item: HitItem = {\n name: slice.data.name,\n seriesIndex: slice.index,\n value: slice.value,\n text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,\n x: cx + x,\n y: cy + y,\n }\n if (slice.data.color) item.color = slice.data.color\n return {\n index: position,\n label: slice.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: slice.index,\n // A thin halo just outside the slice.\n highlight: {\n kind: 'halo',\n d: arcPathStable({ ...geometry(slice, outer + 2, outer + 6), cornerRadius: 2 }),\n x: cx,\n y: cy,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => {\n const slice = drawn[position]\n return slice ? hitFor(slice, position) : null\n },\n hitTest(px, py) {\n const dx = px - cx\n const dy = py - cy\n const r = Math.hypot(dx, dy)\n if (r < inner - 2 || r > outer + HALO) return null\n const start = (options.startAngle ?? 0) * DEG\n const turn = Math.PI * 2\n // Clockwise angle from 12 o'clock, normalized into [start, start + turn).\n let angle = Math.atan2(dx, -dy)\n angle = start + ((((angle - start) % turn) + turn) % turn)\n const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle)\n return position === -1 ? null : hitFor(drawn[position] as Slice, position)\n },\n }\n\n const groups = slices.map((slice) =>\n h(\n 'g',\n groupAttrs(slice.data, slice.index),\n // The path keeps its arc, so new data sweeps slices around the center\n // (see `sweep`). An empty slice keeps its path, a line with no area in\n // the gap between its neighbors, to grow from there.\n arcNode('tc-slice', geometry(slice)),\n ),\n )\n\n const center = options.center\n const showCenter = inner > 0 && center !== false\n const centerValue = showCenter ? (center?.value ?? value(total)) : ''\n const centerLabel = showCenter ? center?.label : undefined\n\n const content = [\n h(\n 'g',\n { class: 'tc-pie', style: `transform:translate(${cx}px,${cy}px)` },\n total === 0 &&\n h('path', {\n class: 'tc-pie-track',\n d: arcPathStable({\n innerRadius: inner,\n outerRadius: outer,\n startAngle: 0,\n endAngle: Math.PI * 2,\n }),\n }),\n h(\n 'g',\n {\n class: 'tc-pie-slices',\n style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : undefined,\n },\n groups,\n ),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-pie-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-pie-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-pie-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n return { content, interaction }\n}\n\nfunction pieTable(options: PieModel, ctx: TableContext): DataTable {\n const { slices, total } = layoutSlices(options, ctx.hidden)\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: slices.map((slice) => [\n slice.data.name,\n value(slice.value),\n share.format(total > 0 ? slice.value / total : 0),\n ]),\n }\n}\n\nfunction pieType(\n name: string,\n defaults: { inner: number; corner: number },\n): ChartType<PieOptions, PieModel> {\n return {\n name,\n clean: cleanData(cleanItems),\n prepare: withSlices,\n render: (options, ctx): RenderResult => renderPie(options, ctx, defaults),\n sweep,\n legend: slicesLegend,\n table: pieTable,\n valueLabels: { marks: 'slice' },\n }\n}\n\n/**\n * Pie chart: parts of a whole as slices, in data order, clockwise from the top.\n *\n * ```ts\n * new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })\n * ```\n */\nexport const pie: ChartType<PieOptions, PieModel> = pieType('pie', { inner: 0, corner: 0 })\n\n/** Donut chart: a pie with a hole showing the total (or your own `center`). */\nexport const donut: ChartType<PieOptions, PieModel> = pieType('donut', { inner: 0.62, corner: 4 })\n"],"mappings":";;;;;;;;;;AA+DA,SAAS,aACP,OACA,QACoC;CACpC,MAAM,UAAU,MAAM,OAAO,QAAQ,UAAU,CAAC,OAAO,IAAI,MAAM,MAAM,IAAI,CAAC,CAAC;CAC7E,MAAM,QAAQ,QAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;CACjE,IAAI,SAAS,MAAM,cAAc,KAAK;CAOtC,OAAO;EAAE,QANM,QAAQ,KAAK,UAAU;GACpC,MAAM,QAAQ,QAAQ,IAAK,MAAM,QAAQ,QAAS,KAAK,KAAK,IAAI;GAChE,MAAM,MAAa;IAAE,GAAG;IAAO,YAAY;IAAO,UAAU,QAAQ;GAAM;GAC1E,SAAS;GACT,OAAO;EACT,CACc;EAAG;CAAM;AACzB;AAEA,SAAS,UACP,SACA,KACA,UACA;CACA,MAAM,EAAE,OAAO,QAAQ,WAAW;CAClC,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,OAAO,UAAU,OAAO,QAAQ,OAAO,QAAQ,SAAS,CAAC,CAAC;CAChE,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,OAAO,KAAK,MAAM,IAAI,IAAA,CAAQ;CAEtE,MAAM,QAAQ,QADA,KAAK,IAAI,KAAM,KAAK,IAAI,GAAG,QAAQ,eAAe,S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":"pie-BseZlCgP.cjs","names":["keyOf","DEG","innerRect","insets","padAngleForGap","formatNumber","getNumberFormat","arcCentroid","arcPathStable","h","groupAttrs","arcNode","cleanData","cleanItems","withSlices","sweep","slicesLegend"],"sources":["../src/charts/pie.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext, RenderResult, TableContext } from '../chart.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 } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO, padAngleForGap } from '../shapes/arc.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf } from './named.ts'\nimport { type SliceGrouping, slicesLegend, type WithSlices, withSlices } from './others.ts'\n\n/** One slice of a pie or donut. */\nexport interface PieSlice {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: 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 slice group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PieOptions extends SliceGrouping {\n data: readonly PieSlice[]\n /** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */\n innerRadius?: number\n /** Gap between slices in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */\n cornerRadius?: number\n /** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Format of the values (tooltip, table, donut total). */\n format?: NumberFormat\n /**\n * Text in the donut hole: the total by default; `false` hides it, or give\n * your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the pie, in pixels. */\n padding?: InsetsInput\n}\n\n/** The chart model of a pie: its options, with the slices as drawn (the rest grouped). */\nexport type PieModel = WithSlices<PieOptions>\n\ninterface Slice {\n data: PieSlice\n index: number\n value: number\n startAngle: number\n endAngle: number\n}\n\n/** Angles of the visible slices, clockwise from `startAngle`. */\nfunction layoutSlices(\n model: PieModel,\n hidden: ReadonlySet<string>,\n): { slices: Slice[]; total: number } {\n const visible = model.slices.filter((slice) => !hidden.has(keyOf(slice.data)))\n const total = visible.reduce((sum, slice) => sum + slice.value, 0)\n let angle = (model.startAngle ?? 0) * DEG\n const slices = visible.map((slice) => {\n const sweep = total > 0 ? (slice.value / total) * Math.PI * 2 : 0\n const out: Slice = { ...slice, startAngle: angle, endAngle: angle + sweep }\n angle += sweep\n return out\n })\n return { slices, total }\n}\n\nfunction renderPie(\n options: PieModel,\n ctx: RenderContext,\n defaults: { inner: number; corner: number },\n) {\n const { width, height, locale } = ctx\n const gap = options.gap ?? 2\n const area = innerRect(width, height, insets(options.padding, 0))\n const outer = Math.max(0, Math.min(area.width, area.height) / 2 - HALO)\n const ratio = Math.min(0.95, Math.max(0, options.innerRadius ?? defaults.inner))\n const inner = outer * ratio\n const cornerRadius = options.cornerRadius ?? defaults.corner\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const drawn = slices.filter((slice) => slice.value > 0)\n // A single slice is a full ring: no gap to cut.\n // Rings get a pad angle, which keeps a constant gap width along the whole\n // edge. In a full pie every slice meets at the center, so a pad angle would\n // widen into a wedge: the gap is a surface-colored stroke instead.\n const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0\n const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const geometry = (slice: Slice, r0 = inner, r1 = outer) => ({\n innerRadius: r0,\n outerRadius: r1,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n padAngle,\n cornerRadius,\n })\n\n const hitFor = (slice: Slice, position: number): Hit => {\n const [x, y] = arcCentroid(geometry(slice))\n const item: HitItem = {\n name: slice.data.name,\n seriesIndex: slice.index,\n value: slice.value,\n text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,\n x: cx + x,\n y: cy + y,\n }\n if (slice.data.color) item.color = slice.data.color\n return {\n index: position,\n label: slice.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: slice.index,\n // A thin halo just outside the slice.\n highlight: {\n kind: 'halo',\n d: arcPathStable({ ...geometry(slice, outer + 2, outer + 6), cornerRadius: 2 }),\n x: cx,\n y: cy,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => {\n const slice = drawn[position]\n return slice ? hitFor(slice, position) : null\n },\n hitTest(px, py) {\n const dx = px - cx\n const dy = py - cy\n const r = Math.hypot(dx, dy)\n if (r < inner - 2 || r > outer + HALO) return null\n const start = (options.startAngle ?? 0) * DEG\n const turn = Math.PI * 2\n // Clockwise angle from 12 o'clock, normalized into [start, start + turn).\n let angle = Math.atan2(dx, -dy)\n angle = start + ((((angle - start) % turn) + turn) % turn)\n const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle)\n return position === -1 ? null : hitFor(drawn[position] as Slice, position)\n },\n }\n\n const groups = slices.map((slice) =>\n h(\n 'g',\n groupAttrs(slice.data, slice.index),\n // The path keeps its arc, so new data sweeps slices around the center\n // (see `sweep`). An empty slice keeps its path, a line with no area in\n // the gap between its neighbors, to grow from there.\n arcNode('tc-slice', geometry(slice)),\n ),\n )\n\n const center = options.center\n const showCenter = inner > 0 && center !== false\n const centerValue = showCenter ? (center?.value ?? value(total)) : ''\n const centerLabel = showCenter ? center?.label : undefined\n\n const content = [\n h(\n 'g',\n { class: 'tc-pie', style: `transform:translate(${cx}px,${cy}px)` },\n total === 0 &&\n h('path', {\n class: 'tc-pie-track',\n d: arcPathStable({\n innerRadius: inner,\n outerRadius: outer,\n startAngle: 0,\n endAngle: Math.PI * 2,\n }),\n }),\n h(\n 'g',\n {\n class: 'tc-pie-slices',\n style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : undefined,\n },\n groups,\n ),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-pie-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-pie-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-pie-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n return { content, interaction }\n}\n\nfunction pieTable(options: PieModel, ctx: TableContext): DataTable {\n const { slices, total } = layoutSlices(options, ctx.hidden)\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: slices.map((slice) => [\n slice.data.name,\n value(slice.value),\n share.format(total > 0 ? slice.value / total : 0),\n ]),\n }\n}\n\nfunction pieType(\n name: string,\n defaults: { inner: number; corner: number },\n): ChartType<PieOptions, PieModel> {\n return {\n name,\n clean: cleanData(cleanItems),\n prepare: withSlices,\n render: (options, ctx): RenderResult => renderPie(options, ctx, defaults),\n sweep,\n legend: slicesLegend,\n table: pieTable,\n valueLabels: { marks: 'slice' },\n }\n}\n\n/**\n * Pie chart: parts of a whole as slices, in data order, clockwise from the top.\n *\n * ```ts\n * new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })\n * ```\n */\nexport const pie: ChartType<PieOptions, PieModel> = pieType('pie', { inner: 0, corner: 0 })\n\n/** Donut chart: a pie with a hole showing the total (or your own `center`). */\nexport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;GACE,OAAO;GACP,GAAG;GACH,GAAG;GACH,IAAI,cAAc,MAAM;GACxB,eAAe;EACjB,GACA,WACF,GACA,eACEA,cAAAA,EACE,QACA;GAAE,OAAO;GAAgB,GAAG;GAAI,GAAG;GAAI,IAAI;GAAS,eAAe;EAAS,GAC5E,WACF,CACJ,CAEW;EAAG;CAAY;AAChC;AAEA,SAAS,SAAS,SAAmB,KAA8B;CACjE,MAAM,EAAE,QAAQ,UAAU,aAAa,SAAS,IAAI,MAAM;CAC1D,MAAM,QAAQJ,eAAAA,aAAa,QAAQ,QAAQ,IAAI,MAAM;CACrD,MAAM,QAAQC,eAAAA,gBAAgB,IAAI,QAAQ;EAAE,OAAO;EAAW,uBAAuB;CAAE,CAAC;CACxF,OAAO;EACL,SAAS;GAAC;GAAI;GAAS;EAAO;EAC9B,MAAM,OAAO,KAAK,UAAU;GAC1B,MAAM,KAAK;GACX,MAAM,MAAM,KAAK;GACjB,MAAM,OAAO,QAAQ,IAAI,MAAM,QAAQ,QAAQ,CAAC;EAClD,CAAC;CACH;AACF;AAEA,SAAS,QACP,MACA,UACiC;CACjC,OAAO;EACL;EACA,OAAOM,cAAAA,UAAUC,cAAAA,UAAU;EAC3B,SAASC,eAAAA;EACT,SAAS,SAAS,QAAsB,UAAU,SAAS,KAAK,QAAQ;EACxEC,OAAAA,cAAAA;EACA,QAAQC,eAAAA;EACR,OAAO;EACP,aAAa,EAAE,OAAO,QAAQ;CAChC;AACF;;;;;;;;AASA,MAAa,MAAuC,QAAQ,OAAO;CAAE,OAAO;CAAG,QAAQ;AAAE,CAAC;;AAG1F,MAAa,QAAyC,QAAQ,SAAS;CAAE,OAAO;CAAM,QAAQ;AAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-Bwkblr4L.cjs","names":["keyOf","extent","tickCount","plottable","domainOf","valueTicks","valueScale","estimateTextWidth","plotFrame","LINE_HEIGHT","axisSize","axisTitleSize","thinTicks","formatDetail","formatNumber","circlePath","round","markerShape","h","grid","plotClip","groupAttrs","axis","axisTitle","cleanData","isRecord","records","named","finite","text","legendItems"],"sources":["../src/charts/scatter.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport {\n axis,\n axisSize,\n axisTitle,\n axisTitleSize,\n type Tick,\n thinTicks,\n} from '../components/axis.ts'\nimport { grid } from '../components/grid.ts'\nimport { formatDetail, formatNumber } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { estimateTextWidth, type InsetsInput, LINE_HEIGHT, plotFrame, round } from '../layout.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport {\n domainOf,\n markerShape,\n plotClip,\n plottable,\n tickCount,\n type ValueAxisOptions,\n valueScale,\n valueTicks,\n} from './cartesian.ts'\nimport { cleanData, finite, isRecord, named, records, text } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** A point of a scatter or bubble chart. */\nexport interface ScatterPoint {\n x: number\n y: number\n /** Bubble size; the circle area is proportional to it. */\n size?: number\n /** Name shown in the tooltip and table (e.g. a country). */\n label?: string\n}\n\nexport interface ScatterSeries {\n name: string\n points: readonly ScatterPoint[]\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 series group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n /**\n * Write values on this series' marks, whatever the chart's `valueLabels`\n * says: `true` labels it even when the chart option is off, `false` leaves\n * it out. Needs `@tabler/charts/value-labels` on the core.\n */\n valueLabels?: boolean\n}\n\nexport interface ScatterOptions {\n data: { series: readonly ScatterSeries[] }\n /** Horizontal value axis; `reverse` runs it from the right (the default with `rtl`). */\n x?: ValueAxisOptions & { reverse?: boolean }\n /** Vertical value axis. */\n y?: ValueAxisOptions\n /** Radius of points without a size, in pixels. Defaults to `4`. */\n radius?: number\n /** Radius range for bubbles (points with `size`). Defaults to `{ min: 4, max: 24 }`. */\n size?: { min?: number; max?: number }\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\n/** Pointer distance (in pixels, beyond the radius) that still hits a point. */\nconst HIT_RADIUS = 24\nconst EDGE = 8\n\ninterface Placed {\n seriesIndex: number\n pointIndex: number\n point: ScatterPoint\n cx: number\n cy: number\n r: number\n}\n\n/** A point's bubble size, or `undefined` when it has none (or an invalid one). */\nconst sizeOf = (p: ScatterPoint): number | undefined =>\n p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : undefined\n\nfunction renderScatter(options: ScatterOptions, ctx: RenderContext) {\n const { width, height, fontSize, locale } = ctx\n const xOptions = options.x ?? {}\n const yOptions = options.y ?? {}\n const radius = options.radius ?? 4\n const visible = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const points = visible.flatMap((s) => s.points)\n const sizes = points.map(sizeOf).filter((v): v is number => v !== undefined)\n const maxSize = extent(sizes)?.[1] ?? 0\n const rMin = options.size?.min ?? 4\n const rMax = options.size?.max ?? 24\n // Area-proportional bubbles: the radius grows with the square root of the size.\n const bubble = (size: number | undefined) =>\n size != null && size > 0 && maxSize > 0\n ? rMin + (rMax - rMin) * Math.sqrt(size / maxSize)\n : radius\n const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2\n\n const countY = tickCount(yOptions, Math.max(2, Math.round(height / 60)))\n const countX = tickCount(xOptions, Math.max(2, Math.round(width / 80)))\n // Only points that can be plotted on both axes take part.\n const usable = (p: ScatterPoint) => plottable(p.x, xOptions) && plottable(p.y, yOptions)\n const shown = points.filter(usable)\n const xDomain = domainOf(\n shown.map((p) => p.x),\n xOptions,\n false,\n countX,\n )\n const yDomain = domainOf(\n shown.map((p) => p.y),\n yOptions,\n false,\n countY,\n )\n\n const showX = xOptions.show !== false\n const showY = yOptions.show !== false\n // Linear or logarithmic, as each axis asks (see valueScale).\n const ticksOf = (scale: LinearScale, axis: ValueAxisOptions, count: number) =>\n valueTicks(scale, axis, count, axis.format, locale)\n const probeY = ticksOf(valueScale(yDomain, [1, 0], yOptions), yOptions, countY)\n const probeX = ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX)\n const half = (tick: Tick | undefined) =>\n showX && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0\n const reverse = xOptions.reverse ?? ctx.rtl === true\n // The x tick on the start side of the plot, and the one on the end side.\n const near = reverse === (ctx.rtl === true) ? 0 : probeX.length - 1\n const { area, side, range } = plotFrame(ctx, options.padding, (pad) => ({\n top:\n pad.top + Math.max(showY ? Math.ceil((fontSize * LINE_HEIGHT) / 2) : 0, overhang, EDGE / 2),\n bottom:\n pad.bottom +\n Math.max(\n (showX ? axisSize('bottom', probeX, fontSize) : 0) +\n axisTitleSize(xOptions.title, fontSize),\n overhang,\n EDGE / 2,\n ),\n start:\n pad.start +\n Math.max(\n (showY ? axisSize('left', probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize),\n half(probeX[near]),\n overhang,\n ),\n end: pad.end + Math.max(half(probeX[probeX.length - 1 - near]), overhang, EDGE),\n }))\n const x = valueScale(xDomain, range(reverse), xOptions)\n const y = valueScale(yDomain, [area.y + area.height, area.y], yOptions)\n // Thinned like the ticks of the other charts: on a log axis they crowd at the end of each decade.\n const xTicks = thinTicks(ticksOf(x, xOptions, countX), 'bottom', fontSize)\n const yTicks = thinTicks(ticksOf(y, yOptions, countY), 'left', fontSize, 4)\n\n // Every visible point in pixels, sorted by x for fast nearest-point lookups.\n const placed: Placed[] = []\n options.data.series.forEach((series, seriesIndex) => {\n if (ctx.hidden.has(keyOf(series))) return\n series.points.forEach((point, pointIndex) => {\n if (!usable(point)) return\n placed.push({\n seriesIndex,\n pointIndex,\n point,\n cx: x(point.x),\n cy: y(point.y),\n r: bubble(sizeOf(point)),\n })\n })\n })\n placed.sort((a, b) => a.cx - b.cx)\n\n const fx = formatDetail(xOptions.format, locale)\n const fy = formatDetail(yOptions.format, locale)\n const fs = formatNumber(undefined, locale)\n const hitFor = (p: Placed, index: number): Hit => {\n const series = options.data.series[p.seriesIndex] as ScatterSeries\n const sz = sizeOf(p.point)\n const size = sz === undefined ? '' : ` · ${fs(sz)}`\n const item: HitItem = {\n name: series.name,\n seriesIndex: p.seriesIndex,\n value: p.point.y,\n text: `${fx(p.point.x)}, ${fy(p.point.y)}${size}`,\n x: p.cx,\n y: p.cy,\n }\n if (series.color) item.color = series.color\n return {\n index,\n label: p.point.label ?? series.name,\n title: p.point.label ?? '',\n x: p.cx,\n area,\n items: [item],\n seriesIndex: p.seriesIndex,\n highlight: { kind: 'halo', d: circlePath(round(p.r + 4)), x: p.cx, y: p.cy },\n }\n }\n\n const interaction: Interaction = {\n count: placed.length,\n hitIndex: (index) => {\n const p = placed[index]\n return p ? hitFor(p, index) : null\n },\n hitTest(px, py) {\n // Binary search the first point within reach on x, then scan the window.\n let lo = 0\n let hi = placed.length\n const reach = HIT_RADIUS + rMax\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n if ((placed[mid] as Placed).cx < px - reach) lo = mid + 1\n else hi = mid\n }\n let best = -1\n let bestDistance = Number.POSITIVE_INFINITY\n for (let i = lo; i < placed.length; i++) {\n const p = placed[i] as Placed\n if (p.cx > px + reach) break\n const distance = Math.hypot(p.cx - px, p.cy - py) - p.r\n if (distance < bestDistance && distance <= HIT_RADIUS) {\n best = i\n bestDistance = distance\n }\n }\n return best === -1 ? null : hitFor(placed[best] as Placed, best)\n },\n }\n\n /** One path drawing a dot of `radius` at every point (two arcs each, or the series' shape). */\n const shape = markerShape(options)\n const dotsPath = (dots: readonly ScatterPoint[], slot: number) => {\n if (!dots.length) return null\n const r = round(radius)\n let d = ''\n for (const p of dots) {\n d += shape\n ? shape(slot, x(p.x), y(p.y), r)\n : `M${round(x(p.x) - radius)},${round(y(p.y))}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0`\n }\n return h('path', { key: 'dots', class: ['tc-point tc-dots', shape && 'tc-marker'], d })\n }\n\n const background = []\n if (yOptions.grid !== false) background.push(grid({ direction: 'y', ticks: yTicks, area }))\n if (xOptions.grid) background.push(grid({ direction: 'x', ticks: xTicks, area }))\n\n // Dots may reach a little past the plot edges; bubbles are cut at them (like\n // Chart.js), as a big one there would cover the axis labels.\n const clip = plotClip(ctx, area, sizes.length ? 0 : overhang)\n const groups = options.data.series.map(\n (series, seriesIndex) =>\n !ctx.hidden.has(keyOf(series)) &&\n h(\n 'g',\n groupAttrs(series, seriesIndex),\n // Plain points share one path per series: thousands of circles would\n // each cost the browser style and layout work. The path keeps its\n // commands while the point count does, so new data morphs. Bubbles\n // stay circles: each is see-through over the others.\n dotsPath(\n series.points.filter((p) => usable(p) && sizeOf(p) === undefined),\n seriesIndex,\n ),\n series.points.map(\n (point, i) =>\n usable(point) &&\n sizeOf(point) !== undefined &&\n h('circle', {\n key: i,\n class: 'tc-point tc-bubble',\n cx: round(x(point.x)),\n cy: round(y(point.y)),\n r: round(bubble(sizeOf(point))),\n }),\n ),\n ),\n )\n\n const content = [\n h('defs', null, clip.def),\n background,\n h('g', { key: 'series', class: 'tc-series-list', 'clip-path': clip.url }, groups),\n showY && axis({ position: side, ticks: yTicks, area }),\n showX && axis({ position: 'bottom', ticks: xTicks, area }),\n !!yOptions.title && axisTitle(side, showY ? yTicks : [], area, yOptions.title, fontSize),\n !!xOptions.title && axisTitle('bottom', showX ? xTicks : [], area, xOptions.title, fontSize),\n ]\n return { content, interaction }\n}\n\nfunction scatterTable(\n options: ScatterOptions,\n ctx: RenderContext,\n limit: number = Number.POSITIVE_INFINITY,\n): DataTable {\n const fx = formatDetail(options.x?.format, ctx.locale)\n const fy = formatDetail(options.y?.format, ctx.locale)\n const fs = formatNumber(undefined, ctx.locale)\n const series = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const withSize = series.some((s) => s.points.some((p) => p.size != null))\n const withLabel = series.some((s) => s.points.some((p) => p.label != null))\n const total = series.reduce((sum, s) => sum + s.points.length, 0)\n let left = limit\n return {\n columns: ['', ...(withLabel ? ['Label'] : []), 'x', 'y', ...(withSize ? ['Size'] : [])],\n total,\n rows: series.flatMap((s) => {\n const take = s.points.slice(0, Math.max(0, left))\n left -= take.length\n return take.map((p) => [\n s.name,\n ...(withLabel ? [p.label ?? ''] : []),\n fx(p.x),\n fy(p.y),\n ...(withSize ? [sizeOf(p) === undefined ? '–' : fs(sizeOf(p) as number)] : []),\n ])\n }),\n }\n}\n\n/**\n * Scatter chart: points on two value axes; give points a `size` for a\n * bubble chart (area-proportional radii).\n *\n * ```ts\n * new Chart('#el', {\n * type: scatter,\n * data: { series: [{ name: 'Cities', points: [{ x: 12, y: 3.4 }, { x: 18, y: 5.1 }] }] },\n * })\n * ```\n */\nexport const scatter: ChartType<ScatterOptions> = {\n name: 'scatter',\n clean: cleanData((data) => ({\n ...(isRecord(data) ? data : {}),\n series: records(isRecord(data) && data.series, (s) => ({\n ...named(s),\n points: records(s.points, (p) => ({\n ...p,\n x: finite(p.x),\n y: finite(p.y),\n size: finite(p.size) ?? undefined,\n label: p.label == null ? undefined : text(p.label),\n })).filter((p) => p.x !== null && p.y !== null),\n })),\n })),\n render: renderScatter,\n legend: (options) => legendItems(options.data.series),\n table: scatterTable,\n valueLabels: { format: (options) => options.y?.format },\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,aAAa;AACnB,MAAM,OAAO;;AAYb,MAAM,UAAU,MACd,EAAE,QAAQ,QAAQ,OAAO,SAAS,EAAE,IAAI,KAAK,EAAE,OAAO,IAAI,EAAE,OAAO,KAAA;AAErE,SAAS,cAAc,SAAyB,KAAoB;CAClE,MAAM,EAAE,OAAO,QAAQ,UAAU,WAAW;CAC5C,MAAM,WAAW,QAAQ,KAAK,C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CAAC;GAChD,QAAQ,KAAK;GACb,OAAO,KAAK,KAAK,MAAM;IACrB,EAAE;IACF,GAAI,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC;IACnC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAI,WAAW,CAAC,OAAO,CAAC,MAAM,KAAA,IAAY,MAAM,GAAG,OAAO,CAAC,CAAW,CAAC,IAAI,CAAC;GAC9E,CAAC;EACH,CAAC;CACH;AACF;;;;;;;;;;;;AAaA,MAAa,UAAqC;CAChD,MAAM;CACN,OAAOwB,cAAAA,WAAW,UAAU;EAC1B,GAAIC,cAAAA,SAAS,IAAI,IAAI,OAAO,CAAC;EAC7B,QAAQC,cAAAA,QAAQD,cAAAA,SAAS,IAAI,KAAK,KAAK,SAAS,OAAO;GACrD,GAAGE,cAAAA,MAAM,CAAC;GACV,QAAQD,cAAAA,QAAQ,EAAE,SAAS,OAAO;IAChC,GAAG;IACH,GAAGE,cAAAA,OAAO,EAAE,CAAC;IACb,GAAGA,cAAAA,OAAO,EAAE,CAAC;IACb,MAAMA,cAAAA,OAAO,EAAE,IAAI,KAAK,KAAA;IACxB,OAAO,EAAE,SAAS,OAAO,KAAA,IAAYC,cAAAA,KAAK,EAAE,KAAK;GACnD,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE,MAAM,QAAQ,EAAE,MAAM,IAAI;EAChD,EAAE;CACJ,EAAE;CACF,QAAQ;CACR,SAAS,YAAYC,cAAAA,YAAY,QAAQ,KAAK,MAAM;CACpD,OAAO;CACP,aAAa,EAAE,SAAS,YAAY,QAAQ,GAAG,OAAO;AACxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-DCMAtt5L.js","names":[],"sources":["../src/charts/scatter.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport {\n axis,\n axisSize,\n axisTitle,\n axisTitleSize,\n type Tick,\n thinTicks,\n} from '../components/axis.ts'\nimport { grid } from '../components/grid.ts'\nimport { formatDetail, formatNumber } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { estimateTextWidth, type InsetsInput, LINE_HEIGHT, plotFrame, round } from '../layout.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport {\n domainOf,\n markerShape,\n plotClip,\n plottable,\n tickCount,\n type ValueAxisOptions,\n valueScale,\n valueTicks,\n} from './cartesian.ts'\nimport { cleanData, finite, isRecord, named, records, text } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** A point of a scatter or bubble chart. */\nexport interface ScatterPoint {\n x: number\n y: number\n /** Bubble size; the circle area is proportional to it. */\n size?: number\n /** Name shown in the tooltip and table (e.g. a country). */\n label?: string\n}\n\nexport interface ScatterSeries {\n name: string\n points: readonly ScatterPoint[]\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 series group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n /**\n * Write values on this series' marks, whatever the chart's `valueLabels`\n * says: `true` labels it even when the chart option is off, `false` leaves\n * it out. Needs `@tabler/charts/value-labels` on the core.\n */\n valueLabels?: boolean\n}\n\nexport interface ScatterOptions {\n data: { series: readonly ScatterSeries[] }\n /** Horizontal value axis; `reverse` runs it from the right (the default with `rtl`). */\n x?: ValueAxisOptions & { reverse?: boolean }\n /** Vertical value axis. */\n y?: ValueAxisOptions\n /** Radius of points without a size, in pixels. Defaults to `4`. */\n radius?: number\n /** Radius range for bubbles (points with `size`). Defaults to `{ min: 4, max: 24 }`. */\n size?: { min?: number; max?: number }\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\n/** Pointer distance (in pixels, beyond the radius) that still hits a point. */\nconst HIT_RADIUS = 24\nconst EDGE = 8\n\ninterface Placed {\n seriesIndex: number\n pointIndex: number\n point: ScatterPoint\n cx: number\n cy: number\n r: number\n}\n\n/** A point's bubble size, or `undefined` when it has none (or an invalid one). */\nconst sizeOf = (p: ScatterPoint): number | undefined =>\n p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : undefined\n\nfunction renderScatter(options: ScatterOptions, ctx: RenderContext) {\n const { width, height, fontSize, locale } = ctx\n const xOptions = options.x ?? {}\n const yOptions = options.y ?? {}\n const radius = options.radius ?? 4\n const visible = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const points = visible.flatMap((s) => s.points)\n const sizes = points.map(sizeOf).filter((v): v is number => v !== undefined)\n const maxSize = extent(sizes)?.[1] ?? 0\n const rMin = options.size?.min ?? 4\n const rMax = options.size?.max ?? 24\n // Area-proportional bubbles: the radius grows with the square root of the size.\n const bubble = (size: number | undefined) =>\n size != null && size > 0 && maxSize > 0\n ? rMin + (rMax - rMin) * Math.sqrt(size / maxSize)\n : radius\n const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2\n\n const countY = tickCount(yOptions, Math.max(2, Math.round(height / 60)))\n const countX = tickCount(xOptions, Math.max(2, Math.round(width / 80)))\n // Only points that can be plotted on both axes take part.\n const usable = (p: ScatterPoint) => plottable(p.x, xOptions) && plottable(p.y, yOptions)\n const shown = points.filter(usable)\n const xDomain = domainOf(\n shown.map((p) => p.x),\n xOptions,\n false,\n countX,\n )\n const yDomain = domainOf(\n shown.map((p) => p.y),\n yOptions,\n false,\n countY,\n )\n\n const showX = xOptions.show !== false\n const showY = yOptions.show !== false\n // Linear or logarithmic, as each axis asks (see valueScale).\n const ticksOf = (scale: LinearScale, axis: ValueAxisOptions, count: number) =>\n valueTicks(scale, axis, count, axis.format, locale)\n const probeY = ticksOf(valueScale(yDomain, [1, 0], yOptions), yOptions, countY)\n const probeX = ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX)\n const half = (tick: Tick | undefined) =>\n showX && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0\n const reverse = xOptions.reverse ?? ctx.rtl === true\n // The x tick on the start side of the plot, and the one on the end side.\n const near = reverse === (ctx.rtl === true) ? 0 : probeX.length - 1\n const { area, side, range } = plotFrame(ctx, options.padding, (pad) => ({\n top:\n pad.top + Math.max(showY ? Math.ceil((fontSize * LINE_HEIGHT) / 2) : 0, overhang, EDGE / 2),\n bottom:\n pad.bottom +\n Math.max(\n (showX ? axisSize('bottom', probeX, fontSize) : 0) +\n axisTitleSize(xOptions.title, fontSize),\n overhang,\n EDGE / 2,\n ),\n start:\n pad.start +\n Math.max(\n (showY ? axisSize('left', probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize),\n half(probeX[near]),\n overhang,\n ),\n end: pad.end + Math.max(half(probeX[probeX.length - 1 - near]), overhang, EDGE),\n }))\n const x = valueScale(xDomain, range(reverse), xOptions)\n const y = valueScale(yDomain, [area.y + area.height, area.y], yOptions)\n // Thinned like the ticks of the other charts: on a log axis they crowd at the end of each decade.\n const xTicks = thinTicks(ticksOf(x, xOptions, countX), 'bottom', fontSize)\n const yTicks = thinTicks(ticksOf(y, yOptions, countY), 'left', fontSize, 4)\n\n // Every visible point in pixels, sorted by x for fast nearest-point lookups.\n const placed: Placed[] = []\n options.data.series.forEach((series, seriesIndex) => {\n if (ctx.hidden.has(keyOf(series))) return\n series.points.forEach((point, pointIndex) => {\n if (!usable(point)) return\n placed.push({\n seriesIndex,\n pointIndex,\n point,\n cx: x(point.x),\n cy: y(point.y),\n r: bubble(sizeOf(point)),\n })\n })\n })\n placed.sort((a, b) => a.cx - b.cx)\n\n const fx = formatDetail(xOptions.format, locale)\n const fy = formatDetail(yOptions.format, locale)\n const fs = formatNumber(undefined, locale)\n const hitFor = (p: Placed, index: number): Hit => {\n const series = options.data.series[p.seriesIndex] as ScatterSeries\n const sz = sizeOf(p.point)\n const size = sz === undefined ? '' : ` · ${fs(sz)}`\n const item: HitItem = {\n name: series.name,\n seriesIndex: p.seriesIndex,\n value: p.point.y,\n text: `${fx(p.point.x)}, ${fy(p.point.y)}${size}`,\n x: p.cx,\n y: p.cy,\n }\n if (series.color) item.color = series.color\n return {\n index,\n label: p.point.label ?? series.name,\n title: p.point.label ?? '',\n x: p.cx,\n area,\n items: [item],\n seriesIndex: p.seriesIndex,\n highlight: { kind: 'halo', d: circlePath(round(p.r + 4)), x: p.cx, y: p.cy },\n }\n }\n\n const interaction: Interaction = {\n count: placed.length,\n hitIndex: (index) => {\n const p = placed[index]\n return p ? hitFor(p, index) : null\n },\n hitTest(px, py) {\n // Binary search the first point within reach on x, then scan the window.\n let lo = 0\n let hi = placed.length\n const reach = HIT_RADIUS + rMax\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n if ((placed[mid] as Placed).cx < px - reach) lo = mid + 1\n else hi = mid\n }\n let best = -1\n let bestDistance = Number.POSITIVE_INFINITY\n for (let i = lo; i < placed.length; i++) {\n const p = placed[i] as Placed\n if (p.cx > px + reach) break\n const distance = Math.hypot(p.cx - px, p.cy - py) - p.r\n if (distance < bestDistance && distance <= HIT_RADIUS) {\n best = i\n bestDistance = distance\n }\n }\n return best === -1 ? null : hitFor(placed[best] as Placed, best)\n },\n }\n\n /** One path drawing a dot of `radius` at every point (two arcs each, or the series' shape). */\n const shape = markerShape(options)\n const dotsPath = (dots: readonly ScatterPoint[], slot: number) => {\n if (!dots.length) return null\n const r = round(radius)\n let d = ''\n for (const p of dots) {\n d += shape\n ? shape(slot, x(p.x), y(p.y), r)\n : `M${round(x(p.x) - radius)},${round(y(p.y))}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0`\n }\n return h('path', { key: 'dots', class: ['tc-point tc-dots', shape && 'tc-marker'], d })\n }\n\n const background = []\n if (yOptions.grid !== false) background.push(grid({ direction: 'y', ticks: yTicks, area }))\n if (xOptions.grid) background.push(grid({ direction: 'x', ticks: xTicks, area }))\n\n // Dots may reach a little past the plot edges; bubbles are cut at them (like\n // Chart.js), as a big one there would cover the axis labels.\n const clip = plotClip(ctx, area, sizes.length ? 0 : overhang)\n const groups = options.data.series.map(\n (series, seriesIndex) =>\n !ctx.hidden.has(keyOf(series)) &&\n h(\n 'g',\n groupAttrs(series, seriesIndex),\n // Plain points share one path per series: thousands of circles would\n // each cost the browser style and layout work. The path keeps its\n // commands while the point count does, so new data morphs. Bubbles\n // stay circles: each is see-through over the others.\n dotsPath(\n series.points.filter((p) => usable(p) && sizeOf(p) === undefined),\n seriesIndex,\n ),\n series.points.map(\n (point, i) =>\n usable(point) &&\n sizeOf(point) !== undefined &&\n h('circle', {\n key: i,\n class: 'tc-point tc-bubble',\n cx: round(x(point.x)),\n cy: round(y(point.y)),\n r: round(bubble(sizeOf(point))),\n }),\n ),\n ),\n )\n\n const content = [\n h('defs', null, clip.def),\n background,\n h('g', { key: 'series', class: 'tc-series-list', 'clip-path': clip.url }, groups),\n showY && axis({ position: side, ticks: yTicks, area }),\n showX && axis({ position: 'bottom', ticks: xTicks, area }),\n !!yOptions.title && axisTitle(side, showY ? yTicks : [], area, yOptions.title, fontSize),\n !!xOptions.title && axisTitle('bottom', showX ? xTicks : [], area, xOptions.title, fontSize),\n ]\n return { content, interaction }\n}\n\nfunction scatterTable(\n options: ScatterOptions,\n ctx: RenderContext,\n limit: number = Number.POSITIVE_INFINITY,\n): DataTable {\n const fx = formatDetail(options.x?.format, ctx.locale)\n const fy = formatDetail(options.y?.format, ctx.locale)\n const fs = formatNumber(undefined, ctx.locale)\n const series = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const withSize = series.some((s) => s.points.some((p) => p.size != null))\n const withLabel = series.some((s) => s.points.some((p) => p.label != null))\n const total = series.reduce((sum, s) => sum + s.points.length, 0)\n let left = limit\n return {\n columns: ['', ...(withLabel ? ['Label'] : []), 'x', 'y', ...(withSize ? ['Size'] : [])],\n total,\n rows: series.flatMap((s) => {\n const take = s.points.slice(0, Math.max(0, left))\n left -= take.length\n return take.map((p) => [\n s.name,\n ...(withLabel ? [p.label ?? ''] : []),\n fx(p.x),\n fy(p.y),\n ...(withSize ? [sizeOf(p) === undefined ? '–' : fs(sizeOf(p) as number)] : []),\n ])\n }),\n }\n}\n\n/**\n * Scatter chart: points on two value axes; give points a `size` for a\n * bubble chart (area-proportional radii).\n *\n * ```ts\n * new Chart('#el', {\n * type: scatter,\n * data: { series: [{ name: 'Cities', points: [{ x: 12, y: 3.4 }, { x: 18, y: 5.1 }] }] },\n * })\n * ```\n */\nexport const scatter: ChartType<ScatterOptions> = {\n name: 'scatter',\n clean: cleanData((data) => ({\n ...(isRecord(data) ? data : {}),\n series: records(isRecord(data) && data.series, (s) => ({\n ...named(s),\n points: records(s.points, (p) => ({\n ...p,\n x: finite(p.x),\n y: finite(p.y),\n size: finite(p.size) ?? undefined,\n label: p.label == null ? undefined : text(p.label),\n })).filter((p) => p.x !== null && p.y !== null),\n })),\n })),\n render: renderScatter,\n legend: (options) => legendItems(options.data.series),\n table: scatterTable,\n valueLabels: { format: (options) => options.y?.format },\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,aAAa;AACnB,MAAM,OAAO;;AAYb,MAAM,UAAU,MACd,EAAE,QAAQ,QAAQ,OAAO,SAAS,EAAE,IAAI,KAAK,EAAE,OAAO,IAAI,EAAE,OAAO,KAAA;AAErE,SAAS,cAAc,SAAyB,KAAoB;CAClE,MAAM,EAAE,OAAO,QAAQ,UAAU,WAAW;CAC5C,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,SAAS,QAAQ,UAAU;CAEjC,MAAM,SADU,QAAQ,KAAK,OAAO,QAAQ,MAAM,CAAC,IAAI,OAAO,IAAI,MAAM,CAAC,CAAC,CACrD,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM;CAC9C,MAAM,QAA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IAAY,KAAK,EAAE,KAAK;GACnD,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE,MAAM,QAAQ,EAAE,MAAM,IAAI;EAChD,EAAE;CACJ,EAAE;CACF,QAAQ;CACR,SAAS,YAAY,YAAY,QAAQ,KAAK,MAAM;CACpD,OAAO;CACP,aAAa,EAAE,SAAS,YAAY,QAAQ,GAAG,OAAO;AACxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"treemap-C4glsx-g.js","names":[],"sources":["../src/charts/treemap.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext, RenderResult, TableContext } from '../chart.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { estimateTextWidth, type InsetsInput, innerRect, insets, round } from '../layout.ts'\nimport { rectPath } from '../shapes/rect.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport { cleanData, finite, isRecord, list, named } from './clean.ts'\nimport { fit } from './fit.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** A tile of a treemap, or a group of them. */\nexport interface TreemapNode {\n name: string\n /** Size of the tile; a negative value is zero. A group is as large as its `children`. */\n value?: number\n /** Tiles (or groups) inside this one; they share its color. */\n children?: readonly TreemapNode[]\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 group (top level) or the tile. */\n class?: ClassValue\n /** Start hidden (top level; toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface TreemapOptions {\n /** Tiles, or groups of tiles; each top-level entry takes a palette color and a legend entry. */\n data: readonly TreemapNode[]\n /** Space between tiles in pixels. Defaults to `2`. */\n gap?: number\n /** Corner radius of the tiles. Defaults to `3`. */\n radius?: number\n /** Names (and values, where they fit) written in the tiles. Defaults to `true`. */\n labels?: boolean\n /** Format of the values (tiles, tooltip, table). */\n format?: NumberFormat\n /** Extra space around the chart, in pixels. */\n padding?: InsetsInput\n}\n\n/** Levels of nesting read from the data, and the most nodes: enough for any chart, few enough to draw. */\nconst MAX_DEPTH = 8\nconst MAX_NODES = 5000\n\n/** Space between a tile's edge and its text. */\nconst INSET = 6\n\n/** A node with its size worked out. */\nexport interface Sized {\n node: TreemapNode\n value: number\n children?: Sized[]\n}\n\ninterface Tile {\n node: TreemapNode\n key: string\n /** Position of the top-level ancestor in `data` (the color slot). */\n top: number\n /** Names of the ancestors, outermost first. */\n trail: readonly string[]\n value: number\n x: number\n y: number\n width: number\n height: number\n}\n\nfunction sized(nodes: readonly TreemapNode[]): Sized[] {\n return nodes.map((node) => {\n if (node.children?.length) {\n const children = sized(node.children)\n return { node, children, value: children.reduce((sum, child) => sum + child.value, 0) }\n }\n return { node, value: Math.max(0, node.value ?? 0) }\n })\n}\n\n/** The chart model of a treemap: its options, with every node's size worked out. */\nexport type TreemapModel = TreemapOptions & { sized: Sized[] }\n\n/** The top-level entries with their sizes and color slots, without the hidden ones. */\nfunction visible(model: TreemapModel, hidden: ReadonlySet<string>) {\n return model.sized\n .map((entry, index) => ({ entry, index }))\n .filter(({ entry }) => !hidden.has(keyOf(entry.node)))\n}\n\n/**\n * Squarified layout (Bruls, Huizing, van Wijk): `items`, largest first, fill\n * the rectangle in rows along its shorter side, each row closed as soon as\n * another item would make its tiles less square.\n */\nfunction squarify(\n items: readonly Sized[],\n x: number,\n y: number,\n w: number,\n hgt: number,\n place: (item: Sized, x: number, y: number, w: number, hgt: number) => void,\n): void {\n const sorted = items.filter((item) => item.value > 0).sort((a, b) => b.value - a.value)\n let left = sorted.reduce((sum, item) => sum + item.value, 0)\n let i = 0\n while (i < sorted.length && w > 0 && hgt > 0) {\n const short = Math.min(w, hgt)\n // Pixels of area per unit of value in what is left of the rectangle.\n const k = (w * hgt) / left\n const largest = (sorted[i] as Sized).value\n let sum = 0\n let best = Number.POSITIVE_INFINITY\n let j = i\n for (; j < sorted.length; j++) {\n const next = sum + (sorted[j] as Sized).value\n // Thickness of the row squared: its worst tile is the largest or the smallest.\n const t2 = ((next * k) / short) ** 2\n const worst = Math.max(t2 / ((sorted[j] as Sized).value * k), (largest * k) / t2)\n if (worst > best) break\n best = worst\n sum = next\n }\n const thickness = (sum * k) / short\n let offset = 0\n for (; i < j; i++) {\n const item = sorted[i] as Sized\n const length = (item.value * k) / thickness\n if (w >= hgt) place(item, x, y + offset, thickness, length)\n else place(item, x + offset, y, length, thickness)\n offset += length\n }\n if (w >= hgt) {\n x += thickness\n w -= thickness\n } else {\n y += thickness\n hgt -= thickness\n }\n left -= sum\n }\n}\n\n/** Half gaps left around a tile on its left, top, right and bottom side. */\ntype Edges = readonly [number, number, number, number]\n\n/**\n * The tiles of `items` in a rectangle, groups laid out inside their own.\n * The gap is cut from the tiles after they are placed, so it does not change\n * their arrangement: half of it on every side (a whole one between any two\n * neighbors), none at the edge of the chart. `edges` are the half gaps of\n * the rectangle itself.\n */\nfunction layout(\n items: readonly Sized[],\n x: number,\n y: number,\n w: number,\n hgt: number,\n gap: number,\n out: Tile[],\n edges: Edges,\n top?: { index: number; key: string; trail: readonly string[] },\n slots?: readonly number[],\n): void {\n squarify(items, x, y, w, hgt, (item, tx, ty, tw, th) => {\n const index = top?.index ?? (slots?.[items.indexOf(item)] as number)\n const key = top ? `${top.key}/${keyOf(item.node)}` : keyOf(item.node)\n const trail = top?.trail ?? []\n // A side on the border of the rectangle takes its half gap (none at the chart's edge), the others one.\n const near = 0.01\n const sides: Edges = [\n tx - x < near ? edges[0] : 1,\n ty - y < near ? edges[1] : 1,\n x + w - tx - tw < near ? edges[2] : 1,\n y + hgt - ty - th < near ? edges[3] : 1,\n ]\n if (item.children) {\n layout(item.children, tx, ty, tw, th, gap, out, sides, {\n index,\n key,\n trail: [...trail, item.node.name],\n })\n } else {\n const half = gap / 2\n out.push({\n node: item.node,\n key,\n top: index,\n trail,\n value: item.value,\n x: tx + sides[0] * half,\n y: ty + sides[1] * half,\n width: Math.max(0, tw - (sides[0] + sides[2]) * half),\n height: Math.max(0, th - (sides[1] + sides[3]) * half),\n })\n }\n })\n}\n\nfunction renderTreemap(options: TreemapModel, ctx: RenderContext): RenderResult {\n const { width, height, fontSize, locale } = ctx\n const gap = Math.max(0, options.gap ?? 2)\n const radius = Math.max(0, options.radius ?? 3)\n const area = innerRect(width, height, insets(options.padding, 0))\n const entries = visible(options, ctx.hidden)\n const total = entries.reduce((sum, { entry }) => sum + entry.value, 0)\n\n const tiles: Tile[] = []\n layout(\n entries.map(({ entry }) => entry),\n area.x,\n area.y,\n area.width,\n area.height,\n gap,\n tiles,\n [0, 0, 0, 0],\n undefined,\n entries.map(({ index }) => index),\n )\n\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n const hitFor = (tile: Tile, index: number): Hit => {\n const x = tile.x + tile.width / 2\n const item: HitItem = {\n name: tile.node.name,\n seriesIndex: tile.top,\n value: tile.value,\n text: `${value(tile.value)} (${share.format(total > 0 ? tile.value / total : 0)})`,\n x,\n y: tile.y + tile.height / 2,\n }\n const color = tile.node.color ?? options.data[tile.top]?.color\n if (color) item.color = color\n return {\n index,\n label: [...tile.trail, tile.node.name].join(' › '),\n title: tile.trail.join(' › '),\n x,\n area,\n items: [item],\n seriesIndex: tile.top,\n // A ring just inside the hovered tile.\n highlight: {\n kind: 'halo',\n d: rectPath(tile.x + 1, tile.y + 1, tile.width - 2, tile.height - 2, radius - 1),\n },\n }\n }\n\n const interaction: Interaction = {\n count: tiles.length,\n hitIndex: (index) => {\n const tile = tiles[index]\n return tile ? hitFor(tile, index) : null\n },\n hitTest(px, py) {\n const index = tiles.findIndex(\n (tile) =>\n px >= tile.x - gap / 2 &&\n px <= tile.x + tile.width + gap / 2 &&\n py >= tile.y - gap / 2 &&\n py <= tile.y + tile.height + gap / 2,\n )\n return index < 0 ? null : hitFor(tiles[index] as Tile, index)\n },\n }\n\n const groups = entries.map(({ entry, index }) =>\n h(\n 'g',\n groupAttrs(entry.node, index),\n tiles\n .filter((tile) => tile.top === index)\n .map((tile) =>\n h('rect', {\n key: tile.key,\n class: ['tc-tile', tile.trail.length > 0 && tile.node.class],\n x: round(tile.x),\n y: round(tile.y),\n width: round(tile.width),\n height: round(tile.height),\n rx: round(Math.min(radius, tile.width / 2, tile.height / 2)),\n // A tile inside a group may have a color of its own.\n style: tile.trail.length > 0 ? { '--tc-series-color': tile.node.color } : undefined,\n }),\n ),\n ),\n )\n\n // Names where a few letters fit, values below where there is a second line.\n const line = fontSize * 1.3\n const labels =\n options.labels !== false &&\n tiles.flatMap((tile) => {\n const room = tile.width - INSET * 2\n const name = tile.height >= line + INSET ? fit(tile.node.name, room, fontSize) : ''\n if (!name) return []\n const text = value(tile.value)\n const x = round(tile.x + INSET)\n const y = tile.y + INSET + fontSize * 0.85\n return [\n h('text', { key: tile.key, class: 'tc-treemap-label', x, y: round(y) }, name),\n tile.height >= line * 2 + INSET * 1.5 &&\n estimateTextWidth(text, fontSize) <= room &&\n h(\n 'text',\n {\n key: `${tile.key}/value`,\n class: 'tc-treemap-label tc-treemap-value',\n x,\n y: round(y + line),\n },\n text,\n ),\n ]\n })\n\n const content = [\n h('g', { class: 'tc-treemap-tiles' }, groups),\n labels && h('g', { class: 'tc-treemap-labels', 'aria-hidden': 'true' }, labels),\n ]\n return { content, interaction }\n}\n\nfunction treemapTable(options: TreemapModel, ctx: TableContext, limit: number): DataTable {\n const entries = visible(options, ctx.hidden)\n const total = entries.reduce((sum, { entry }) => sum + entry.value, 0)\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n const rows: string[][] = []\n const walk = (items: readonly Sized[], trail: readonly string[]) => {\n for (const item of items) {\n const path = [...trail, item.node.name]\n if (item.children) walk(item.children, path)\n else {\n rows.push([\n path.join(' › '),\n value(item.value),\n share.format(total > 0 ? item.value / total : 0),\n ])\n }\n }\n }\n walk(\n entries.map(({ entry }) => entry),\n [],\n )\n const table: DataTable = { columns: ['', 'Value', 'Share'], rows }\n if (rows.length > limit) {\n table.rows = rows.slice(0, limit)\n table.total = rows.length\n }\n return table\n}\n\n/** Nodes with text for names and finite values, at most `MAX_DEPTH` deep and `MAX_NODES` in all. */\nfunction cleanNodes(data: unknown, depth = 0, budget = { left: MAX_NODES }): TreemapNode[] {\n const nodes: TreemapNode[] = []\n for (const r of list(data)) {\n if (!isRecord(r) || budget.left <= 0) continue\n budget.left--\n const children =\n depth < MAX_DEPTH && Array.isArray(r.children)\n ? cleanNodes(r.children, depth + 1, budget)\n : undefined\n nodes.push({ ...named(r), value: finite(r.value) ?? 0, children } as unknown as TreemapNode)\n }\n return nodes\n}\n\n/**\n * Treemap: parts of a whole as tiles, each as large as its value, laid out\n * as close to squares as they go with the largest in the top left corner.\n * Entries with `children` are groups: their tiles stay together and share\n * the group's color.\n *\n * ```ts\n * new Chart('#el', {\n * type: treemap,\n * data: [\n * { name: 'Search', value: 42 },\n * { name: 'Social', children: [{ name: 'Video', value: 18 }, { name: 'Posts', value: 9 }] },\n * ],\n * })\n * ```\n */\nexport const treemap: ChartType<TreemapOptions, TreemapModel> = {\n name: 'treemap',\n clean: cleanData((data) => cleanNodes(data)),\n prepare: (options) => ({ ...options, sized: sized(options.data) }),\n render: renderTreemap,\n legend: (options) => legendItems(options.data),\n table: treemapTable,\n}\n"],"mappings":";;;;;;;;;AA+CA,MAAM,YAAY;AAClB,MAAM,YAAY;;AAGlB,MAAM,QAAQ;AAuBd,SAAS,MAAM,OAAwC;CACrD,OAAO,MAAM,KAAK,SAAS;EACzB,IAAI,KAAK,UAAU,QAAQ;GACzB,MAAM,WAAW,MAAM,KAAK,QAAQ;GACpC,OAAO;IAAE;IAAM;IAAU,OAAO,SAAS,QAAQ,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;GAAE;EACxF;EACA,OAA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