@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
package/dist/core.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as estimateTextWidth, i as Rect, n as InsetsInput, o as innerRect, r as LINE_HEIGHT, s as insets, t as Insets } from "./layout-CYerDebD.js";
|
|
2
2
|
import { a as point, i as band, n as BandScale, r as BandScaleOptions, t as BandKey } from "./band-CNKvdnTC.js";
|
|
3
3
|
import { a as ClassValue, c as StyleValue, d as normalizeClass, f as normalizeStyle, i as ChildInput, l as VNode, n as Attrs, o as Key, r as Child, s as Props, t as AttrValue, u as h } from "./vnode-Du2cC8Fm.js";
|
|
4
|
-
import {
|
|
4
|
+
import { t as Annotation } from "./annotations-CCDUC1lW.js";
|
|
5
|
+
import { A as DownloadOption, At as axis, B as BeforeRenderState, Bt as HitCursor, C as TooltipOptions, D as tooltipContent, Dt as AxisPosition, E as placeTooltip, Et as AxisOptions, F as Features, Ft as DataTable, H as PluginInstance, Ht as HitTester, I as feature, It as describeHit, L as features, Lt as tableContent, Mt as bandTicks, Nt as linearTicks, O as DownloadFormat, Ot as LinearTicksOptions, Pt as thinTicks, R as register, Rt as Highlight, S as resolveSize, St as ZoomOptions, T as hitAnchor, Ut as Interaction, V as ChartPlugin, Vt as HitItem, _ as chartModel, _t as domainOf, a as ChartEvents, at as LegendOptions, b as renderContext, bt as seriesTable, c as CrosshairOptions, d as ResolvedLegend, dt as CartesianOptions, f as Size, ft as CategoryAxisOptions, g as chartLabel, gt as categoryInteraction, h as chartEvents, ht as ValueAxisOptions, i as ChartConfig, it as LegendItem, j as download, jt as axisSize, k as DownloadMenuOptions, kt as Tick, l as RenderContext, m as buildChart, mt as Series, n as BuiltChart, o as ChartType, ot as defaultHidden, p as TableContext, pt as Label, r as Chart, s as ContextOptions, st as legendContent, t as BaseOptions, u as RenderResult, ut as CartesianData, v as chartToString, vt as seriesKey, w as TooltipPlacement, x as resolveLegend, xt as ViewWindow, y as renderChart, yt as seriesLegend, z as AfterRenderState, zt as Hit } from "./chart-CE9EVbfV.js";
|
|
5
6
|
import { c as NumberFormat, d as formatDetail, f as formatNumber, g as stepPrecision, h as getNumberFormat, l as NumberFormatOptions, m as getDateFormat, o as DateFormat, p as formatTicks, s as Locale, u as formatDate } from "./time-DRIDgv2a.js";
|
|
6
7
|
import { a as linear, i as LinearScaleOptions, r as LinearScale } from "./log-CI41TmcU.js";
|
|
7
|
-
import { A as arcCentroid, C as keyboard, D as GridOptions, E as hoverUnderlay, M as padAngleForGap, O as grid, S as legend, T as hoverOverlay, _ as defaultPlugins, a as flush, b as sync, c as tickIncrement, d as extent, f as RenderToStringOptions, g as render, h as renderToString, i as cancel, j as arcPathStable, k as ArcOptions, l as tickStep, m as escapeText, n as barPath, o as schedule, p as escapeAttr, r as hbarPath, s as niceDomain, t as VERSION, u as ticks, v as tooltip, w as highlight, x as pointer, y as dataTable } from "./core-C3qEppSm.js";
|
|
8
8
|
import { a as linePath, i as areaPath, n as PathOptions, r as Point, t as Curve } from "./path-YeUiOfG8.js";
|
|
9
|
-
import { n as
|
|
10
|
-
import { n as
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
13
|
-
import { n as
|
|
14
|
-
import { n as
|
|
15
|
-
import { n as
|
|
16
|
-
import { n as
|
|
17
|
-
import {
|
|
18
|
-
import { n as
|
|
19
|
-
import { n as
|
|
20
|
-
import {
|
|
21
|
-
import { n as
|
|
22
|
-
import {
|
|
23
|
-
import { i as
|
|
24
|
-
import { n as
|
|
25
|
-
import { n as
|
|
26
|
-
|
|
9
|
+
import { A as grid, C as legend, D as hoverUnderlay, E as hoverOverlay, M as arcCentroid, N as arcPathStable, O as hoverValue, P as padAngleForGap, S as pointer, T as highlight, _ as defaultPlugins, a as flush, b as dataTable, c as tickIncrement, d as extent, f as RenderToStringOptions, g as render, h as renderToString, i as cancel, j as ArcOptions, k as GridOptions, l as tickStep, m as escapeText, n as barPath, o as schedule, p as escapeAttr, r as hbarPath, s as niceDomain, t as VERSION, u as ticks, v as zoom, w as keyboard, x as sync, y as tooltip } from "./core-BUQzLsRJ.js";
|
|
10
|
+
import { n as line, t as LineOptions } from "./line-TkzA7wMK.js";
|
|
11
|
+
import { n as area, t as AreaOptions } from "./area-DEFL-Yun.js";
|
|
12
|
+
import { n as bar, t as BarOptions } from "./bar-Bs_rPqgR.js";
|
|
13
|
+
import { a as calendar, i as CalendarSeries, n as CalendarEntry, r as CalendarOptions, t as CalendarData } from "./calendar-D10_ki1S.js";
|
|
14
|
+
import { n as CandlestickOptions, r as candlestick, t as Candle } from "./candlestick-XpqJvarq.js";
|
|
15
|
+
import { n as FunnelStage, r as funnel, t as FunnelOptions } from "./funnel-FogM8flk.js";
|
|
16
|
+
import { n as GaugeRing, r as gauge, t as GaugeOptions } from "./gauge-D78oq1Lx.js";
|
|
17
|
+
import { n as HeatmapRange, r as heatmap, t as HeatmapOptions } from "./heatmap-mFCnP6aB.js";
|
|
18
|
+
import { a as MapOptions, c as map, i as MapMarker, l as MapLayout, n as MapHit, o as MapRegion, r as MapLine, s as addMap, t as MapData, u as MapView } from "./map-DNqog2Xs.js";
|
|
19
|
+
import { n as ParliamentParty, r as parliament, t as ParliamentOptions } from "./parliament-CHdf13XU.js";
|
|
20
|
+
import { n as PercentageBarSegment, r as percentageBar, t as PercentageBarOptions } from "./percentage-bar-CSAbzDOn.js";
|
|
21
|
+
import { i as pie, n as PieSlice, r as donut, t as PieOptions } from "./pie-Cn2H3pz8.js";
|
|
22
|
+
import { n as RadialAxisOptions, r as radar, t as RadarOptions } from "./radar-DEer2jjd.js";
|
|
23
|
+
import { a as RangeRowAxisOptions, i as RangeBarOptions, n as RangeBarAnnotation, o as RangeValue, r as RangeBarItem, s as rangeBar, t as RangeAxisOptions } from "./range-bar-C4cRaaQE.js";
|
|
24
|
+
import { a as sankey, i as SankeyOptions, n as SankeyLink, r as SankeyNode, t as SankeyData } from "./sankey-DpYJsOI4.js";
|
|
25
|
+
import { a as scatter, i as ScatterSeries, n as ScatterOptions, r as ScatterPoint, t as ScatterData } from "./scatter-BAL5K9_4.js";
|
|
26
|
+
import { n as sparkline, t as SparklineOptions } from "./sparkline-CtoBJe-a.js";
|
|
27
|
+
import { n as TreemapOptions, r as treemap, t as TreemapNode } from "./treemap-D_zbubo3.js";
|
|
28
|
+
export { type AfterRenderState, type Annotation, type ArcOptions, type AreaOptions, type AttrValue, type Attrs, type AxisOptions, type AxisPosition, type BandKey, type BandScale, type BandScaleOptions, type BarOptions, type BaseOptions, type BeforeRenderState, type BuiltChart, type CalendarData, type CalendarEntry, type CalendarOptions, type CalendarSeries, type Candle, type CandlestickOptions, type CartesianData, type CartesianOptions, type CategoryAxisOptions, Chart, type ChartConfig, type ChartEvents, type ChartPlugin, type ChartType, type Child, type ChildInput, type ClassValue, type ContextOptions, type CrosshairOptions, type Curve, type DataTable, type DateFormat, type DownloadFormat, type DownloadMenuOptions, type DownloadOption, type Features, type FunnelOptions, type FunnelStage, type GaugeOptions, type GaugeRing, type GridOptions, type HeatmapOptions, type HeatmapRange, type Highlight, type Hit, type HitCursor, type HitItem, type HitTester, type Insets, type InsetsInput, type Interaction, type Key, LINE_HEIGHT, type Label, type LegendItem, type LegendOptions, type LineOptions, type LinearScale, type LinearScaleOptions, type LinearTicksOptions, type Locale, type MapData, type MapHit, type MapLayout, type MapLine, type MapMarker, type MapOptions, type MapRegion, type MapView, type NumberFormat, type NumberFormatOptions, type ParliamentOptions, type ParliamentParty, type PathOptions, type PercentageBarOptions, type PercentageBarSegment, type PieOptions, type PieSlice, type PluginInstance, type Point, type Props, type RadarOptions, type RadialAxisOptions, type RangeAxisOptions, type RangeBarAnnotation, type RangeBarItem, type RangeBarOptions, type RangeRowAxisOptions, type RangeValue, type Rect, type RenderContext, type RenderResult, type RenderToStringOptions, type ResolvedLegend, type SankeyData, type SankeyLink, type SankeyNode, type SankeyOptions, type ScatterData, type ScatterOptions, type ScatterPoint, type ScatterSeries, type Series, type Size, type SparklineOptions, type StyleValue, type TableContext, type Tick, type TooltipOptions, type TooltipPlacement, type TreemapNode, type TreemapOptions, VERSION, type VNode, type ValueAxisOptions, type ViewWindow, type ZoomOptions, addMap, arcCentroid, arcPathStable, area, areaPath, axis, axisSize, band, bandTicks, bar, barPath, buildChart, calendar, cancel, candlestick, categoryInteraction, chartEvents, chartLabel, chartModel, chartToString, dataTable, defaultHidden, defaultPlugins, describeHit, domainOf, donut, download, escapeAttr, escapeText, estimateTextWidth, extent, feature, features, flush, formatDate, formatDetail, formatNumber, formatTicks, funnel, gauge, getDateFormat, getNumberFormat, grid, h, hbarPath, heatmap, highlight, hitAnchor, hoverOverlay, hoverUnderlay, hoverValue, innerRect, insets, keyboard, legend, legendContent, line, linePath, linear, linearTicks, map, niceDomain, normalizeClass, normalizeStyle, padAngleForGap, parliament, percentageBar, pie, placeTooltip, point, pointer, radar, rangeBar, register, render, renderChart, renderContext, renderToString, resolveLegend, resolveSize, sankey, scatter, schedule, seriesKey, seriesLegend, seriesTable, sparkline, stepPrecision, sync, tableContent, thinTicks, tickIncrement, tickStep, ticks, tooltip, tooltipContent, treemap, zoom };
|
package/dist/core.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { i as insets, n as estimateTextWidth, r as innerRect, t as LINE_HEIGHT } from "./layout-DqAte3H8.js";
|
|
2
2
|
import { n as normalizeClass, r as normalizeStyle, t as h } from "./vnode-_EMUqysL.js";
|
|
3
3
|
import { a as getDateFormat, i as formatTicks, n as formatDetail, o as getNumberFormat, r as formatNumber, s as stepPrecision, t as formatDate } from "./format-it1kepFG.js";
|
|
4
|
-
import { a as bandTicks, c as niceDomain, d as ticks, l as tickIncrement, n as axisSize, o as linearTicks, s as thinTicks, t as axis, u as tickStep } from "./axis-
|
|
5
|
-
import {
|
|
4
|
+
import { a as bandTicks, c as niceDomain, d as ticks, l as tickIncrement, n as axisSize, o as linearTicks, s as thinTicks, t as axis, u as tickStep } from "./axis-C5obgdJt.js";
|
|
5
|
+
import { D as grid, E as point, T as band, _ as seriesTable, h as seriesLegend, m as seriesKey, n as categoryInteraction, r as domainOf, w as linear } from "./cartesian-COglz544.js";
|
|
6
6
|
import { i as register, n as feature, r as features } from "./features-B55rwpQC.js";
|
|
7
7
|
import { t as extent } from "./extent-DOV8rs-6.js";
|
|
8
|
-
import { _ as
|
|
8
|
+
import { _ as escapeAttr, a as chartModel, b as defaultHidden, c as renderChart, d as resolveSize, f as cancel, g as schedule, i as chartLabel, l as renderContext, n as buildChart, o as chartToString, p as flush, r as chartEvents, t as Chart, u as resolveLegend, v as escapeText, x as legendContent, y as renderToString } from "./chart-B97FBRCd.js";
|
|
9
9
|
import { a as render } from "./dom-CTse6Rvd.js";
|
|
10
10
|
import { n as areaPath, r as linePath } from "./fade-CDrQjnDz.js";
|
|
11
|
-
import { _ as
|
|
12
|
-
import { t as line } from "./line-
|
|
13
|
-
import { t as area } from "./area-
|
|
11
|
+
import { _ as hoverUnderlay, a as hitAnchor, c as dataTable, d as keyboard, f as describeHit, g as hoverOverlay, h as pointer, i as tooltip, l as sync, m as highlight, n as defaultPlugins, o as placeTooltip, p as tableContent, r as zoom, s as tooltipContent, t as VERSION, u as legend, v as hoverValue, y as download } from "./core-7fgM3su0.js";
|
|
12
|
+
import { t as line } from "./line-CXH0L10d.js";
|
|
13
|
+
import { t as area } from "./area-BN0uE9R0.js";
|
|
14
14
|
import { n as hbarPath, t as barPath } from "./bar-CgpC2EpX.js";
|
|
15
|
-
import { t as bar } from "./bar-
|
|
16
|
-
import { t as calendar } from "./calendar-
|
|
17
|
-
import { t as candlestick } from "./candlestick-
|
|
15
|
+
import { t as bar } from "./bar-D_KKd2fL.js";
|
|
16
|
+
import { t as calendar } from "./calendar-CF3gfDQk.js";
|
|
17
|
+
import { t as candlestick } from "./candlestick-B1onjo1o.js";
|
|
18
18
|
import { t as funnel } from "./funnel-CYCv8cq2.js";
|
|
19
19
|
import { i as padAngleForGap, n as arcCentroid, r as arcPathStable } from "./arc-B3V5IR0w.js";
|
|
20
20
|
import { t as gauge } from "./gauge-DiTk5aWO.js";
|
|
21
|
-
import { t as heatmap } from "./heatmap-
|
|
22
|
-
import { n as map, t as addMap } from "./map-
|
|
21
|
+
import { t as heatmap } from "./heatmap-J7fxG7MM.js";
|
|
22
|
+
import { n as map, t as addMap } from "./map-CYp6x-uS.js";
|
|
23
23
|
import { t as parliament } from "./parliament-BKN6ikBJ.js";
|
|
24
24
|
import { t as percentageBar } from "./percentage-bar-CaInxrL8.js";
|
|
25
|
-
import { n as pie, t as donut } from "./pie-
|
|
26
|
-
import { t as radar } from "./radar-
|
|
25
|
+
import { n as pie, t as donut } from "./pie-Ch6Bx0ih.js";
|
|
26
|
+
import { t as radar } from "./radar-Bg-IiIWB.js";
|
|
27
|
+
import { t as rangeBar } from "./range-bar-Dx6ce0J1.js";
|
|
27
28
|
import { t as sankey } from "./sankey-Dp4CuLVe.js";
|
|
28
|
-
import { t as scatter } from "./scatter-
|
|
29
|
-
import { t as sparkline } from "./sparkline-
|
|
30
|
-
import { t as treemap } from "./treemap-
|
|
31
|
-
export { Chart, LINE_HEIGHT, VERSION, addMap, arcCentroid, arcPathStable, area, areaPath, axis, axisSize, band, bandTicks, bar, barPath, buildChart, calendar, cancel, candlestick, categoryInteraction, chartEvents, chartLabel, chartModel, chartToString, dataTable, defaultHidden, defaultPlugins, describeHit, domainOf, donut, download, escapeAttr, escapeText, estimateTextWidth, extent, feature, features, flush, formatDate, formatDetail, formatNumber, formatTicks, funnel, gauge, getDateFormat, getNumberFormat, grid, h, hbarPath, heatmap, highlight, hitAnchor, hoverOverlay, hoverUnderlay, innerRect, insets, keyboard, legend, legendContent, line, linePath, linear, linearTicks, map, niceDomain, normalizeClass, normalizeStyle, padAngleForGap, parliament, percentageBar, pie, placeTooltip, point, pointer, radar, register, render, renderChart, renderContext, renderToString, resolveLegend, resolveSize, sankey, scatter, schedule, seriesKey, seriesLegend, seriesTable, sparkline, stepPrecision, sync, tableContent, thinTicks, tickIncrement, tickStep, ticks, tooltip, tooltipContent, treemap };
|
|
29
|
+
import { t as scatter } from "./scatter-0Z7K_YUz.js";
|
|
30
|
+
import { t as sparkline } from "./sparkline-_dxwtdli.js";
|
|
31
|
+
import { t as treemap } from "./treemap-lbYxb-7h.js";
|
|
32
|
+
export { Chart, LINE_HEIGHT, VERSION, addMap, arcCentroid, arcPathStable, area, areaPath, axis, axisSize, band, bandTicks, bar, barPath, buildChart, calendar, cancel, candlestick, categoryInteraction, chartEvents, chartLabel, chartModel, chartToString, dataTable, defaultHidden, defaultPlugins, describeHit, domainOf, donut, download, escapeAttr, escapeText, estimateTextWidth, extent, feature, features, flush, formatDate, formatDetail, formatNumber, formatTicks, funnel, gauge, getDateFormat, getNumberFormat, grid, h, hbarPath, heatmap, highlight, hitAnchor, hoverOverlay, hoverUnderlay, hoverValue, innerRect, insets, keyboard, legend, legendContent, line, linePath, linear, linearTicks, map, niceDomain, normalizeClass, normalizeStyle, padAngleForGap, parliament, percentageBar, pie, placeTooltip, point, pointer, radar, rangeBar, register, render, renderChart, renderContext, renderToString, resolveLegend, resolveSize, sankey, scatter, schedule, seriesKey, seriesLegend, seriesTable, sparkline, stepPrecision, sync, tableContent, thinTicks, tickIncrement, tickStep, ticks, tooltip, tooltipContent, treemap, zoom };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_format = require("./format-CAE5ruy6.cjs");
|
|
2
|
-
const require_cartesian = require("./cartesian-
|
|
2
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
3
3
|
// src/charts/dates.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formatter for date labels on a time axis (tooltips, tables, band axes):
|
|
@@ -28,4 +28,4 @@ Object.defineProperty(exports, "dateLabels", {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=dates-
|
|
31
|
+
//# sourceMappingURL=dates-0YNY49KQ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates-
|
|
1
|
+
{"version":3,"file":"dates-0YNY49KQ.cjs","names":["toMs","formatDate"],"sources":["../src/charts/dates.ts"],"sourcesContent":["import type { Locale } from '../format.ts'\nimport { formatDate } from '../format.ts'\nimport { type Label, toMs } from './cartesian.ts'\n\n/**\n * Formatter for date labels on a time axis (tooltips, tables, band axes):\n * the date, with the time of day when the labels span less than a few days.\n */\nexport function dateLabels(\n labels: readonly Label[],\n utc: boolean | undefined,\n locale: Locale,\n): (label: Label) => string {\n const first = labels[0]\n const last = labels[labels.length - 1]\n const span = first !== undefined && last !== undefined ? Math.abs(toMs(last) - toMs(first)) : 0\n const withTime = span > 0 && span < 3 * 24 * 60 * 60 * 1000\n const fmt = formatDate(\n {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n ...(withTime ? { hour: 'numeric', minute: '2-digit' } : {}),\n ...(utc ? { timeZone: 'UTC' } : {}),\n },\n locale,\n )\n return (label) => (Number.isFinite(toMs(label)) ? fmt(toMs(label)) : String(label))\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,WACd,QACA,KACA,QAC0B;CAC1B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,OAAO,SAAS;CACpC,MAAM,OAAO,UAAU,KAAA,KAAa,SAAS,KAAA,IAAY,KAAK,IAAIA,kBAAAA,KAAK,IAAI,IAAIA,kBAAAA,KAAK,KAAK,CAAC,IAAI;CAE9F,MAAM,MAAMC,eAAAA,WACV;EACE,MAAM;EACN,OAAO;EACP,KAAK;EACL,GANa,OAAO,KAAK,OAAO,SAMjB;GAAE,MAAM;GAAW,QAAQ;EAAU,IAAI,CAAC;EACzD,GAAI,MAAM,EAAE,UAAU,MAAM,IAAI,CAAC;CACnC,GACA,MACF;CACA,QAAQ,UAAW,OAAO,SAASD,kBAAAA,KAAK,KAAK,CAAC,IAAI,IAAIA,kBAAAA,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK;AACnF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as formatDate } from "./format-it1kepFG.js";
|
|
2
|
-
import { y as toMs } from "./cartesian-
|
|
2
|
+
import { y as toMs } from "./cartesian-COglz544.js";
|
|
3
3
|
// src/charts/dates.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formatter for date labels on a time axis (tooltips, tables, band axes):
|
|
@@ -23,4 +23,4 @@ function dateLabels(labels, utc, locale) {
|
|
|
23
23
|
}
|
|
24
24
|
export { dateLabels as t };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=dates-
|
|
26
|
+
//# sourceMappingURL=dates-CKDRgpin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates-
|
|
1
|
+
{"version":3,"file":"dates-CKDRgpin.js","names":[],"sources":["../src/charts/dates.ts"],"sourcesContent":["import type { Locale } from '../format.ts'\nimport { formatDate } from '../format.ts'\nimport { type Label, toMs } from './cartesian.ts'\n\n/**\n * Formatter for date labels on a time axis (tooltips, tables, band axes):\n * the date, with the time of day when the labels span less than a few days.\n */\nexport function dateLabels(\n labels: readonly Label[],\n utc: boolean | undefined,\n locale: Locale,\n): (label: Label) => string {\n const first = labels[0]\n const last = labels[labels.length - 1]\n const span = first !== undefined && last !== undefined ? Math.abs(toMs(last) - toMs(first)) : 0\n const withTime = span > 0 && span < 3 * 24 * 60 * 60 * 1000\n const fmt = formatDate(\n {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n ...(withTime ? { hour: 'numeric', minute: '2-digit' } : {}),\n ...(utc ? { timeZone: 'UTC' } : {}),\n },\n locale,\n )\n return (label) => (Number.isFinite(toMs(label)) ? fmt(toMs(label)) : String(label))\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,WACd,QACA,KACA,QAC0B;CAC1B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,OAAO,SAAS;CACpC,MAAM,OAAO,UAAU,KAAA,KAAa,SAAS,KAAA,IAAY,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI;CAE9F,MAAM,MAAM,WACV;EACE,MAAM;EACN,OAAO;EACP,KAAK;EACL,GANa,OAAO,KAAK,OAAO,SAMjB;GAAE,MAAM;GAAW,QAAQ;EAAU,IAAI,CAAC;EACzD,GAAI,MAAM,EAAE,UAAU,MAAM,IAAI,CAAC;CACnC,GACA,MACF;CACA,QAAQ,UAAW,OAAO,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK;AACnF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { n as formatDetail, r as formatNumber } from "./format-it1kepFG.js";
|
|
2
|
+
import { i as insets, n as estimateTextWidth, s as round, t as LINE_HEIGHT } from "./layout-DqAte3H8.js";
|
|
3
|
+
import { t as h } from "./vnode-_EMUqysL.js";
|
|
4
|
+
import { l as plottable, m as seriesKey, p as seriesAxes } from "./cartesian-COglz544.js";
|
|
5
|
+
// src/charts/end-labels.ts
|
|
6
|
+
/** Space between a point and its label (the joining line runs through it), and between name and value. */
|
|
7
|
+
const LEAD = 14;
|
|
8
|
+
const GAP = 6;
|
|
9
|
+
/** The labels of a chart: one per visible series that has a value. */
|
|
10
|
+
function endLabelTexts(options, ctx) {
|
|
11
|
+
const own = typeof options.endLabels === "object" ? options.endLabels : {};
|
|
12
|
+
const axisOf = seriesAxes(options);
|
|
13
|
+
return options.data.series.flatMap((series, index) => {
|
|
14
|
+
const { axis } = axisOf(series);
|
|
15
|
+
const last = series.values.filter((v) => plottable(v, axis)).pop();
|
|
16
|
+
if (last == null || ctx.hidden.has(seriesKey(series))) return [];
|
|
17
|
+
const format = own.format ? formatNumber(own.format, ctx.locale) : formatDetail(axis.format, ctx.locale);
|
|
18
|
+
return {
|
|
19
|
+
index,
|
|
20
|
+
key: seriesKey(series),
|
|
21
|
+
name: series.name,
|
|
22
|
+
value: own.value === false ? "" : format(last),
|
|
23
|
+
color: series.color
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const width = (label, fontSize) => {
|
|
28
|
+
const value = label.value ? GAP + estimateTextWidth(label.value, fontSize) * 1.06 : 0;
|
|
29
|
+
return estimateTextWidth(label.name, fontSize) + value;
|
|
30
|
+
};
|
|
31
|
+
/** Width the labels need beside the plot, in pixels (0 without labels). */
|
|
32
|
+
const endLabelRoom = (labels, fontSize) => labels.length ? Math.ceil(LEAD + Math.max(...labels.map((label) => width(label, fontSize)))) : 0;
|
|
33
|
+
/**
|
|
34
|
+
* The labels layer: every label beside the `point` its line ends at, on the
|
|
35
|
+
* left of the plot when the lines run that way (`left`). `overhang` is what
|
|
36
|
+
* the marks take beyond the plot's edge.
|
|
37
|
+
*/
|
|
38
|
+
function endLabelLayer(labels, area, left, fontSize, overhang) {
|
|
39
|
+
const step = Math.ceil(fontSize * LINE_HEIGHT);
|
|
40
|
+
const placed = labels.flatMap((label) => label.point ? {
|
|
41
|
+
...label,
|
|
42
|
+
point: label.point,
|
|
43
|
+
y: label.point[1]
|
|
44
|
+
} : []).sort((a, b) => a.point[1] - b.point[1]);
|
|
45
|
+
if (!placed.length) return null;
|
|
46
|
+
let floor = area.y;
|
|
47
|
+
for (const label of placed) {
|
|
48
|
+
label.y = Math.max(label.y, floor);
|
|
49
|
+
floor = label.y + step;
|
|
50
|
+
}
|
|
51
|
+
let ceiling = Math.max(area.y + area.height, (placed[0]?.y ?? 0) + (placed.length - 1) * step);
|
|
52
|
+
for (const label of placed.slice().reverse()) {
|
|
53
|
+
label.y = Math.min(label.y, ceiling);
|
|
54
|
+
ceiling = label.y - step;
|
|
55
|
+
}
|
|
56
|
+
const sign = left ? -1 : 1;
|
|
57
|
+
const at = (left ? area.x - overhang : area.x + area.width + overhang) + sign * LEAD;
|
|
58
|
+
return h("g", {
|
|
59
|
+
key: "end-labels",
|
|
60
|
+
class: "tc-end-labels",
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}, placed.map((label) => {
|
|
63
|
+
const [px, py] = label.point;
|
|
64
|
+
const moved = Math.abs(label.y - py) > 1;
|
|
65
|
+
return h("g", {
|
|
66
|
+
key: label.key,
|
|
67
|
+
class: [
|
|
68
|
+
"tc-end-label",
|
|
69
|
+
"tc-series",
|
|
70
|
+
`tc-series-${label.index + 1}`
|
|
71
|
+
],
|
|
72
|
+
style: { "--tc-series-color": label.color }
|
|
73
|
+
}, moved && h("path", {
|
|
74
|
+
class: "tc-end-label-line",
|
|
75
|
+
d: `M${round(px + sign * (overhang + 2))},${round(py)}L${round(at - sign * 3)},${round(label.y)}`
|
|
76
|
+
}), h("text", {
|
|
77
|
+
class: "tc-end-label-text",
|
|
78
|
+
style: `transform:translate(${round(at)}px,${round(label.y)}px)`,
|
|
79
|
+
"text-anchor": left ? "end" : "start",
|
|
80
|
+
dy: "0.35em"
|
|
81
|
+
}, left ? [label.value && h("tspan", { class: "tc-end-label-value" }, label.value), h("tspan", { dx: label.value ? GAP : void 0 }, label.name)] : [label.name, label.value && h("tspan", {
|
|
82
|
+
class: "tc-end-label-value",
|
|
83
|
+
dx: GAP
|
|
84
|
+
}, label.value)]));
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The end labels of a line chart: its `options` with room for the labels
|
|
89
|
+
* beside the plot (on the side the lines end at), and the `layer` that
|
|
90
|
+
* draws them once the points of every series (`null` for gaps) and the plot
|
|
91
|
+
* area are known. `overhang` is what the marks take beyond the plot's edge.
|
|
92
|
+
*/
|
|
93
|
+
function endLabels(options, ctx, overhang) {
|
|
94
|
+
const texts = endLabelTexts(options, ctx);
|
|
95
|
+
const left = options.x?.reverse ?? ctx.rtl === true;
|
|
96
|
+
const side = left ? "left" : "right";
|
|
97
|
+
const pad = insets(options.padding);
|
|
98
|
+
return {
|
|
99
|
+
options: {
|
|
100
|
+
...options,
|
|
101
|
+
padding: {
|
|
102
|
+
...pad,
|
|
103
|
+
[side]: pad[side] + endLabelRoom(texts, ctx.fontSize)
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
layer: (points, area) => endLabelLayer(texts.map((label) => ({
|
|
107
|
+
...label,
|
|
108
|
+
point: (points[label.index] ?? []).filter((p) => p != null).pop() ?? null
|
|
109
|
+
})), area, left, ctx.fontSize, overhang)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export { endLabels as t };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=end-labels-B3oRvjxw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-labels-B3oRvjxw.js","names":[],"sources":["../src/charts/end-labels.ts"],"sourcesContent":["/**\n * End labels: each line named at its end, with its last value, in a column\n * past the edge of the plot. Labels of lines that end close together are\n * moved apart, and a thin line in the series color joins a moved label to\n * its point, so a chart reads without its legend.\n */\nimport type { RenderContext } from '../chart.ts'\nimport { formatDetail, formatNumber, type NumberFormat } from '../format.ts'\nimport { estimateTextWidth, insets, LINE_HEIGHT, type Rect, round } from '../layout.ts'\nimport type { Point } from '../shapes/path.ts'\nimport { h, type VNode } from '../vnode.ts'\nimport { type CartesianOptions, plottable, seriesAxes, seriesKey } from './cartesian.ts'\n\nexport interface EndLabelOptions {\n /** Format of the values. Defaults to the format of the series' value axis. */\n format?: NumberFormat\n /** Write the last value after the name. Defaults to `true`. */\n value?: boolean\n}\n\n/** The text of one label: the series (by index), its name and its last value. */\nexport interface EndLabelText {\n index: number\n key: string\n name: string\n value: string\n /** The series' own color, if it has one. */\n color?: string\n}\n\n/** Space between a point and its label (the joining line runs through it), and between name and value. */\nconst LEAD = 14\nconst GAP = 6\n\n/** The labels of a chart: one per visible series that has a value. */\nfunction endLabelTexts(\n options: CartesianOptions & { endLabels?: boolean | EndLabelOptions },\n ctx: RenderContext,\n): EndLabelText[] {\n const own: EndLabelOptions = typeof options.endLabels === 'object' ? options.endLabels : {}\n const axisOf = seriesAxes(options)\n return options.data.series.flatMap((series, index) => {\n const { axis } = axisOf(series)\n const last = series.values.filter((v) => plottable(v, axis)).pop()\n if (last == null || ctx.hidden.has(seriesKey(series))) return []\n const format = own.format\n ? formatNumber(own.format, ctx.locale)\n : formatDetail(axis.format, ctx.locale)\n return {\n index,\n key: seriesKey(series),\n name: series.name,\n value: own.value === false ? '' : format(last),\n color: series.color,\n }\n })\n}\n\nconst width = (label: EndLabelText, fontSize: number): number => {\n // The value is set in a heavier weight: a little wider than estimated.\n const value = label.value ? GAP + estimateTextWidth(label.value, fontSize) * 1.06 : 0\n return estimateTextWidth(label.name, fontSize) + value\n}\n\n/** Width the labels need beside the plot, in pixels (0 without labels). */\nconst endLabelRoom = (labels: readonly EndLabelText[], fontSize: number): number =>\n labels.length ? Math.ceil(LEAD + Math.max(...labels.map((label) => width(label, fontSize)))) : 0\n\n/**\n * The labels layer: every label beside the `point` its line ends at, on the\n * left of the plot when the lines run that way (`left`). `overhang` is what\n * the marks take beyond the plot's edge.\n */\nfunction endLabelLayer(\n labels: readonly (EndLabelText & { point: readonly [number, number] | null })[],\n area: Rect,\n left: boolean,\n fontSize: number,\n overhang: number,\n): VNode | null {\n const step = Math.ceil(fontSize * LINE_HEIGHT)\n const placed = labels\n .flatMap((label) => (label.point ? { ...label, point: label.point, y: label.point[1] } : []))\n .sort((a, b) => a.point[1] - b.point[1])\n if (!placed.length) return null\n // Top to bottom, each a line below the one before; then back up from the bottom of the plot.\n let floor = area.y\n for (const label of placed) {\n label.y = Math.max(label.y, floor)\n floor = label.y + step\n }\n let ceiling = Math.max(area.y + area.height, (placed[0]?.y ?? 0) + (placed.length - 1) * step)\n for (const label of placed.slice().reverse()) {\n label.y = Math.min(label.y, ceiling)\n ceiling = label.y - step\n }\n const sign = left ? -1 : 1\n const edge = left ? area.x - overhang : area.x + area.width + overhang\n const at = edge + sign * LEAD\n return h(\n 'g',\n { key: 'end-labels', class: 'tc-end-labels', 'aria-hidden': 'true' },\n placed.map((label) => {\n const [px, py] = label.point\n const moved = Math.abs(label.y - py) > 1\n return h(\n 'g',\n {\n key: label.key,\n class: ['tc-end-label', 'tc-series', `tc-series-${label.index + 1}`],\n // A map, so values from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': label.color },\n },\n // From past the point's dot to just before the text.\n moved &&\n h('path', {\n class: 'tc-end-label-line',\n d: `M${round(px + sign * (overhang + 2))},${round(py)}L${round(at - sign * 3)},${round(label.y)}`,\n }),\n h(\n 'text',\n {\n class: 'tc-end-label-text',\n style: `transform:translate(${round(at)}px,${round(label.y)}px)`,\n 'text-anchor': left ? 'end' : 'start',\n dy: '0.35em',\n },\n left\n ? [\n label.value && h('tspan', { class: 'tc-end-label-value' }, label.value),\n h('tspan', { dx: label.value ? GAP : undefined }, label.name),\n ]\n : [\n label.name,\n label.value && h('tspan', { class: 'tc-end-label-value', dx: GAP }, label.value),\n ],\n ),\n )\n }),\n )\n}\n\ntype Options = CartesianOptions & { endLabels?: boolean | EndLabelOptions }\n\n/**\n * The end labels of a line chart: its `options` with room for the labels\n * beside the plot (on the side the lines end at), and the `layer` that\n * draws them once the points of every series (`null` for gaps) and the plot\n * area are known. `overhang` is what the marks take beyond the plot's edge.\n */\nexport function endLabels<O extends Options>(\n options: O,\n ctx: RenderContext,\n overhang: number,\n): { options: O; layer: (points: readonly (readonly Point[])[], area: Rect) => VNode | null } {\n const texts = endLabelTexts(options, ctx)\n const left = options.x?.reverse ?? ctx.rtl === true\n const side = left ? 'left' : 'right'\n const pad = insets(options.padding)\n return {\n options: {\n ...options,\n padding: { ...pad, [side]: pad[side] + endLabelRoom(texts, ctx.fontSize) },\n },\n layer: (points, area) =>\n endLabelLayer(\n texts.map((label) => ({\n ...label,\n point: (points[label.index] ?? []).filter((p) => p != null).pop() ?? null,\n })),\n area,\n left,\n ctx.fontSize,\n overhang,\n ),\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const require_format = require("./format-CAE5ruy6.cjs");
|
|
2
|
+
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
3
|
+
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
4
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
5
|
+
// src/charts/end-labels.ts
|
|
6
|
+
/** Space between a point and its label (the joining line runs through it), and between name and value. */
|
|
7
|
+
const LEAD = 14;
|
|
8
|
+
const GAP = 6;
|
|
9
|
+
/** The labels of a chart: one per visible series that has a value. */
|
|
10
|
+
function endLabelTexts(options, ctx) {
|
|
11
|
+
const own = typeof options.endLabels === "object" ? options.endLabels : {};
|
|
12
|
+
const axisOf = require_cartesian.seriesAxes(options);
|
|
13
|
+
return options.data.series.flatMap((series, index) => {
|
|
14
|
+
const { axis } = axisOf(series);
|
|
15
|
+
const last = series.values.filter((v) => require_cartesian.plottable(v, axis)).pop();
|
|
16
|
+
if (last == null || ctx.hidden.has(require_cartesian.seriesKey(series))) return [];
|
|
17
|
+
const format = own.format ? require_format.formatNumber(own.format, ctx.locale) : require_format.formatDetail(axis.format, ctx.locale);
|
|
18
|
+
return {
|
|
19
|
+
index,
|
|
20
|
+
key: require_cartesian.seriesKey(series),
|
|
21
|
+
name: series.name,
|
|
22
|
+
value: own.value === false ? "" : format(last),
|
|
23
|
+
color: series.color
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const width = (label, fontSize) => {
|
|
28
|
+
const value = label.value ? GAP + require_layout.estimateTextWidth(label.value, fontSize) * 1.06 : 0;
|
|
29
|
+
return require_layout.estimateTextWidth(label.name, fontSize) + value;
|
|
30
|
+
};
|
|
31
|
+
/** Width the labels need beside the plot, in pixels (0 without labels). */
|
|
32
|
+
const endLabelRoom = (labels, fontSize) => labels.length ? Math.ceil(LEAD + Math.max(...labels.map((label) => width(label, fontSize)))) : 0;
|
|
33
|
+
/**
|
|
34
|
+
* The labels layer: every label beside the `point` its line ends at, on the
|
|
35
|
+
* left of the plot when the lines run that way (`left`). `overhang` is what
|
|
36
|
+
* the marks take beyond the plot's edge.
|
|
37
|
+
*/
|
|
38
|
+
function endLabelLayer(labels, area, left, fontSize, overhang) {
|
|
39
|
+
const step = Math.ceil(fontSize * require_layout.LINE_HEIGHT);
|
|
40
|
+
const placed = labels.flatMap((label) => label.point ? {
|
|
41
|
+
...label,
|
|
42
|
+
point: label.point,
|
|
43
|
+
y: label.point[1]
|
|
44
|
+
} : []).sort((a, b) => a.point[1] - b.point[1]);
|
|
45
|
+
if (!placed.length) return null;
|
|
46
|
+
let floor = area.y;
|
|
47
|
+
for (const label of placed) {
|
|
48
|
+
label.y = Math.max(label.y, floor);
|
|
49
|
+
floor = label.y + step;
|
|
50
|
+
}
|
|
51
|
+
let ceiling = Math.max(area.y + area.height, (placed[0]?.y ?? 0) + (placed.length - 1) * step);
|
|
52
|
+
for (const label of placed.slice().reverse()) {
|
|
53
|
+
label.y = Math.min(label.y, ceiling);
|
|
54
|
+
ceiling = label.y - step;
|
|
55
|
+
}
|
|
56
|
+
const sign = left ? -1 : 1;
|
|
57
|
+
const at = (left ? area.x - overhang : area.x + area.width + overhang) + sign * LEAD;
|
|
58
|
+
return require_vnode.h("g", {
|
|
59
|
+
key: "end-labels",
|
|
60
|
+
class: "tc-end-labels",
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}, placed.map((label) => {
|
|
63
|
+
const [px, py] = label.point;
|
|
64
|
+
const moved = Math.abs(label.y - py) > 1;
|
|
65
|
+
return require_vnode.h("g", {
|
|
66
|
+
key: label.key,
|
|
67
|
+
class: [
|
|
68
|
+
"tc-end-label",
|
|
69
|
+
"tc-series",
|
|
70
|
+
`tc-series-${label.index + 1}`
|
|
71
|
+
],
|
|
72
|
+
style: { "--tc-series-color": label.color }
|
|
73
|
+
}, moved && require_vnode.h("path", {
|
|
74
|
+
class: "tc-end-label-line",
|
|
75
|
+
d: `M${require_layout.round(px + sign * (overhang + 2))},${require_layout.round(py)}L${require_layout.round(at - sign * 3)},${require_layout.round(label.y)}`
|
|
76
|
+
}), require_vnode.h("text", {
|
|
77
|
+
class: "tc-end-label-text",
|
|
78
|
+
style: `transform:translate(${require_layout.round(at)}px,${require_layout.round(label.y)}px)`,
|
|
79
|
+
"text-anchor": left ? "end" : "start",
|
|
80
|
+
dy: "0.35em"
|
|
81
|
+
}, left ? [label.value && require_vnode.h("tspan", { class: "tc-end-label-value" }, label.value), require_vnode.h("tspan", { dx: label.value ? GAP : void 0 }, label.name)] : [label.name, label.value && require_vnode.h("tspan", {
|
|
82
|
+
class: "tc-end-label-value",
|
|
83
|
+
dx: GAP
|
|
84
|
+
}, label.value)]));
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The end labels of a line chart: its `options` with room for the labels
|
|
89
|
+
* beside the plot (on the side the lines end at), and the `layer` that
|
|
90
|
+
* draws them once the points of every series (`null` for gaps) and the plot
|
|
91
|
+
* area are known. `overhang` is what the marks take beyond the plot's edge.
|
|
92
|
+
*/
|
|
93
|
+
function endLabels(options, ctx, overhang) {
|
|
94
|
+
const texts = endLabelTexts(options, ctx);
|
|
95
|
+
const left = options.x?.reverse ?? ctx.rtl === true;
|
|
96
|
+
const side = left ? "left" : "right";
|
|
97
|
+
const pad = require_layout.insets(options.padding);
|
|
98
|
+
return {
|
|
99
|
+
options: {
|
|
100
|
+
...options,
|
|
101
|
+
padding: {
|
|
102
|
+
...pad,
|
|
103
|
+
[side]: pad[side] + endLabelRoom(texts, ctx.fontSize)
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
layer: (points, area) => endLabelLayer(texts.map((label) => ({
|
|
107
|
+
...label,
|
|
108
|
+
point: (points[label.index] ?? []).filter((p) => p != null).pop() ?? null
|
|
109
|
+
})), area, left, ctx.fontSize, overhang)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
Object.defineProperty(exports, "endLabels", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function() {
|
|
115
|
+
return endLabels;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=end-labels-CS-fnpp-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-labels-CS-fnpp-.cjs","names":["seriesAxes","plottable","seriesKey","formatNumber","formatDetail","estimateTextWidth","LINE_HEIGHT","h","round","insets"],"sources":["../src/charts/end-labels.ts"],"sourcesContent":["/**\n * End labels: each line named at its end, with its last value, in a column\n * past the edge of the plot. Labels of lines that end close together are\n * moved apart, and a thin line in the series color joins a moved label to\n * its point, so a chart reads without its legend.\n */\nimport type { RenderContext } from '../chart.ts'\nimport { formatDetail, formatNumber, type NumberFormat } from '../format.ts'\nimport { estimateTextWidth, insets, LINE_HEIGHT, type Rect, round } from '../layout.ts'\nimport type { Point } from '../shapes/path.ts'\nimport { h, type VNode } from '../vnode.ts'\nimport { type CartesianOptions, plottable, seriesAxes, seriesKey } from './cartesian.ts'\n\nexport interface EndLabelOptions {\n /** Format of the values. Defaults to the format of the series' value axis. */\n format?: NumberFormat\n /** Write the last value after the name. Defaults to `true`. */\n value?: boolean\n}\n\n/** The text of one label: the series (by index), its name and its last value. */\nexport interface EndLabelText {\n index: number\n key: string\n name: string\n value: string\n /** The series' own color, if it has one. */\n color?: string\n}\n\n/** Space between a point and its label (the joining line runs through it), and between name and value. */\nconst LEAD = 14\nconst GAP = 6\n\n/** The labels of a chart: one per visible series that has a value. */\nfunction endLabelTexts(\n options: CartesianOptions & { endLabels?: boolean | EndLabelOptions },\n ctx: RenderContext,\n): EndLabelText[] {\n const own: EndLabelOptions = typeof options.endLabels === 'object' ? options.endLabels : {}\n const axisOf = seriesAxes(options)\n return options.data.series.flatMap((series, index) => {\n const { axis } = axisOf(series)\n const last = series.values.filter((v) => plottable(v, axis)).pop()\n if (last == null || ctx.hidden.has(seriesKey(series))) return []\n const format = own.format\n ? formatNumber(own.format, ctx.locale)\n : formatDetail(axis.format, ctx.locale)\n return {\n index,\n key: seriesKey(series),\n name: series.name,\n value: own.value === false ? '' : format(last),\n color: series.color,\n }\n })\n}\n\nconst width = (label: EndLabelText, fontSize: number): number => {\n // The value is set in a heavier weight: a little wider than estimated.\n const value = label.value ? GAP + estimateTextWidth(label.value, fontSize) * 1.06 : 0\n return estimateTextWidth(label.name, fontSize) + value\n}\n\n/** Width the labels need beside the plot, in pixels (0 without labels). */\nconst endLabelRoom = (labels: readonly EndLabelText[], fontSize: number): number =>\n labels.length ? Math.ceil(LEAD + Math.max(...labels.map((label) => width(label, fontSize)))) : 0\n\n/**\n * The labels layer: every label beside the `point` its line ends at, on the\n * left of the plot when the lines run that way (`left`). `overhang` is what\n * the marks take beyond the plot's edge.\n */\nfunction endLabelLayer(\n labels: readonly (EndLabelText & { point: readonly [number, number] | null })[],\n area: Rect,\n left: boolean,\n fontSize: number,\n overhang: number,\n): VNode | null {\n const step = Math.ceil(fontSize * LINE_HEIGHT)\n const placed = labels\n .flatMap((label) => (label.point ? { ...label, point: label.point, y: label.point[1] } : []))\n .sort((a, b) => a.point[1] - b.point[1])\n if (!placed.length) return null\n // Top to bottom, each a line below the one before; then back up from the bottom of the plot.\n let floor = area.y\n for (const label of placed) {\n label.y = Math.max(label.y, floor)\n floor = label.y + step\n }\n let ceiling = Math.max(area.y + area.height, (placed[0]?.y ?? 0) + (placed.length - 1) * step)\n for (const label of placed.slice().reverse()) {\n label.y = Math.min(label.y, ceiling)\n ceiling = label.y - step\n }\n const sign = left ? -1 : 1\n const edge = left ? area.x - overhang : area.x + area.width + overhang\n const at = edge + sign * LEAD\n return h(\n 'g',\n { key: 'end-labels', class: 'tc-end-labels', 'aria-hidden': 'true' },\n placed.map((label) => {\n const [px, py] = label.point\n const moved = Math.abs(label.y - py) > 1\n return h(\n 'g',\n {\n key: label.key,\n class: ['tc-end-label', 'tc-series', `tc-series-${label.index + 1}`],\n // A map, so values from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': label.color },\n },\n // From past the point's dot to just before the text.\n moved &&\n h('path', {\n class: 'tc-end-label-line',\n d: `M${round(px + sign * (overhang + 2))},${round(py)}L${round(at - sign * 3)},${round(label.y)}`,\n }),\n h(\n 'text',\n {\n class: 'tc-end-label-text',\n style: `transform:translate(${round(at)}px,${round(label.y)}px)`,\n 'text-anchor': left ? 'end' : 'start',\n dy: '0.35em',\n },\n left\n ? [\n label.value && h('tspan', { class: 'tc-end-label-value' }, label.value),\n h('tspan', { dx: label.value ? GAP : undefined }, label.name),\n ]\n : [\n label.name,\n label.value && h('tspan', { class: 'tc-end-label-value', dx: GAP }, label.value),\n ],\n ),\n )\n }),\n )\n}\n\ntype Options = CartesianOptions & { endLabels?: boolean | EndLabelOptions }\n\n/**\n * The end labels of a line chart: its `options` with room for the labels\n * beside the plot (on the side the lines end at), and the `layer` that\n * draws them once the points of every series (`null` for gaps) and the plot\n * area are known. `overhang` is what the marks take beyond the plot's edge.\n */\nexport function endLabels<O extends Options>(\n options: O,\n ctx: RenderContext,\n overhang: number,\n): { options: O; layer: (points: readonly (readonly Point[])[], area: Rect) => VNode | null } {\n const texts = endLabelTexts(options, ctx)\n const left = options.x?.reverse ?? ctx.rtl === true\n const side = left ? 'left' : 'right'\n const pad = insets(options.padding)\n return {\n options: {\n ...options,\n padding: { ...pad, [side]: pad[side] + endLabelRoom(texts, ctx.fontSize) },\n },\n layer: (points, area) =>\n endLabelLayer(\n texts.map((label) => ({\n ...label,\n point: (points[label.index] ?? []).filter((p) => p != null).pop() ?? null,\n })),\n area,\n left,\n ctx.fontSize,\n overhang,\n ),\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_end_labels = require("./end-labels-CS-fnpp-.cjs");
|
|
3
|
+
// src/end-labels.ts
|
|
4
|
+
/**
|
|
5
|
+
* Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`
|
|
6
|
+
* (the name and last value at the end of each line) on the core.
|
|
7
|
+
*/
|
|
8
|
+
require("./features-DEDP5CEQ.cjs").register({ "end-labels": require_end_labels.endLabels });
|
|
9
|
+
exports.endLabels = require_end_labels.endLabels;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=end-labels.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-labels.cjs","names":["register","endLabels"],"sources":["../src/end-labels.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`\n * (the name and last value at the end of each line) on the core.\n */\nimport { endLabels } from './charts/end-labels.ts'\nimport { register } from './features.ts'\n\nregister({ 'end-labels': endLabels })\n\nexport type { EndLabelOptions } from './charts/end-labels.ts'\nexport { endLabels }\n"],"mappings":";;;;;;;A,iCAOAA,CAAAA,CAAAA,SAAS,EAAE,cAAcC,mBAAAA,UAAU,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`
|
|
3
|
+
* (the name and last value at the end of each line) on the core.
|
|
4
|
+
*/
|
|
5
|
+
import { ft as EndLabelOptions, pt as endLabels } from "./chart-Dz4geQZy.cjs";
|
|
6
|
+
export { type EndLabelOptions, endLabels };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`
|
|
3
|
+
* (the name and last value at the end of each line) on the core.
|
|
4
|
+
*/
|
|
5
|
+
import { ct as EndLabelOptions, lt as endLabels } from "./chart-CE9EVbfV.js";
|
|
6
|
+
export { type EndLabelOptions, endLabels };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as endLabels } from "./end-labels-B3oRvjxw.js";
|
|
2
|
+
import { i as register } from "./features-B55rwpQC.js";
|
|
3
|
+
// src/end-labels.ts
|
|
4
|
+
/**
|
|
5
|
+
* Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`
|
|
6
|
+
* (the name and last value at the end of each line) on the core.
|
|
7
|
+
*/
|
|
8
|
+
register({ "end-labels": endLabels });
|
|
9
|
+
export { endLabels };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=end-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-labels.js","names":[],"sources":["../src/end-labels.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/end-labels'` enables `endLabels`\n * (the name and last value at the end of each line) on the core.\n */\nimport { endLabels } from './charts/end-labels.ts'\nimport { register } from './features.ts'\n\nregister({ 'end-labels': endLabels })\n\nexport type { EndLabelOptions } from './charts/end-labels.ts'\nexport { endLabels }\n"],"mappings":";;;;;;;AAOA,SAAS,EAAE,cAAc,UAAU,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import { a as chartModel } from "./chart-B97FBRCd.js";
|
|
1
2
|
import { s as round } from "./layout-DqAte3H8.js";
|
|
2
3
|
// src/export-chart.ts
|
|
4
|
+
/**
|
|
5
|
+
* Export a rendered chart as a standalone SVG or an image, or its data as CSV
|
|
6
|
+
* (`exportSVG()`, `exportImage()`, `exportCSV()`, `downloadChart()` of
|
|
7
|
+
* `@tabler/charts/export`).
|
|
8
|
+
*
|
|
9
|
+
* Charts are styled by CSS, so the export copies the computed styles of
|
|
10
|
+
* every mark into the SVG: the file looks the same anywhere, without the
|
|
11
|
+
* stylesheet or the page's custom properties. Browser only.
|
|
12
|
+
*
|
|
13
|
+
* Kept free of side effects, so `@tabler/charts` can re-export the functions
|
|
14
|
+
* without carrying them into every bundle: the `/export` entry registers the
|
|
15
|
+
* `download` menu's saver on top.
|
|
16
|
+
*/
|
|
3
17
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
4
18
|
/** Properties copied from the computed style, with the values they can be left out at. */
|
|
5
19
|
const SHAPE = {
|
|
@@ -210,8 +224,66 @@ async function exportImage(target, options = {}) {
|
|
|
210
224
|
canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("@tabler/charts: could not encode.")), type, quality);
|
|
211
225
|
});
|
|
212
226
|
}
|
|
227
|
+
/** The rows of a chart with `{ labels, series }` data, values as they are. */
|
|
228
|
+
function seriesRows(chart) {
|
|
229
|
+
const { config, interaction } = chart;
|
|
230
|
+
const { data, x } = config;
|
|
231
|
+
const series = data?.series;
|
|
232
|
+
if (!interaction || !Array.isArray(series) || !series.every((s) => Array.isArray(s?.values))) return;
|
|
233
|
+
const hits = Array.from({ length: interaction.count }, (_, i) => interaction.hitIndex(i));
|
|
234
|
+
const names = /* @__PURE__ */ new Map();
|
|
235
|
+
for (const hit of hits) for (const item of hit?.items ?? []) names.set(item.seriesIndex, item.name);
|
|
236
|
+
const order = [...names.keys()].sort((a, b) => a - b);
|
|
237
|
+
const rows = [["", ...order.map((index) => names.get(index))]];
|
|
238
|
+
for (const hit of hits) {
|
|
239
|
+
if (!hit) continue;
|
|
240
|
+
const label = data?.labels?.[hit.index];
|
|
241
|
+
const date = label instanceof Date ? label : x?.type === "time" && typeof hit.label === "number" && new Date(hit.label);
|
|
242
|
+
rows.push([date && Number.isFinite(date.getTime()) ? date.toISOString() : String(hit.label), ...order.map((index) => {
|
|
243
|
+
const value = hit.items.find((item) => item.seriesIndex === index)?.value;
|
|
244
|
+
return value == null ? "" : String(value);
|
|
245
|
+
})]);
|
|
246
|
+
}
|
|
247
|
+
return rows;
|
|
248
|
+
}
|
|
249
|
+
/** The rows of any other chart: the text of its data table, every row of it. */
|
|
250
|
+
function tableRows(chart) {
|
|
251
|
+
const { config } = chart;
|
|
252
|
+
const model = chartModel(config);
|
|
253
|
+
const hidden = new Set((config.type.legend?.(model) ?? []).map((item) => item.key).filter((key) => chart.isHidden(key)));
|
|
254
|
+
const table = config.type.table?.(model, {
|
|
255
|
+
locale: config.locale,
|
|
256
|
+
hidden,
|
|
257
|
+
rtl: chart.rtl
|
|
258
|
+
}, Number.POSITIVE_INFINITY);
|
|
259
|
+
if (!table) throw new Error("@tabler/charts: this chart type has no data for a CSV.");
|
|
260
|
+
return [table.columns, ...table.rows];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The chart's data as CSV (RFC 4180): one row per category with a column per
|
|
264
|
+
* visible series, as in the chart's data table but with every row. Line,
|
|
265
|
+
* area, bar, heatmap and radar charts give plain values (numbers without
|
|
266
|
+
* their format, dates in ISO 8601, gaps empty); the other types give the
|
|
267
|
+
* text of their table. Text that a spreadsheet would run as a formula (`=`,
|
|
268
|
+
* `+`, `-` or `@` first) is prefixed with `'`. Takes the rendered chart
|
|
269
|
+
* itself, not its element.
|
|
270
|
+
*
|
|
271
|
+
* ```ts
|
|
272
|
+
* const csv = exportCSV(chart)
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
function exportCSV(chart, options = {}) {
|
|
276
|
+
if (!chart?.config?.type) throw new Error("@tabler/charts: exportCSV() takes the chart, not its element.");
|
|
277
|
+
const delimiter = options.delimiter ?? ",";
|
|
278
|
+
const cell = (text) => {
|
|
279
|
+
const safe = /^[=+\-@\t\r]/.test(text) && !Number.isFinite(Number(text)) ? `'${text}` : text;
|
|
280
|
+
return safe.includes(delimiter) || /["\r\n]/.test(safe) ? `"${safe.replace(/"/g, "\"\"")}"` : safe;
|
|
281
|
+
};
|
|
282
|
+
return (seriesRows(chart) ?? tableRows(chart)).map((row) => row.map(cell).join(delimiter)).join("\r\n");
|
|
283
|
+
}
|
|
213
284
|
/**
|
|
214
|
-
* Save the chart as a file: PNG by default,
|
|
285
|
+
* Save the chart as a file: PNG by default, SVG, JPEG or WebP, or its data
|
|
286
|
+
* as CSV (which needs the chart itself, not its element).
|
|
215
287
|
*
|
|
216
288
|
* ```ts
|
|
217
289
|
* button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })
|
|
@@ -220,7 +292,7 @@ async function exportImage(target, options = {}) {
|
|
|
220
292
|
async function downloadChart(target, options = {}) {
|
|
221
293
|
const { format = "png" } = options;
|
|
222
294
|
const svg = rootOf(target);
|
|
223
|
-
const blob = format === "svg" ? new Blob([exportSVG(target, options)], { type: "image/svg+xml" }) : await exportImage(target, {
|
|
295
|
+
const blob = format === "csv" ? new Blob([`${exportCSV(target, options)}`], { type: "text/csv;charset=utf-8" }) : format === "svg" ? new Blob([exportSVG(target, options)], { type: "image/svg+xml" }) : await exportImage(target, {
|
|
224
296
|
...options,
|
|
225
297
|
type: `image/${format}`
|
|
226
298
|
});
|
|
@@ -231,6 +303,6 @@ async function downloadChart(target, options = {}) {
|
|
|
231
303
|
link.click();
|
|
232
304
|
setTimeout(() => URL.revokeObjectURL(link.href), 1e3);
|
|
233
305
|
}
|
|
234
|
-
export {
|
|
306
|
+
export { exportSVG as i, exportCSV as n, exportImage as r, downloadChart as t };
|
|
235
307
|
|
|
236
|
-
//# sourceMappingURL=export-chart-
|
|
308
|
+
//# sourceMappingURL=export-chart-BOH_nfcH.js.map
|