@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,6 +1,6 @@
|
|
|
1
1
|
import { n as estimateTextWidth, s as round } from "./layout-DqAte3H8.js";
|
|
2
2
|
import { t as h } from "./vnode-_EMUqysL.js";
|
|
3
|
-
import { o as labelKey, y as toMs } from "./cartesian-
|
|
3
|
+
import { o as labelKey, y as toMs } from "./cartesian-COglz544.js";
|
|
4
4
|
import { d as text, i as finite, o as label, u as records } from "./clean-CkoQobGv.js";
|
|
5
5
|
// src/charts/annotations.ts
|
|
6
6
|
/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */
|
|
@@ -86,7 +86,19 @@ function annotationLayers(annotations, scales) {
|
|
|
86
86
|
vertical
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
|
|
89
|
+
/** Where a point annotation (a single `x` and a single `y`) lands; `undefined` off the plot. */
|
|
90
|
+
const pointOf = (a) => {
|
|
91
|
+
if (a.x === void 0 || a.y === void 0 || isPair(a.x) || isPair(a.y)) return void 0;
|
|
92
|
+
const along = categorySpan(scales, a.x);
|
|
93
|
+
const v = scales.value(a.y);
|
|
94
|
+
if (!along || !Number.isFinite(v)) return void 0;
|
|
95
|
+
const c = (along[0] + along[1]) / 2;
|
|
96
|
+
const [px, py] = horizontal ? [v, c] : [c, v];
|
|
97
|
+
return inside(px, x0, x1) && inside(py, y0, y1) ? [px, py] : void 0;
|
|
98
|
+
};
|
|
99
|
+
const isPoint = (a) => a.x !== void 0 && a.y !== void 0 && !isPair(a.x) && !isPair(a.y);
|
|
100
|
+
const dots = annotations.map(pointOf);
|
|
101
|
+
const shapes = annotations.map((a) => isPoint(a) ? void 0 : geometry(a));
|
|
90
102
|
/** Boxes labels keep clear of: the labels placed so far, and every line. */
|
|
91
103
|
const placed = [];
|
|
92
104
|
const obstacles = [];
|
|
@@ -105,6 +117,15 @@ function annotationLayers(annotations, scales) {
|
|
|
105
117
|
at + 1.5
|
|
106
118
|
]]);
|
|
107
119
|
});
|
|
120
|
+
const DOT = 4;
|
|
121
|
+
dots.forEach((p, i) => {
|
|
122
|
+
if (p) obstacles.push([i, [
|
|
123
|
+
p[0] - DOT,
|
|
124
|
+
p[1] - DOT,
|
|
125
|
+
p[0] + DOT,
|
|
126
|
+
p[1] + DOT
|
|
127
|
+
]]);
|
|
128
|
+
});
|
|
108
129
|
const apart = (box, [l, t, r, b]) => box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b;
|
|
109
130
|
const clearOfLabels = (box) => placed.every((p) => apart(box, p));
|
|
110
131
|
const clear = (box, own) => clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l));
|
|
@@ -114,12 +135,71 @@ function annotationLayers(annotations, scales) {
|
|
|
114
135
|
key: part ? `${key}-${part}` : key,
|
|
115
136
|
class: [
|
|
116
137
|
"tc-annotation",
|
|
117
|
-
a.y !== void 0 ? "tc-annotation-y" : "tc-annotation-x",
|
|
138
|
+
isPoint(a) ? "tc-annotation-point" : a.y !== void 0 ? "tc-annotation-y" : "tc-annotation-x",
|
|
118
139
|
a.class
|
|
119
140
|
],
|
|
120
|
-
style: {
|
|
141
|
+
style: {
|
|
142
|
+
"--tc-annotation-color": a.color,
|
|
143
|
+
"--tc-annotation-dash": Number.isFinite(a.dash) ? `${a.dash}px` : a.dash
|
|
144
|
+
}
|
|
121
145
|
});
|
|
146
|
+
/** The label at a spot ([left edge, baseline]), on its background when asked for. */
|
|
147
|
+
const labelAt = (spot, w) => {
|
|
148
|
+
const size = fontSize * .92;
|
|
149
|
+
const text = h("text", {
|
|
150
|
+
class: "tc-annotation-label",
|
|
151
|
+
x: round(spot[0]),
|
|
152
|
+
y: round(spot[1])
|
|
153
|
+
}, a.label);
|
|
154
|
+
return a.labelBackground ? [h("rect", {
|
|
155
|
+
class: "tc-annotation-label-bg",
|
|
156
|
+
x: round(spot[0] - 3),
|
|
157
|
+
y: round(spot[1] - size),
|
|
158
|
+
width: round(w + 6),
|
|
159
|
+
height: round(size * 1.35),
|
|
160
|
+
rx: 2
|
|
161
|
+
}), text] : [text];
|
|
162
|
+
};
|
|
122
163
|
const end = a.position !== "start";
|
|
164
|
+
const dot = dots[index];
|
|
165
|
+
if (dot) {
|
|
166
|
+
const [px, py] = dot;
|
|
167
|
+
let text;
|
|
168
|
+
if (a.label) {
|
|
169
|
+
const w = estimateTextWidth(a.label, fontSize * .92);
|
|
170
|
+
const off = 8;
|
|
171
|
+
const mid = py + fontSize * .35;
|
|
172
|
+
const spots = [
|
|
173
|
+
[px + off, mid],
|
|
174
|
+
[px - off - w, mid],
|
|
175
|
+
[px - w / 2, py - off],
|
|
176
|
+
[px - w / 2, py + off + fontSize * .8],
|
|
177
|
+
[px + off, py + off + fontSize * .8],
|
|
178
|
+
[px + off, py - off],
|
|
179
|
+
[px - off - w, py + off + fontSize * .8],
|
|
180
|
+
[px - off - w, py - off]
|
|
181
|
+
];
|
|
182
|
+
const box = ([x, y]) => [
|
|
183
|
+
x,
|
|
184
|
+
y - fontSize,
|
|
185
|
+
x + w,
|
|
186
|
+
y + fontSize * .25
|
|
187
|
+
];
|
|
188
|
+
const within = (s) => s[0] >= x0 && s[0] + w <= x1;
|
|
189
|
+
const spot = spots.find((s) => within(s) && clear(box(s), index)) ?? spots.find((s) => within(s) && clearOfLabels(box(s)));
|
|
190
|
+
if (spot) {
|
|
191
|
+
placed.push(box(spot));
|
|
192
|
+
text = labelAt(spot, w);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
lines.push(h("g", attrs(), h("circle", {
|
|
196
|
+
class: "tc-annotation-dot",
|
|
197
|
+
cx: round(px),
|
|
198
|
+
cy: round(py),
|
|
199
|
+
r: DOT
|
|
200
|
+
}), text));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
123
203
|
const shape = shapes[index];
|
|
124
204
|
if (!shape) return;
|
|
125
205
|
const { a0, a1, vertical } = shape;
|
|
@@ -153,11 +233,7 @@ function annotationLayers(annotations, scales) {
|
|
|
153
233
|
];
|
|
154
234
|
const spot = spots.find((s) => clear(box(s), index)) ?? spots.find((s) => clearOfLabels(box(s))) ?? spots[0];
|
|
155
235
|
placed.push(box(spot));
|
|
156
|
-
label =
|
|
157
|
-
class: "tc-annotation-label",
|
|
158
|
-
x: round(spot[0]),
|
|
159
|
-
y: round(spot[1])
|
|
160
|
-
}, a.label);
|
|
236
|
+
label = labelAt(spot, w);
|
|
161
237
|
}
|
|
162
238
|
if (a1 - a0 > .5) {
|
|
163
239
|
const d = vertical ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z` : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`;
|
|
@@ -198,4 +274,4 @@ function annotationLayers(annotations, scales) {
|
|
|
198
274
|
}
|
|
199
275
|
export { annotationValues as n, annotationLayers as t };
|
|
200
276
|
|
|
201
|
-
//# sourceMappingURL=annotations-
|
|
277
|
+
//# sourceMappingURL=annotations-DGITy6th.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations-DGITy6th.js","names":[],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n * With both a single `x` and a single `y` it is a point: a dot at that\n * category and value, with its label beside it.\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or the point, or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /**\n * The dashes of the line: dash and gap length in pixels, or a full\n * `stroke-dasharray` such as `'6 3'`; `0` draws it solid. Sets\n * `--tc-annotation-dash`. Defaults to `'4 3'`.\n */\n dash?: number | string\n /**\n * Draw the label on a background (the surface color), so it reads where\n * it crosses lines and points. Defaults to `false`.\n */\n labelBackground?: boolean\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n /** Where a point annotation (a single `x` and a single `y`) lands; `undefined` off the plot. */\n const pointOf = (a: Annotation): readonly [number, number] | undefined => {\n if (a.x === undefined || a.y === undefined || isPair(a.x) || isPair(a.y)) return undefined\n const along = categorySpan(scales, a.x)\n const v = scales.value(a.y)\n if (!along || !Number.isFinite(v)) return undefined\n const c = (along[0] + along[1]) / 2\n const [px, py] = horizontal ? [v, c] : [c, v]\n return inside(px, x0, x1) && inside(py, y0, y1) ? [px, py] : undefined\n }\n const isPoint = (a: Annotation) =>\n a.x !== undefined && a.y !== undefined && !isPair(a.x) && !isPair(a.y)\n const dots = annotations.map(pointOf)\n const shapes = annotations.map((a) => (isPoint(a) ? undefined : geometry(a)))\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const DOT = 4\n dots.forEach((p, i) => {\n if (p) obstacles.push([i, [p[0] - DOT, p[1] - DOT, p[0] + DOT, p[1] + DOT]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: [\n 'tc-annotation',\n isPoint(a)\n ? 'tc-annotation-point'\n : a.y !== undefined\n ? 'tc-annotation-y'\n : 'tc-annotation-x',\n a.class,\n ],\n style: {\n '--tc-annotation-color': a.color,\n '--tc-annotation-dash': Number.isFinite(a.dash) ? `${a.dash}px` : a.dash,\n },\n })\n /** The label at a spot ([left edge, baseline]), on its background when asked for. */\n const labelAt = (spot: [number, number], w: number): VNode[] => {\n const size = fontSize * 0.92\n const text = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n return a.labelBackground\n ? [\n h('rect', {\n class: 'tc-annotation-label-bg',\n x: round(spot[0] - 3),\n y: round(spot[1] - size),\n width: round(w + 6),\n height: round(size * 1.35),\n rx: 2,\n }),\n text,\n ]\n : [text]\n }\n const end = a.position !== 'start'\n\n const dot = dots[index]\n if (dot) {\n const [px, py] = dot\n let text: VNode[] | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const off = DOT + pad\n const mid = py + fontSize * 0.35\n // Beside the dot, then above or below it, then at its corners.\n const spots: [number, number][] = [\n [px + off, mid],\n [px - off - w, mid],\n [px - w / 2, py - off],\n [px - w / 2, py + off + fontSize * 0.8],\n [px + off, py + off + fontSize * 0.8],\n [px + off, py - off],\n [px - off - w, py + off + fontSize * 0.8],\n [px - off - w, py - off],\n ]\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n const within = (s: [number, number]) => s[0] >= x0 && s[0] + w <= x1\n // A label with no room in the plot is left out: the dot stays.\n const spot =\n spots.find((s) => within(s) && clear(box(s), index)) ??\n spots.find((s) => within(s) && clearOfLabels(box(s)))\n if (spot) {\n placed.push(box(spot))\n text = labelAt(spot, w)\n }\n }\n lines.push(\n h(\n 'g',\n attrs(),\n h('circle', { class: 'tc-annotation-dot', cx: round(px), cy: round(py), r: DOT }),\n text,\n ),\n )\n return\n }\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode[] | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = labelAt(spot, w)\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AA+DA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAA;CACvC;CACA,MAAM,IAAI,OAAO,KAAK,QAAQ,SAAS,KAAK,CAAC;CAC7C,OAAO,IAAI,IAAI,KAAA,IAAY,CAAC,OAAO,KAAK,GAAG,CAAC,GAAG,OAAO,KAAK,GAAG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AAoB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
package/dist/annotations.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_annotations = require("./annotations-
|
|
2
|
+
const require_annotations = require("./annotations--m-HzMBM.cjs");
|
|
3
3
|
// src/annotations.ts
|
|
4
4
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
5
5
|
require("./features-DEDP5CEQ.cjs").register({ annotations: {
|
package/dist/annotations.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
2
|
-
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-
|
|
2
|
+
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-CqZM1z9R.cjs";
|
|
3
3
|
export { type Annotation, annotationLayers, annotationValues };
|
package/dist/annotations.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
2
|
-
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-
|
|
2
|
+
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-CCDUC1lW.js";
|
|
3
3
|
export { type Annotation, annotationLayers, annotationValues };
|
package/dist/annotations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as annotationValues, t as annotationLayers } from "./annotations-
|
|
1
|
+
import { n as annotationValues, t as annotationLayers } from "./annotations-DGITy6th.js";
|
|
2
2
|
import { i as register } from "./features-B55rwpQC.js";
|
|
3
3
|
// src/annotations.ts
|
|
4
4
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as seriesTable, h as seriesLegend } from "./cartesian-
|
|
1
|
+
import { C as windowed, _ as seriesTable, h as seriesLegend } from "./cartesian-COglz544.js";
|
|
2
2
|
import { r as cleanSeries, t as cleanData } from "./clean-CkoQobGv.js";
|
|
3
|
-
import { n as renderLines } from "./line-
|
|
3
|
+
import { n as renderLines } from "./line-CXH0L10d.js";
|
|
4
4
|
// src/charts/area.ts
|
|
5
5
|
/**
|
|
6
6
|
* Area chart: filled lines over category labels, with zero in the y domain
|
|
@@ -16,10 +16,11 @@ import { n as renderLines } from "./line-CxR4tg1Q.js";
|
|
|
16
16
|
const area = {
|
|
17
17
|
name: "area",
|
|
18
18
|
clean: cleanData(cleanSeries),
|
|
19
|
+
prepare: windowed,
|
|
19
20
|
render: (options, ctx) => renderLines(options, ctx, true),
|
|
20
21
|
legend: (options) => seriesLegend(options.data),
|
|
21
22
|
table: (options, ctx, limit) => seriesTable(options, ctx, limit)
|
|
22
23
|
};
|
|
23
24
|
export { area as t };
|
|
24
25
|
|
|
25
|
-
//# sourceMappingURL=area-
|
|
26
|
+
//# sourceMappingURL=area-BN0uE9R0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area-BN0uE9R0.js","names":[],"sources":["../src/charts/area.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport { seriesLegend, seriesTable, windowed } from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\nimport { type LineOptions, renderLines } from './line.ts'\n\n/** Options of the area chart: line options with the fill always on. */\nexport type AreaOptions = Omit<LineOptions, 'area'>\n\n/**\n * Area chart: filled lines over category labels, with zero in the y domain\n * by default and a vertical fade (`fill: 'gradient'`).\n *\n * ```ts\n * new Chart('#el', {\n * type: area,\n * data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },\n * })\n * ```\n */\nexport const area: ChartType<AreaOptions> = {\n name: 'area',\n clean: cleanData(cleanSeries),\n prepare: windowed,\n render: (options, ctx) => renderLines(options, ctx, true),\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) => seriesTable(options, ctx, limit),\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,OAA+B;CAC1C,MAAM;CACN,OAAO,UAAU,WAAW;CAC5B,SAAS;CACT,SAAS,SAAS,QAAQ,YAAY,SAAS,KAAK,IAAI;CACxD,SAAS,YAAY,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UAAU,YAAY,SAAS,KAAK,KAAK;AACjE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ChartType } from "./chart-
|
|
2
|
-
import { t as LineOptions } from "./line-
|
|
1
|
+
import { o as ChartType } from "./chart-Dz4geQZy.cjs";
|
|
2
|
+
import { t as LineOptions } from "./line-Cu9ctpbv.cjs";
|
|
3
3
|
/** Options of the area chart: line options with the fill always on. */
|
|
4
4
|
type AreaOptions = Omit<LineOptions, "area">;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ChartType } from "./chart-
|
|
2
|
-
import { t as LineOptions } from "./line-
|
|
1
|
+
import { o as ChartType } from "./chart-CE9EVbfV.js";
|
|
2
|
+
import { t as LineOptions } from "./line-TkzA7wMK.js";
|
|
3
3
|
/** Options of the area chart: line options with the fill always on. */
|
|
4
4
|
type AreaOptions = Omit<LineOptions, "area">;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_cartesian = require("./cartesian-
|
|
1
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
2
2
|
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
3
|
-
const require_line = require("./line-
|
|
3
|
+
const require_line = require("./line-DHbYCQy4.cjs");
|
|
4
4
|
// src/charts/area.ts
|
|
5
5
|
/**
|
|
6
6
|
* Area chart: filled lines over category labels, with zero in the y domain
|
|
@@ -16,6 +16,7 @@ const require_line = require("./line-YiCuhVMI.cjs");
|
|
|
16
16
|
const area = {
|
|
17
17
|
name: "area",
|
|
18
18
|
clean: require_clean.cleanData(require_clean.cleanSeries),
|
|
19
|
+
prepare: require_cartesian.windowed,
|
|
19
20
|
render: (options, ctx) => require_line.renderLines(options, ctx, true),
|
|
20
21
|
legend: (options) => require_cartesian.seriesLegend(options.data),
|
|
21
22
|
table: (options, ctx, limit) => require_cartesian.seriesTable(options, ctx, limit)
|
|
@@ -27,4 +28,4 @@ Object.defineProperty(exports, "area", {
|
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
//# sourceMappingURL=area-
|
|
31
|
+
//# sourceMappingURL=area-D_N8b4Ng.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area-D_N8b4Ng.cjs","names":["cleanData","cleanSeries","windowed","renderLines","seriesLegend","seriesTable"],"sources":["../src/charts/area.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport { seriesLegend, seriesTable, windowed } from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\nimport { type LineOptions, renderLines } from './line.ts'\n\n/** Options of the area chart: line options with the fill always on. */\nexport type AreaOptions = Omit<LineOptions, 'area'>\n\n/**\n * Area chart: filled lines over category labels, with zero in the y domain\n * by default and a vertical fade (`fill: 'gradient'`).\n *\n * ```ts\n * new Chart('#el', {\n * type: area,\n * data: { labels: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Sales', values: [3, 5, 4] }] },\n * })\n * ```\n */\nexport const area: ChartType<AreaOptions> = {\n name: 'area',\n clean: cleanData(cleanSeries),\n prepare: windowed,\n render: (options, ctx) => renderLines(options, ctx, true),\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) => seriesTable(options, ctx, limit),\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,OAA+B;CAC1C,MAAM;CACN,OAAOA,cAAAA,UAAUC,cAAAA,WAAW;CAC5B,SAASC,kBAAAA;CACT,SAAS,SAAS,QAAQC,aAAAA,YAAY,SAAS,KAAK,IAAI;CACxD,SAAS,YAAYC,kBAAAA,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UAAUC,kBAAAA,YAAY,SAAS,KAAK,KAAK;AACjE"}
|
package/dist/area.cjs
CHANGED
package/dist/area.d.cts
CHANGED
package/dist/area.d.ts
CHANGED
package/dist/area.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as area } from "./area-
|
|
1
|
+
export { t as area } from "./area-BN0uE9R0.js";
|
|
@@ -149,9 +149,9 @@ function thinTicks(ticks, position, fontSize, gap = 8) {
|
|
|
149
149
|
}
|
|
150
150
|
/** Pixels an axis occupies perpendicular to the plot edge (for margins). */
|
|
151
151
|
function axisSize(position, ticks, fontSize, options = {}) {
|
|
152
|
-
const { tickSize = 0, tickPadding = 8 } = options;
|
|
152
|
+
const { tickSize = 0, tickPadding = 8, rotate } = options;
|
|
153
153
|
if (ticks.length === 0) return 0;
|
|
154
|
-
const labels = isHorizontal(position) ? fontSize * require_layout.LINE_HEIGHT : ticks.reduce((max, t) => Math.max(max, require_layout.estimateTextWidth(t.label, fontSize)), 0) + 3;
|
|
154
|
+
const labels = isHorizontal(position) && !rotate ? fontSize * require_layout.LINE_HEIGHT : ticks.reduce((max, t) => Math.max(max, require_layout.estimateTextWidth(t.label, fontSize)), 0) + 3;
|
|
155
155
|
return Math.ceil(labels + tickSize + tickPadding);
|
|
156
156
|
}
|
|
157
157
|
/** Space between the tick labels and the axis title. */
|
|
@@ -164,8 +164,8 @@ const axisTitleSize = (title, fontSize) => title ? Math.ceil(fontSize * require_
|
|
|
164
164
|
* bottom, turned 90° beside the plot to read away from it (bottom to top on
|
|
165
165
|
* the left, top to bottom on the right).
|
|
166
166
|
*/
|
|
167
|
-
function axisTitle(position, ticks, area, title, fontSize) {
|
|
168
|
-
const reach = axisSize(position, ticks, fontSize) + TITLE_GAP;
|
|
167
|
+
function axisTitle(position, ticks, area, title, fontSize, rotate) {
|
|
168
|
+
const reach = axisSize(position, ticks, fontSize, { rotate }) + TITLE_GAP;
|
|
169
169
|
const sign = position === "left" ? -1 : 1;
|
|
170
170
|
const side = reach + fontSize * require_layout.LINE_HEIGHT / 2;
|
|
171
171
|
return require_vnode.h("text", {
|
|
@@ -183,12 +183,17 @@ function axisTitle(position, ticks, area, title, fontSize) {
|
|
|
183
183
|
* transition when the scale changes.
|
|
184
184
|
*/
|
|
185
185
|
function axis(options) {
|
|
186
|
-
const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false } = options;
|
|
186
|
+
const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false, rotate } = options;
|
|
187
187
|
const horizontal = isHorizontal(position);
|
|
188
188
|
const sign = position === "top" || position === "left" ? -1 : 1;
|
|
189
189
|
const offset = sign * (tickSize + tickPadding);
|
|
190
190
|
const edge = position === "top" ? area.y : position === "bottom" ? area.y + area.height : position === "left" ? area.x : area.x + area.width;
|
|
191
|
-
const label =
|
|
191
|
+
const label = rotate ? {
|
|
192
|
+
transform: "rotate(-90)",
|
|
193
|
+
x: -offset,
|
|
194
|
+
dy: "0.32em",
|
|
195
|
+
"text-anchor": "end"
|
|
196
|
+
} : horizontal ? {
|
|
192
197
|
y: offset,
|
|
193
198
|
dy: position === "top" ? "0em" : "0.71em",
|
|
194
199
|
"text-anchor": "middle"
|
|
@@ -297,4 +302,4 @@ Object.defineProperty(exports, "ticks", {
|
|
|
297
302
|
}
|
|
298
303
|
});
|
|
299
304
|
|
|
300
|
-
//# sourceMappingURL=axis-
|
|
305
|
+
//# sourceMappingURL=axis-BzBkkC5X.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis-BzBkkC5X.cjs","names":["formatTicks","estimateTextWidth","LINE_HEIGHT","h","round"],"sources":["../src/scales/ticks.ts","../src/components/axis.ts"],"sourcesContent":["const E10 = Math.sqrt(50)\nconst E5 = Math.sqrt(10)\nconst E2 = Math.sqrt(2)\n\n/**\n * Integer tick indices `[i1, i2]` and an increment `inc`. A negative `inc`\n * means \"divide by -inc\", which keeps decimal ticks exact (0.3, not\n * 0.30000000000000004).\n */\nfunction tickSpec(start: number, stop: number, count: number): [number, number, number] {\n const step = (stop - start) / Math.max(0, count)\n const power = Math.floor(Math.log10(step))\n const error = step / 10 ** power\n const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1\n let i1: number\n let i2: number\n let inc: number\n if (power < 0) {\n inc = 10 ** -power / factor\n i1 = Math.round(start * inc)\n i2 = Math.round(stop * inc)\n if (i1 / inc < start) ++i1\n if (i2 / inc > stop) --i2\n inc = -inc\n } else {\n inc = 10 ** power * factor\n i1 = Math.round(start / inc)\n i2 = Math.round(stop / inc)\n if (i1 * inc < start) ++i1\n if (i2 * inc > stop) --i2\n }\n if (i2 < i1 && count >= 0.5 && count < 2) return tickSpec(start, stop, count * 2)\n return [i1, i2, inc]\n}\n\n/**\n * Roughly `count` evenly spaced, \"nice\" values (multiples of 1, 2 or 5 × 10ⁿ)\n * between `start` and `stop`, inclusive. Order follows `start → stop`.\n */\nexport function ticks(start: number, stop: number, count = 5): number[] {\n if (!(count > 0) || !Number.isFinite(start) || !Number.isFinite(stop)) return []\n if (start === stop) return [start]\n const reverse = stop < start\n const [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count)\n if (!(i2 >= i1)) return []\n const n = i2 - i1 + 1\n const out = new Array<number>(n)\n for (let i = 0; i < n; i++) {\n const index = reverse ? i2 - i : i1 + i\n out[i] = inc < 0 ? index / -inc : index * inc\n }\n return out\n}\n\n/**\n * Signed tick increment: positive values are the step, negative values `-k`\n * mean a step of `1 / k`.\n */\nexport function tickIncrement(start: number, stop: number, count: number): number {\n return tickSpec(start, stop, count)[2]\n}\n\n/** Distance between ticks produced by {@link ticks} for the same arguments. */\nexport function tickStep(start: number, stop: number, count = 5): number {\n const reverse = stop < start\n const inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count)\n return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc)\n}\n\n/**\n * Extend `[start, stop]` to round tick values, e.g. `[0.2, 9.7] → [0, 10]`.\n * Iterates because rounding can change the ideal step; if the step does not\n * settle (e.g. very low `count` around zero keeps doubling the domain), the\n * domain is returned unchanged, matching d3.\n */\nexport function niceDomain(start: number, stop: number, count = 5): [number, number] {\n if (!Number.isFinite(start) || !Number.isFinite(stop) || start === stop || !(count > 0)) {\n return [start, stop]\n }\n const reverse = stop < start\n let lo = reverse ? stop : start\n let hi = reverse ? start : stop\n let prev: number | undefined\n for (let i = 0; i < 10; i++) {\n const step = tickIncrement(lo, hi, count)\n if (step === prev) return reverse ? [hi, lo] : [lo, hi]\n if (step > 0) {\n lo = Math.floor(lo / step) * step\n hi = Math.ceil(hi / step) * step\n } else if (step < 0) {\n lo = Math.ceil(lo * step) / step\n hi = Math.floor(hi * step) / step\n } else {\n break\n }\n prev = step\n }\n return [start, stop]\n}\n","import { formatTicks, type Locale, type NumberFormat } from '../format.ts'\nimport { estimateTextWidth, LINE_HEIGHT, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { tickStep } from '../scales/ticks.ts'\nimport { h, type VNode } from '../vnode.ts'\n\nexport type AxisPosition = 'top' | 'right' | 'bottom' | 'left'\n\n/** A single axis tick: its data value, pixel position along the axis and label. */\nexport interface Tick {\n value: number | BandKey\n position: number\n label: string\n}\n\nexport interface LinearTicksOptions {\n /** Approximate number of ticks. Defaults to `5`. */\n count?: number\n format?: NumberFormat\n locale?: Locale\n}\n\n/** Ticks for a linear scale, labelled with a shared precision. */\nexport function linearTicks(scale: LinearScale, options: LinearTicksOptions = {}): Tick[] {\n const { count = 5, format, locale } = options\n const [d0, d1] = scale.domain\n const fmt = formatTicks(tickStep(d0, d1, count), format, locale)\n return scale.ticks(count).map((value) => ({ value, position: scale(value), label: fmt(value) }))\n}\n\n/** Ticks at the center of every band. */\nexport function bandTicks(\n scale: BandScale,\n format: (key: BandKey, index: number) => string = String,\n): Tick[] {\n return scale.domain.map((key, i) => ({\n value: key,\n position: scale.at(i) + scale.bandwidth / 2,\n label: format(key, i),\n }))\n}\n\n/** Whether labels are laid out along x (horizontal axes). */\nconst isHorizontal = (position: AxisPosition): boolean =>\n position === 'top' || position === 'bottom'\n\n/**\n * Keep every n-th tick (smallest n) so labels do not overlap along the axis.\n * The first and the last tick are always kept: when the last one does not\n * land on the step, it replaces the last kept tick if they would collide.\n */\nexport function thinTicks(\n ticks: readonly Tick[],\n position: AxisPosition,\n fontSize: number,\n gap = 8,\n): Tick[] {\n if (ticks.length < 2) return ticks.slice()\n const size = (tick: Tick) =>\n isHorizontal(position) ? estimateTextWidth(tick.label, fontSize) : fontSize * LINE_HEIGHT\n const sizes = ticks.map(size)\n const fitsBetween = (i: number, j: number) =>\n Math.abs((ticks[j] as Tick).position - (ticks[i] as Tick).position) >=\n ((sizes[i] as number) + (sizes[j] as number)) / 2 + gap\n\n const last = ticks.length - 1\n // Start from the step the total label size demands, instead of trying every one.\n const span = Math.abs((ticks[last] as Tick).position - (ticks[0] as Tick).position)\n const total = sizes.reduce((sum, size) => sum + size + gap, 0)\n const first = span > 0 ? Math.max(1, Math.floor(total / span)) : last\n for (let step = first; step <= last; step++) {\n let fits = true\n for (let i = step; i <= last && fits; i += step) fits = fitsBetween(i - step, i)\n if (!fits) continue\n\n const kept: number[] = []\n for (let i = 0; i <= last; i += step) kept.push(i)\n const tail = kept[kept.length - 1] as number\n if (tail !== last) {\n if (fitsBetween(tail, last)) kept.push(last)\n else if (kept.length > 1 && fitsBetween(kept[kept.length - 2] as number, last))\n kept[kept.length - 1] = last\n }\n return kept.map((i) => ticks[i] as Tick)\n }\n return ticks.slice(0, 1)\n}\n\nexport interface AxisOptions {\n position: AxisPosition\n ticks: readonly Tick[]\n /** Plot area the axis is attached to. */\n area: Rect\n /** Length of tick marks. Defaults to `0` (labels only). */\n tickSize?: number\n /** Distance between tick marks and labels. Defaults to `8`. */\n tickPadding?: number\n /** Draw the axis line along the plot edge. Defaults to `false`. */\n line?: boolean\n /** Turn the labels of an axis below the plot 90°, reading bottom to top. */\n rotate?: boolean\n}\n\n/** Pixels an axis occupies perpendicular to the plot edge (for margins). */\nexport function axisSize(\n position: AxisPosition,\n ticks: readonly Tick[],\n fontSize: number,\n options: { tickSize?: number; tickPadding?: number; rotate?: boolean } = {},\n): number {\n const { tickSize = 0, tickPadding = 8, rotate } = options\n if (ticks.length === 0) return 0\n // Beside the plot (and turned below it), labels are as wide as their text: a little slack\n // covers fonts wider than the estimate, so they do not touch the chart's edge.\n const labels =\n isHorizontal(position) && !rotate\n ? fontSize * LINE_HEIGHT\n : ticks.reduce((max, t) => Math.max(max, estimateTextWidth(t.label, fontSize)), 0) + 3\n return Math.ceil(labels + tickSize + tickPadding)\n}\n\n/** Space between the tick labels and the axis title. */\nconst TITLE_GAP = 6\n\n/** Pixels an axis title adds to the axis (for margins): none without a title. */\nexport const axisTitleSize = (title: string | undefined, fontSize: number): number =>\n title ? Math.ceil(fontSize * LINE_HEIGHT) + TITLE_GAP : 0\n\n/**\n * Render the title of an axis as `<text class=\"tc-axis-title tc-axis-title-{position}\">`,\n * past the labels of `ticks` and centered on the plot: along the axis at the\n * bottom, turned 90° beside the plot to read away from it (bottom to top on\n * the left, top to bottom on the right).\n */\nexport function axisTitle(\n position: 'right' | 'bottom' | 'left',\n ticks: readonly Tick[],\n area: Rect,\n title: string,\n fontSize: number,\n rotate?: boolean,\n): VNode {\n const reach = axisSize(position, ticks, fontSize, { rotate }) + TITLE_GAP\n const sign = position === 'left' ? -1 : 1\n const side = reach + (fontSize * LINE_HEIGHT) / 2\n return h(\n 'text',\n {\n key: `axis-title-${position}`,\n class: `tc-axis-title tc-axis-title-${position}`,\n transform:\n position === 'bottom'\n ? `translate(${round(area.x + area.width / 2)},${round(area.y + area.height + reach)})`\n : `translate(${round(position === 'left' ? area.x - side : area.x + area.width + side)},${round(area.y + area.height / 2)}) rotate(${sign * 90})`,\n dy: position === 'bottom' ? '0.71em' : '0.32em',\n 'text-anchor': 'middle',\n 'aria-hidden': 'true',\n },\n title,\n )\n}\n\n/**\n * Render an axis as `<g class=\"tc-axis tc-axis-{x|y} tc-axis-{position}\">`\n * with one `<g class=\"tc-tick\">` per tick, keyed by value so ticks can\n * transition when the scale changes.\n */\nexport function axis(options: AxisOptions): VNode {\n const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false, rotate } = options\n const horizontal = isHorizontal(position)\n const sign = position === 'top' || position === 'left' ? -1 : 1\n const offset = sign * (tickSize + tickPadding)\n\n // Edge of the plot the axis sits on.\n const edge =\n position === 'top'\n ? area.y\n : position === 'bottom'\n ? area.y + area.height\n : position === 'left'\n ? area.x\n : area.x + area.width\n\n const label = rotate\n ? { transform: 'rotate(-90)', x: -offset, dy: '0.32em', 'text-anchor': 'end' }\n : horizontal\n ? { y: offset, dy: position === 'top' ? '0em' : '0.71em', 'text-anchor': 'middle' }\n : { x: offset, dy: '0.32em', 'text-anchor': position === 'left' ? 'end' : 'start' }\n\n const tickLine = horizontal ? { y2: sign * tickSize } : { x2: sign * tickSize }\n\n return h(\n 'g',\n {\n // Keyed, so an axis keeps its nodes when layers around it come and go.\n key: `axis-${position}`,\n class: ['tc-axis', horizontal ? 'tc-axis-x' : 'tc-axis-y', `tc-axis-${position}`],\n 'aria-hidden': 'true',\n },\n line &&\n h(\n 'line',\n horizontal\n ? { class: 'tc-axis-line', x1: area.x, x2: area.x + area.width, y1: edge, y2: edge }\n : { class: 'tc-axis-line', x1: edge, x2: edge, y1: area.y, y2: area.y + area.height },\n ),\n ticks.map((tick) =>\n h(\n 'g',\n {\n key: tick.value,\n class: 'tc-tick',\n // An inline style (not the transform attribute) so CSS can transition it.\n style: horizontal\n ? `transform:translate(${round(tick.position)}px,${round(edge)}px)`\n : `transform:translate(${round(edge)}px,${round(tick.position)}px)`,\n },\n tickSize > 0 && h('line', { class: 'tc-tick-line', ...tickLine }),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aAAa,EAAE,IAAI,OAAO,SAAS,IAAI,EAAE,IAAI,OAAO,SAAS;CAE9E,OAAOD,cAAAA,EACL,KACA;EAEE,KAAK,QAAQ;EACb,OAAO;GAAC;GAAW,aAAa,cAAc;GAAa,WAAW;EAAU;EAChF,eAAe;CACjB,GACA,QACEA,cAAAA,EACE,QACA,aACI;EAAE,OAAO;EAAgB,IAAI,KAAK;EAAG,IAAI,KAAK,IAAI,KAAK;EAAO,IAAI;EAAM,IAAI;CAAK,IACjF;EAAE,OAAO;EAAgB,IAAI;EAAM,IAAI;EAAM,IAAI,KAAK;EAAG,IAAI,KAAK,IAAI,KAAK;CAAO,CACxF,GACF,MAAM,KAAK,SACTA,cAAAA,EACE,KACA;EACE,KAAK,KAAK;EACV,OAAO;EAEP,OAAO,aACH,uBAAuBC,eAAAA,MAAM,KAAK,QAAQ,EAAE,KAAKA,eAAAA,MAAM,IAAI,EAAE,OAC7D,uBAAuBA,eAAAA,MAAM,IAAI,EAAE,KAAKA,eAAAA,MAAM,KAAK,QAAQ,EAAE;CACnE,GACA,WAAW,KAAKD,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAgB,GAAG;CAAS,CAAC,GAChEA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAiB,GAAG;CAAM,GAAG,KAAK,KAAK,CAC5D,CACF,CACF;AACF"}
|
|
@@ -149,9 +149,9 @@ function thinTicks(ticks, position, fontSize, gap = 8) {
|
|
|
149
149
|
}
|
|
150
150
|
/** Pixels an axis occupies perpendicular to the plot edge (for margins). */
|
|
151
151
|
function axisSize(position, ticks, fontSize, options = {}) {
|
|
152
|
-
const { tickSize = 0, tickPadding = 8 } = options;
|
|
152
|
+
const { tickSize = 0, tickPadding = 8, rotate } = options;
|
|
153
153
|
if (ticks.length === 0) return 0;
|
|
154
|
-
const labels = isHorizontal(position) ? fontSize * LINE_HEIGHT : ticks.reduce((max, t) => Math.max(max, estimateTextWidth(t.label, fontSize)), 0) + 3;
|
|
154
|
+
const labels = isHorizontal(position) && !rotate ? fontSize * LINE_HEIGHT : ticks.reduce((max, t) => Math.max(max, estimateTextWidth(t.label, fontSize)), 0) + 3;
|
|
155
155
|
return Math.ceil(labels + tickSize + tickPadding);
|
|
156
156
|
}
|
|
157
157
|
/** Space between the tick labels and the axis title. */
|
|
@@ -164,8 +164,8 @@ const axisTitleSize = (title, fontSize) => title ? Math.ceil(fontSize * LINE_HEI
|
|
|
164
164
|
* bottom, turned 90° beside the plot to read away from it (bottom to top on
|
|
165
165
|
* the left, top to bottom on the right).
|
|
166
166
|
*/
|
|
167
|
-
function axisTitle(position, ticks, area, title, fontSize) {
|
|
168
|
-
const reach = axisSize(position, ticks, fontSize) + TITLE_GAP;
|
|
167
|
+
function axisTitle(position, ticks, area, title, fontSize, rotate) {
|
|
168
|
+
const reach = axisSize(position, ticks, fontSize, { rotate }) + TITLE_GAP;
|
|
169
169
|
const sign = position === "left" ? -1 : 1;
|
|
170
170
|
const side = reach + fontSize * LINE_HEIGHT / 2;
|
|
171
171
|
return h("text", {
|
|
@@ -183,12 +183,17 @@ function axisTitle(position, ticks, area, title, fontSize) {
|
|
|
183
183
|
* transition when the scale changes.
|
|
184
184
|
*/
|
|
185
185
|
function axis(options) {
|
|
186
|
-
const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false } = options;
|
|
186
|
+
const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false, rotate } = options;
|
|
187
187
|
const horizontal = isHorizontal(position);
|
|
188
188
|
const sign = position === "top" || position === "left" ? -1 : 1;
|
|
189
189
|
const offset = sign * (tickSize + tickPadding);
|
|
190
190
|
const edge = position === "top" ? area.y : position === "bottom" ? area.y + area.height : position === "left" ? area.x : area.x + area.width;
|
|
191
|
-
const label =
|
|
191
|
+
const label = rotate ? {
|
|
192
|
+
transform: "rotate(-90)",
|
|
193
|
+
x: -offset,
|
|
194
|
+
dy: "0.32em",
|
|
195
|
+
"text-anchor": "end"
|
|
196
|
+
} : horizontal ? {
|
|
192
197
|
y: offset,
|
|
193
198
|
dy: position === "top" ? "0em" : "0.71em",
|
|
194
199
|
"text-anchor": "middle"
|
|
@@ -232,4 +237,4 @@ function axis(options) {
|
|
|
232
237
|
}
|
|
233
238
|
export { bandTicks as a, niceDomain as c, ticks as d, axisTitleSize as i, tickIncrement as l, axisSize as n, linearTicks as o, axisTitle as r, thinTicks as s, axis as t, tickStep as u };
|
|
234
239
|
|
|
235
|
-
//# sourceMappingURL=axis-
|
|
240
|
+
//# sourceMappingURL=axis-C5obgdJt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis-C5obgdJt.js","names":[],"sources":["../src/scales/ticks.ts","../src/components/axis.ts"],"sourcesContent":["const E10 = Math.sqrt(50)\nconst E5 = Math.sqrt(10)\nconst E2 = Math.sqrt(2)\n\n/**\n * Integer tick indices `[i1, i2]` and an increment `inc`. A negative `inc`\n * means \"divide by -inc\", which keeps decimal ticks exact (0.3, not\n * 0.30000000000000004).\n */\nfunction tickSpec(start: number, stop: number, count: number): [number, number, number] {\n const step = (stop - start) / Math.max(0, count)\n const power = Math.floor(Math.log10(step))\n const error = step / 10 ** power\n const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1\n let i1: number\n let i2: number\n let inc: number\n if (power < 0) {\n inc = 10 ** -power / factor\n i1 = Math.round(start * inc)\n i2 = Math.round(stop * inc)\n if (i1 / inc < start) ++i1\n if (i2 / inc > stop) --i2\n inc = -inc\n } else {\n inc = 10 ** power * factor\n i1 = Math.round(start / inc)\n i2 = Math.round(stop / inc)\n if (i1 * inc < start) ++i1\n if (i2 * inc > stop) --i2\n }\n if (i2 < i1 && count >= 0.5 && count < 2) return tickSpec(start, stop, count * 2)\n return [i1, i2, inc]\n}\n\n/**\n * Roughly `count` evenly spaced, \"nice\" values (multiples of 1, 2 or 5 × 10ⁿ)\n * between `start` and `stop`, inclusive. Order follows `start → stop`.\n */\nexport function ticks(start: number, stop: number, count = 5): number[] {\n if (!(count > 0) || !Number.isFinite(start) || !Number.isFinite(stop)) return []\n if (start === stop) return [start]\n const reverse = stop < start\n const [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count)\n if (!(i2 >= i1)) return []\n const n = i2 - i1 + 1\n const out = new Array<number>(n)\n for (let i = 0; i < n; i++) {\n const index = reverse ? i2 - i : i1 + i\n out[i] = inc < 0 ? index / -inc : index * inc\n }\n return out\n}\n\n/**\n * Signed tick increment: positive values are the step, negative values `-k`\n * mean a step of `1 / k`.\n */\nexport function tickIncrement(start: number, stop: number, count: number): number {\n return tickSpec(start, stop, count)[2]\n}\n\n/** Distance between ticks produced by {@link ticks} for the same arguments. */\nexport function tickStep(start: number, stop: number, count = 5): number {\n const reverse = stop < start\n const inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count)\n return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc)\n}\n\n/**\n * Extend `[start, stop]` to round tick values, e.g. `[0.2, 9.7] → [0, 10]`.\n * Iterates because rounding can change the ideal step; if the step does not\n * settle (e.g. very low `count` around zero keeps doubling the domain), the\n * domain is returned unchanged, matching d3.\n */\nexport function niceDomain(start: number, stop: number, count = 5): [number, number] {\n if (!Number.isFinite(start) || !Number.isFinite(stop) || start === stop || !(count > 0)) {\n return [start, stop]\n }\n const reverse = stop < start\n let lo = reverse ? stop : start\n let hi = reverse ? start : stop\n let prev: number | undefined\n for (let i = 0; i < 10; i++) {\n const step = tickIncrement(lo, hi, count)\n if (step === prev) return reverse ? [hi, lo] : [lo, hi]\n if (step > 0) {\n lo = Math.floor(lo / step) * step\n hi = Math.ceil(hi / step) * step\n } else if (step < 0) {\n lo = Math.ceil(lo * step) / step\n hi = Math.floor(hi * step) / step\n } else {\n break\n }\n prev = step\n }\n return [start, stop]\n}\n","import { formatTicks, type Locale, type NumberFormat } from '../format.ts'\nimport { estimateTextWidth, LINE_HEIGHT, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { tickStep } from '../scales/ticks.ts'\nimport { h, type VNode } from '../vnode.ts'\n\nexport type AxisPosition = 'top' | 'right' | 'bottom' | 'left'\n\n/** A single axis tick: its data value, pixel position along the axis and label. */\nexport interface Tick {\n value: number | BandKey\n position: number\n label: string\n}\n\nexport interface LinearTicksOptions {\n /** Approximate number of ticks. Defaults to `5`. */\n count?: number\n format?: NumberFormat\n locale?: Locale\n}\n\n/** Ticks for a linear scale, labelled with a shared precision. */\nexport function linearTicks(scale: LinearScale, options: LinearTicksOptions = {}): Tick[] {\n const { count = 5, format, locale } = options\n const [d0, d1] = scale.domain\n const fmt = formatTicks(tickStep(d0, d1, count), format, locale)\n return scale.ticks(count).map((value) => ({ value, position: scale(value), label: fmt(value) }))\n}\n\n/** Ticks at the center of every band. */\nexport function bandTicks(\n scale: BandScale,\n format: (key: BandKey, index: number) => string = String,\n): Tick[] {\n return scale.domain.map((key, i) => ({\n value: key,\n position: scale.at(i) + scale.bandwidth / 2,\n label: format(key, i),\n }))\n}\n\n/** Whether labels are laid out along x (horizontal axes). */\nconst isHorizontal = (position: AxisPosition): boolean =>\n position === 'top' || position === 'bottom'\n\n/**\n * Keep every n-th tick (smallest n) so labels do not overlap along the axis.\n * The first and the last tick are always kept: when the last one does not\n * land on the step, it replaces the last kept tick if they would collide.\n */\nexport function thinTicks(\n ticks: readonly Tick[],\n position: AxisPosition,\n fontSize: number,\n gap = 8,\n): Tick[] {\n if (ticks.length < 2) return ticks.slice()\n const size = (tick: Tick) =>\n isHorizontal(position) ? estimateTextWidth(tick.label, fontSize) : fontSize * LINE_HEIGHT\n const sizes = ticks.map(size)\n const fitsBetween = (i: number, j: number) =>\n Math.abs((ticks[j] as Tick).position - (ticks[i] as Tick).position) >=\n ((sizes[i] as number) + (sizes[j] as number)) / 2 + gap\n\n const last = ticks.length - 1\n // Start from the step the total label size demands, instead of trying every one.\n const span = Math.abs((ticks[last] as Tick).position - (ticks[0] as Tick).position)\n const total = sizes.reduce((sum, size) => sum + size + gap, 0)\n const first = span > 0 ? Math.max(1, Math.floor(total / span)) : last\n for (let step = first; step <= last; step++) {\n let fits = true\n for (let i = step; i <= last && fits; i += step) fits = fitsBetween(i - step, i)\n if (!fits) continue\n\n const kept: number[] = []\n for (let i = 0; i <= last; i += step) kept.push(i)\n const tail = kept[kept.length - 1] as number\n if (tail !== last) {\n if (fitsBetween(tail, last)) kept.push(last)\n else if (kept.length > 1 && fitsBetween(kept[kept.length - 2] as number, last))\n kept[kept.length - 1] = last\n }\n return kept.map((i) => ticks[i] as Tick)\n }\n return ticks.slice(0, 1)\n}\n\nexport interface AxisOptions {\n position: AxisPosition\n ticks: readonly Tick[]\n /** Plot area the axis is attached to. */\n area: Rect\n /** Length of tick marks. Defaults to `0` (labels only). */\n tickSize?: number\n /** Distance between tick marks and labels. Defaults to `8`. */\n tickPadding?: number\n /** Draw the axis line along the plot edge. Defaults to `false`. */\n line?: boolean\n /** Turn the labels of an axis below the plot 90°, reading bottom to top. */\n rotate?: boolean\n}\n\n/** Pixels an axis occupies perpendicular to the plot edge (for margins). */\nexport function axisSize(\n position: AxisPosition,\n ticks: readonly Tick[],\n fontSize: number,\n options: { tickSize?: number; tickPadding?: number; rotate?: boolean } = {},\n): number {\n const { tickSize = 0, tickPadding = 8, rotate } = options\n if (ticks.length === 0) return 0\n // Beside the plot (and turned below it), labels are as wide as their text: a little slack\n // covers fonts wider than the estimate, so they do not touch the chart's edge.\n const labels =\n isHorizontal(position) && !rotate\n ? fontSize * LINE_HEIGHT\n : ticks.reduce((max, t) => Math.max(max, estimateTextWidth(t.label, fontSize)), 0) + 3\n return Math.ceil(labels + tickSize + tickPadding)\n}\n\n/** Space between the tick labels and the axis title. */\nconst TITLE_GAP = 6\n\n/** Pixels an axis title adds to the axis (for margins): none without a title. */\nexport const axisTitleSize = (title: string | undefined, fontSize: number): number =>\n title ? Math.ceil(fontSize * LINE_HEIGHT) + TITLE_GAP : 0\n\n/**\n * Render the title of an axis as `<text class=\"tc-axis-title tc-axis-title-{position}\">`,\n * past the labels of `ticks` and centered on the plot: along the axis at the\n * bottom, turned 90° beside the plot to read away from it (bottom to top on\n * the left, top to bottom on the right).\n */\nexport function axisTitle(\n position: 'right' | 'bottom' | 'left',\n ticks: readonly Tick[],\n area: Rect,\n title: string,\n fontSize: number,\n rotate?: boolean,\n): VNode {\n const reach = axisSize(position, ticks, fontSize, { rotate }) + TITLE_GAP\n const sign = position === 'left' ? -1 : 1\n const side = reach + (fontSize * LINE_HEIGHT) / 2\n return h(\n 'text',\n {\n key: `axis-title-${position}`,\n class: `tc-axis-title tc-axis-title-${position}`,\n transform:\n position === 'bottom'\n ? `translate(${round(area.x + area.width / 2)},${round(area.y + area.height + reach)})`\n : `translate(${round(position === 'left' ? area.x - side : area.x + area.width + side)},${round(area.y + area.height / 2)}) rotate(${sign * 90})`,\n dy: position === 'bottom' ? '0.71em' : '0.32em',\n 'text-anchor': 'middle',\n 'aria-hidden': 'true',\n },\n title,\n )\n}\n\n/**\n * Render an axis as `<g class=\"tc-axis tc-axis-{x|y} tc-axis-{position}\">`\n * with one `<g class=\"tc-tick\">` per tick, keyed by value so ticks can\n * transition when the scale changes.\n */\nexport function axis(options: AxisOptions): VNode {\n const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false, rotate } = options\n const horizontal = isHorizontal(position)\n const sign = position === 'top' || position === 'left' ? -1 : 1\n const offset = sign * (tickSize + tickPadding)\n\n // Edge of the plot the axis sits on.\n const edge =\n position === 'top'\n ? area.y\n : position === 'bottom'\n ? area.y + area.height\n : position === 'left'\n ? area.x\n : area.x + area.width\n\n const label = rotate\n ? { transform: 'rotate(-90)', x: -offset, dy: '0.32em', 'text-anchor': 'end' }\n : horizontal\n ? { y: offset, dy: position === 'top' ? '0em' : '0.71em', 'text-anchor': 'middle' }\n : { x: offset, dy: '0.32em', 'text-anchor': position === 'left' ? 'end' : 'start' }\n\n const tickLine = horizontal ? { y2: sign * tickSize } : { x2: sign * tickSize }\n\n return h(\n 'g',\n {\n // Keyed, so an axis keeps its nodes when layers around it come and go.\n key: `axis-${position}`,\n class: ['tc-axis', horizontal ? 'tc-axis-x' : 'tc-axis-y', `tc-axis-${position}`],\n 'aria-hidden': 'true',\n },\n line &&\n h(\n 'line',\n horizontal\n ? { class: 'tc-axis-line', x1: area.x, x2: area.x + area.width, y1: edge, y2: edge }\n : { class: 'tc-axis-line', x1: edge, x2: edge, y1: area.y, y2: area.y + area.height },\n ),\n ticks.map((tick) =>\n h(\n 'g',\n {\n key: tick.value,\n class: 'tc-tick',\n // An inline style (not the transform attribute) so CSS can transition it.\n style: horizontal\n ? `transform:translate(${round(tick.position)}px,${round(edge)}px)`\n : `transform:translate(${round(edge)}px,${round(tick.position)}px)`,\n },\n tickSize > 0 && h('line', { class: 'tc-tick-line', ...tickLine }),\n h('text', { class: 'tc-tick-label', ...label }, tick.label),\n ),\n ),\n )\n}\n"],"mappings":";;;;AAAA,MAAM,MAAM,KAAK,KAAK,EAAE;AACxB,MAAM,KAAK,KAAK,KAAK,EAAE;AACvB,MAAM,KAAK,KAAK,KAAK,CAAC;;;;;;AAOtB,SAAS,SAAS,OAAe,MAAc,OAAyC;CACtF,MAAM,QAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,KAAK;CAC/C,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,IAAI,CAAC;CACzC,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,SAAS,SAAS,MAAM,KAAK,SAAS,KAAK,IAAI,SAAS,KAAK,IAAI;CACvE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,QAAQ,GAAG;EACb,MAAM,MAAM,CAAC,QAAQ;EACrB,KAAK,KAAK,MAAM,QAAQ,GAAG;EAC3B,KAAK,KAAK,MAAM,OAAO,GAAG;EAC1B,IAAI,KAAK,MAAM,OAAO,EAAE;EACxB,IAAI,KAAK,MAAM,MAAM,EAAE;EACvB,MAAM,CAAC;CACT,OAAO;EAC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EDP5CEQ.cjs");
|
|
2
2
|
const require_bar = require("./bar-wVykm1us.cjs");
|
|
3
3
|
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
4
|
-
const require_cartesian = require("./cartesian-
|
|
4
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
5
5
|
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
6
|
-
const require_axis = require("./axis-
|
|
6
|
+
const require_axis = require("./axis-BzBkkC5X.cjs");
|
|
7
7
|
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
8
|
-
const require_stack = require("./stack-
|
|
8
|
+
const require_stack = require("./stack-DBhmYNat.cjs");
|
|
9
9
|
// src/charts/horizontal.ts
|
|
10
10
|
/**
|
|
11
11
|
* Cartesian layout with categories along y (labels on the left) and values
|
|
@@ -69,6 +69,7 @@ function horizontalLayout(options, ctx, layout) {
|
|
|
69
69
|
const bar = {
|
|
70
70
|
name: "bar",
|
|
71
71
|
clean: require_clean.cleanData(require_clean.cleanSeries),
|
|
72
|
+
prepare: require_cartesian.windowed,
|
|
72
73
|
render(options, ctx) {
|
|
73
74
|
const { radius = 4, maxBarWidth = 24, gap = 2, groupPadding = .3, stacked = false, orientation = "vertical", curve = "monotone" } = options;
|
|
74
75
|
const horizontal = orientation === "horizontal";
|
|
@@ -258,4 +259,4 @@ Object.defineProperty(exports, "bar", {
|
|
|
258
259
|
}
|
|
259
260
|
});
|
|
260
261
|
|
|
261
|
-
//# sourceMappingURL=bar-
|
|
262
|
+
//# sourceMappingURL=bar-BrmfXugT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-BrmfXugT.cjs","names":["resolveLabels","labelFormatter","valueAxis","labelKey","estimateTextWidth","plotFrame","axisSize","axisTitleSize","band","thinTicks","bandTicks","finishLayout","cleanData","cleanSeries","windowed","resolveLabels","seriesKey","seriesAxes","stackSeries","stackBounds","cartesianLayout","seriesScale","plottable","categoryInteraction","h","seriesAttrs","hbarPath","barPath","labelKey","feature","seriesLegend","seriesTable"],"sources":["../src/charts/horizontal.ts","../src/charts/bar.ts"],"sourcesContent":["import type { RenderContext } from '../chart.ts'\nimport { axisSize, axisTitleSize, bandTicks, type Tick, thinTicks } from '../components/axis.ts'\nimport { estimateTextWidth, plotFrame } from '../layout.ts'\nimport { type BandKey, band } from '../scales/band.ts'\nimport {\n type CartesianLayout,\n type CartesianLayoutOptions,\n type CartesianOptions,\n EDGE,\n finishLayout,\n type Label,\n labelFormatter,\n labelKey,\n resolveLabels,\n TICK_SPACING_X,\n valueAxis,\n} from './cartesian.ts'\n\n/**\n * Cartesian layout with categories along y (labels on the left) and values\n * along x (labels at the bottom), for horizontal bars. Only bar charts use\n * it, so it lives outside `cartesianLayout()` and stays out of other bundles.\n */\nexport function horizontalLayout(\n options: CartesianOptions,\n ctx: RenderContext,\n layout: CartesianLayoutOptions,\n): CartesianLayout {\n const yOptions = options.y ?? {}\n const xOptions = options.x ?? {}\n const { fontSize, width } = ctx\n const overhang = layout.overhang ?? 0\n const labels = resolveLabels(options.data)\n const format = labelFormatter(options, ctx)\n const value = valueAxis(options, ctx, layout, Math.round(width / TICK_SPACING_X))\n const probeValues = value.probe\n const showValues = yOptions.show !== false\n const showCategories = xOptions.show !== false && labels.length > 0\n\n const probeCategories: Tick[] = labels.map((label, i) => ({\n value: labelKey(label),\n position: 0,\n label: format(label, i),\n }))\n const edgeLabel = (tick: Tick | undefined) =>\n showValues && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0\n\n const { area, side, range } = plotFrame(ctx, options.padding, (pad) => ({\n top: pad.top + Math.max(overhang, EDGE / 2),\n bottom:\n pad.bottom +\n Math.max(\n (showValues ? axisSize('bottom', probeValues, fontSize) : 0) +\n axisTitleSize(yOptions.title, fontSize),\n overhang,\n EDGE / 2,\n ),\n start:\n pad.start +\n Math.max(\n (showCategories ? axisSize('left', probeCategories, fontSize) : 0) +\n axisTitleSize(xOptions.title, fontSize),\n edgeLabel(probeValues[0]),\n overhang,\n EDGE,\n ),\n end: pad.end + Math.max(edgeLabel(probeValues[probeValues.length - 1]), overhang, EDGE),\n }))\n\n const keys = labels.map(labelKey)\n const x = band(keys, [area.y, area.y + area.height], {\n paddingInner: layout.paddingInner ?? 0.3,\n paddingOuter: layout.paddingOuter ?? 0.15,\n })\n // Values grow away from the categories, from the start side.\n const y = value.scale(range())\n const yTicks = thinTicks(value.ticks(y), 'bottom', fontSize)\n const xTicks = showCategories\n ? thinTicks(\n bandTicks(x, (_: BandKey, i) => format(labels[i] as Label, i)),\n 'left',\n fontSize,\n )\n : []\n\n // The value axis runs along x here, categories along y.\n return finishLayout(\n options,\n ctx,\n side,\n overhang,\n { area, labels, x, y, horizontal: true, xTicks, yTicks },\n keys,\n )\n}\n","import type { ChartType } from '../chart.ts'\nimport { feature } from '../features.ts'\nimport { barPath, hbarPath } from '../shapes/bar.ts'\nimport type { Curve, Point } from '../shapes/path.ts'\nimport { h } from '../vnode.ts'\nimport {\n type CartesianLayoutOptions,\n type CartesianOptions,\n cartesianLayout,\n categoryInteraction,\n labelKey,\n plottable,\n resolveLabels,\n seriesAttrs,\n seriesAxes,\n seriesKey,\n seriesLegend,\n seriesScale,\n seriesTable,\n windowed,\n} from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\nimport { horizontalLayout } from './horizontal.ts'\nimport { type Segment, type StackMode, stackBounds, stackSeries } from './stack.ts'\n\nexport interface BarOptions extends CartesianOptions {\n /** Corner radius of the data end of each bar (or stack). Defaults to `4`. */\n radius?: number\n /** Maximum bar thickness in pixels; leftover band space stays empty. Defaults to `24`. */\n maxBarWidth?: number\n /** Gap between bars of a group, or between stacked segments, in pixels. Defaults to `2`. */\n gap?: number\n /** Share of each category left empty between groups, `0…1`. Defaults to `0.3`. */\n groupPadding?: number\n /**\n * Stack series in one bar per category instead of side by side; `'percent'`\n * shows each category as 100%. Negative values stack down from zero.\n */\n stacked?: StackMode\n /**\n * `'horizontal'` lays categories out along y with bars growing right\n * (left for negative values). The `x` / `y` options keep describing the\n * category / value axis. Defaults to `'vertical'`.\n */\n orientation?: 'vertical' | 'horizontal'\n /** Interpolation of series drawn as lines (`series.type`). Defaults to `'monotone'`. */\n curve?: Curve\n}\n\n/**\n * Bar chart: vertical bars per category, grouped side by side or stacked,\n * growing from zero (negative values grow down).\n *\n * ```ts\n * new Chart('#el', {\n * type: bar,\n * data: { labels: ['Q1', 'Q2'], series: [{ name: '2025', values: [3, 5] }] },\n * stacked: true,\n * })\n * ```\n */\nexport const bar: ChartType<BarOptions> = {\n name: 'bar',\n clean: cleanData(cleanSeries),\n prepare: windowed,\n render(options, ctx) {\n const {\n radius = 4,\n maxBarWidth = 24,\n gap = 2,\n groupPadding = 0.3,\n stacked = false,\n orientation = 'vertical',\n curve = 'monotone',\n } = options\n const horizontal = orientation === 'horizontal'\n const { series } = options.data\n const count = resolveLabels(options.data).length\n // Series drawn as lines sit on top of the bars and stay out of the stacks.\n const isLine = (index: number) => (series[index]?.type ?? 'bar') !== 'bar'\n const lineKeys = series.filter((_, index) => isLine(index)).map(seriesKey)\n const axisOf = seriesAxes(options)\n const onY2 = (index: number) => axisOf(series[index]).second\n // Bars on the second axis stand beside the stack, in a column of their own.\n const apart = series.filter((_, index) => isLine(index) || onY2(index)).map(seriesKey)\n const stackHidden = apart.length ? new Set([...ctx.hidden, ...apart]) : ctx.hidden\n const stacks = stacked\n ? stackSeries(series, count, { percent: stacked === 'percent', hidden: stackHidden })\n : null\n const inStack = (index: number) => !!stacks && !isLine(index) && !onY2(index)\n\n const layoutOptions: CartesianLayoutOptions = {\n scale: 'band',\n zero: true,\n paddingInner: groupPadding,\n paddingOuter: groupPadding / 2,\n // Bars and areas on the second axis grow from zero too, lines need not.\n zero2: series.some((s, index) => onY2(index) && s.type !== 'line'),\n ...(stacks\n ? {\n values: [\n ...stackBounds(stacks),\n ...series.flatMap((s, index) => (isLine(index) && !onY2(index) ? s.values : [])),\n ],\n }\n : {}),\n ...(stacked === 'percent' ? { tickFormat: { style: 'percent' } } : {}),\n }\n const layout = horizontal\n ? horizontalLayout(options, ctx, layoutOptions)\n : cartesianLayout(options, ctx, layoutOptions)\n const { x, labels } = layout\n const scaleOf = (index: number) => seriesScale(layout, series[index])\n\n // The column of each bar series in its group: a stack takes one column\n // for all its series. Hidden series keep their color slot but give up their place.\n const slots = new Map<number, number>()\n let used = 0\n let stackColumn = -1\n series.forEach((s, index) => {\n if (ctx.hidden.has(seriesKey(s)) || isLine(index)) return\n if (!inStack(index)) slots.set(index, used++)\n else {\n if (stackColumn < 0) stackColumn = used++\n slots.set(index, stackColumn)\n }\n })\n const order = [...slots.keys()]\n const columns = Math.max(1, used)\n\n const barWidth = Math.max(\n 0,\n Math.min(maxBarWidth, (x.bandwidth - gap * (columns - 1)) / columns),\n )\n const groupWidth = barWidth * columns + gap * (columns - 1)\n const offset = (x.bandwidth - groupWidth) / 2\n // Grouped bars follow the categories: from the right when those are reversed.\n const slotAt = (slot: number) => (x.range[1] < x.range[0] ? columns - 1 - slot : slot)\n const barLeft = (seriesIndex: number, i: number) =>\n x.at(i) + offset + slotAt(slots.get(seriesIndex) ?? 0) * (barWidth + gap)\n\n /** Data extent of a bar: from zero to the value, or its stacked segment. */\n const segment = (seriesIndex: number, i: number): Segment | null => {\n if (inStack(seriesIndex)) return stacks?.[seriesIndex]?.[i] ?? null\n const s = series[seriesIndex]\n const v = s?.values[i]\n return plottable(v, axisOf(s).axis) ? { y0: 0, y1: v } : null\n }\n\n // In a stack only the outermost segment of each sign gets rounded.\n const outer = labels.map((_, i) => {\n let up = -1\n let down = -1\n for (const index of order) {\n if (!inStack(index)) continue\n const seg = segment(index, i)\n if (!seg) continue\n if (seg.y1 > seg.y0) up = index\n else if (seg.y1 < seg.y0) down = index\n }\n return { up, down }\n })\n\n const interaction = categoryInteraction(\n layout,\n options,\n ctx,\n (seriesIndex, i, v) => {\n const y = scaleOf(seriesIndex)\n if (isLine(seriesIndex)) {\n const across = x.at(i) + x.bandwidth / 2\n return horizontal ? { x: y(v), y: across } : { x: across, y: y(v) }\n }\n const left = barLeft(seriesIndex, i)\n const seg = segment(seriesIndex, i)\n const end = y(seg?.y1 ?? 0)\n const base = y(seg?.y0 ?? 0)\n // The bar's box, for value labels inside it.\n const lo = Math.min(end, base)\n const length = Math.abs(end - base)\n return horizontal\n ? {\n x: end,\n y: left + barWidth / 2,\n box: { x: lo, y: left, width: length, height: barWidth },\n }\n : {\n x: left + barWidth / 2,\n y: end,\n box: { x: left, y: lo, width: barWidth, height: length },\n }\n },\n (px, py, i) => {\n // Pointer position across the categories and along the values.\n const across = horizontal ? py : px\n const along = horizontal ? px : py\n // The column under the pointer, gaps included, so thin bars are easy to hit.\n const column = slotAt(\n Math.floor((across - (x.at(i) + offset) + gap / 2) / (barWidth + gap)),\n )\n if (column === stackColumn) {\n // The segment under the pointer, within the stack (gaps included).\n return order.find((index) => {\n if (!inStack(index)) return false\n const seg = segment(index, i)\n if (!seg) return false\n const y = scaleOf(index)\n const a = y(seg.y0)\n const b = y(seg.y1)\n return along >= Math.min(a, b) - gap / 2 && along <= Math.max(a, b) + gap / 2\n })\n }\n const seriesIndex = order.find((index) => slots.get(index) === column)\n return seriesIndex !== undefined && segment(seriesIndex, i) ? seriesIndex : undefined\n },\n )\n\n const groups = series.map(\n (s, index) =>\n slots.has(index) &&\n h(\n 'g',\n seriesAttrs(s, index),\n labels.map((label, i) => {\n const seg = segment(index, i)\n if (!seg) return null\n const y = scaleOf(index)\n const negative = seg.y1 < seg.y0\n // Leave a surface-colored gap where this segment sits on another one,\n // on the side it grows to (in pixels: up, right, or left when mirrored).\n const away = Math.sign(y(seg.y1) - y(seg.y0))\n const inner = seg.y0 === 0 ? 0 : away * gap\n const rounded = !inStack(index) || (negative ? outer[i]?.down : outer[i]?.up) === index\n const draw = horizontal ? hbarPath : barPath\n return h('path', {\n key: labelKey(label),\n class: ['tc-bar', negative && 'tc-bar-negative', horizontal && 'tc-bar-horizontal'],\n d: draw(\n barLeft(index, i),\n barWidth,\n y(seg.y0) + inner,\n y(seg.y1),\n rounded ? radius : 0,\n ),\n })\n }),\n ),\n )\n\n // Lines through the band centers, drawn after (over) every bar. The path\n // generators come with the line module, so plain bar charts do not ship them.\n const paths = lineKeys.length ? feature('line') : null\n const lines = series.map((s, index) => {\n if (!paths) return null\n if (!isLine(index) || ctx.hidden.has(seriesKey(s))) return null\n const y = scaleOf(index)\n const axis = axisOf(s).axis\n const baseline = y(Math.min(Math.max(0, y.domain[0]), y.domain[1]))\n const points = labels.map((_, i): Point => {\n const v = s.values[i]\n if (!plottable(v, axis)) return null\n const center = x.at(i) + x.bandwidth / 2\n return horizontal ? [y(v), center] : [center, y(v)]\n })\n // Areas need a vertical baseline; sideways they fall back to a line.\n const filled = s.type === 'area' && !horizontal\n return h(\n 'g',\n seriesAttrs(s, index),\n filled && h('path', { class: 'tc-area', d: paths.areaPath(points, baseline, { curve }) }),\n h('path', { class: 'tc-line', d: paths.linePath(points, { curve }) }),\n )\n })\n\n const content = [\n h('defs', { key: 'defs' }, layout.clip.def),\n layout.background,\n // Layers are keyed: an annotation band or a grid that comes and goes must not\n // shift the series list onto another node (that would recreate every series).\n h(\n 'g',\n { key: 'series', class: 'tc-series-list', 'clip-path': layout.clip.url },\n groups,\n lines,\n ),\n layout.foreground,\n ]\n return { content, interaction }\n },\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) => seriesTable(options, ctx, limit),\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAgB,iBACd,SACA,KACA,QACiB;CACjB,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,WAAW,QAAQ,KAAK,CAAC;CAC/B,MAAM,EAAE,UAAU,UAAU;CAC5B,MAAM,WAAW,OAAO,YAAY;CACpC,MAAM,SAASA,kBAAAA,cAAc,QAAQ,IAAI;CACzC,MAAM,SAASC,kBAAAA,eAAe,SAAS,GAAG;CAC1C,MAAM,QAAQC,kBAAAA,UAAU,SAAS,KAAK,QAAQ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,EAAE,CAAC,CAAC;GACpD,CAAC;GAED,MAAM,SAAS,EAAE,SAAS,UAAU,CAAC;GACrC,OAAOE,cAAAA,EACL,KACAC,kBAAAA,YAAY,GAAG,KAAK,GACpB,UAAUD,cAAAA,EAAE,QAAQ;IAAE,OAAO;IAAW,GAAG,MAAM,SAAS,QAAQ,UAAU,EAAE,MAAM,CAAC;GAAE,CAAC,GACxFA,cAAAA,EAAE,QAAQ;IAAE,OAAO;IAAW,GAAG,MAAM,SAAS,QAAQ,EAAE,MAAM,CAAC;GAAE,CAAC,CACtE;EACF,CAAC;EAeD,OAAO;GAAE,SAAA;IAZPA,cAAAA,EAAE,QAAQ,EAAE,KAAK,OAAO,GAAG,OAAO,KAAK,GAAG;IAC1C,OAAO;IAGPA,cAAAA,EACE,KACA;KAAE,KAAK;KAAU,OAAO;KAAkB,aAAa,OAAO,KAAK;IAAI,GACvE,QACA,KACF;IACA,OAAO;GAEM;GAAG;EAAY;CAChC;CACA,SAAS,YAAYM,kBAAAA,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UAAUC,kBAAAA,YAAY,SAAS,KAAK,KAAK;AACjE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as CartesianOptions, o as ChartType } from "./chart-CE9EVbfV.js";
|
|
2
2
|
import { t as Curve } from "./path-YeUiOfG8.js";
|
|
3
3
|
import { t as StackMode } from "./stack-DR0eQTsB.js";
|
|
4
4
|
interface BarOptions extends CartesianOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ht as CartesianOptions, o as ChartType } from "./chart-Dz4geQZy.cjs";
|
|
2
2
|
import { t as Curve } from "./path-YeUiOfG8.cjs";
|
|
3
|
-
import { t as StackMode } from "./stack-
|
|
3
|
+
import { t as StackMode } from "./stack-CcmyALx0.cjs";
|
|
4
4
|
interface BarOptions extends CartesianOptions {
|
|
5
5
|
/** Corner radius of the data end of each bar (or stack). Defaults to `4`. */
|
|
6
6
|
radius?: number;
|