@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candlestick-B1onjo1o.js","names":[],"sources":["../src/charts/candlestick.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport type { Hit, Interaction } from '../interaction.ts'\nimport type { InsetsInput } from '../layout.ts'\nimport { round } from '../layout.ts'\nimport { h } from '../vnode.ts'\nimport type { Annotation } from './annotations.ts'\nimport {\n type CartesianData,\n type CartesianOptions,\n type CategoryAxisOptions,\n cartesianLayout,\n categoryInteraction,\n type Label,\n labelKey,\n plottable,\n seriesTable,\n type ValueAxisOptions,\n windowed,\n} from './cartesian.ts'\nimport { cleanData, finite, label, records } from './clean.ts'\nimport type { Zoomable } from './view.ts'\n\n/** One period: where the price opened, its range and where it closed. */\nexport interface Candle {\n /** The period (a date for `x: { type: 'time' }`, or any label). */\n x: Label\n open: number\n high: number\n low: number\n close: number\n}\n\n/**\n * A rounded rectangle with the same commands whatever its size and radius\n * (a zero radius draws square corners), so CSS can morph one into another.\n */\nconst bodyPath = (x: number, y: number, w: number, h: number, r: number): string => {\n const a = `A${r},${r},0,0,1,`\n return `M${round(x + r)},${y}H${round(x + w - r)}${a}${round(x + w)},${round(y + r)}V${round(y + h - r)}${a}${round(x + w - r)},${round(y + h)}H${round(x + r)}${a}${x},${round(y + h - r)}V${round(y + r)}${a}${round(x + r)},${y}Z`\n}\n\nexport interface CandlestickOptions extends Zoomable {\n data: readonly Candle[]\n /** Maximum candle body width in pixels. Defaults to `16`. */\n maxCandleWidth?: number\n /** Share of each period left empty between candles, `0…1`. Defaults to `0.3`. */\n groupPadding?: number\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n /** Corner radius of the bodies. Defaults to `1`. */\n radius?: number\n x?: CategoryAxisOptions\n y?: ValueAxisOptions\n /** Reference lines and bands, e.g. a price target or a trading halt. */\n annotations?: readonly Annotation[]\n}\n\nconst UP = 'var(--tc-up-color,var(--tc-color-6))'\nconst DOWN = 'var(--tc-negative-color,var(--tc-color-8))'\n\n/** Whether every price can be placed on the value axis (positive ones only on a log axis). */\nconst valid = (c: Candle, axis: ValueAxisOptions | undefined): boolean =>\n [c.open, c.high, c.low, c.close].every((v) => plottable(v, axis))\n\n/** The candles as four series, for the shared axes, tooltip and table. */\nfunction asCartesian(options: CandlestickOptions): CartesianOptions {\n const pick = (key: 'open' | 'high' | 'low' | 'close') =>\n options.data.map((c) => (valid(c, options.y) ? c[key] : null))\n const data: CartesianData = {\n labels: options.data.map((c) => c.x),\n series: [\n { name: 'Open', values: pick('open') },\n { name: 'High', values: pick('high') },\n { name: 'Low', values: pick('low') },\n { name: 'Close', values: pick('close') },\n ],\n }\n const out: CartesianOptions = { data }\n if (options.x) out.x = options.x\n if (options.y) out.y = options.y\n if (options.padding !== undefined) out.padding = options.padding\n if (options.annotations) out.annotations = options.annotations\n return out\n}\n\n/**\n * Candlestick (OHLC) chart: per period a wick from low to high and a body\n * from open to close, green when it closed higher (`--tc-up-color`) and red\n * when lower (`--tc-negative-color`).\n *\n * ```ts\n * new Chart('#el', {\n * type: candlestick,\n * data: [{ x: '2026-01-01', open: 98, high: 102, low: 89, close: 94 }],\n * x: { type: 'time' },\n * })\n * ```\n */\nexport const candlestick: ChartType<CandlestickOptions> = {\n name: 'candlestick',\n clean: cleanData((data) =>\n records(data, (c) => ({\n ...c,\n x: label(c.x),\n open: finite(c.open),\n high: finite(c.high),\n low: finite(c.low),\n close: finite(c.close),\n })),\n ),\n prepare: windowed,\n render(options, ctx) {\n const { maxCandleWidth = 16, groupPadding = 0.3, radius = 1 } = options\n const cartesian = asCartesian(options)\n const layout = cartesianLayout(cartesian, ctx, {\n scale: 'band',\n zero: false,\n paddingInner: groupPadding,\n paddingOuter: groupPadding / 2,\n })\n const { x, y, labels } = layout\n const width = Math.max(1, Math.min(maxCandleWidth, x.bandwidth))\n const center = (i: number) => x.at(i) + x.bandwidth / 2\n const up = (c: Candle) => c.close >= c.open\n\n const base = categoryInteraction(layout, cartesian, ctx, (_, i, v) => ({\n x: center(i),\n y: y(v),\n }))\n // Tooltip swatches take the color of the candle, not four palette slots.\n const paint = (hit: Hit | null): Hit | null => {\n const candle = hit ? options.data[hit.index] : undefined\n if (!hit || !candle) return hit\n const color = up(candle) ? UP : DOWN\n return { ...hit, items: hit.items.map((item) => ({ ...item, color })) }\n }\n const interaction: Interaction = {\n count: base.count,\n hitIndex: (i, s) => paint(base.hitIndex(i, s)),\n hitTest: (px, py) => paint(base.hitTest(px, py)),\n }\n\n const candles = options.data.map((c, i) => {\n if (!valid(c, options.y)) return null\n const cx = round(center(i))\n const top = y(Math.max(c.open, c.close))\n // A flat period still shows a 1px body.\n const bottom = Math.max(y(Math.min(c.open, c.close)), top + 1)\n const left = round(center(i) - width / 2)\n const r = round(Math.min(radius, width / 2, (bottom - top) / 2))\n return h(\n 'g',\n {\n key: labelKey(labels[i] as Label),\n class: ['tc-candle', up(c) ? 'tc-candle-up' : 'tc-candle-down'],\n },\n h('path', {\n class: 'tc-candle-wick',\n d: `M${cx},${round(y(c.high))}V${round(y(c.low))}`,\n }),\n // A path, not a rect, so it morphs between updates (d), in Safari too.\n h('path', {\n class: 'tc-candle-body',\n d: bodyPath(left, round(top), round(width), round(bottom - top), r),\n }),\n )\n })\n\n const content = [\n h('defs', { key: 'defs' }, layout.clip.def),\n layout.background,\n h(\n 'g',\n { key: 'series', class: 'tc-series-list tc-candles', 'clip-path': layout.clip.url },\n candles,\n ),\n layout.foreground,\n ]\n return { content, interaction }\n },\n table: (options, ctx, limit) => seriesTable(asCartesian(options), ctx, limit),\n}\n"],"mappings":";;;;;;;;;AAoCA,MAAM,YAAY,GAAW,GAAW,GAAW,GAAW,MAAsB;CAClF,MAAM,IAAI,IAAI,EAAE,GAAG,EAAE;CACrB,OAAO,IAAI,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,IAAI,EAAE,GAAG,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE;AACrO;AAkBA,MAAM,KAAK;AACX,MAAM,OAAO;;AAGb,MAAM,SAAS,GAAW,SACxB;CAAC,EAAE;CAAM,EAAE;CAAM,EAAE;CAAK,EAAE;AAAK,CAAC,CAAC,OAAO,MAAM,UAAU,GAAG,IAAI,CAAC;;AAGlE,SAAS,YAAY,SAA+C;CAClE,MAAM,QAAQ,QACZ,QAAQ,KAAK,KAAK,MAAO,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAK;CAU/D,MAAM,MAAwB,EAAE,MAAA;EAR9B,QAAQ,QAAQ,KAAK,KAAK,MAAM,EAAE,CAAC;EACnC,QAAQ;GACN;IAAE,MAAM;IAAQ,QAAQ,KAAK,MAAM;GAAE;GACrC;IAAE,MAAM;IAAQ,QAAQ,KAAK,MAAM;GAAE;GACrC;IAAE,MAAM;IAAO,QAAQ,KAAK,KAAK;GAAE;GACnC;IAAE,MAAM;IAAS,QAAQ,KAAK,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EACE,KACA;KAAE,KAAK;KAAU,OAAO;KAA6B,aAAa,OAAO,KAAK;IAAI,GAClF,OACF;IACA,OAAO;GAEM;GAAG;EAAY;CAChC;CACA,QAAQ,SAAS,KAAK,UAAU,YAAY,YAAY,OAAO,GAAG,KAAK,KAAK;AAC9E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Dt as Zoomable, _t as Label, gt as CategoryAxisOptions, o as ChartType, yt as ValueAxisOptions } from "./chart-Dz4geQZy.cjs";
|
|
2
|
+
import { n as InsetsInput } from "./layout-CYerDebD.cjs";
|
|
3
|
+
import { t as Annotation } from "./annotations-CqZM1z9R.cjs";
|
|
3
4
|
/** One period: where the price opened, its range and where it closed. */
|
|
4
5
|
interface Candle {
|
|
5
6
|
/** The period (a date for `x: { type: 'time' }`, or any label). */
|
|
@@ -9,7 +10,7 @@ interface Candle {
|
|
|
9
10
|
low: number;
|
|
10
11
|
close: number;
|
|
11
12
|
}
|
|
12
|
-
interface CandlestickOptions {
|
|
13
|
+
interface CandlestickOptions extends Zoomable {
|
|
13
14
|
data: readonly Candle[];
|
|
14
15
|
/** Maximum candle body width in pixels. Defaults to `16`. */
|
|
15
16
|
maxCandleWidth?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
2
2
|
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
3
|
-
const require_cartesian = require("./cartesian-
|
|
3
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
4
4
|
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
5
5
|
// src/charts/candlestick.ts
|
|
6
6
|
/**
|
|
@@ -73,6 +73,7 @@ const candlestick = {
|
|
|
73
73
|
low: require_clean.finite(c.low),
|
|
74
74
|
close: require_clean.finite(c.close)
|
|
75
75
|
}))),
|
|
76
|
+
prepare: require_cartesian.windowed,
|
|
76
77
|
render(options, ctx) {
|
|
77
78
|
const { maxCandleWidth = 16, groupPadding = .3, radius = 1 } = options;
|
|
78
79
|
const cartesian = asCartesian(options);
|
|
@@ -148,4 +149,4 @@ Object.defineProperty(exports, "candlestick", {
|
|
|
148
149
|
}
|
|
149
150
|
});
|
|
150
151
|
|
|
151
|
-
//# sourceMappingURL=candlestick-
|
|
152
|
+
//# sourceMappingURL=candlestick-BwrFKak_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candlestick-BwrFKak_.cjs","names":["round","plottable","cleanData","records","label","finite","windowed","cartesianLayout","categoryInteraction","h","labelKey","seriesTable"],"sources":["../src/charts/candlestick.ts"],"sourcesContent":["import type { ChartType } from '../chart.ts'\nimport type { Hit, Interaction } from '../interaction.ts'\nimport type { InsetsInput } from '../layout.ts'\nimport { round } from '../layout.ts'\nimport { h } from '../vnode.ts'\nimport type { Annotation } from './annotations.ts'\nimport {\n type CartesianData,\n type CartesianOptions,\n type CategoryAxisOptions,\n cartesianLayout,\n categoryInteraction,\n type Label,\n labelKey,\n plottable,\n seriesTable,\n type ValueAxisOptions,\n windowed,\n} from './cartesian.ts'\nimport { cleanData, finite, label, records } from './clean.ts'\nimport type { Zoomable } from './view.ts'\n\n/** One period: where the price opened, its range and where it closed. */\nexport interface Candle {\n /** The period (a date for `x: { type: 'time' }`, or any label). */\n x: Label\n open: number\n high: number\n low: number\n close: number\n}\n\n/**\n * A rounded rectangle with the same commands whatever its size and radius\n * (a zero radius draws square corners), so CSS can morph one into another.\n */\nconst bodyPath = (x: number, y: number, w: number, h: number, r: number): string => {\n const a = `A${r},${r},0,0,1,`\n return `M${round(x + r)},${y}H${round(x + w - r)}${a}${round(x + w)},${round(y + r)}V${round(y + h - r)}${a}${round(x + w - r)},${round(y + h)}H${round(x + r)}${a}${x},${round(y + h - r)}V${round(y + r)}${a}${round(x + r)},${y}Z`\n}\n\nexport interface CandlestickOptions extends Zoomable {\n data: readonly Candle[]\n /** Maximum candle body width in pixels. Defaults to `16`. */\n maxCandleWidth?: number\n /** Share of each period left empty between candles, `0…1`. Defaults to `0.3`. */\n groupPadding?: number\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n /** Corner radius of the bodies. Defaults to `1`. */\n radius?: number\n x?: CategoryAxisOptions\n y?: ValueAxisOptions\n /** Reference lines and bands, e.g. a price target or a trading halt. */\n annotations?: readonly Annotation[]\n}\n\nconst UP = 'var(--tc-up-color,var(--tc-color-6))'\nconst DOWN = 'var(--tc-negative-color,var(--tc-color-8))'\n\n/** Whether every price can be placed on the value axis (positive ones only on a log axis). */\nconst valid = (c: Candle, axis: ValueAxisOptions | undefined): boolean =>\n [c.open, c.high, c.low, c.close].every((v) => plottable(v, axis))\n\n/** The candles as four series, for the shared axes, tooltip and table. */\nfunction asCartesian(options: CandlestickOptions): CartesianOptions {\n const pick = (key: 'open' | 'high' | 'low' | 'close') =>\n options.data.map((c) => (valid(c, options.y) ? c[key] : null))\n const data: CartesianData = {\n labels: options.data.map((c) => c.x),\n series: [\n { name: 'Open', values: pick('open') },\n { name: 'High', values: pick('high') },\n { name: 'Low', values: pick('low') },\n { name: 'Close', values: pick('close') },\n ],\n }\n const out: CartesianOptions = { data }\n if (options.x) out.x = options.x\n if (options.y) out.y = options.y\n if (options.padding !== undefined) out.padding = options.padding\n if (options.annotations) out.annotations = options.annotations\n return out\n}\n\n/**\n * Candlestick (OHLC) chart: per period a wick from low to high and a body\n * from open to close, green when it closed higher (`--tc-up-color`) and red\n * when lower (`--tc-negative-color`).\n *\n * ```ts\n * new Chart('#el', {\n * type: candlestick,\n * data: [{ x: '2026-01-01', open: 98, high: 102, low: 89, close: 94 }],\n * x: { type: 'time' },\n * })\n * ```\n */\nexport const candlestick: ChartType<CandlestickOptions> = {\n name: 'candlestick',\n clean: cleanData((data) =>\n records(data, (c) => ({\n ...c,\n x: label(c.x),\n open: finite(c.open),\n high: finite(c.high),\n low: finite(c.low),\n close: finite(c.close),\n })),\n ),\n prepare: windowed,\n render(options, ctx) {\n const { maxCandleWidth = 16, groupPadding = 0.3, radius = 1 } = options\n const cartesian = asCartesian(options)\n const layout = cartesianLayout(cartesian, ctx, {\n scale: 'band',\n zero: false,\n paddingInner: groupPadding,\n paddingOuter: groupPadding / 2,\n })\n const { x, y, labels } = layout\n const width = Math.max(1, Math.min(maxCandleWidth, x.bandwidth))\n const center = (i: number) => x.at(i) + x.bandwidth / 2\n const up = (c: Candle) => c.close >= c.open\n\n const base = categoryInteraction(layout, cartesian, ctx, (_, i, v) => ({\n x: center(i),\n y: y(v),\n }))\n // Tooltip swatches take the color of the candle, not four palette slots.\n const paint = (hit: Hit | null): Hit | null => {\n const candle = hit ? options.data[hit.index] : undefined\n if (!hit || !candle) return hit\n const color = up(candle) ? UP : DOWN\n return { ...hit, items: hit.items.map((item) => ({ ...item, color })) }\n }\n const interaction: Interaction = {\n count: base.count,\n hitIndex: (i, s) => paint(base.hitIndex(i, s)),\n hitTest: (px, py) => paint(base.hitTest(px, py)),\n }\n\n const candles = options.data.map((c, i) => {\n if (!valid(c, options.y)) return null\n const cx = round(center(i))\n const top = y(Math.max(c.open, c.close))\n // A flat period still shows a 1px body.\n const bottom = Math.max(y(Math.min(c.open, c.close)), top + 1)\n const left = round(center(i) - width / 2)\n const r = round(Math.min(radius, width / 2, (bottom - top) / 2))\n return h(\n 'g',\n {\n key: labelKey(labels[i] as Label),\n class: ['tc-candle', up(c) ? 'tc-candle-up' : 'tc-candle-down'],\n },\n h('path', {\n class: 'tc-candle-wick',\n d: `M${cx},${round(y(c.high))}V${round(y(c.low))}`,\n }),\n // A path, not a rect, so it morphs between updates (d), in Safari too.\n h('path', {\n class: 'tc-candle-body',\n d: bodyPath(left, round(top), round(width), round(bottom - top), r),\n }),\n )\n })\n\n const content = [\n h('defs', { key: 'defs' }, layout.clip.def),\n layout.background,\n h(\n 'g',\n { key: 'series', class: 'tc-series-list tc-candles', 'clip-path': layout.clip.url },\n candles,\n ),\n layout.foreground,\n ]\n return { content, interaction }\n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AAM,GAAG,GAAGA,eAAAA,MAAM,KAAK,GAAGA,eAAAA,MAAM,SAAS,GAAG,GAAG,CAAC;GACpE,CAAC,CACH;EACF,CAAC;EAYD,OAAO;GAAE,SAAA;IATPS,cAAAA,EAAE,QAAQ,EAAE,KAAK,OAAO,GAAG,OAAO,KAAK,GAAG;IAC1C,OAAO;IACPA,cAAAA,EACE,KACA;KAAE,KAAK;KAAU,OAAO;KAA6B,aAAa,OAAO,KAAK;IAAI,GAClF,OACF;IACA,OAAO;GAEM;GAAG;EAAY;CAChC;CACA,QAAQ,SAAS,KAAK,UAAUE,kBAAAA,YAAY,YAAY,OAAO,GAAG,KAAK,KAAK;AAC9E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Ct as Zoomable, ft as CategoryAxisOptions, ht as ValueAxisOptions, o as ChartType, pt as Label } from "./chart-CE9EVbfV.js";
|
|
2
|
+
import { n as InsetsInput } from "./layout-CYerDebD.js";
|
|
3
|
+
import { t as Annotation } from "./annotations-CCDUC1lW.js";
|
|
3
4
|
/** One period: where the price opened, its range and where it closed. */
|
|
4
5
|
interface Candle {
|
|
5
6
|
/** The period (a date for `x: { type: 'time' }`, or any label). */
|
|
@@ -9,7 +10,7 @@ interface Candle {
|
|
|
9
10
|
low: number;
|
|
10
11
|
close: number;
|
|
11
12
|
}
|
|
12
|
-
interface CandlestickOptions {
|
|
13
|
+
interface CandlestickOptions extends Zoomable {
|
|
13
14
|
data: readonly Candle[];
|
|
14
15
|
/** Maximum candle body width in pixels. Defaults to `16`. */
|
|
15
16
|
maxCandleWidth?: number;
|
package/dist/candlestick.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dates = require("./dates-
|
|
2
|
+
const require_dates = require("./dates-0YNY49KQ.cjs");
|
|
3
3
|
const require_features = require("./features-DEDP5CEQ.cjs");
|
|
4
|
-
const require_candlestick = require("./candlestick-
|
|
4
|
+
const require_candlestick = require("./candlestick-BwrFKak_.cjs");
|
|
5
5
|
// src/candlestick.ts
|
|
6
6
|
/** Standalone entry: `import { candlestick } from '@tabler/charts/candlestick'`. */
|
|
7
7
|
require_features.register({ dates: require_dates.dateLabels });
|
package/dist/candlestick.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CandlestickOptions, r as candlestick, t as Candle } from "./candlestick-
|
|
1
|
+
import { n as CandlestickOptions, r as candlestick, t as Candle } from "./candlestick-B7YXUVVh.cjs";
|
|
2
2
|
export { type Candle, type CandlestickOptions, candlestick };
|
package/dist/candlestick.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CandlestickOptions, r as candlestick, t as Candle } from "./candlestick-
|
|
1
|
+
import { n as CandlestickOptions, r as candlestick, t as Candle } from "./candlestick-XpqJvarq.js";
|
|
2
2
|
export { type Candle, type CandlestickOptions, candlestick };
|
package/dist/candlestick.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as dateLabels } from "./dates-
|
|
1
|
+
import { t as dateLabels } from "./dates-CKDRgpin.js";
|
|
2
2
|
import { i as register } from "./features-B55rwpQC.js";
|
|
3
|
-
export { t as candlestick } from "./candlestick-
|
|
3
|
+
export { t as candlestick } from "./candlestick-B1onjo1o.js";
|
|
4
4
|
// src/candlestick.ts
|
|
5
5
|
/** Standalone entry: `import { candlestick } from '@tabler/charts/candlestick'`. */
|
|
6
6
|
register({ dates: dateLabels });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_axis = require("./axis-
|
|
1
|
+
const require_axis = require("./axis-BzBkkC5X.cjs");
|
|
2
2
|
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
3
3
|
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
4
4
|
const require_features = require("./features-DEDP5CEQ.cjs");
|
|
@@ -146,6 +146,11 @@ function linear(domain, range, options = {}) {
|
|
|
146
146
|
// src/charts/cartesian.ts
|
|
147
147
|
/** A label as a `key` for keyed rendering (dates by their timestamp). */
|
|
148
148
|
const labelKey = (label) => label instanceof Date ? label.getTime() : label;
|
|
149
|
+
/**
|
|
150
|
+
* The options a chart type draws: the ones given, or only the categories of
|
|
151
|
+
* their `view` (`prepare()` of the chart types that can be zoomed).
|
|
152
|
+
*/
|
|
153
|
+
const windowed = (options) => options.view || options.zoom ? require_features.feature("zoom").window(options) : options;
|
|
149
154
|
/** Stable key of a series: its `id`, or its name. */
|
|
150
155
|
const seriesKey = require_named.keyOf;
|
|
151
156
|
/**
|
|
@@ -311,6 +316,7 @@ function valueAxis(options, ctx, layout, auto, which) {
|
|
|
311
316
|
function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
312
317
|
const { area, x, y, xTicks, yTicks, y2Ticks, horizontal: flip } = plot;
|
|
313
318
|
const xOptions = options.x ?? {};
|
|
319
|
+
const rotate = turned(options, !flip && !time && xOptions.show !== false);
|
|
314
320
|
const opposite = side === "left" ? "right" : "left";
|
|
315
321
|
const notes = notesFeature(options)?.layers(options.annotations, {
|
|
316
322
|
area,
|
|
@@ -330,14 +336,15 @@ function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
|
330
336
|
position: flip ? side : "bottom",
|
|
331
337
|
ticks: xTicks,
|
|
332
338
|
area,
|
|
333
|
-
line: xOptions.line === true
|
|
339
|
+
line: xOptions.line === true,
|
|
340
|
+
rotate
|
|
334
341
|
})];
|
|
335
342
|
const seconds = !!y2Ticks && options.y2?.show !== false && [require_axis.axis({
|
|
336
343
|
position: opposite,
|
|
337
344
|
ticks: y2Ticks,
|
|
338
345
|
area
|
|
339
346
|
})];
|
|
340
|
-
const title = (text, position, ticks) => !!text && require_axis.axisTitle(position, ticks || [], area, text, ctx.fontSize);
|
|
347
|
+
const title = (text, position, ticks) => !!text && require_axis.axisTitle(position, ticks || [], area, text, ctx.fontSize, position === "bottom" && rotate);
|
|
341
348
|
const titles = [
|
|
342
349
|
title(options.y?.title, flip ? "bottom" : side, !!values && yTicks),
|
|
343
350
|
title(xOptions.title, flip ? side : "bottom", xTicks),
|
|
@@ -369,6 +376,8 @@ function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
|
369
376
|
clip: plotClip(ctx, area, overhang)
|
|
370
377
|
};
|
|
371
378
|
}
|
|
379
|
+
/** Whether the category labels are turned 90° (`x.rotate`), when the axis can take it. */
|
|
380
|
+
const turned = (options, able) => able && options.x?.rotate === true;
|
|
372
381
|
/** Compute scales, ticks, grid and axes shared by line, area and bar charts. */
|
|
373
382
|
function cartesianLayout(options, ctx, layout) {
|
|
374
383
|
const { data } = options;
|
|
@@ -402,8 +411,14 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
402
411
|
ticks: (scale) => require_axis.bandTicks(scale, (_, i) => labelAt(i))
|
|
403
412
|
};
|
|
404
413
|
const edgeLabels = xAxis.edges;
|
|
414
|
+
const rotate = turned(options, showX && !timed);
|
|
415
|
+
const allX = rotate ? labels.map((_, i) => ({
|
|
416
|
+
value: i,
|
|
417
|
+
position: 0,
|
|
418
|
+
label: labelAt(i)
|
|
419
|
+
})) : [];
|
|
405
420
|
const halfLine = Math.ceil(fontSize * require_layout.LINE_HEIGHT / 2);
|
|
406
|
-
const edgeWidth = (last) => showX ? require_layout.estimateTextWidth(edgeLabels[last ? edgeLabels.length - 1 : 0] ?? "", fontSize) : 0;
|
|
421
|
+
const edgeWidth = (last) => rotate ? fontSize * require_layout.LINE_HEIGHT : showX ? require_layout.estimateTextWidth(edgeLabels[last ? edgeLabels.length - 1 : 0] ?? "", fontSize) : 0;
|
|
407
422
|
const firstLabel = edgeWidth(reverse !== rtl);
|
|
408
423
|
const lastLabel = edgeWidth(reverse === rtl);
|
|
409
424
|
const edgeX = layout.scale === "point";
|
|
@@ -422,7 +437,7 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
422
437
|
if (!edgeX) both = sides((width - both.start - both.end) / steps);
|
|
423
438
|
return {
|
|
424
439
|
top: pad.top + Math.max(showY || showY2 ? halfLine : 0, overhang, 4),
|
|
425
|
-
bottom: pad.bottom + Math.max((showX ? require_axis.axisSize("bottom", [probeY[0]], fontSize) : showY ? halfLine : 0) + require_axis.axisTitleSize(xOptions.title, fontSize), overhang, 4),
|
|
440
|
+
bottom: pad.bottom + Math.max((rotate ? require_axis.axisSize("bottom", allX, fontSize, { rotate }) : showX ? require_axis.axisSize("bottom", [probeY[0]], fontSize) : showY ? halfLine : 0) + require_axis.axisTitleSize(xOptions.title, fontSize), overhang, 4),
|
|
426
441
|
...both
|
|
427
442
|
};
|
|
428
443
|
});
|
|
@@ -436,7 +451,7 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
436
451
|
x,
|
|
437
452
|
y,
|
|
438
453
|
horizontal: false,
|
|
439
|
-
xTicks: showX ? require_axis.thinTicks(xAxis.ticks(x), "bottom", fontSize) : [],
|
|
454
|
+
xTicks: showX ? rotate ? require_axis.thinTicks(xAxis.ticks(x), "left", fontSize / require_layout.LINE_HEIGHT, 2) : require_axis.thinTicks(xAxis.ticks(x), "bottom", fontSize) : [],
|
|
440
455
|
yTicks
|
|
441
456
|
};
|
|
442
457
|
if (value2 && y2) {
|
|
@@ -487,6 +502,25 @@ function categoryInteraction(layout, options, ctx, anchor, markAt) {
|
|
|
487
502
|
const axisOf = seriesAxes(options);
|
|
488
503
|
const axes = data.series.map((s) => axisOf(s).axis);
|
|
489
504
|
const formats = axes.map((axis) => require_format.formatDetail(axis.format, ctx.locale));
|
|
505
|
+
const yAxis = options.y ?? {};
|
|
506
|
+
const [d0, d1] = layout.y.domain;
|
|
507
|
+
const [r0, r1] = layout.y.range;
|
|
508
|
+
const cursorText = yAxis.scale === "log" || r0 === r1 ? require_format.formatDetail(yAxis.format, ctx.locale) : require_format.formatTicks(Math.abs((d1 - d0) / (r1 - r0)), yAxis.format, ctx.locale);
|
|
509
|
+
const cursorAt = (px, py) => {
|
|
510
|
+
const position = horizontal ? px : py;
|
|
511
|
+
const lo = Math.min(r0, r1);
|
|
512
|
+
const hi = Math.max(r0, r1);
|
|
513
|
+
const value = layout.y.invert(position);
|
|
514
|
+
if (position < lo || position > hi || !Number.isFinite(value)) return void 0;
|
|
515
|
+
const cursor = {
|
|
516
|
+
value,
|
|
517
|
+
text: cursorText(value),
|
|
518
|
+
position,
|
|
519
|
+
side: horizontal ? "bottom" : ctx.rtl ? "right" : "left"
|
|
520
|
+
};
|
|
521
|
+
if (yAxis.show === false) cursor.inside = true;
|
|
522
|
+
return cursor;
|
|
523
|
+
};
|
|
490
524
|
const hitAt = (index) => {
|
|
491
525
|
const start = x.at(index);
|
|
492
526
|
const center = start + x.bandwidth / 2;
|
|
@@ -551,6 +585,8 @@ function categoryInteraction(layout, options, ctx, anchor, markAt) {
|
|
|
551
585
|
const hit = hitAt(index);
|
|
552
586
|
const mark = markAt?.(px, py, index);
|
|
553
587
|
if (mark !== void 0) hit.seriesIndex = mark;
|
|
588
|
+
const cursor = cursorAt(px, py);
|
|
589
|
+
if (cursor) hit.cursor = cursor;
|
|
554
590
|
return hit;
|
|
555
591
|
},
|
|
556
592
|
hitIndex(index, seriesIndex) {
|
|
@@ -734,5 +770,11 @@ Object.defineProperty(exports, "valueTicks", {
|
|
|
734
770
|
return valueTicks;
|
|
735
771
|
}
|
|
736
772
|
});
|
|
773
|
+
Object.defineProperty(exports, "windowed", {
|
|
774
|
+
enumerable: true,
|
|
775
|
+
get: function() {
|
|
776
|
+
return windowed;
|
|
777
|
+
}
|
|
778
|
+
});
|
|
737
779
|
|
|
738
|
-
//# sourceMappingURL=cartesian-
|
|
780
|
+
//# sourceMappingURL=cartesian-B9CrasFJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cartesian-B9CrasFJ.cjs","names":["h","round","ticks","niceDomain","feature","keyOf","legendItems","linearTicks","features","h","finite","extent","niceDomain","axis","axisTitle","bandTicks","LINE_HEIGHT","estimateTextWidth","axisSize","axisTitleSize","plotFrame","thinTicks","groupAttrs","formatDetail","formatTicks"],"sources":["../src/components/grid.ts","../src/scales/band.ts","../src/scales/linear.ts","../src/charts/cartesian.ts"],"sourcesContent":["import type { Rect } from '../layout.ts'\nimport { round } from '../layout.ts'\nimport { h, type VNode } from '../vnode.ts'\nimport type { Tick } from './axis.ts'\n\nexport interface GridOptions {\n /** `'y'` draws horizontal lines at y ticks, `'x'` vertical lines at x ticks. */\n direction: 'x' | 'y'\n ticks: readonly Tick[]\n area: Rect\n}\n\n/**\n * Render grid lines as `<g class=\"tc-grid tc-grid-{x|y}\">`. The line at\n * value `0` also gets `tc-grid-line-zero`, so the baseline can be emphasized.\n */\nexport function grid(options: GridOptions): VNode {\n const { direction, ticks, area } = options\n return h(\n 'g',\n { key: `grid-${direction}`, class: ['tc-grid', `tc-grid-${direction}`], 'aria-hidden': 'true' },\n ticks.map((tick) => {\n const p = round(tick.position)\n return h('line', {\n key: tick.value,\n class: ['tc-grid-line', tick.value === 0 && 'tc-grid-line-zero'],\n // Positioned with a transitionable transform, so lines glide when the scale changes.\n ...(direction === 'y'\n ? {\n x1: area.x,\n x2: area.x + area.width,\n y1: 0,\n y2: 0,\n style: `transform:translateY(${p}px)`,\n }\n : {\n x1: 0,\n x2: 0,\n y1: area.y,\n y2: area.y + area.height,\n style: `transform:translateX(${p}px)`,\n }),\n })\n }),\n )\n}\n","/** Category identifier used by band and point scales. */\nexport type BandKey = string | number\n\nexport interface BandScaleOptions {\n /** Share of each step left empty between bands, `0…1`. Defaults to `0`. */\n paddingInner?: number\n /** Space before the first and after the last band, in steps. Defaults to `0`. */\n paddingOuter?: number\n /** Where leftover space goes: `0` start, `0.5` center, `1` end. Defaults to `0.5`. */\n align?: number\n}\n\n/** Discrete scale splitting a range into equal bands, one per category. */\nexport interface BandScale {\n /** Start of the band for `key`, or `undefined` for unknown keys. */\n (key: BandKey): number | undefined\n readonly domain: readonly BandKey[]\n readonly range: readonly [number, number]\n /** Width of a single band. */\n readonly bandwidth: number\n /** Distance between the starts of adjacent bands. */\n readonly step: number\n /** Start of the band at `index`. */\n at(index: number): number\n /** Center of the band for `key`. */\n center(key: BandKey): number | undefined\n /** Index of the band nearest to `pixel` (for hit testing), or `-1` when empty. */\n indexAt(pixel: number): number\n}\n\n/**\n * Create a band scale, e.g. for bar charts.\n *\n * ```ts\n * const x = band(['Jan', 'Feb', 'Mar'], [0, 300], { paddingInner: 0.2 })\n * x('Feb') // start of the \"Feb\" band\n * x.bandwidth // bar width\n * ```\n */\nexport function band(\n domain: readonly BandKey[],\n range: readonly [number, number],\n options: BandScaleOptions = {},\n): BandScale {\n const { paddingInner = 0, paddingOuter = 0, align = 0.5 } = options\n const inner = Math.min(1, Math.max(0, paddingInner))\n const n = domain.length\n const [r0, r1] = range\n const reverse = r1 < r0\n const lo = reverse ? r1 : r0\n const hi = reverse ? r0 : r1\n\n const step = (hi - lo) / Math.max(1, n - inner + paddingOuter * 2)\n const start = lo + (hi - lo - step * (n - inner)) * align\n const bandwidth = step * (1 - inner)\n\n const index = new Map<BandKey, number>()\n for (let i = 0; i < n; i++) {\n const key = domain[i] as BandKey\n if (!index.has(key)) index.set(key, i)\n }\n\n const at = (i: number): number => start + step * (reverse ? n - 1 - i : i)\n\n const scale = (key: BandKey): number | undefined => {\n const i = index.get(key)\n return i === undefined ? undefined : at(i)\n }\n\n return Object.assign(scale, {\n domain: domain.slice(),\n range: [r0, r1] as const,\n bandwidth,\n step,\n at,\n center(key: BandKey): number | undefined {\n const px = scale(key)\n return px === undefined ? undefined : px + bandwidth / 2\n },\n indexAt(pixel: number): number {\n if (n === 0) return -1\n const raw = step === 0 ? 0 : Math.round((pixel - start - bandwidth / 2) / step)\n const i = Math.min(n - 1, Math.max(0, raw))\n return reverse ? n - 1 - i : i\n },\n })\n}\n\n/**\n * Create a point scale: a band scale with zero-width bands, placing each\n * category on a single point (e.g. line charts over labels).\n * `padding` is the space before the first and after the last point, in steps.\n */\nexport function point(\n domain: readonly BandKey[],\n range: readonly [number, number],\n options: { padding?: number; align?: number } = {},\n): BandScale {\n const { padding = 0, align } = options\n return band(domain, range, {\n paddingInner: 1,\n paddingOuter: padding,\n ...(align === undefined ? {} : { align }),\n })\n}\n","import { niceDomain, ticks } from './ticks.ts'\n\nexport interface LinearScaleOptions {\n /** Clamp output to the range (and `invert()` output to the domain). */\n clamp?: boolean\n}\n\n/** Continuous scale mapping a numeric domain to a pixel range. */\nexport interface LinearScale {\n (value: number): number\n readonly domain: readonly [number, number]\n readonly range: readonly [number, number]\n /** Map a pixel back to a domain value. */\n invert(pixel: number): number\n /** Nice tick values inside the domain. */\n ticks(count?: number): number[]\n /** A copy of the scale with its domain extended to round values. */\n nice(count?: number): LinearScale\n}\n\n/**\n * Create a linear scale.\n *\n * ```ts\n * const y = linear([0, 120], [300, 0]).nice()\n * y(60) // 150\n * ```\n *\n * A zero-width domain (e.g. a single data point) maps to the middle of the range.\n */\nexport function linear(\n domain: readonly [number, number],\n range: readonly [number, number],\n options: LinearScaleOptions = {},\n): LinearScale {\n const [d0, d1] = domain\n const [r0, r1] = range\n const span = d1 - d0\n const k = span === 0 ? 0 : (r1 - r0) / span\n const mid = (r0 + r1) / 2\n const { clamp = false } = options\n const rMin = Math.min(r0, r1)\n const rMax = Math.max(r0, r1)\n const dMin = Math.min(d0, d1)\n const dMax = Math.max(d0, d1)\n\n const scale = (value: number): number => {\n if (span === 0) return mid\n const px = r0 + (value - d0) * k\n return clamp ? Math.min(rMax, Math.max(rMin, px)) : px\n }\n\n return Object.assign(scale, {\n domain: [d0, d1] as const,\n range: [r0, r1] as const,\n invert(pixel: number): number {\n if (span === 0 || r1 === r0) return d0\n const value = d0 + (pixel - r0) / k\n return clamp ? Math.min(dMax, Math.max(dMin, value)) : value\n },\n ticks(count?: number): number[] {\n return ticks(d0, d1, count)\n },\n nice(count?: number): LinearScale {\n return linear(niceDomain(d0, d1, count), range, options)\n },\n })\n}\n","import type { DataTable, LegendItem, RenderContext, TableContext } from '../chart.ts'\nimport {\n axis,\n axisSize,\n axisTitle,\n axisTitleSize,\n bandTicks,\n linearTicks,\n type Tick,\n thinTicks,\n} from '../components/axis.ts'\nimport { grid } from '../components/grid.ts'\nimport { type Features, feature, features } from '../features.ts'\nimport { formatDetail, formatTicks, type NumberFormat } from '../format.ts'\nimport type { Hit, HitCursor, HitItem, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n LINE_HEIGHT,\n type PlotFrame,\n plotFrame,\n type Rect,\n} from '../layout.ts'\nimport { type BandKey, type BandScale, band, point } from '../scales/band.ts'\nimport { extent } from '../scales/extent.ts'\nimport { type LinearScale, linear } from '../scales/linear.ts'\nimport { niceDomain } from '../scales/ticks.ts'\nimport { type ClassValue, h, type Props, type VNode } from '../vnode.ts'\nimport type { Annotation } from './annotations.ts'\nimport { finite } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\nimport type { Zoomable } from './view.ts'\n\n/** Category label on the x axis. */\nexport type Label = string | number | Date\n\n/** A label as a `key` for keyed rendering (dates by their timestamp). */\nexport const labelKey = (label: Label): string | number =>\n label instanceof Date ? label.getTime() : label\n\n/** One data series. `null` values are gaps. */\nexport interface Series {\n /** Display name (legend, tooltip, accessibility). */\n name: string\n /** One value per label; `null`/`undefined` leaves a gap. */\n values: readonly (number | null | undefined)[]\n /** Stable identity for keyed updates. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /**\n * Dashed line: dash and gap length in pixels, or a full `stroke-dasharray`\n * such as `'6 3'`. Sets `--tc-series-dash` on the series group; values\n * that could inject CSS are ignored, as for `color`.\n */\n dash?: number | string\n /**\n * Dash the line only from this label on (a forecast, provisional figures):\n * it stays solid up to the label and takes `dash` (`'5 4'` when left out)\n * after it. Line and area charts.\n */\n dashFrom?: Label\n /** Line width in pixels; overrides `--tc-stroke-width` via `--tc-series-width`. */\n width?: number\n /**\n * In a `bar` chart, draw this series as a line or a filled area over the\n * bars instead (it is left out of stacks). Needs the line module\n * (`@tabler/charts/line`, or `@tabler/charts`). Defaults to `'bar'`.\n */\n type?: 'bar' | 'line' | 'area'\n /**\n * Value axis of the series: `'y2'` draws it against the second axis\n * (options in `y2`), on the right of the plot (on the left in a\n * right-to-left chart), and leaves it out of stacks. Line, area and\n * vertical bar charts. Defaults to `'y'`.\n */\n axis?: 'y' | 'y2'\n /** Extra classes on the series group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n /**\n * Write values on this series' marks, whatever the chart's `valueLabels`\n * says: `true` labels it even when the chart option is off, `false` leaves\n * it out. Needs `@tabler/charts/value-labels` on the core.\n */\n valueLabels?: boolean\n}\n\nexport interface CartesianData {\n /** Categories along x. Defaults to `1…n` for the longest series. */\n labels?: readonly Label[]\n series: readonly Series[]\n}\n\n/** Options for the value (y) axis. */\nexport interface ValueAxisOptions {\n /** Render the axis labels. Defaults to `true`. */\n show?: boolean\n /**\n * Title of the axis (e.g. a unit), beside its labels: turned 90° on the\n * left of the plot, or on the right in a right-to-left chart.\n */\n title?: string\n /** Render horizontal grid lines. Defaults to `true`. */\n grid?: boolean\n /** Fixed lower bound; overrides data and `zero`. */\n min?: number\n /** Fixed upper bound. */\n max?: number\n /** Include zero in the domain. */\n zero?: boolean\n /** Extend the domain to round tick values. Defaults to `true`. */\n nice?: boolean\n /** Approximate tick count. Defaults to one per ~60px of height. */\n ticks?: number\n format?: NumberFormat\n /** `'log'` for a logarithmic axis (positive values only). Defaults to `'linear'`. */\n scale?: 'linear' | 'log'\n}\n\n/** Options for the category (x) axis. */\nexport interface CategoryAxisOptions {\n /** Render the axis labels. Defaults to `true`. */\n show?: boolean\n /** Title of the axis, below its labels. */\n title?: string\n /** Render vertical grid lines. Defaults to `false`. */\n grid?: boolean\n /** Draw the axis line along the bottom edge. Defaults to `false`. */\n line?: boolean\n /** Format a label for display (axis ticks for categories, tooltips and the table). */\n format?: (label: Label, index: number) => string\n /**\n * Turn the labels 90°, reading bottom to top, so that many or long\n * categories all keep their label. Categories along the bottom only: not\n * on a time axis, nor in horizontal bars.\n */\n rotate?: boolean\n /**\n * `'time'` treats labels as dates or timestamps: line and area charts place\n * points at their real distance in time, with calendar-aware ticks.\n * Labels must be in ascending order. Needs `@tabler/charts/time` (included\n * in `@tabler/charts`; candlesticks label dates without it). Defaults to `'category'`.\n */\n type?: 'category' | 'time'\n /** Align time ticks to UTC instead of local time (use it for SSR). */\n utc?: boolean\n /** Run the categories from the right. Defaults to the chart's `rtl`. */\n reverse?: boolean\n}\n\nexport interface CartesianOptions extends Zoomable {\n data: CartesianData\n y?: ValueAxisOptions\n /**\n * The second value axis, for series with `axis: 'y2'` (it is drawn only\n * when a series uses it). Its labels and title stand on the other side of\n * the plot; the grid lines follow `y`.\n */\n y2?: ValueAxisOptions\n x?: CategoryAxisOptions\n /** Reference lines and bands: targets, normal ranges, events and periods. */\n annotations?: readonly Annotation[]\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\nexport interface CartesianLayoutOptions {\n /** `point` places categories on points (lines), `band` on bands (bars). */\n scale: 'point' | 'band'\n /** Values spanning the y domain, when they differ from the raw data (stacks). */\n values?: readonly (number | null | undefined)[]\n /** Format of the value axis ticks, when it differs from `y.format` (percent stacks). */\n tickFormat?: NumberFormat\n /** Default for `y.zero`. */\n zero: boolean\n /** Default for `y2.zero`. Defaults to `zero`. */\n zero2?: boolean\n /** Space marks need beyond the plot edge (point radius, stroke). */\n overhang?: number\n /** Band padding for `scale: 'band'`. */\n paddingInner?: number\n paddingOuter?: number\n}\n\nexport interface CartesianLayout {\n area: Rect\n labels: readonly Label[]\n /** Category scale (along x, or along y when `horizontal`). */\n x: BandScale\n /** Value scale (along y, or along x when `horizontal`). */\n y: LinearScale\n /** Scale of the second value axis, when a series uses it. */\n y2?: LinearScale\n /** Whether categories run along y. */\n horizontal: boolean\n xTicks: Tick[]\n yTicks: Tick[]\n /** Ticks of the second value axis (with `y2`). */\n y2Ticks?: Tick[]\n /** Grid lines, drawn below the marks. */\n background: VNode[]\n /** Axes, drawn above the marks. */\n foreground: VNode[]\n /** Clip path definition and its url, for the marks group. */\n clip: { def: VNode; url: string }\n}\n\n/**\n * The options a chart type draws: the ones given, or only the categories of\n * their `view` (`prepare()` of the chart types that can be zoomed).\n */\nexport const windowed = <O extends Zoomable>(options: O): O =>\n options.view || options.zoom ? feature('zoom').window(options) : options\n\nexport const TICK_SPACING = 60\n/** Horizontal value axes need more room per label. */\nexport const TICK_SPACING_X = 80\n/** Minimal margin around the plot, in pixels. */\nexport const EDGE = 8\n\n/** Stable key of a series: its `id`, or its name. */\nexport const seriesKey: (series: Series) => string = keyOf\n\n/**\n * Whether the chart draws a second value axis: a series asks for it with\n * `axis: 'y2'`, and the values run along y (not in horizontal bars).\n */\nexport const hasY2 = (options: CartesianOptions): boolean =>\n (options as { orientation?: unknown }).orientation !== 'horizontal' &&\n options.data.series.some((s) => s.axis === 'y2')\n\n/**\n * The value axis a series is read on: a function giving each series'\n * axis options, and whether it is the second one.\n */\nexport function seriesAxes(\n options: CartesianOptions,\n): (series: Series | undefined) => { second: boolean; axis: ValueAxisOptions } {\n const second = hasY2(options)\n const y = { second: false, axis: options.y ?? {} }\n const y2 = { second: true, axis: options.y2 ?? {} }\n return (series) => (second && series?.axis === 'y2' ? y2 : y)\n}\n\n/** The scale of a series: the second one for series on `y2`. */\nexport const seriesScale = (\n layout: Pick<CartesianLayout, 'y' | 'y2'>,\n series: Series | undefined,\n): LinearScale => (layout.y2 && series?.axis === 'y2' ? layout.y2 : layout.y)\n\n/** Legend entries for series-based charts. */\nexport const seriesLegend = (data: CartesianData): LegendItem[] => legendItems(data.series)\n\n/** Categories from `data.labels`, or `1…n` for the longest series. */\nexport function resolveLabels(data: CartesianData): Label[] {\n if (data.labels) return data.labels.slice()\n const n = Math.max(0, ...data.series.map((s) => s.values.length))\n return Array.from({ length: n }, (_, i) => i + 1)\n}\n\n/**\n * Whether a value can be plotted on the axis: finite, and positive on a log\n * scale (zero and negatives become gaps there).\n */\nexport function plottable(\n value: number | null | undefined,\n axis: ValueAxisOptions | undefined,\n): value is number {\n if (value == null || !Number.isFinite(value)) return false\n return axis?.scale !== 'log' || value > 0\n}\n\n/**\n * Whether the category axis carries time: `x.type === 'time'` and every label\n * is a date, a timestamp or a parseable string. Otherwise the axis falls back\n * to categories instead of producing NaN positions.\n */\nexport const isTimeAxis = (options: CartesianOptions): boolean =>\n options.x?.type === 'time' && resolveLabels(options.data).every((l) => Number.isFinite(toMs(l)))\n\n/** Formatter for category labels in tooltips and tables. */\nexport function labelFormatter(\n options: CartesianOptions,\n ctx: TableContext,\n): (label: Label, index: number) => string {\n if (options.x?.format) return options.x.format\n if (!isTimeAxis(options)) return (label) => String(label)\n return feature('dates')(resolveLabels(options.data), options.x?.utc, ctx.locale)\n}\n\n/** A label as a timestamp: dates, numbers, or parseable strings (ISO); `NaN` otherwise. */\n// Through Date, so timestamps out of its range are NaN too.\nexport const toMs = (label: Label): number => new Date(label).getTime()\n\n/** Value scale for a domain: linear, or logarithmic with positive-only ticks. */\nexport function valueScale(\n domain: [number, number],\n range: [number, number],\n options: ValueAxisOptions,\n): LinearScale {\n return options.scale === 'log' ? feature('log').scale(domain, range) : linear(domain, range)\n}\n\n/** Ticks of a value scale with labels; log scales format each power as is. */\nexport function valueTicks(\n scale: LinearScale,\n options: ValueAxisOptions,\n count: number,\n format: NumberFormat | undefined,\n locale: RenderContext['locale'],\n): Tick[] {\n return options.scale === 'log'\n ? feature('log').ticks(scale, count, format, locale)\n : linearTicks(scale, { count, format, locale })\n}\n\n/** The point shapes of a chart (`shapes`, or with `patterns: true`), if it has them. */\nexport const markerShape = (options: object): NonNullable<Features['point-shapes']> | undefined => {\n const { shapes, patterns } = options as { shapes?: boolean; patterns?: unknown }\n // On the core, the shapes come with their module (like the points of line charts).\n return (shapes ?? patterns === true) ? features['point-shapes'] : undefined\n}\n\n/**\n * A point of the series in color slot `slot`: a circle, or the slot's marker\n * when the chart has point shapes (see `markerShape`).\n */\nexport function pointMark(\n shape: ReturnType<typeof markerShape>,\n slot: number,\n key: string | number,\n cls: ClassValue,\n cx: number,\n cy: number,\n r: number,\n): VNode {\n return shape\n ? h('path', { key, class: [cls, 'tc-marker'], d: shape(slot, cx, cy, r) })\n : h('circle', { key, class: cls, cx, cy, r })\n}\n\n/** The tick count asked for on an axis (a number up to 100), or `auto`. */\nexport const tickCount = (axis: { ticks?: number } | undefined, auto: number): number =>\n Math.min(finite(axis?.ticks) ?? auto, 100)\n\n/** Y domain from the data and axis options. */\nexport function valueDomain(\n data: CartesianData,\n options: ValueAxisOptions,\n zeroDefault: boolean,\n count: number,\n hidden: ReadonlySet<string> = new Set(),\n override?: readonly (number | null | undefined)[],\n extra: readonly number[] = [],\n): [number, number] {\n // (extra: values to include besides the data, e.g. annotation targets)\n const values =\n override ?? data.series.filter((s) => !hidden.has(seriesKey(s))).flatMap((s) => s.values)\n return domainOf(extra.length ? [...values, ...extra] : values, options, zeroDefault, count)\n}\n\n/** A niced numeric domain for `values`, honouring zero, min, max and nice. */\nexport function domainOf(\n values: readonly (number | null | undefined)[],\n options: ValueAxisOptions,\n zeroDefault: boolean,\n count: number,\n): [number, number] {\n if (options.scale === 'log') return feature('log').domain(values, options)\n // Bounds may come from outside: only numbers count.\n const min = finite(options.min)\n const max = finite(options.max)\n let [lo, hi] = extent(values) ?? [0, 1]\n if (options.zero ?? zeroDefault) {\n lo = Math.min(lo, 0)\n hi = Math.max(hi, 0)\n }\n if (lo === hi) {\n // A flat series still needs a visible range.\n if (lo === 0) {\n hi = 1\n } else {\n const pad = Math.abs(lo) * 0.1\n lo -= pad\n hi += pad\n }\n }\n if (min !== null) lo = min\n if (max !== null) hi = max\n if (options.nice !== false) {\n const [nlo, nhi] = niceDomain(lo, hi, count)\n if (min === null) lo = nlo\n if (max === null) hi = nhi\n }\n return [lo, hi]\n}\n\n/** The annotations feature, when the chart has annotations (it then must be registered). */\nexport function notesFeature(\n options: CartesianOptions,\n): NonNullable<Features['annotations']> | undefined {\n return options.annotations?.length ? feature('annotations') : undefined\n}\n\n/**\n * The category axis of a cartesian layout: the labels at its edges (for the\n * margins), its scale over a pixel range, and its ticks on that scale.\n */\nexport interface CategoryAxis {\n edges: readonly string[]\n scale(range: [number, number]): BandScale\n ticks(scale: BandScale): Tick[]\n /** Pixel position of a date, on time axes (after `scale()`). */\n readonly time?: ((date: Date) => number) | undefined\n}\n\n/**\n * The value axis of a cartesian layout, before the plot area is known: its\n * scale over a pixel range, the ticks of that scale, and `probe`, ticks to\n * measure the labels with (their positions mean nothing). `auto` is the\n * tick count the plot has room for, unless the axis asks for its own.\n */\nexport function valueAxis(\n options: CartesianOptions,\n ctx: RenderContext,\n layout: CartesianLayoutOptions,\n auto: number,\n /** Only the series of this axis (`y` or `y2`); every series when not set. */\n which?: 'y' | 'y2',\n): {\n scale(range: [number, number]): LinearScale\n ticks(scale: LinearScale): Tick[]\n probe: Tick[]\n} {\n const second = which === 'y2'\n const axis = (second ? options.y2 : options.y) ?? {}\n const count = tickCount(axis, Math.max(2, auto))\n let domain: [number, number]\n if (second) {\n const own = options.data.series.filter((s) => s.axis === 'y2')\n const shown = own.filter((s) => !ctx.hidden.has(seriesKey(s)))\n // With all its series hidden, the axis keeps its scale instead of jumping to 0…1.\n const values = (shown.length ? shown : own).flatMap((s) => s.values)\n domain = domainOf(values, axis, layout.zero2 ?? layout.zero, count)\n } else {\n const data =\n which === 'y'\n ? { ...options.data, series: options.data.series.filter((s) => s.axis !== 'y2') }\n : options.data\n domain = valueDomain(\n data,\n axis,\n layout.zero,\n count,\n ctx.hidden,\n layout.values,\n notesFeature(options)?.values(options.annotations),\n )\n }\n const format = second ? axis.format : (layout.tickFormat ?? axis.format)\n const scale = (range: [number, number]) => valueScale(domain, range, axis)\n const ticks = (of: LinearScale) => valueTicks(of, axis, count, format, ctx.locale)\n return { scale, ticks, probe: ticks(scale([0, 1])) }\n}\n\n/**\n * Finish a layout that has its plot area, scales and ticks with what is\n * drawn around the marks: grid lines and annotation bands below them,\n * annotation lines and the axes above. Values run along y and categories\n * along x, or the other way round when `horizontal`. The value axis (the\n * category axis when `horizontal`) sits on the start `side`.\n */\nexport function finishLayout(\n options: CartesianOptions,\n ctx: RenderContext,\n side: PlotFrame['side'],\n overhang: number,\n plot: Omit<CartesianLayout, 'background' | 'foreground' | 'clip'>,\n keys: readonly BandKey[],\n time?: (date: Date) => number,\n): CartesianLayout {\n const { area, x, y, xTicks, yTicks, y2Ticks, horizontal: flip } = plot\n const xOptions = options.x ?? {}\n const rotate = turned(options, !flip && !time && xOptions.show !== false)\n // The second value axis stands on the other side.\n const opposite = side === 'left' ? 'right' : 'left'\n // Annotations: bands under the series, lines above them (and below the axes).\n const notes = notesFeature(options)?.layers(options.annotations, {\n area,\n horizontal: flip,\n fontSize: ctx.fontSize,\n value: y,\n band: x,\n keys,\n time,\n })\n const values = options.y?.show !== false && [\n axis({ position: flip ? 'bottom' : side, ticks: yTicks, area }),\n ]\n const categories = ((xOptions.show !== false && plot.labels.length > 0) || xOptions.line) && [\n axis({\n position: flip ? side : 'bottom',\n ticks: xTicks,\n area,\n line: xOptions.line === true,\n rotate,\n }),\n ]\n // Titles stand past the labels of their axis, or at the plot's edge when it is hidden.\n const seconds = !!y2Ticks &&\n options.y2?.show !== false && [axis({ position: opposite, ticks: y2Ticks, area })]\n const title = (\n text: string | undefined,\n position: 'left' | 'right' | 'bottom',\n ticks: readonly Tick[] | false,\n ) =>\n !!text &&\n axisTitle(position, ticks || [], area, text, ctx.fontSize, position === 'bottom' && rotate)\n const titles = [\n title(options.y?.title, flip ? 'bottom' : side, !!values && yTicks),\n title(xOptions.title, flip ? side : 'bottom', xTicks),\n !!y2Ticks && title(options.y2?.title, opposite, !!seconds && y2Ticks),\n ]\n const present = (parts: (VNode | VNode[] | null | false | undefined)[]): VNode[] =>\n parts.flatMap((part) => part || [])\n return {\n ...plot,\n background: present([\n options.y?.grid !== false && grid({ direction: flip ? 'x' : 'y', ticks: yTicks, area }),\n xOptions.grid && grid({ direction: flip ? 'y' : 'x', ticks: xTicks, area }),\n notes?.under,\n ]),\n // The axis on the left first, then the one at the bottom.\n foreground: present([\n notes?.over,\n flip ? categories : values,\n flip ? values : categories,\n seconds,\n ...titles,\n ]),\n clip: plotClip(ctx, area, overhang),\n }\n}\n\n/** Whether the category labels are turned 90° (`x.rotate`), when the axis can take it. */\nconst turned = (options: CartesianOptions, able: boolean): boolean =>\n able && options.x?.rotate === true\n\n/** Compute scales, ticks, grid and axes shared by line, area and bar charts. */\nexport function cartesianLayout(\n options: CartesianOptions,\n ctx: RenderContext,\n layout: CartesianLayoutOptions,\n): CartesianLayout {\n const { data } = options\n const yOptions = options.y ?? {}\n const xOptions = options.x ?? {}\n const { fontSize, locale, width, height } = ctx\n const overhang = layout.overhang ?? 0\n const rtl = ctx.rtl === true\n const reverse = xOptions.reverse ?? rtl\n const labels = resolveLabels(data)\n const format = labelFormatter(options, ctx)\n const showY = yOptions.show !== false\n const showX = xOptions.show !== false && labels.length > 0\n const timed = isTimeAxis(options) && layout.scale === 'point'\n\n const auto = Math.round(height / TICK_SPACING)\n const second = hasY2(options)\n const value = valueAxis(options, ctx, layout, auto, second ? 'y' : undefined)\n const probeY = value.probe\n const y2Options = options.y2 ?? {}\n const value2 = second ? valueAxis(options, ctx, layout, auto, 'y2') : null\n const showY2 = !!value2 && y2Options.show !== false\n const countX = Math.max(2, Math.round(width / TICK_SPACING_X))\n const keys = labels.map(labelKey)\n const labelAt = (i: number) => format(labels[i] as Label, i)\n // Time axes (from the time module) place points by date, with calendar ticks.\n const xAxis: CategoryAxis = timed\n ? feature('time').axis(labels, keys, xOptions, countX, locale)\n : {\n // No labels, no edges: a custom format is not asked about a label that is not there.\n edges: labels.length ? [labelAt(0), labelAt(labels.length - 1)] : [],\n scale: (range) =>\n layout.scale === 'point'\n ? point(keys, range)\n : band(keys, range, {\n paddingInner: layout.paddingInner ?? 0.3,\n paddingOuter: layout.paddingOuter ?? 0.15,\n }),\n ticks: (scale) => bandTicks(scale, (_: BandKey, i) => labelAt(i)),\n }\n const edgeLabels = xAxis.edges\n const rotate = turned(options, showX && !timed)\n // Every label, to measure the longest when they are turned.\n const allX: Tick[] = rotate\n ? labels.map((_, i) => ({ value: i, position: 0, label: labelAt(i) }))\n : []\n\n // Margins: labels outside the plot, half a line above the top tick,\n // half of the first/last x label for point scales.\n const halfLine = Math.ceil((fontSize * LINE_HEIGHT) / 2)\n // The label at the value axis' end of the plot, and the one at the other end.\n const edgeWidth = (last: boolean) =>\n rotate\n ? fontSize * LINE_HEIGHT\n : showX\n ? estimateTextWidth(edgeLabels[last ? edgeLabels.length - 1 : 0] ?? '', fontSize)\n : 0\n const firstLabel = edgeWidth(reverse !== rtl)\n const lastLabel = edgeWidth(reverse === rtl)\n const edgeX = layout.scale === 'point'\n // On bands a label is centered half a step from the edge: only what is wider\n // than that needs margin (long labels on narrow bands, e.g. dates on candles).\n // The step depends on the margins, so they are worked out twice.\n const valueWidth =\n (showY ? axisSize('left', probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize)\n // The second axis takes the end side (measured as the right, then mirrored).\n const value2Width = value2\n ? (showY2 ? axisSize('right', value2.probe, fontSize) : 0) +\n axisTitleSize(y2Options.title, fontSize)\n : 0\n const { area, side, range } = plotFrame(ctx, options.padding, (pad) => {\n const sides = (halfStep: number) => {\n const overflow = (label: number) =>\n edgeX ? Math.ceil(label / 2) : Math.max(0, Math.ceil(label / 2 - halfStep))\n return {\n start: pad.start + Math.max(valueWidth, overflow(firstLabel), overhang, showY ? 0 : EDGE),\n end: pad.end + Math.max(value2Width, overflow(lastLabel), overhang, EDGE),\n }\n }\n const steps = Math.max(1, labels.length) * 2\n let both = sides((width - pad.start - pad.end - valueWidth - value2Width) / steps)\n if (!edgeX) both = sides((width - both.start - both.end) / steps)\n return {\n top: pad.top + Math.max(showY || showY2 ? halfLine : 0, overhang, EDGE / 2),\n bottom:\n pad.bottom +\n Math.max(\n // Without an x axis, the lowest value label still needs half a line.\n (rotate\n ? axisSize('bottom', allX, fontSize, { rotate })\n : showX\n ? axisSize('bottom', [probeY[0] as Tick], fontSize)\n : showY\n ? halfLine\n : 0) + axisTitleSize(xOptions.title, fontSize),\n overhang,\n EDGE / 2,\n ),\n ...both,\n }\n })\n\n const x = xAxis.scale(range(reverse))\n const y = value.scale([area.y + area.height, area.y])\n const y2 = value2?.scale([area.y + area.height, area.y])\n\n // Nice ticks can outnumber the count asked for: on a short plot, thin them\n // like category labels so none overlap (the grid follows the ticks kept).\n const yTicks = thinTicks(value.ticks(y), 'left', fontSize, 4)\n // Turned labels take the height of their letters along the axis, and little air between them.\n const xTicks = showX\n ? rotate\n ? thinTicks(xAxis.ticks(x), 'left', fontSize / LINE_HEIGHT, 2)\n : thinTicks(xAxis.ticks(x), 'bottom', fontSize)\n : []\n const plot: Omit<CartesianLayout, 'background' | 'foreground' | 'clip'> = {\n area,\n labels,\n x,\n y,\n horizontal: false,\n xTicks,\n yTicks,\n }\n if (value2 && y2) {\n plot.y2 = y2\n plot.y2Ticks = thinTicks(value2.ticks(y2), 'right', fontSize, 4)\n }\n\n return finishLayout(options, ctx, side, overhang, plot, keys, xAxis.time)\n}\n\n/** Clip path around the plot area, a little larger so strokes and dots are not cut. */\nexport function plotClip(\n ctx: RenderContext,\n area: Rect,\n overhang: number,\n): CartesianLayout['clip'] {\n const clipId = `${ctx.id}-clip`\n const bleed = overhang + 1\n return {\n def: h(\n 'clipPath',\n { id: clipId },\n h('rect', {\n x: area.x - bleed,\n y: area.y - bleed,\n width: area.width + bleed * 2,\n height: area.height + bleed * 2,\n }),\n ),\n url: `url(#${clipId})`,\n }\n}\n\n/** Attributes shared by every series group. */\nexport function seriesAttrs(series: Series, index: number): Props {\n const { dash, width } = series\n return {\n ...groupAttrs(series, index),\n // A map, so values from data cannot inject CSS (see normalizeStyle).\n style: {\n '--tc-series-color': series.color,\n '--tc-series-dash': Number.isFinite(dash) ? `${dash}px` : dash,\n '--tc-series-width': Number.isFinite(width) ? `${width}px` : undefined,\n },\n }\n}\n\n/** Pixels around the plot area that still count as hovering it. */\nconst HOVER_SLOP = 8\n\n/**\n * Interaction by category: the nearest category to the pointer while it is\n * over the plot area, with every visible series' value there. `anchor`\n * places each value (line point, bar end, and the bar's box); `markAt` names the series of the\n * mark directly under the pointer, if the chart has distinct marks (bars).\n * Labels and values are formatted with `x.format` / `y.format` and the locale.\n */\nexport function categoryInteraction(\n layout: CartesianLayout,\n options: CartesianOptions,\n ctx: RenderContext,\n anchor: (\n seriesIndex: number,\n index: number,\n value: number,\n ) => { x: number; y: number; box?: Rect },\n markAt?: (x: number, y: number, index: number) => number | undefined,\n): Interaction {\n const { area, x, labels, horizontal } = layout\n const { data } = options\n const formatLabel = labelFormatter(options, ctx)\n const axisOf = seriesAxes(options)\n // Each series reads its values like its axis: bounds (log) and format.\n const axes = data.series.map((s) => axisOf(s).axis)\n const formats = axes.map((axis) => formatDetail(axis.format, ctx.locale))\n // The value under the pointer, on the first value axis, a pixel precise.\n const yAxis = options.y ?? {}\n const [d0, d1] = layout.y.domain\n const [r0, r1] = layout.y.range\n const cursorText =\n yAxis.scale === 'log' || r0 === r1\n ? formatDetail(yAxis.format, ctx.locale)\n : formatTicks(Math.abs((d1 - d0) / (r1 - r0)), yAxis.format, ctx.locale)\n const cursorAt = (px: number, py: number): HitCursor | undefined => {\n const position = horizontal ? px : py\n const lo = Math.min(r0, r1)\n const hi = Math.max(r0, r1)\n const value = layout.y.invert(position)\n if (position < lo || position > hi || !Number.isFinite(value)) return undefined\n const cursor: HitCursor = {\n value,\n text: cursorText(value),\n position,\n side: horizontal ? 'bottom' : ctx.rtl ? 'right' : 'left',\n }\n if (yAxis.show === false) cursor.inside = true\n return cursor\n }\n\n const hitAt = (index: number): Hit => {\n const start = x.at(index)\n const center = start + x.bandwidth / 2\n const label = labels[index] as Label\n // Where a missing value is anchored: the category center on its axis.\n const empty = horizontal ? { x: area.x, y: center } : { x: center, y: null }\n const items: HitItem[] = []\n data.series.forEach((series, seriesIndex) => {\n if (ctx.hidden.has(seriesKey(series))) return\n const raw = series.values[index]\n const value = plottable(raw, axes[seriesIndex]) ? raw : null\n const point = value === null ? empty : anchor(seriesIndex, index, value)\n const item: HitItem = {\n name: series.name,\n seriesIndex,\n value,\n text: value === null ? '–' : (formats[seriesIndex] as (v: number) => string)(value),\n ...point,\n }\n if (series.color) item.color = series.color\n items.push(item)\n })\n // Horizontal bars run the categories along y: the hit sits at the plot center on x.\n const hit: Hit = {\n index,\n label: labelKey(label),\n title: formatLabel(label, index),\n x: horizontal ? area.x + area.width / 2 : center,\n area,\n items,\n }\n if (horizontal) {\n hit.y = center\n hit.axis = 'y'\n }\n if (x.bandwidth > 0) {\n hit.highlight = horizontal\n ? { kind: 'band', x: area.x, y: start, width: area.width, height: x.bandwidth }\n : { kind: 'band', x: start, y: area.y, width: x.bandwidth, height: area.height }\n }\n return hit\n }\n\n return {\n count: labels.length,\n reversed: x.range[1] < x.range[0],\n hitTest(px, py) {\n if (labels.length === 0) return null\n if (\n px < area.x - HOVER_SLOP ||\n px > area.x + area.width + HOVER_SLOP ||\n py < area.y - HOVER_SLOP ||\n py > area.y + area.height + HOVER_SLOP\n ) {\n return null\n }\n const index = x.indexAt(horizontal ? py : px)\n const hit = hitAt(index)\n const mark = markAt?.(px, py, index)\n if (mark !== undefined) hit.seriesIndex = mark\n const cursor = cursorAt(px, py)\n if (cursor) hit.cursor = cursor\n return hit\n },\n hitIndex(index, seriesIndex) {\n if (index < 0 || index >= labels.length) return null\n const hit = hitAt(index)\n if (seriesIndex !== undefined && hit.items.some((item) => item.seriesIndex === seriesIndex)) {\n hit.seriesIndex = seriesIndex\n }\n return hit\n },\n }\n}\n\n/** Accessible table of series values: one row per category, one column per visible series. */\nexport function seriesTable(\n options: CartesianOptions,\n ctx: TableContext,\n limit: number = Number.POSITIVE_INFINITY,\n): DataTable {\n const all = resolveLabels(options.data)\n const labels = all.length > limit ? all.slice(0, limit) : all\n const formatLabel = labelFormatter(options, ctx)\n const axisOf = seriesAxes(options)\n const series = options.data.series.filter((s) => !ctx.hidden.has(seriesKey(s)))\n const formats = series.map((s) => formatDetail(axisOf(s).axis.format, ctx.locale))\n return {\n columns: ['', ...series.map((s) => s.name)],\n total: all.length,\n rows: labels.map((label, i) => [\n formatLabel(label, i),\n ...series.map((s, n) => {\n const v = s.values[i]\n return v == null || !Number.isFinite(v) ? '–' : (formats[n] as (v: number) => string)(v)\n }),\n ]),\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,KAAK,SAA6B;CAChD,MAAM,EAAE,WAAW,OAAO,SAAS;CACnC,OAAOA,cAAAA,EACL,KACA;EAAE,KAAK,QAAQ;EAAa,OAAO,CAAC,WAAW,WAAW,WAAW;EAAG,eAAe;CAAO,GAC9F,MAAM,KAAK,SAAS;EAClB,MAAM,IAAIC,eAAAA,MAAM,KAAK,QAAQ;EAC7B,OAAOD,cAAAA,EAAE,QAAQ;GACf,KAAK,KAAK;GACV,OAAO,CAAC,gBAAgB,KAAK,UAAU,KAAK,mBAAmB;GAE/D,GAAI,cAAc,MACd;IACE,IAAI,KAAK;IACT,IAAI,KAAK,IAAI,KAAK;IAClB,IAAI;IACJ,IAAI;IACJ,OAAO,wBAAwB,EAAE;GACnC,IACA;IACE,IAAI;IACJ,IAAI;IACJ,IAAI,KAAK;IACT,IAAI,KAAK,IAAI,KAAK;IAClB,OAAO,wBAAwB,EAAE;GACnC;EACN,CAAC;CACH,CAAC,CACH;AACF;;;;;;;;;;;ACNA,SAAgB,KACd,QACA,OACA,UAA4B,CAAC,GAClB;CACX,MAAM,EAAE,eAAe,GAAG,eAAe,GAAG,QAAQ,OAAQ;CAC5D,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,YAAY,CAAC;CACnD,MAAM,IAAI,OAAO;CACjB,MAAM,CAAC,IAAI,MAAM;CACjB,MAAM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SACA,KACA,QAAgB,OAAO,mBACZ;CACX,MAAM,MAAM,cAAc,QAAQ,IAAI;CACtC,MAAM,SAAS,IAAI,SAAS,QAAQ,IAAI,MAAM,GAAG,KAAK,IAAI;CAC1D,MAAM,cAAc,eAAe,SAAS,GAAG;CAC/C,MAAM,SAAS,WAAW,OAAO;CACjC,MAAM,SAAS,QAAQ,KAAK,OAAO,QAAQ,MAAM,CAAC,IAAI,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC;CAC9E,MAAM,UAAU,OAAO,KAAK,MAAMD,eAAAA,aAAa,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC;CACjF,OAAO;EACL,SAAS,CAAC,IAAI,GAAG,OAAO,KAAK,MAAM,EAAE,IAAI,CAAC;EAC1C,OAAO,IAAI;EACX,MAAM,OAAO,KAAK,OAAO,MAAM,CAC7B,YAAY,OAAO,CAAC,GACpB,GAAG,OAAO,KAAK,GAAG,MAAM;GACtB,MAAM,IAAI,EAAE,OAAO;GACnB,OAAO,KAAK,QAAQ,CAAC,OAAO,SAAS,CAAC,IAAI,MAAO,QAAQ,EAAE,CAA2B,CAAC;EACzF,CAAC,CACH,CAAC;CACH;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as bandTicks, c as niceDomain, d as ticks, i as axisTitleSize, n as axisSize, o as linearTicks, r as axisTitle, s as thinTicks, t as axis } from "./axis-
|
|
1
|
+
import { a as bandTicks, c as niceDomain, d as ticks, i as axisTitleSize, n as axisSize, o as linearTicks, r as axisTitle, s as thinTicks, t as axis } from "./axis-C5obgdJt.js";
|
|
2
2
|
import { n as estimateTextWidth, o as plotFrame, s as round, t as LINE_HEIGHT } from "./layout-DqAte3H8.js";
|
|
3
3
|
import { t as h } from "./vnode-_EMUqysL.js";
|
|
4
4
|
import { n as feature, r as features } from "./features-B55rwpQC.js";
|
|
5
|
-
import { n as formatDetail } from "./format-it1kepFG.js";
|
|
5
|
+
import { i as formatTicks, n as formatDetail } from "./format-it1kepFG.js";
|
|
6
6
|
import { t as extent } from "./extent-DOV8rs-6.js";
|
|
7
7
|
import { i as finite } from "./clean-CkoQobGv.js";
|
|
8
8
|
import { n as keyOf, r as legendItems, t as groupAttrs } from "./named-BOiBah6I.js";
|
|
@@ -146,6 +146,11 @@ function linear(domain, range, options = {}) {
|
|
|
146
146
|
// src/charts/cartesian.ts
|
|
147
147
|
/** A label as a `key` for keyed rendering (dates by their timestamp). */
|
|
148
148
|
const labelKey = (label) => label instanceof Date ? label.getTime() : label;
|
|
149
|
+
/**
|
|
150
|
+
* The options a chart type draws: the ones given, or only the categories of
|
|
151
|
+
* their `view` (`prepare()` of the chart types that can be zoomed).
|
|
152
|
+
*/
|
|
153
|
+
const windowed = (options) => options.view || options.zoom ? feature("zoom").window(options) : options;
|
|
149
154
|
/** Stable key of a series: its `id`, or its name. */
|
|
150
155
|
const seriesKey = keyOf;
|
|
151
156
|
/**
|
|
@@ -311,6 +316,7 @@ function valueAxis(options, ctx, layout, auto, which) {
|
|
|
311
316
|
function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
312
317
|
const { area, x, y, xTicks, yTicks, y2Ticks, horizontal: flip } = plot;
|
|
313
318
|
const xOptions = options.x ?? {};
|
|
319
|
+
const rotate = turned(options, !flip && !time && xOptions.show !== false);
|
|
314
320
|
const opposite = side === "left" ? "right" : "left";
|
|
315
321
|
const notes = notesFeature(options)?.layers(options.annotations, {
|
|
316
322
|
area,
|
|
@@ -330,14 +336,15 @@ function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
|
330
336
|
position: flip ? side : "bottom",
|
|
331
337
|
ticks: xTicks,
|
|
332
338
|
area,
|
|
333
|
-
line: xOptions.line === true
|
|
339
|
+
line: xOptions.line === true,
|
|
340
|
+
rotate
|
|
334
341
|
})];
|
|
335
342
|
const seconds = !!y2Ticks && options.y2?.show !== false && [axis({
|
|
336
343
|
position: opposite,
|
|
337
344
|
ticks: y2Ticks,
|
|
338
345
|
area
|
|
339
346
|
})];
|
|
340
|
-
const title = (text, position, ticks) => !!text && axisTitle(position, ticks || [], area, text, ctx.fontSize);
|
|
347
|
+
const title = (text, position, ticks) => !!text && axisTitle(position, ticks || [], area, text, ctx.fontSize, position === "bottom" && rotate);
|
|
341
348
|
const titles = [
|
|
342
349
|
title(options.y?.title, flip ? "bottom" : side, !!values && yTicks),
|
|
343
350
|
title(xOptions.title, flip ? side : "bottom", xTicks),
|
|
@@ -369,6 +376,8 @@ function finishLayout(options, ctx, side, overhang, plot, keys, time) {
|
|
|
369
376
|
clip: plotClip(ctx, area, overhang)
|
|
370
377
|
};
|
|
371
378
|
}
|
|
379
|
+
/** Whether the category labels are turned 90° (`x.rotate`), when the axis can take it. */
|
|
380
|
+
const turned = (options, able) => able && options.x?.rotate === true;
|
|
372
381
|
/** Compute scales, ticks, grid and axes shared by line, area and bar charts. */
|
|
373
382
|
function cartesianLayout(options, ctx, layout) {
|
|
374
383
|
const { data } = options;
|
|
@@ -402,8 +411,14 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
402
411
|
ticks: (scale) => bandTicks(scale, (_, i) => labelAt(i))
|
|
403
412
|
};
|
|
404
413
|
const edgeLabels = xAxis.edges;
|
|
414
|
+
const rotate = turned(options, showX && !timed);
|
|
415
|
+
const allX = rotate ? labels.map((_, i) => ({
|
|
416
|
+
value: i,
|
|
417
|
+
position: 0,
|
|
418
|
+
label: labelAt(i)
|
|
419
|
+
})) : [];
|
|
405
420
|
const halfLine = Math.ceil(fontSize * LINE_HEIGHT / 2);
|
|
406
|
-
const edgeWidth = (last) => showX ? estimateTextWidth(edgeLabels[last ? edgeLabels.length - 1 : 0] ?? "", fontSize) : 0;
|
|
421
|
+
const edgeWidth = (last) => rotate ? fontSize * LINE_HEIGHT : showX ? estimateTextWidth(edgeLabels[last ? edgeLabels.length - 1 : 0] ?? "", fontSize) : 0;
|
|
407
422
|
const firstLabel = edgeWidth(reverse !== rtl);
|
|
408
423
|
const lastLabel = edgeWidth(reverse === rtl);
|
|
409
424
|
const edgeX = layout.scale === "point";
|
|
@@ -422,7 +437,7 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
422
437
|
if (!edgeX) both = sides((width - both.start - both.end) / steps);
|
|
423
438
|
return {
|
|
424
439
|
top: pad.top + Math.max(showY || showY2 ? halfLine : 0, overhang, 4),
|
|
425
|
-
bottom: pad.bottom + Math.max((showX ? axisSize("bottom", [probeY[0]], fontSize) : showY ? halfLine : 0) + axisTitleSize(xOptions.title, fontSize), overhang, 4),
|
|
440
|
+
bottom: pad.bottom + Math.max((rotate ? axisSize("bottom", allX, fontSize, { rotate }) : showX ? axisSize("bottom", [probeY[0]], fontSize) : showY ? halfLine : 0) + axisTitleSize(xOptions.title, fontSize), overhang, 4),
|
|
426
441
|
...both
|
|
427
442
|
};
|
|
428
443
|
});
|
|
@@ -436,7 +451,7 @@ function cartesianLayout(options, ctx, layout) {
|
|
|
436
451
|
x,
|
|
437
452
|
y,
|
|
438
453
|
horizontal: false,
|
|
439
|
-
xTicks: showX ? thinTicks(xAxis.ticks(x), "bottom", fontSize) : [],
|
|
454
|
+
xTicks: showX ? rotate ? thinTicks(xAxis.ticks(x), "left", fontSize / LINE_HEIGHT, 2) : thinTicks(xAxis.ticks(x), "bottom", fontSize) : [],
|
|
440
455
|
yTicks
|
|
441
456
|
};
|
|
442
457
|
if (value2 && y2) {
|
|
@@ -487,6 +502,25 @@ function categoryInteraction(layout, options, ctx, anchor, markAt) {
|
|
|
487
502
|
const axisOf = seriesAxes(options);
|
|
488
503
|
const axes = data.series.map((s) => axisOf(s).axis);
|
|
489
504
|
const formats = axes.map((axis) => formatDetail(axis.format, ctx.locale));
|
|
505
|
+
const yAxis = options.y ?? {};
|
|
506
|
+
const [d0, d1] = layout.y.domain;
|
|
507
|
+
const [r0, r1] = layout.y.range;
|
|
508
|
+
const cursorText = yAxis.scale === "log" || r0 === r1 ? formatDetail(yAxis.format, ctx.locale) : formatTicks(Math.abs((d1 - d0) / (r1 - r0)), yAxis.format, ctx.locale);
|
|
509
|
+
const cursorAt = (px, py) => {
|
|
510
|
+
const position = horizontal ? px : py;
|
|
511
|
+
const lo = Math.min(r0, r1);
|
|
512
|
+
const hi = Math.max(r0, r1);
|
|
513
|
+
const value = layout.y.invert(position);
|
|
514
|
+
if (position < lo || position > hi || !Number.isFinite(value)) return void 0;
|
|
515
|
+
const cursor = {
|
|
516
|
+
value,
|
|
517
|
+
text: cursorText(value),
|
|
518
|
+
position,
|
|
519
|
+
side: horizontal ? "bottom" : ctx.rtl ? "right" : "left"
|
|
520
|
+
};
|
|
521
|
+
if (yAxis.show === false) cursor.inside = true;
|
|
522
|
+
return cursor;
|
|
523
|
+
};
|
|
490
524
|
const hitAt = (index) => {
|
|
491
525
|
const start = x.at(index);
|
|
492
526
|
const center = start + x.bandwidth / 2;
|
|
@@ -551,6 +585,8 @@ function categoryInteraction(layout, options, ctx, anchor, markAt) {
|
|
|
551
585
|
const hit = hitAt(index);
|
|
552
586
|
const mark = markAt?.(px, py, index);
|
|
553
587
|
if (mark !== void 0) hit.seriesIndex = mark;
|
|
588
|
+
const cursor = cursorAt(px, py);
|
|
589
|
+
if (cursor) hit.cursor = cursor;
|
|
554
590
|
return hit;
|
|
555
591
|
},
|
|
556
592
|
hitIndex(index, seriesIndex) {
|
|
@@ -578,6 +614,6 @@ function seriesTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
|
|
|
578
614
|
})])
|
|
579
615
|
};
|
|
580
616
|
}
|
|
581
|
-
export {
|
|
617
|
+
export { windowed as C, grid as D, point as E, valueTicks as S, band as T, seriesTable as _, labelFormatter as a, valueAxis as b, plotClip as c, resolveLabels as d, seriesAttrs as f, seriesScale as g, seriesLegend as h, finishLayout as i, plottable as l, seriesKey as m, categoryInteraction as n, labelKey as o, seriesAxes as p, domainOf as r, markerShape as s, cartesianLayout as t, pointMark as u, tickCount as v, linear as w, valueScale as x, toMs as y };
|
|
582
618
|
|
|
583
|
-
//# sourceMappingURL=cartesian-
|
|
619
|
+
//# sourceMappingURL=cartesian-COglz544.js.map
|