@tabler/charts 0.1.0 → 0.3.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 +92 -4
- package/dist/{annotations-Bp7HwtF5.d.ts → annotations-B02GR_KU.d.ts} +3 -8
- package/dist/{annotations-BszTTjf9.js → annotations-BQ8l-qHs.js} +6 -7
- package/dist/{annotations-BszTTjf9.js.map → annotations-BQ8l-qHs.js.map} +1 -1
- package/dist/{annotations-lyt0I3HU.d.cts → annotations-CHafaGd4.d.cts} +3 -8
- package/dist/{annotations-DpETO8dE.cjs → annotations-CpCWA29b.cjs} +6 -7
- package/dist/{annotations-DpETO8dE.cjs.map → annotations-CpCWA29b.cjs.map} +1 -1
- package/dist/annotations.cjs +3 -5
- package/dist/annotations.cjs.map +1 -1
- package/dist/annotations.d.cts +2 -1
- package/dist/annotations.d.ts +2 -1
- package/dist/annotations.js +3 -4
- package/dist/{arc-a1tRTEw7.js → arc-B3V5IR0w.js} +2 -3
- package/dist/{arc-a1tRTEw7.js.map → arc-B3V5IR0w.js.map} +1 -1
- package/dist/{arc-BXpLrt9b.cjs → arc-CYhI62kO.cjs} +2 -3
- package/dist/{arc-BXpLrt9b.cjs.map → arc-CYhI62kO.cjs.map} +1 -1
- package/dist/{area-CF__HOwL.d.ts → area-DEFQm_SQ.d.ts} +3 -6
- package/dist/{area-sHCE3pg5.cjs → area-DYdQ_sMV.cjs} +5 -6
- package/dist/{area-sHCE3pg5.cjs.map → area-DYdQ_sMV.cjs.map} +1 -1
- package/dist/{area-DQsLERhx.js → area-WdtfqvhX.js} +5 -6
- package/dist/{area-DQsLERhx.js.map → area-WdtfqvhX.js.map} +1 -1
- package/dist/{area-DIxaAbYZ.d.cts → area-h_FvieFb.d.cts} +3 -6
- package/dist/area.cjs +1 -1
- package/dist/area.d.cts +2 -1
- package/dist/area.d.ts +2 -1
- package/dist/area.js +1 -2
- package/dist/axis-MMaVoSWB.js +235 -0
- package/dist/axis-MMaVoSWB.js.map +1 -0
- package/dist/axis-YfAerNBA.cjs +300 -0
- package/dist/axis-YfAerNBA.cjs.map +1 -0
- package/dist/{band-DTcNDAFO.d.ts → band-CNKvdnTC.d.cts} +1 -4
- package/dist/{band-DTcNDAFO.d.cts → band-CNKvdnTC.d.ts} +1 -4
- package/dist/{bar-jZEoao74.js → bar-BOcRcArc.js} +80 -62
- package/dist/bar-BOcRcArc.js.map +1 -0
- package/dist/{bar-C-7zR2qp.cjs → bar-CVkOJ7WA.cjs} +82 -64
- package/dist/bar-CVkOJ7WA.cjs.map +1 -0
- package/dist/{bar-DM16NUvV.js → bar-CgpC2EpX.js} +3 -4
- package/dist/{bar-DM16NUvV.js.map → bar-CgpC2EpX.js.map} +1 -1
- package/dist/{bar-BBM8RhoL.d.ts → bar-D9B_arKf.d.ts} +4 -7
- package/dist/{bar-CRKLDg98.d.cts → bar-DZCQ-kyf.d.cts} +4 -7
- package/dist/{bar-DGuUN3nc.cjs → bar-wVykm1us.cjs} +3 -4
- package/dist/{bar-DGuUN3nc.cjs.map → bar-wVykm1us.cjs.map} +1 -1
- package/dist/bar.cjs +1 -1
- package/dist/bar.d.cts +2 -1
- package/dist/bar.d.ts +2 -1
- package/dist/bar.js +1 -2
- package/dist/calendar-BSvO8nRb.d.cts +106 -0
- package/dist/calendar-BXgIX5H1.js +502 -0
- package/dist/calendar-BXgIX5H1.js.map +1 -0
- package/dist/calendar-Bq3vFzPl.d.ts +106 -0
- package/dist/calendar-DAFXjV99.cjs +507 -0
- package/dist/calendar-DAFXjV99.cjs.map +1 -0
- package/dist/calendar.cjs +3 -0
- package/dist/calendar.d.cts +3 -0
- package/dist/calendar.d.ts +3 -0
- package/dist/calendar.js +1 -0
- package/dist/{candlestick-D_vV0_XZ.d.ts → candlestick-B3WcLzph.d.ts} +3 -6
- package/dist/{candlestick-__pXl_pV.d.cts → candlestick-BcomxeVG.d.cts} +3 -6
- package/dist/{candlestick-DuXwAFID.js → candlestick-BtT9glp9.js} +19 -18
- package/dist/{candlestick-DuXwAFID.js.map → candlestick-BtT9glp9.js.map} +1 -1
- package/dist/{candlestick-B5r1w3kc.cjs → candlestick-CSmRuZ4v.cjs} +19 -18
- package/dist/{candlestick-B5r1w3kc.cjs.map → candlestick-CSmRuZ4v.cjs.map} +1 -1
- package/dist/candlestick.cjs +4 -5
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +4 -6
- package/dist/{cartesian-Cr0AF0nG.js → cartesian-BrPqb5Qn.js} +138 -264
- package/dist/cartesian-BrPqb5Qn.js.map +1 -0
- package/dist/{cartesian-BoDfgBCV.cjs → cartesian-DRSXHxWe.cjs} +162 -324
- package/dist/cartesian-DRSXHxWe.cjs.map +1 -0
- package/dist/{chart-BF2CK9I_.js → chart-B6TTY4Kr.js} +120 -77
- package/dist/chart-B6TTY4Kr.js.map +1 -0
- package/dist/{chart-DyN7bcx8.d.ts → chart-CYrrUCi3.d.ts} +222 -102
- package/dist/{chart-D7ooEFnk.d.cts → chart-CbPzP5Dp.d.cts} +248 -102
- package/dist/{chart-CowF_lWY.cjs → chart-D_lyOy-M.cjs} +132 -83
- package/dist/chart-D_lyOy-M.cjs.map +1 -0
- package/dist/{circle-BQMuAfls.cjs → circle-Bwxy5j7B.cjs} +2 -3
- package/dist/{circle-BQMuAfls.cjs.map → circle-Bwxy5j7B.cjs.map} +1 -1
- package/dist/{circle-Z7YfCoCM.js → circle-YRDaOBpk.js} +2 -3
- package/dist/{circle-Z7YfCoCM.js.map → circle-YRDaOBpk.js.map} +1 -1
- package/dist/{clean-o1vDEhFV.js → clean-CkoQobGv.js} +3 -4
- package/dist/{clean-o1vDEhFV.js.map → clean-CkoQobGv.js.map} +1 -1
- package/dist/{clean-Byl6kzf0.cjs → clean-Die2iCNc.cjs} +8 -3
- package/dist/{clean-Byl6kzf0.cjs.map → clean-Die2iCNc.cjs.map} +1 -1
- package/dist/{core-D1vO1LrC.d.cts → core-9BnLEW4K.d.cts} +31 -72
- package/dist/{core-DcbemzGf.d.ts → core-C3qEppSm.d.ts} +10 -46
- package/dist/{core-CegR_j55.js → core-CQ0FaJ4G.js} +138 -99
- package/dist/core-CQ0FaJ4G.js.map +1 -0
- package/dist/{core-RzS9IQO5.cjs → core-D2PSked3.cjs} +139 -100
- package/dist/core-D2PSked3.cjs.map +1 -0
- package/dist/core.cjs +47 -33
- package/dist/core.d.cts +26 -21
- package/dist/core.d.ts +26 -21
- package/dist/core.js +31 -25
- package/dist/{dates-CG-FvioW.js → dates-DLe2Ww64.js} +4 -5
- package/dist/{dates-CG-FvioW.js.map → dates-DLe2Ww64.js.map} +1 -1
- package/dist/{dates-Btm7Zm6W.cjs → dates-DerXTb1J.cjs} +4 -5
- package/dist/{dates-Btm7Zm6W.cjs.map → dates-DerXTb1J.cjs.map} +1 -1
- package/dist/{decimate-tLhDk1ys.cjs → decimate-BS3x8g-f.cjs} +2 -3
- package/dist/{decimate-tLhDk1ys.cjs.map → decimate-BS3x8g-f.cjs.map} +1 -1
- package/dist/{decimate-BGg9XgF0.d.ts → decimate-BxxYBJJk.d.cts} +2 -5
- package/dist/{decimate-C87cl_Sp.js → decimate-CapfgiDY.js} +2 -3
- package/dist/{decimate-C87cl_Sp.js.map → decimate-CapfgiDY.js.map} +1 -1
- package/dist/{decimate-CNSpgGa5.d.cts → decimate-Du87fMLG.d.ts} +2 -5
- package/dist/decimate.cjs +3 -4
- package/dist/decimate.d.cts +1 -1
- package/dist/decimate.d.ts +1 -1
- package/dist/decimate.js +3 -4
- package/dist/{dom-CLF868Qs.cjs → dom-C33zvtPo.cjs} +5 -11
- package/dist/dom-C33zvtPo.cjs.map +1 -0
- package/dist/{dom-vP3IcMak.js → dom-CTse6Rvd.js} +5 -11
- package/dist/dom-CTse6Rvd.js.map +1 -0
- package/dist/{export-chart-BhhYgksr.cjs → export-chart-CPtXmZvi.cjs} +18 -14
- package/dist/export-chart-CPtXmZvi.cjs.map +1 -0
- package/dist/{export-chart-9w8t3rjZ.js → export-chart-DoeiAyR2.js} +18 -14
- package/dist/export-chart-DoeiAyR2.js.map +1 -0
- package/dist/export.cjs +3 -5
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +8 -1
- package/dist/export.d.ts +8 -1
- package/dist/export.js +3 -4
- package/dist/{extent-BAMZo0Nq.js → extent-DOV8rs-6.js} +2 -3
- package/dist/{extent-BAMZo0Nq.js.map → extent-DOV8rs-6.js.map} +1 -1
- package/dist/{extent-DsFWvAHJ.cjs → extent-DuYDcvM9.cjs} +2 -3
- package/dist/{extent-DsFWvAHJ.cjs.map → extent-DuYDcvM9.cjs.map} +1 -1
- package/dist/{fade-D3NxH5Qg.js → fade-CDrQjnDz.js} +59 -83
- package/dist/fade-CDrQjnDz.js.map +1 -0
- package/dist/{fade-Cs74puQS.cjs → fade-CRqcKMWY.cjs} +59 -83
- package/dist/fade-CRqcKMWY.cjs.map +1 -0
- package/dist/{features-wASyHGic.js → features-B55rwpQC.js} +5 -4
- package/dist/features-B55rwpQC.js.map +1 -0
- package/dist/{features-BclHgg2W.cjs → features-DEDP5CEQ.cjs} +10 -3
- package/dist/features-DEDP5CEQ.cjs.map +1 -0
- package/dist/fit-BPyPRnsK.js +16 -0
- package/dist/fit-BPyPRnsK.js.map +1 -0
- package/dist/fit-D4MIIQQz.cjs +21 -0
- package/dist/fit-D4MIIQQz.cjs.map +1 -0
- package/dist/{format-B0yKXBTH.cjs → format-CAE5ruy6.cjs} +2 -3
- package/dist/{format-B0yKXBTH.cjs.map → format-CAE5ruy6.cjs.map} +1 -1
- package/dist/{format-lStwuc1L.js → format-it1kepFG.js} +2 -3
- package/dist/{format-lStwuc1L.js.map → format-it1kepFG.js.map} +1 -1
- package/dist/funnel-BdcfUkb5.d.ts +50 -0
- package/dist/funnel-CFEEulw_.cjs +244 -0
- package/dist/funnel-CFEEulw_.cjs.map +1 -0
- package/dist/funnel-CYCv8cq2.js +239 -0
- package/dist/funnel-CYCv8cq2.js.map +1 -0
- package/dist/funnel-CarOh8w_.d.cts +50 -0
- package/dist/funnel.cjs +3 -0
- package/dist/funnel.d.cts +3 -0
- package/dist/funnel.d.ts +3 -0
- package/dist/funnel.js +1 -0
- package/dist/{gauge-D-FYhuds.cjs → gauge-6HfDcLMJ.cjs} +35 -36
- package/dist/gauge-6HfDcLMJ.cjs.map +1 -0
- package/dist/{gauge-Dh423FHh.js → gauge-DiTk5aWO.js} +35 -36
- package/dist/gauge-DiTk5aWO.js.map +1 -0
- package/dist/{gauge-zpia05t2.d.ts → gauge-Ds9k1UV2.d.cts} +5 -8
- package/dist/{gauge-DP_EB2z3.d.cts → gauge-Zy25jfps.d.ts} +5 -8
- package/dist/gauge.cjs +1 -1
- package/dist/gauge.d.cts +2 -1
- package/dist/gauge.d.ts +2 -1
- package/dist/gauge.js +1 -2
- package/dist/{heatmap-DSZ2bVIa.js → heatmap-C1v8bwpq.js} +43 -43
- package/dist/heatmap-C1v8bwpq.js.map +1 -0
- package/dist/{heatmap-BectCEeE.d.ts → heatmap-CJ-0dfhJ.d.cts} +4 -7
- package/dist/{heatmap-BK18EBgJ.cjs → heatmap-Dcc_bsoQ.cjs} +47 -47
- package/dist/heatmap-Dcc_bsoQ.cjs.map +1 -0
- package/dist/{heatmap-CCso6m61.d.cts → heatmap-Jp5sHRTo.d.ts} +4 -7
- package/dist/heatmap.cjs +1 -1
- package/dist/heatmap.d.cts +2 -1
- package/dist/heatmap.d.ts +2 -1
- package/dist/heatmap.js +1 -2
- package/dist/{hydrate-DDNIHYv_.js → hydrate-BB3MlR36.js} +3 -4
- package/dist/{hydrate-DDNIHYv_.js.map → hydrate-BB3MlR36.js.map} +1 -1
- package/dist/{hydrate-CzfxLfTv.d.ts → hydrate-BtAZf_5K.d.cts} +2 -5
- package/dist/{hydrate-CTTmQy0x.d.cts → hydrate-OjM1pIUG.d.ts} +2 -5
- package/dist/{hydrate-CxwTXDqO.cjs → hydrate-m0I5m6ue.cjs} +3 -4
- package/dist/hydrate-m0I5m6ue.cjs.map +1 -0
- package/dist/hydrate.cjs +3 -4
- package/dist/hydrate.cjs.map +1 -1
- package/dist/hydrate.d.cts +1 -1
- package/dist/hydrate.d.ts +1 -1
- package/dist/hydrate.js +3 -4
- package/dist/index.cjs +72 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -28
- package/dist/index.d.ts +28 -28
- package/dist/index.js +52 -44
- package/dist/index.js.map +1 -1
- package/dist/interaction-DXYSjgnP.cjs +32 -0
- package/dist/interaction-DXYSjgnP.cjs.map +1 -0
- package/dist/interaction-En1KlwFO.js +21 -0
- package/dist/interaction-En1KlwFO.js.map +1 -0
- package/dist/{layout-CtMBhNd9.cjs → layout-Cfg9x1k2.cjs} +45 -3
- package/dist/layout-Cfg9x1k2.cjs.map +1 -0
- package/dist/{layout-B3hiqVEw.js → layout-DqAte3H8.js} +34 -4
- package/dist/layout-DqAte3H8.js.map +1 -0
- package/dist/{line-CN4uZ9ZX.d.ts → line-Bpr5uVLQ.d.ts} +4 -7
- package/dist/{line-B3Ed6u7j.js → line-CxR4tg1Q.js} +49 -38
- package/dist/line-CxR4tg1Q.js.map +1 -0
- package/dist/{line-fQbtP_jL.cjs → line-YiCuhVMI.cjs} +49 -38
- package/dist/line-YiCuhVMI.cjs.map +1 -0
- package/dist/{line-W7VD_qs1.d.cts → line-vyWO030v.d.cts} +4 -7
- package/dist/line.cjs +4 -5
- package/dist/line.cjs.map +1 -1
- package/dist/line.d.cts +1 -1
- package/dist/line.d.ts +1 -1
- package/dist/line.js +4 -6
- package/dist/{log-CaofN3-n.d.ts → log-CI41TmcU.d.cts} +1 -6
- package/dist/{log-CaofN3-n.d.cts → log-CI41TmcU.d.ts} +1 -6
- package/dist/{log-axis-83rSpvL5.cjs → log-axis-DdRNyAq8.cjs} +6 -8
- package/dist/{log-axis-83rSpvL5.cjs.map → log-axis-DdRNyAq8.cjs.map} +1 -1
- package/dist/{log-axis-B_uvvOFc.js → log-axis-DhthtHFk.js} +6 -8
- package/dist/{log-axis-B_uvvOFc.js.map → log-axis-DhthtHFk.js.map} +1 -1
- package/dist/log.cjs +3 -5
- package/dist/log.cjs.map +1 -1
- package/dist/log.d.cts +1 -1
- package/dist/log.d.ts +1 -1
- package/dist/log.js +3 -4
- package/dist/map-49FcfdmJ.d.cts +156 -0
- package/dist/map-BMC61J-P.d.ts +156 -0
- package/dist/map-BqrZ80vT.cjs +818 -0
- package/dist/map-BqrZ80vT.cjs.map +1 -0
- package/dist/map-C15NC7kW.js +807 -0
- package/dist/map-C15NC7kW.js.map +1 -0
- package/dist/map.cjs +4 -0
- package/dist/map.d.cts +3 -0
- package/dist/map.d.ts +3 -0
- package/dist/map.js +1 -0
- package/dist/maps/world.cjs +875 -0
- package/dist/maps/world.cjs.map +1 -0
- package/dist/maps/world.d.cts +2 -0
- package/dist/maps/world.d.ts +2 -0
- package/dist/maps/world.js +874 -0
- package/dist/maps/world.js.map +1 -0
- package/dist/{morph-CqYDu1bY.cjs → morph-3I1Nf_tR.cjs} +4 -5
- package/dist/morph-3I1Nf_tR.cjs.map +1 -0
- package/dist/{morph-BMxz3X2b.d.ts → morph-Dh7gJkV4.d.cts} +1 -4
- package/dist/{morph-BMxz3X2b.d.cts → morph-Dh7gJkV4.d.ts} +1 -4
- package/dist/{morph-Bgg-24l8.js → morph-GfBab-b3.js} +4 -5
- package/dist/{morph-Bgg-24l8.js.map → morph-GfBab-b3.js.map} +1 -1
- package/dist/morph.cjs +3 -4
- package/dist/morph.cjs.map +1 -1
- package/dist/morph.d.cts +1 -1
- package/dist/morph.d.ts +1 -1
- package/dist/morph.js +3 -4
- package/dist/{named-BWWb5LQJ.cjs → named-BBASc8dW.cjs} +2 -3
- package/dist/{named-BWWb5LQJ.cjs.map → named-BBASc8dW.cjs.map} +1 -1
- package/dist/{named-DE15TOgh.js → named-BOiBah6I.js} +2 -3
- package/dist/{named-DE15TOgh.js.map → named-BOiBah6I.js.map} +1 -1
- package/dist/others-DBIGE6jr.js +57 -0
- package/dist/others-DBIGE6jr.js.map +1 -0
- package/dist/others-DBO4Kjwl.d.ts +29 -0
- package/dist/others-WfjCsjqT.cjs +68 -0
- package/dist/others-WfjCsjqT.cjs.map +1 -0
- package/dist/others-ls5eKtZ4.d.cts +31 -0
- package/dist/{parliament-Dw0sOERi.js → parliament-BKN6ikBJ.js} +36 -36
- package/dist/parliament-BKN6ikBJ.js.map +1 -0
- package/dist/{parliament-1Zv2Xh0D.d.ts → parliament-C7V8UJj1.d.cts} +5 -8
- package/dist/{parliament-DdrLVZwt.d.cts → parliament-Cz9n_DoK.d.ts} +5 -8
- package/dist/{parliament-CpWnoEvG.cjs → parliament-DhxAaIZ3.cjs} +36 -36
- package/dist/parliament-DhxAaIZ3.cjs.map +1 -0
- package/dist/parliament.cjs +1 -1
- package/dist/parliament.d.cts +2 -1
- package/dist/parliament.d.ts +2 -1
- package/dist/parliament.js +1 -2
- package/dist/{path-CwB28da0.d.ts → path-YeUiOfG8.d.cts} +1 -4
- package/dist/{path-CwB28da0.d.cts → path-YeUiOfG8.d.ts} +1 -4
- package/dist/{patterns-DtgcnA8o.js → patterns-BMUINoka.js} +4 -5
- package/dist/{patterns-DtgcnA8o.js.map → patterns-BMUINoka.js.map} +1 -1
- package/dist/{patterns-LfcQAWCy.cjs → patterns-Dw7OMD_2.cjs} +4 -5
- package/dist/{patterns-LfcQAWCy.cjs.map → patterns-Dw7OMD_2.cjs.map} +1 -1
- package/dist/patterns.cjs +3 -5
- package/dist/patterns.cjs.map +1 -1
- package/dist/patterns.d.cts +5 -1
- package/dist/patterns.d.ts +5 -1
- package/dist/patterns.js +3 -4
- package/dist/percentage-bar-BChkTRoz.cjs +164 -0
- package/dist/percentage-bar-BChkTRoz.cjs.map +1 -0
- package/dist/percentage-bar-CaInxrL8.js +159 -0
- package/dist/percentage-bar-CaInxrL8.js.map +1 -0
- package/dist/percentage-bar-R1--2grK.d.cts +58 -0
- package/dist/percentage-bar-cSeiLdwU.d.ts +58 -0
- package/dist/percentage-bar.cjs +3 -0
- package/dist/percentage-bar.d.cts +3 -0
- package/dist/percentage-bar.d.ts +3 -0
- package/dist/percentage-bar.js +1 -0
- package/dist/{pie-BF9yI5mE.d.cts → pie-BQQkvy1N.d.ts} +11 -11
- package/dist/{pie-DzUXDTcn.js → pie-Bd8wyrtY.js} +52 -55
- package/dist/pie-Bd8wyrtY.js.map +1 -0
- package/dist/{pie-BxTZt6Go.cjs → pie-BseZlCgP.cjs} +52 -55
- package/dist/pie-BseZlCgP.cjs.map +1 -0
- package/dist/{pie-5z1fDdKO.d.ts → pie-vD5-g8je.d.cts} +11 -11
- package/dist/pie.cjs +1 -1
- package/dist/pie.d.cts +2 -1
- package/dist/pie.d.ts +2 -1
- package/dist/pie.js +1 -2
- package/dist/{point-shapes-CGl4dugc.cjs → point-shapes-BRawRM78.cjs} +24 -24
- package/dist/point-shapes-BRawRM78.cjs.map +1 -0
- package/dist/{point-shapes-DI84NNpI.js → point-shapes-DI6GhcI7.js} +19 -25
- package/dist/point-shapes-DI6GhcI7.js.map +1 -0
- package/dist/point-shapes.cjs +7 -6
- package/dist/point-shapes.cjs.map +1 -1
- package/dist/point-shapes.d.cts +6 -2
- package/dist/point-shapes.d.ts +6 -2
- package/dist/point-shapes.js +8 -7
- package/dist/point-shapes.js.map +1 -1
- package/dist/{radar-1-EryihA.d.ts → radar-7I6hsY_h.d.cts} +4 -7
- package/dist/{radar-CYPab_I4.js → radar-D6XqkFWQ.js} +25 -27
- package/dist/radar-D6XqkFWQ.js.map +1 -0
- package/dist/{radar-CoGUNNSb.cjs → radar-DjISDnSf.cjs} +26 -28
- package/dist/radar-DjISDnSf.cjs.map +1 -0
- package/dist/{radar-DBW4O0Vt.d.cts → radar-vLxilcr4.d.ts} +4 -7
- package/dist/radar.cjs +1 -1
- package/dist/radar.d.cts +2 -1
- package/dist/radar.d.ts +2 -1
- package/dist/radar.js +1 -2
- package/dist/rect-CZTNvMlf.js +11 -0
- package/dist/rect-CZTNvMlf.js.map +1 -0
- package/dist/rect-DPr9QRxl.cjs +16 -0
- package/dist/rect-DPr9QRxl.cjs.map +1 -0
- package/dist/{sankey-Bacx4fVe.cjs → sankey-0CSp_Er9.cjs} +100 -95
- package/dist/sankey-0CSp_Er9.cjs.map +1 -0
- package/dist/{sankey-OV_WoPrl.d.ts → sankey-7As41Fo4.d.ts} +4 -7
- package/dist/{sankey-B4PNKusJ.js → sankey-Dp4CuLVe.js} +100 -95
- package/dist/sankey-Dp4CuLVe.js.map +1 -0
- package/dist/{sankey-DuGI3Qc5.d.cts → sankey-DqiuxUx7.d.cts} +4 -7
- package/dist/sankey.cjs +1 -1
- package/dist/sankey.d.cts +2 -1
- package/dist/sankey.d.ts +2 -1
- package/dist/sankey.js +1 -2
- package/dist/{scatter-DbxLyZX0.d.cts → scatter-BXkXGgM_.d.ts} +14 -9
- package/dist/{scatter-DgMN9zRy.cjs → scatter-Bwkblr4L.cjs} +47 -42
- package/dist/scatter-Bwkblr4L.cjs.map +1 -0
- package/dist/{scatter-kgtgR318.js → scatter-DCMAtt5L.js} +45 -40
- package/dist/scatter-DCMAtt5L.js.map +1 -0
- package/dist/{scatter-BqzgJqdX.d.ts → scatter-DL0zAV09.d.cts} +14 -9
- package/dist/scatter.cjs +1 -1
- package/dist/scatter.d.cts +2 -1
- package/dist/scatter.d.ts +2 -1
- package/dist/scatter.js +1 -2
- package/dist/{sparkline-BfyO_oNM.d.ts → sparkline-BElUSd0r.d.ts} +5 -8
- package/dist/{sparkline-BS9-hltA.cjs → sparkline-BMSuEPHP.cjs} +22 -23
- package/dist/sparkline-BMSuEPHP.cjs.map +1 -0
- package/dist/{sparkline-BQzt27Fr.js → sparkline-NDmq90kP.js} +22 -23
- package/dist/sparkline-NDmq90kP.js.map +1 -0
- package/dist/{sparkline-CWlJDKyh.d.cts → sparkline-RYly7bR0.d.cts} +5 -8
- package/dist/sparkline.cjs +1 -1
- package/dist/sparkline.d.cts +2 -1
- package/dist/sparkline.d.ts +2 -1
- package/dist/sparkline.js +1 -2
- package/dist/{stack-DVhJWaki.cjs → stack-BO4624CY.cjs} +3 -4
- package/dist/{stack-DVhJWaki.cjs.map → stack-BO4624CY.cjs.map} +1 -1
- package/dist/{stack-CpR6RGKd.d.ts → stack-BTWYIwLO.d.cts} +2 -4
- package/dist/{stack-CpR6RGKd.d.cts → stack-DR0eQTsB.d.ts} +1 -4
- package/dist/{stack-DRbwTeF3.js → stack-jVKvg2x_.js} +3 -4
- package/dist/{stack-DRbwTeF3.js.map → stack-jVKvg2x_.js.map} +1 -1
- package/dist/style.css +1 -1
- package/dist/{sweep-CbfR7--d.js → sweep-BpRPlhs6.js} +5 -6
- package/dist/{sweep-CbfR7--d.js.map → sweep-BpRPlhs6.js.map} +1 -1
- package/dist/{sweep-DaTEDDuC.cjs → sweep-Dnp6LDBz.cjs} +5 -6
- package/dist/sweep-Dnp6LDBz.cjs.map +1 -0
- package/dist/{time-CNVnt-B2.d.cts → time-B4oxWHQI.d.cts} +2 -7
- package/dist/{time-CHjiY9Q4.d.ts → time-DRIDgv2a.d.ts} +2 -7
- package/dist/{time-axis-VSX34_Tb.cjs → time-axis-B3VekUfX.cjs} +11 -11
- package/dist/{time-axis-VSX34_Tb.cjs.map → time-axis-B3VekUfX.cjs.map} +1 -1
- package/dist/{time-axis-Bc9eHX1r.js → time-axis-CLjqOakA.js} +10 -10
- package/dist/{time-axis-Bc9eHX1r.js.map → time-axis-CLjqOakA.js.map} +1 -1
- package/dist/time.cjs +4 -6
- package/dist/time.cjs.map +1 -1
- package/dist/time.d.cts +1 -1
- package/dist/time.d.ts +1 -1
- package/dist/time.js +4 -5
- package/dist/treemap-25vHO_UK.d.cts +65 -0
- package/dist/treemap-BCXUbixd.d.ts +65 -0
- package/dist/treemap-C4glsx-g.js +293 -0
- package/dist/treemap-C4glsx-g.js.map +1 -0
- package/dist/treemap-CZk8kKFD.cjs +298 -0
- package/dist/treemap-CZk8kKFD.cjs.map +1 -0
- package/dist/treemap.cjs +3 -0
- package/dist/treemap.d.cts +3 -0
- package/dist/treemap.d.ts +3 -0
- package/dist/treemap.js +1 -0
- package/dist/{tween-BCYd0RTY.js → tween-BdQqUmmv.js} +2 -3
- package/dist/{tween-BCYd0RTY.js.map → tween-BdQqUmmv.js.map} +1 -1
- package/dist/{tween-CIGBlryn.cjs → tween-c3aOmfKE.cjs} +2 -3
- package/dist/{tween-CIGBlryn.cjs.map → tween-c3aOmfKE.cjs.map} +1 -1
- package/dist/{value-labels-IZIQPhfk.js → value-labels-C7GrhOXJ.js} +30 -10
- package/dist/value-labels-C7GrhOXJ.js.map +1 -0
- package/dist/{value-labels-B0WJoJ7x.cjs → value-labels-DzaKIWKp.cjs} +30 -10
- package/dist/value-labels-DzaKIWKp.cjs.map +1 -0
- package/dist/value-labels.cjs +3 -5
- package/dist/value-labels.cjs.map +1 -1
- package/dist/value-labels.d.cts +5 -1
- package/dist/value-labels.d.ts +5 -1
- package/dist/value-labels.js +3 -4
- package/dist/{vnode-CkQ27Cxe.cjs → vnode-ClAiw28x.cjs} +2 -3
- package/dist/{vnode-CkQ27Cxe.cjs.map → vnode-ClAiw28x.cjs.map} +1 -1
- package/dist/{vnode-BUflsBsa.d.ts → vnode-Du2cC8Fm.d.cts} +1 -4
- package/dist/{vnode-BUflsBsa.d.cts → vnode-Du2cC8Fm.d.ts} +1 -4
- package/dist/{vnode-tCWItoUH.js → vnode-_EMUqysL.js} +2 -3
- package/dist/{vnode-tCWItoUH.js.map → vnode-_EMUqysL.js.map} +1 -1
- package/package.json +94 -214
- package/dist/bar-C-7zR2qp.cjs.map +0 -1
- package/dist/bar-jZEoao74.js.map +0 -1
- package/dist/cartesian-BoDfgBCV.cjs.map +0 -1
- package/dist/cartesian-Cr0AF0nG.js.map +0 -1
- package/dist/chart-BF2CK9I_.js.map +0 -1
- package/dist/chart-CowF_lWY.cjs.map +0 -1
- package/dist/core-CegR_j55.js.map +0 -1
- package/dist/core-RzS9IQO5.cjs.map +0 -1
- package/dist/dom-CLF868Qs.cjs.map +0 -1
- package/dist/dom-vP3IcMak.js.map +0 -1
- package/dist/export-chart-9w8t3rjZ.js.map +0 -1
- package/dist/export-chart-BhhYgksr.cjs.map +0 -1
- package/dist/fade-Cs74puQS.cjs.map +0 -1
- package/dist/fade-D3NxH5Qg.js.map +0 -1
- package/dist/features-BclHgg2W.cjs.map +0 -1
- package/dist/features-wASyHGic.js.map +0 -1
- package/dist/gauge-D-FYhuds.cjs.map +0 -1
- package/dist/gauge-Dh423FHh.js.map +0 -1
- package/dist/heatmap-BK18EBgJ.cjs.map +0 -1
- package/dist/heatmap-DSZ2bVIa.js.map +0 -1
- package/dist/hydrate-CxwTXDqO.cjs.map +0 -1
- package/dist/layout-B3hiqVEw.js.map +0 -1
- package/dist/layout-CtMBhNd9.cjs.map +0 -1
- package/dist/line-B3Ed6u7j.js.map +0 -1
- package/dist/line-fQbtP_jL.cjs.map +0 -1
- package/dist/morph-CqYDu1bY.cjs.map +0 -1
- package/dist/parliament-CpWnoEvG.cjs.map +0 -1
- package/dist/parliament-Dw0sOERi.js.map +0 -1
- package/dist/pie-BxTZt6Go.cjs.map +0 -1
- package/dist/pie-DzUXDTcn.js.map +0 -1
- package/dist/point-shapes-CGl4dugc.cjs.map +0 -1
- package/dist/point-shapes-DI84NNpI.js.map +0 -1
- package/dist/radar-CYPab_I4.js.map +0 -1
- package/dist/radar-CoGUNNSb.cjs.map +0 -1
- package/dist/sankey-B4PNKusJ.js.map +0 -1
- package/dist/sankey-Bacx4fVe.cjs.map +0 -1
- package/dist/scatter-DgMN9zRy.cjs.map +0 -1
- package/dist/scatter-kgtgR318.js.map +0 -1
- package/dist/sparkline-BQzt27Fr.js.map +0 -1
- package/dist/sparkline-BS9-hltA.cjs.map +0 -1
- package/dist/sweep-DaTEDDuC.cjs.map +0 -1
- package/dist/value-labels-B0WJoJ7x.cjs.map +0 -1
- package/dist/value-labels-IZIQPhfk.js.map +0 -1
package/README.md
CHANGED
|
@@ -81,13 +81,18 @@ A feature you use but did not import throws an error that names the import.
|
|
|
81
81
|
| `line` | `{ labels, series }` | `curve` (`'monotone'`, `'linear'`, `'step'` …), `points` (`'none'`, `'last'`, `'all'`), `area`, `stacked`, `connectNulls`, `decimate` |
|
|
82
82
|
| `area` | `{ labels, series }` | as `line`, filled; `fill: 'gradient' \| 'solid'` |
|
|
83
83
|
| `bar` | `{ labels, series }` | `stacked` (`true` or `'percent'`), `orientation: 'horizontal'`, `radius`, `gap`, `maxBarWidth`; `series[].type: 'line' \| 'area'` mixes in lines |
|
|
84
|
-
| `pie`, `donut` | `[{ name, value }]` | `innerRadius`, `gap`, `cornerRadius`, `center` (text in the middle) |
|
|
84
|
+
| `pie`, `donut` | `[{ name, value }]` | `innerRadius`, `gap`, `cornerRadius`, `center` (text in the middle), `maxSlices` (the rest is grouped into `othersLabel`) |
|
|
85
85
|
| `gauge` | a number, a ring or rings | `max`, `startAngle`, `angle` (`270` for a dial), `thickness`, `center` |
|
|
86
86
|
| `radar` | `{ labels, series }` | `grid: 'polygon' \| 'circle'`, `fill`, `points`, `r` (radial axis), `labelWidth` (long spoke labels wrap at their spaces, by default past a quarter of the width) |
|
|
87
87
|
| `sankey` | `{ nodes?, links: [{ from, to, value }] }` | `nodeWidth`, `nodePadding`, `align: 'justify' \| 'left'`, `format`; nodes with a `color` make the legend |
|
|
88
88
|
| `parliament` | `[{ name, seats }]` | `total` (vacant seats), `rows`, `angle` (`180` for a hemicycle), `innerRadius`, `gap`, `center` |
|
|
89
|
+
| `treemap` | `[{ name, value }]`, or groups `[{ name, children }]` | `gap`, `radius`, `labels` (names and values in the tiles), `format`; `--tc-treemap-opacity` fades the tiles |
|
|
90
|
+
| `percentageBar` | `[{ name, value }]` | `order: 'data' \| 'size'`, `maxSlices` (the rest is grouped into `othersLabel`), `gap`, `radius`, `format`; a strip 16 px tall unless `height` is set |
|
|
91
|
+
| `funnel` | `[{ name, value }]`, in the order of the process | `labels` (name, value and share of the first stage above every stage), `radius`, `format`; `--tc-funnel-color` is the color the stages shade towards |
|
|
89
92
|
| `scatter` | `{ series: [{ name, points: [{ x, y, size? }] }] }` | `radius`, `size` (bubble radii); points with `size` are bubbles |
|
|
90
93
|
| `heatmap` | `{ labels, series }` (rows) | `min`, `max`, `ranges`, `colors` + `mid` (scales), `colorBy: 'series'` |
|
|
94
|
+
| `calendar` | `[{ date, value }]`, or `{ series }` of them (added up per day) | `weeks`, `from`, `to` (more than a year is split into bands of twelve months), `weekStart`, `levels`, `min`, `max`, `colors` + `mid` (a scale of colors, `'diverging'` around zero), `scale`, `dateFormat`; the height follows the range unless `aspectRatio` or `height` is set |
|
|
95
|
+
| `map` | `{ PL: 80, DE: 45 }` (a value per region code) | `map` (a map file such as `world` from `@tabler/charts/maps/world`, or the name given with `addMap()`), `min`, `max`, `colors` + `mid`, `markers` (`{ name, lat, lng }`), `lines` (`{ from, to }`), `markerRadius`, `scale`, `zoom`, `view`, `select`, `selected`, `onSelect`; the proportions follow the map unless `aspectRatio` or `height` is set |
|
|
91
96
|
| `candlestick` | `[{ x, open, high, low, close }]` | time axes, `maxCandleWidth` |
|
|
92
97
|
| `sparkline` | `number[]` | `variant` (`'line'`, `'area'`, `'bar'`, `'tristate'`), `point`, `markers: 'minmax'` |
|
|
93
98
|
|
|
@@ -96,8 +101,30 @@ A feature you use but did not import throws an error that names the import.
|
|
|
96
101
|
Series take `name`, `values`, and optionally `id` (stable identity), `color`, `dash`, `width`, `class` and `hidden`.
|
|
97
102
|
|
|
98
103
|
Cartesian charts share two axes:
|
|
99
|
-
- `x`: `format`, `type: 'time'`, `utc`, `grid`, `line`, `show`.
|
|
100
|
-
- `y`: `min`, `max`, `zero`, `nice`, `ticks`, `format`, `scale: 'log'`, `grid`, `show`.
|
|
104
|
+
- `x`: `format`, `type: 'time'`, `utc`, `grid`, `line`, `show`, `title`.
|
|
105
|
+
- `y`: `min`, `max`, `zero`, `nice`, `ticks`, `format`, `scale: 'log'`, `grid`, `show`, `title`.
|
|
106
|
+
- `y2`: the same as `y`, for series with `axis: 'y2'`.
|
|
107
|
+
|
|
108
|
+
An axis `title` names the axis (a unit, for example): `y.title` is turned 90° beside the value axis — on the right in an `rtl` chart — and `x.title` sits below the categories. Style both with `.tc-axis-title`.
|
|
109
|
+
|
|
110
|
+
A series with `axis: 'y2'` is drawn against a second value axis on the right (on the left in `rtl`), with its own scale; `y2` takes the same options as `y`. Use it for series in different units, such as daily sales as bars and the average price per person as a line:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
new Chart('#chart', {
|
|
114
|
+
type: bar,
|
|
115
|
+
data: {
|
|
116
|
+
labels,
|
|
117
|
+
series: [
|
|
118
|
+
{ name: 'Net revenue', values: revenue },
|
|
119
|
+
{ name: 'Net revenue / PAX', values: perPax, type: 'line', axis: 'y2' },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
y: { title: 'Net revenue' },
|
|
123
|
+
y2: { title: 'Net revenue / PAX' },
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Series on `y2` stay out of stacks (their bars stand beside the stack), and the grid lines follow `y`. Line, area and vertical bar charts.
|
|
101
128
|
|
|
102
129
|
A number `format` is `Intl.NumberFormat` options or a function. `notation: 'compact'` shortens long numbers in the locale's words ("1.1M", "1,1 mln" in Polish); `compactSymbols` writes suffixes of your own in the locale's separators instead:
|
|
103
130
|
|
|
@@ -116,6 +143,36 @@ annotations: [
|
|
|
116
143
|
]
|
|
117
144
|
```
|
|
118
145
|
|
|
146
|
+
### Maps
|
|
147
|
+
|
|
148
|
+
`map` draws the regions of a map file as SVG shapes and shades them by value. The shapes are projected when the map file is built, so no geo library ships to the browser, and the map file is an import of its own:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { Chart, map } from '@tabler/charts'
|
|
152
|
+
import { world } from '@tabler/charts/maps/world'
|
|
153
|
+
|
|
154
|
+
new Chart('#visits', {
|
|
155
|
+
type: map,
|
|
156
|
+
map: world,
|
|
157
|
+
data: { US: 100, DE: 80, PL: 54 }, // by ISO 3166-1 alpha-2 code
|
|
158
|
+
markers: [
|
|
159
|
+
{ name: 'Warsaw', lat: 52.23, lng: 21.01 },
|
|
160
|
+
{ name: 'New York', lat: 40.71, lng: -74.01 },
|
|
161
|
+
],
|
|
162
|
+
lines: [{ from: 'Warsaw', to: 'New York' }],
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Regions take one hue from the empty shade to the full color (`--tc-heat-color` and `--tc-heat-empty`, as heatmap cells do), or a scale through `colors`. Countries too small for a shape are drawn as a dot when they have a value. `--tc-map-marker-color` and `--tc-map-line-color` color the markers and the lines. The `click` event gives the region code in `hit.region` (or the marker's name in `hit.marker`).
|
|
167
|
+
|
|
168
|
+
`zoom: true` lets the map be magnified with its buttons, the wheel, a double click, a pinch or the `+`, `-` and `0` keys, and dragged around; `zoom: { max: 16, wheel: false }` sets the limit and leaves the wheel to the page. The part in sight is the `view` option (`{ x, y, scale }` in the coordinates of the map file): zooming writes it, and you can set it to start on a part of the map, or `chart.update({ view: undefined })` to show all of it again.
|
|
169
|
+
|
|
170
|
+
`select: 'single'` or `'multiple'` lets a click (or Enter on the region the keyboard is on) select regions; a click on a selected region takes it out. The codes are the `selected` option, and `onSelect(selected, code)` is called when they change. `.tc-region-selected` styles the outline.
|
|
171
|
+
|
|
172
|
+
For charts declared in markup or JSON, register the map under a name and pass that name: `addMap('world', world)`, then `map: 'world'`.
|
|
173
|
+
|
|
174
|
+
`world` is the countries of [Natural Earth](https://www.naturalearthdata.com/) (public domain) in the Miller projection, 27 kB gzipped. `pnpm generate:maps` rebuilds it.
|
|
175
|
+
|
|
119
176
|
### Value labels
|
|
120
177
|
|
|
121
178
|
`valueLabels: true` writes the values on the marks: bars at their end (inside when there is no room outside), stacked segments and heatmap cells inside, slices their share, lines and scatters above their last point (`valueLabels: { points: 'all' }` for every point). Values take the axis format (`valueLabels: { format }` overrides it). A label that does not fit its mark or the chart, or would cover another label or mark, is left out: labels never overlap. On the core, `import '@tabler/charts/value-labels'` enables them.
|
|
@@ -124,8 +181,38 @@ annotations: [
|
|
|
124
181
|
new Chart('#el', { type: bar, data, valueLabels: true })
|
|
125
182
|
```
|
|
126
183
|
|
|
184
|
+
A series' own `valueLabels` overrides the chart's for that series: `true` labels it even when the chart option is off, `false` leaves it out. Each label carries the classes of its series (`tc-series tc-series-{n}`), for styling per series.
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
const data = {
|
|
188
|
+
labels,
|
|
189
|
+
series: [
|
|
190
|
+
{ name: 'Revenue', values: revenue },
|
|
191
|
+
{ name: 'Per person', values: perPax, type: 'line', valueLabels: true },
|
|
192
|
+
],
|
|
193
|
+
}
|
|
194
|
+
new Chart('#el', { type: bar, data }) // only the line is labelled
|
|
195
|
+
```
|
|
196
|
+
|
|
127
197
|
A chart type of your own gets labels from its hits like the built-in ones. Its `valueLabels` says what its marks are, when not bars or points (`{ marks: 'slice' }` for shares inside slices, `{ marks: 'cell' }` for values in the middle of cells), and where its number format is (`{ format: (options) => options.format }`).
|
|
128
198
|
|
|
199
|
+
### Right to left
|
|
200
|
+
|
|
201
|
+
`rtl` mirrors line, area, bar, candlestick, scatter, heatmap, sparkline, sankey and percentage bar charts for right-to-left pages: the value axis on the right, categories from the right, flows running to the left, the arrow keys following the screen. The legend, the tooltip and the download menu follow the chart: they read right to left (the menu in the left corner) even on a left-to-right page.
|
|
202
|
+
|
|
203
|
+
`legend: { position: 'left' }` or `'right'` puts the legend beside the chart, its entries stacked, and the chart takes the remaining width (sides swap with `rtl`). `'auto'` puts it on the right when the chart keeps two thirds of the container that way and below it otherwise, so a card is not taller on a wide screen and not cramped on a phone. The legend's `data-position` says where it ended up, for styling.
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
// <html dir="rtl">
|
|
207
|
+
new Chart('#sales', {
|
|
208
|
+
type: bar,
|
|
209
|
+
rtl: 'auto', // follows the container's direction; `true` mirrors on any page (and in SSR)
|
|
210
|
+
locale: 'ar-EG',
|
|
211
|
+
data,
|
|
212
|
+
// x: { reverse: false }, // keep the categories from the left
|
|
213
|
+
})
|
|
214
|
+
```
|
|
215
|
+
|
|
129
216
|
### Synced hover
|
|
130
217
|
|
|
131
218
|
Charts with the same `sync` group share the hover: the category under the pointer is highlighted in every chart of the group, with its crosshair and tooltip, and they clear together. Categories are matched by label, so the charts need not have the same data; a chart without that label clears. Keyboard highlights stay in their own chart. On the core, add the `sync()` plugin.
|
|
@@ -149,9 +236,10 @@ An option that is `NaN` or infinite (a `radius`, a `startAngle`, a `width`, a si
|
|
|
149
236
|
| `aspectRatio` | `2` | |
|
|
150
237
|
| `title`, `description` | | Accessible name and description; without a title the name lists the series ("line chart: Revenue, Costs") |
|
|
151
238
|
| `locale` | runtime default | For `Intl` number and date formatting; set it for SSR |
|
|
239
|
+
| `rtl` | `false` | Mirror cartesian charts, heatmaps, sparklines and sankey diagrams for right-to-left pages: value axis on the right, categories from the right (`x: { reverse: false }` keeps those). Horizontal bars grow to the left. `'auto'` follows the container's `direction` |
|
|
152
240
|
| `fontSize` | `--tc-font-size` | Used to lay out labels; set it for SSR |
|
|
153
241
|
| `id` | generated | Prefix of ids inside the SVG; set it for SSR |
|
|
154
|
-
| `legend` | for 2+ entries | `false`, `true` or `{ position
|
|
242
|
+
| `legend` | for 2+ entries | `false`, `true` or `{ position }`: `'top'`, `'bottom'`, `'left'`, `'right'` or `'auto'` (see below) |
|
|
155
243
|
| `tooltip` | `true` | `false`, or `{ theme, format, footer }`: `theme: 'light'` for a white tooltip instead of the dark one, `format` and `footer` for custom content |
|
|
156
244
|
| `crosshair` | `true` | |
|
|
157
245
|
| `table` | `true` | Hidden data table for screen readers; `'visible'` shows it |
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as BandScale, t as BandKey } from "./band-
|
|
2
|
-
import { a as ClassValue, l as VNode } from "./vnode-
|
|
3
|
-
//#region src/layout.d.ts
|
|
1
|
+
import { n as BandScale, t as BandKey } from "./band-CNKvdnTC.js";
|
|
2
|
+
import { a as ClassValue, l as VNode } from "./vnode-Du2cC8Fm.js";
|
|
4
3
|
/** Axis-aligned rectangle in pixels. */
|
|
5
4
|
interface Rect {
|
|
6
5
|
x: number;
|
|
@@ -29,8 +28,6 @@ declare function innerRect(width: number, height: number, margins: Insets): Rect
|
|
|
29
28
|
declare function estimateTextWidth(text: string, fontSize: number): number;
|
|
30
29
|
/** Line height used for single-line labels, relative to the font size. */
|
|
31
30
|
declare const LINE_HEIGHT = 1.25;
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/charts/annotations.d.ts
|
|
34
31
|
/** A category label, a number, or a date (on a time axis). */
|
|
35
32
|
type AnnotationLabel = string | number | Date;
|
|
36
33
|
/**
|
|
@@ -81,6 +78,4 @@ declare function annotationLayers(annotations: readonly Annotation[] | undefined
|
|
|
81
78
|
under: VNode | null;
|
|
82
79
|
over: VNode | null;
|
|
83
80
|
};
|
|
84
|
-
|
|
85
|
-
export { InsetsInput as a, estimateTextWidth as c, Insets as i, innerRect as l, annotationLayers as n, LINE_HEIGHT as o, annotationValues as r, Rect as s, Annotation as t, insets as u };
|
|
86
|
-
//# sourceMappingURL=annotations-Bp7HwtF5.d.ts.map
|
|
81
|
+
export { InsetsInput as a, estimateTextWidth as c, Insets as i, innerRect as l, annotationLayers as n, LINE_HEIGHT as o, annotationValues as r, Rect as s, Annotation as t, insets as u };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as h } from "./vnode-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { n as estimateTextWidth, s as round } from "./layout-DqAte3H8.js";
|
|
2
|
+
import { t as h } from "./vnode-_EMUqysL.js";
|
|
3
|
+
import { o as labelKey, y as toMs } from "./cartesian-BrPqb5Qn.js";
|
|
4
|
+
import { d as text, i as finite, o as label, u as records } from "./clean-CkoQobGv.js";
|
|
5
|
+
// src/charts/annotations.ts
|
|
6
6
|
/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */
|
|
7
7
|
function categorySpan(scales, label) {
|
|
8
8
|
if (scales.time) {
|
|
@@ -196,7 +196,6 @@ function annotationLayers(annotations, scales) {
|
|
|
196
196
|
}, lines) : null
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
//#endregion
|
|
200
199
|
export { annotationValues as n, annotationLayers as t };
|
|
201
200
|
|
|
202
|
-
//# sourceMappingURL=annotations-
|
|
201
|
+
//# sourceMappingURL=annotations-BQ8l-qHs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations-BszTTjf9.js","names":[],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n const shapes = annotations.map(geometry)\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: ['tc-annotation', a.y !== undefined ? 'tc-annotation-y' : 'tc-annotation-x', a.class],\n style: { '--tc-annotation-color': a.color },\n })\n const end = a.position !== 'start'\n\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode | false | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAA;CACvC;CACA,MAAM,IAAI,OAAO,KAAK,QAAQ,SAAS,KAAK,CAAC;CAC7C,OAAO,IAAI,IAAI,KAAA,IAAY,CAAC,OAAO,KAAK,GAAG,CAAC,GAAG,OAAO,KAAK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AAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
|
1
|
+
{"version":3,"file":"annotations-BQ8l-qHs.js","names":[],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n const shapes = annotations.map(geometry)\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: ['tc-annotation', a.y !== undefined ? 'tc-annotation-y' : 'tc-annotation-x', a.class],\n style: { '--tc-annotation-color': a.color },\n })\n const end = a.position !== 'start'\n\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode | false | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAA;CACvC;CACA,MAAM,IAAI,OAAO,KAAK,QAAQ,SAAS,KAAK,CAAC;CAC7C,OAAO,IAAI,IAAI,KAAA,IAAY,CAAC,OAAO,KAAK,GAAG,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,IAAI,OAAO,KAAK,SAAS;AAC1F;;AAGA,MAAM,QAAW,GAAY,MAAyD;CACpF,IAAI,CAAC,MAAM,QAAQ,CAAC,GAAG,OAAO,EAAE,CAAC;CACjC,MAAM,OAAO,EAAE,IAAI,CAAC;CACpB,OAAO,KAAK,WAAW,KAAK,CAAC,KAAK,SAAS,IAAI,IAAK,OAAe;AACrE;;AAGA,MAAa,oBAAoB,MAC/B,MAAM,KA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K,IAAK;GAEjB,MAAM,IAAI,WACN,IAAI,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,KAClE,IAAI,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE;GACtE,MAAM,KAAK,EAAE,KAAK,MAAM,GAAG,EAAE,QAAQ;IAAE,OAAO;IAAsB;GAAE,CAAC,CAAC,CAAC;GACzE,IAAI,OAAO,MAAM,KAAK,EAAE,KAAK,MAAM,OAAO,GAAG,KAAK,CAAC;GACnD;EACF;EAEA,MAAM,KAAK,MAAM,EAAE;EACnB,MAAM,KACJ,EACE,KACA,MAAM,GACN,EACE,QACA,WACI;GAAE,OAAO;GAAsB,IAAI;GAAI,IAAI;GAAI,IAAI,MAAM,EAAE;GAAG,IAAI,MAAM,EAAE;EAAE,IAC5E;GAAE,OAAO;GAAsB,IAAI,MAAM,EAAE;GAAG,IAAI,MAAM,EAAE;GAAG,IAAI;GAAI,IAAI;EAAG,CAClF,GACA,KACF,CACF;CACF,CAAC;CAED,OAAO;EACL,OAAO,MAAM,SACT,EAAE,KAAK;GAAE,KAAK;GAAqB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IAC1F;EACJ,MAAM,MAAM,SACR,EAAE,KAAK;GAAE,KAAK;GAAoB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as BandScale, t as BandKey } from "./band-
|
|
2
|
-
import { a as ClassValue, l as VNode } from "./vnode-
|
|
3
|
-
//#region src/layout.d.ts
|
|
1
|
+
import { n as BandScale, t as BandKey } from "./band-CNKvdnTC.cjs";
|
|
2
|
+
import { a as ClassValue, l as VNode } from "./vnode-Du2cC8Fm.cjs";
|
|
4
3
|
/** Axis-aligned rectangle in pixels. */
|
|
5
4
|
interface Rect {
|
|
6
5
|
x: number;
|
|
@@ -29,8 +28,6 @@ declare function innerRect(width: number, height: number, margins: Insets): Rect
|
|
|
29
28
|
declare function estimateTextWidth(text: string, fontSize: number): number;
|
|
30
29
|
/** Line height used for single-line labels, relative to the font size. */
|
|
31
30
|
declare const LINE_HEIGHT = 1.25;
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/charts/annotations.d.ts
|
|
34
31
|
/** A category label, a number, or a date (on a time axis). */
|
|
35
32
|
type AnnotationLabel = string | number | Date;
|
|
36
33
|
/**
|
|
@@ -81,6 +78,4 @@ declare function annotationLayers(annotations: readonly Annotation[] | undefined
|
|
|
81
78
|
under: VNode | null;
|
|
82
79
|
over: VNode | null;
|
|
83
80
|
};
|
|
84
|
-
|
|
85
|
-
export { InsetsInput as a, estimateTextWidth as c, Insets as i, innerRect as l, annotationLayers as n, LINE_HEIGHT as o, annotationValues as r, Rect as s, Annotation as t, insets as u };
|
|
86
|
-
//# sourceMappingURL=annotations-lyt0I3HU.d.cts.map
|
|
81
|
+
export { InsetsInput as a, estimateTextWidth as c, Insets as i, innerRect as l, annotationLayers as n, LINE_HEIGHT as o, annotationValues as r, Rect as s, Annotation as t, insets as u };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_layout = require("./layout-
|
|
2
|
-
const require_vnode = require("./vnode-
|
|
3
|
-
const require_cartesian = require("./cartesian-
|
|
4
|
-
const require_clean = require("./clean-
|
|
5
|
-
|
|
1
|
+
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
2
|
+
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
3
|
+
const require_cartesian = require("./cartesian-DRSXHxWe.cjs");
|
|
4
|
+
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
5
|
+
// src/charts/annotations.ts
|
|
6
6
|
/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */
|
|
7
7
|
function categorySpan(scales, label) {
|
|
8
8
|
if (scales.time) {
|
|
@@ -196,7 +196,6 @@ function annotationLayers(annotations, scales) {
|
|
|
196
196
|
}, lines) : null
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
//#endregion
|
|
200
199
|
Object.defineProperty(exports, "annotationLayers", {
|
|
201
200
|
enumerable: true,
|
|
202
201
|
get: function() {
|
|
@@ -210,4 +209,4 @@ Object.defineProperty(exports, "annotationValues", {
|
|
|
210
209
|
}
|
|
211
210
|
});
|
|
212
211
|
|
|
213
|
-
//# sourceMappingURL=annotations-
|
|
212
|
+
//# sourceMappingURL=annotations-CpCWA29b.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations-DpETO8dE.cjs","names":["toMs","labelKey","records","finite","label","text","estimateTextWidth","h","round"],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n const shapes = annotations.map(geometry)\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: ['tc-annotation', a.y !== undefined ? 'tc-annotation-y' : 'tc-annotation-x', a.class],\n style: { '--tc-annotation-color': a.color },\n })\n const end = a.position !== 'start'\n\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode | false | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAKA,kBAAAA,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,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AIC,eAAAA,MAAM,EAAE;GAAG,IAAIA,eAAAA,MAAM,EAAE;EAAE,IAC5E;GAAE,OAAO;GAAsB,IAAIA,eAAAA,MAAM,EAAE;GAAG,IAAIA,eAAAA,MAAM,EAAE;GAAG,IAAI;GAAI,IAAI;EAAG,CAClF,GACA,KACF,CACF;CACF,CAAC;CAED,OAAO;EACL,OAAO,MAAM,SACTD,cAAAA,EAAE,KAAK;GAAE,KAAK;GAAqB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IAC1F;EACJ,MAAM,MAAM,SACRA,cAAAA,EAAE,KAAK;GAAE,KAAK;GAAoB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
|
1
|
+
{"version":3,"file":"annotations-CpCWA29b.cjs","names":["toMs","labelKey","records","finite","label","text","estimateTextWidth","h","round"],"sources":["../src/charts/annotations.ts"],"sourcesContent":["import { estimateTextWidth, type Rect, round } from '../layout.ts'\nimport type { BandKey, BandScale } from '../scales/band.ts'\nimport { type ClassValue, h, type VNode } from '../vnode.ts'\nimport { labelKey, toMs } from './cartesian.ts'\nimport { finite, label, records, text } from './clean.ts'\n\n/** A category label, a number, or a date (on a time axis). */\ntype AnnotationLabel = string | number | Date\n\n/**\n * A reference line or band drawn with the series: a target on the value\n * axis (`y: 99.9`), a normal range (`y: [40, 60]`), an event on the category\n * axis (`x: 'Jun'`, or a date on a time axis) or a period (`x: [from, to]`).\n */\nexport interface Annotation {\n /** A line at a value, or a band between two values, on the value axis. */\n y?: number | readonly [number, number]\n /** A line at a category (or a date on a time axis), or a band between two, on the category axis. */\n x?: AnnotationLabel | readonly [AnnotationLabel, AnnotationLabel]\n /** Short text next to the line or inside the band. */\n label?: string\n /** Where the label sits along the line or band. Defaults to `'end'` (right, or top). */\n position?: 'start' | 'end'\n /**\n * Any CSS color; sets `--tc-annotation-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the annotation group. */\n class?: ClassValue\n /** Stable identity for keyed updates. Defaults to the position in the list. */\n id?: string\n}\n\n/** How the layout maps data to pixels for annotations. */\nexport interface AnnotationScales {\n area: Rect\n /** Whether categories run along y (horizontal bars). */\n horizontal: boolean\n fontSize: number\n /** Pixel position of a value along the value axis. */\n value: (v: number) => number\n /** The category scale, and the keys of its categories in order. */\n band: BandScale\n keys: readonly BandKey[]\n /** Pixel position of a date, when the category axis is a time axis. */\n time?: ((date: Date) => number) | undefined\n}\n\n/** Pixel span of a category (or a date on a time axis), or `undefined` if it is not on the axis. */\nfunction categorySpan(\n scales: AnnotationScales,\n label: AnnotationLabel,\n): readonly [number, number] | undefined {\n if (scales.time) {\n const p = scales.time(new Date(toMs(label)))\n return Number.isFinite(p) ? [p, p] : undefined\n }\n const i = scales.keys.indexOf(labelKey(label))\n return i < 0 ? undefined : [scales.band.at(i), scales.band.at(i) + scales.band.bandwidth]\n}\n\n/** A value or a [from, to] pair, cleaned by `f`; `null` when anything is off. */\nconst span = <T>(v: unknown, f: (x: unknown) => T | null): T | readonly T[] | null => {\n if (!Array.isArray(v)) return f(v)\n const pair = v.map(f)\n return pair.length === 2 && !pair.includes(null) ? (pair as T[]) : null\n}\n\n/** Annotations from outside: lines or bands at finite values or labels, with text labels. */\nexport const cleanAnnotations = (v: unknown): Annotation[] | undefined =>\n v === undefined\n ? v\n : (records(v, (a) => ({\n ...a,\n y: a.y === undefined ? a.y : span(a.y, finite),\n x: a.x === undefined ? a.x : span(a.x, label),\n label: a.label == null ? undefined : text(a.label),\n color: typeof a.color === 'string' ? a.color : undefined,\n })).filter((a) => a.y !== null && a.x !== null && (a.x ?? a.y) !== undefined) as Annotation[])\n\nconst isPair = <T>(v: T | readonly [T, T]): v is readonly [T, T] => Array.isArray(v)\n\n/** Values the value axis should include so every annotation shows. */\nexport function annotationValues(annotations: readonly Annotation[] | undefined): number[] {\n const out: number[] = []\n for (const a of cleanAnnotations(annotations) ?? []) {\n if (a.y === undefined) continue\n for (const v of isPair(a.y) ? a.y : [a.y]) if (Number.isFinite(v)) out.push(v)\n }\n return out\n}\n\n/**\n * Annotation layers: bands go below the series, lines and labels above\n * them. Annotations outside the plot area are skipped.\n */\nexport function annotationLayers(\n annotations: readonly Annotation[] | undefined,\n scales: AnnotationScales,\n): { under: VNode | null; over: VNode | null } {\n // Annotations may come from outside (thresholds from an API).\n annotations = cleanAnnotations(annotations)\n if (!annotations?.length) return { under: null, over: null }\n const { area, horizontal, fontSize } = scales\n const bands: VNode[] = []\n const lines: VNode[] = []\n // Plot edges: \"across\" is the axis the annotation spans, \"along\" the one it marks.\n const x0 = area.x\n const x1 = area.x + area.width\n const y0 = area.y\n const y1 = area.y + area.height\n const inside = (p: number, lo: number, hi: number) => p >= lo - 0.5 && p <= hi + 0.5\n const pad = 4\n /**\n * Where an annotation lands: the pixel span it covers within the plot, and\n * whether it runs across x (a vertical line); `undefined` when it is off\n * the plot or names nothing on the axes.\n */\n const geometry = (a: Annotation): { a0: number; a1: number; vertical: boolean } | undefined => {\n let span: readonly [number, number]\n let vertical: boolean\n if (a.y !== undefined) {\n const [from, to] = isPair(a.y) ? a.y : [a.y, a.y]\n if (!Number.isFinite(from) || !Number.isFinite(to)) return undefined\n span = [scales.value(from), scales.value(to)]\n vertical = horizontal\n } else if (a.x !== undefined) {\n const [from, to] = isPair(a.x) ? a.x : [a.x, a.x]\n const start = categorySpan(scales, from)\n const stop = categorySpan(scales, to)\n if (!start || !stop) return undefined\n // A single category: its center; a range: from the start of one to the end of the other.\n span = isPair(a.x)\n ? [Math.min(start[0], stop[0]), Math.max(start[1], stop[1])]\n : [(start[0] + start[1]) / 2, (start[0] + start[1]) / 2]\n vertical = !horizontal\n } else {\n return undefined\n }\n const lo = Math.min(span[0], span[1])\n const hi = Math.max(span[0], span[1])\n const [min, max] = vertical ? [x0, x1] : [y0, y1]\n if (!inside(lo, min, max) && !inside(hi, min, max) && !(lo < min && hi > max)) return undefined\n return { a0: Math.max(lo, min), a1: Math.min(hi, max), vertical }\n }\n const shapes = annotations.map(geometry)\n\n type Box = [number, number, number, number]\n /** Boxes labels keep clear of: the labels placed so far, and every line. */\n const placed: Box[] = []\n const obstacles: [number, Box][] = []\n shapes.forEach((g, i) => {\n if (!g || g.a1 - g.a0 > 0.5) return\n const at = g.a0\n obstacles.push([i, g.vertical ? [at - 1.5, y0, at + 1.5, y1] : [x0, at - 1.5, x1, at + 1.5]])\n })\n const apart = (box: Box, [l, t, r, b]: Box) =>\n box[2] <= l || box[0] >= r || box[3] <= t || box[1] >= b\n const clearOfLabels = (box: Box) => placed.every((p) => apart(box, p))\n const clear = (box: Box, own: number) =>\n clearOfLabels(box) && obstacles.every(([i, l]) => i === own || apart(box, l))\n\n annotations.forEach((a, index) => {\n const key = a.id ?? index\n // Groups are named by axis; the line, band and label inside by what they are.\n const attrs = (part?: string) => ({\n key: part ? `${key}-${part}` : key,\n class: ['tc-annotation', a.y !== undefined ? 'tc-annotation-y' : 'tc-annotation-x', a.class],\n style: { '--tc-annotation-color': a.color },\n })\n const end = a.position !== 'start'\n\n const shape = shapes[index]\n if (!shape) return\n const { a0, a1, vertical } = shape\n\n // Label: candidate spots in order of preference, inside the plot area; the\n // first that covers neither an earlier label nor another line wins (or the first one).\n let label: VNode | false | undefined\n if (a.label) {\n const w = estimateTextWidth(a.label, fontSize * 0.92)\n const line = a1 - a0 <= 0.5\n // [left edge, baseline] of each spot.\n const spots: [number, number][] = []\n if (vertical) {\n // Beside a line or at the start of a band; on the other side if it would\n // run out, and then on the other side anyway, stepping along the line.\n const after = a0 + pad\n const before = line ? a0 - pad - w : Math.max(x0, a1 - pad - w)\n const sides = after + w <= x1 ? [after, before] : [before, after]\n const top = end ? y0 + fontSize : y1 - pad\n const step = (end ? 1 : -1) * fontSize * 1.2\n for (const x of sides) {\n if (x < x0 || x + w > x1) continue\n for (let k = 0; k < 3; k++) spots.push([x, top + k * step])\n }\n if (!spots.length) spots.push([Math.max(x0 + pad, sides[0] as number), top])\n } else {\n // At the preferred end above or below, then at the other end.\n const near = end ? x1 - pad - w : x0 + pad\n const far = end ? x0 + pad : x1 - pad - w\n for (const x of [near, far]) {\n if (line) spots.push([x, a0 - pad], [x, a0 + fontSize])\n else spots.push([x, a0 + fontSize], [x, a1 - pad])\n }\n }\n const box = ([x, y]: [number, number]): Box => [x, y - fontSize, x + w, y + fontSize * 0.25]\n // Nothing free: at least keep off the other labels; a line through text reads better than text on text.\n const spot =\n spots.find((s) => clear(box(s), index)) ??\n spots.find((s) => clearOfLabels(box(s))) ??\n (spots[0] as [number, number])\n placed.push(box(spot))\n label = h(\n 'text',\n { class: 'tc-annotation-label', x: round(spot[0]), y: round(spot[1]) },\n a.label,\n )\n }\n\n if (a1 - a0 > 0.5) {\n // A band below the series; its label goes with the lines, above them.\n const d = vertical\n ? `M${round(a0)},${round(y0)}H${round(a1)}V${round(y1)}H${round(a0)}Z`\n : `M${round(x0)},${round(a0)}H${round(x1)}V${round(a1)}H${round(x0)}Z`\n bands.push(h('g', attrs(), h('path', { class: 'tc-annotation-band', d })))\n if (label) lines.push(h('g', attrs('label'), label))\n return\n }\n // A line across the plot area.\n const at = round(a0)\n lines.push(\n h(\n 'g',\n attrs(),\n h(\n 'line',\n vertical\n ? { class: 'tc-annotation-line', x1: at, x2: at, y1: round(y0), y2: round(y1) }\n : { class: 'tc-annotation-line', x1: round(x0), x2: round(x1), y1: at, y2: at },\n ),\n label,\n ),\n )\n })\n\n return {\n under: bands.length\n ? h('g', { key: 'annotations-under', class: 'tc-annotations', 'aria-hidden': 'true' }, bands)\n : null,\n over: lines.length\n ? h('g', { key: 'annotations-over', class: 'tc-annotations', 'aria-hidden': 'true' }, lines)\n : null,\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAS,aACP,QACA,OACuC;CACvC,IAAI,OAAO,MAAM;EACf,MAAM,IAAI,OAAO,KAAK,IAAI,KAAKA,kBAAAA,KAAK,KAAK,CAAC,CAAC;EAC3C,OAAO,OAAO,SAAS,CAAC,IAAI,CA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;GAAI,IAAI;GAAI,IAAIC,eAAAA,MAAM,EAAE;GAAG,IAAIA,eAAAA,MAAM,EAAE;EAAE,IAC5E;GAAE,OAAO;GAAsB,IAAIA,eAAAA,MAAM,EAAE;GAAG,IAAIA,eAAAA,MAAM,EAAE;GAAG,IAAI;GAAI,IAAI;EAAG,CAClF,GACA,KACF,CACF;CACF,CAAC;CAED,OAAO;EACL,OAAO,MAAM,SACTD,cAAAA,EAAE,KAAK;GAAE,KAAK;GAAqB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IAC1F;EACJ,MAAM,MAAM,SACRA,cAAAA,EAAE,KAAK;GAAE,KAAK;GAAoB,OAAO;GAAkB,eAAe;EAAO,GAAG,KAAK,IACzF;CACN;AACF"}
|
package/dist/annotations.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
//#region src/annotations.ts
|
|
2
|
+
const require_annotations = require("./annotations-CpCWA29b.cjs");
|
|
3
|
+
// src/annotations.ts
|
|
5
4
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
6
|
-
|
|
5
|
+
require("./features-DEDP5CEQ.cjs").register({ annotations: {
|
|
7
6
|
layers: require_annotations.annotationLayers,
|
|
8
7
|
values: require_annotations.annotationValues
|
|
9
8
|
} });
|
|
10
|
-
//#endregion
|
|
11
9
|
exports.annotationLayers = require_annotations.annotationLayers;
|
|
12
10
|
exports.annotationValues = require_annotations.annotationValues;
|
|
13
11
|
|
package/dist/annotations.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.cjs","names":["register","annotationLayers","annotationValues"],"sources":["../src/annotations.ts"],"sourcesContent":["/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */\nimport { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport { register } from './features.ts'\n\nregister({ annotations: { layers: annotationLayers, values: annotationValues } })\n\nexport type { Annotation } from './charts/annotations.ts'\nexport { annotationLayers, annotationValues }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"annotations.cjs","names":["register","annotationLayers","annotationValues"],"sources":["../src/annotations.ts"],"sourcesContent":["/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */\nimport { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport { register } from './features.ts'\n\nregister({ annotations: { layers: annotationLayers, values: annotationValues } })\n\nexport type { Annotation } from './charts/annotations.ts'\nexport { annotationLayers, annotationValues }\n"],"mappings":";;;;A,iCAIAA,CAAAA,CAAAA,SAAS,EAAE,aAAa;CAAE,QAAQC,oBAAAA;CAAkB,QAAQC,oBAAAA;AAAiB,EAAE,CAAC"}
|
package/dist/annotations.d.cts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
2
|
+
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-CHafaGd4.cjs";
|
|
2
3
|
export { type Annotation, annotationLayers, annotationValues };
|
package/dist/annotations.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
2
|
+
import { n as annotationLayers, r as annotationValues, t as Annotation } from "./annotations-B02GR_KU.js";
|
|
2
3
|
export { type Annotation, annotationLayers, annotationValues };
|
package/dist/annotations.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as annotationValues, t as annotationLayers } from "./annotations-BQ8l-qHs.js";
|
|
2
|
+
import { i as register } from "./features-B55rwpQC.js";
|
|
3
|
+
// src/annotations.ts
|
|
4
4
|
/** Standalone entry: `import '@tabler/charts/annotations'` enables `annotations` in cartesian charts. */
|
|
5
5
|
register({ annotations: {
|
|
6
6
|
layers: annotationLayers,
|
|
7
7
|
values: annotationValues
|
|
8
8
|
} });
|
|
9
|
-
//#endregion
|
|
10
9
|
export { annotationLayers, annotationValues };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=annotations.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/shapes/arc.ts
|
|
2
2
|
/**
|
|
3
3
|
* Annular sector paths with padding and rounded corners, ported from
|
|
4
4
|
* d3-shape's `arc()` (ISC license, Mike Bostock) so geometry matches d3.
|
|
@@ -272,7 +272,6 @@ function arcPathStable(options) {
|
|
|
272
272
|
}
|
|
273
273
|
return `${d}Z`;
|
|
274
274
|
}
|
|
275
|
-
//#endregion
|
|
276
275
|
export { padAngleForGap as i, arcCentroid as n, arcPathStable as r, DEG as t };
|
|
277
276
|
|
|
278
|
-
//# sourceMappingURL=arc-
|
|
277
|
+
//# sourceMappingURL=arc-B3V5IR0w.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arc-a1tRTEw7.js","names":[],"sources":["../src/shapes/arc.ts"],"sourcesContent":["/**\n * Annular sector paths with padding and rounded corners, ported from\n * d3-shape's `arc()` (ISC license, Mike Bostock) so geometry matches d3.\n *\n * Angles are in radians, clockwise from 12 o'clock; paths are centered on\n * the origin (translate the group to place them).\n */\n\nconst EPSILON = 1e-12\nconst PI = Math.PI\nconst HALF_PI = PI / 2\nconst TAU = 2 * PI\n\n/** Degrees to radians. */\nexport const DEG: number = Math.PI / 180\n\n/** Room kept around pies and gauges for the halo of the hovered arc, in pixels. */\nexport const HALO = 8\n\n// Clamped like d3-shape's math helpers, so out-of-range inputs saturate instead of NaN.\nconst asin = (x: number): number => (x >= 1 ? HALF_PI : x <= -1 ? -HALF_PI : Math.asin(x))\nconst acos = (x: number): number => (x > 1 ? 0 : x < -1 ? PI : Math.acos(x))\n\nexport interface ArcOptions {\n innerRadius: number\n outerRadius: number\n startAngle: number\n endAngle: number\n /** Angle removed between adjacent arcs, split between both ends. Defaults to `0`. */\n padAngle?: number\n /** Radius the pad angle is measured at. Defaults to `sqrt(inner² + outer²)` like d3. */\n padRadius?: number\n /** Radius of the rounded corners, clamped to half the ring thickness. Defaults to `0`. */\n cornerRadius?: number\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\n/** Canvas-like path builder emitting SVG path data (after d3-path). */\nclass ArcPath {\n d = ''\n #x0: number | null = null\n #y0: number | null = null\n #x1: number | null = null\n #y1: number | null = null\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n moveTo(x: number, y: number): void {\n this.#x0 = this.#x1 = x\n this.#y0 = this.#y1 = y\n this.d += `M${this.#n(x)},${this.#n(y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.#x1 = x\n this.#y1 = y\n this.d += `L${this.#n(x)},${this.#n(y)}`\n }\n\n closePath(): void {\n if (this.#x1 !== null) {\n this.#x1 = this.#x0\n this.#y1 = this.#y0\n this.d += 'Z'\n }\n }\n\n arc(x: number, y: number, r: number, a0: number, a1: number, ccw: boolean): void {\n const dx = r * Math.cos(a0)\n const dy = r * Math.sin(a0)\n const x0 = x + dx\n const y0 = y + dy\n const cw = ccw ? 0 : 1\n let da = ccw ? a0 - a1 : a1 - a0\n\n if (this.#x1 === null || this.#y1 === null) {\n this.d += `M${this.#n(x0)},${this.#n(y0)}`\n this.#x0 = x0\n this.#y0 = y0\n } else if (Math.abs(this.#x1 - x0) > EPSILON || Math.abs(this.#y1 - y0) > EPSILON) {\n this.d += `L${this.#n(x0)},${this.#n(y0)}`\n }\n this.#x1 = x0\n this.#y1 = y0\n if (!r) return\n\n if (da < 0) da = (da % TAU) + TAU\n const rr = this.#n(r)\n if (da > TAU - EPSILON) {\n // A complete circle: two half arcs.\n this.d += `A${rr},${rr},0,1,${cw},${this.#n(x - dx)},${this.#n(y - dy)}`\n this.d += `A${rr},${rr},0,1,${cw},${this.#n(x0)},${this.#n(y0)}`\n } else if (da > EPSILON) {\n this.#x1 = x + r * Math.cos(a1)\n this.#y1 = y + r * Math.sin(a1)\n this.d += `A${rr},${rr},0,${da >= PI ? 1 : 0},${cw},${this.#n(this.#x1)},${this.#n(this.#y1)}`\n }\n }\n}\n\nfunction intersect(\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n): [number, number] | undefined {\n const x10 = x1 - x0\n const y10 = y1 - y0\n const x32 = x3 - x2\n const y32 = y3 - y2\n let t = y32 * x10 - x32 * y10\n if (t * t < EPSILON) return undefined\n t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t\n return [x0 + t * x10, y0 + t * y10]\n}\n\n/** Center and tangent points of a rounded corner between a radial edge and an arc. */\nfunction cornerTangents(\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n r1: number,\n rc: number,\n cw: boolean,\n) {\n const x01 = x0 - x1\n const y01 = y0 - y1\n const lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01)\n const ox = lo * y01\n const oy = -lo * x01\n const x11 = x0 + ox\n const y11 = y0 + oy\n const x10 = x1 + ox\n const y10 = y1 + oy\n const x00 = (x11 + x10) / 2\n const y00 = (y11 + y10) / 2\n const dx = x10 - x11\n const dy = y10 - y11\n const d2 = dx * dx + dy * dy\n const r = r1 - rc\n const D = x11 * y10 - x10 * y11\n const d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D))\n let cx0 = (D * dy - dx * d) / d2\n let cy0 = (-D * dx - dy * d) / d2\n const cx1 = (D * dy + dx * d) / d2\n const cy1 = (-D * dx + dy * d) / d2\n const dx0 = cx0 - x00\n const dy0 = cy0 - y00\n const dx1 = cx1 - x00\n const dy1 = cy1 - y00\n // Pick the intersection closest to the edge midpoint.\n if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {\n cx0 = cx1\n cy0 = cy1\n }\n return {\n cx: cx0,\n cy: cy0,\n x01: -ox,\n y01: -oy,\n x11: cx0 * (r1 / r - 1),\n y11: cy0 * (r1 / r - 1),\n }\n}\n\n/**\n * Padded angles, clamped corner radii and edge points of a partial sector,\n * shared by both path generators so they agree exactly.\n */\nfunction sector(\n options: ArcOptions,\n r0: number,\n r1: number,\n a0: number,\n a1: number,\n da: number,\n cw: boolean,\n) {\n let a01 = a0\n let a11 = a1\n let a00 = a0\n let a10 = a1\n let da0 = da\n let da1 = da\n const ap = (options.padAngle ?? 0) / 2\n const rp = ap > EPSILON ? (options.padRadius ?? Math.sqrt(r0 * r0 + r1 * r1)) : 0\n const rc = Math.min(Math.abs(r1 - r0) / 2, options.cornerRadius ?? 0)\n let rc0 = rc\n let rc1 = rc\n\n // Apply padding: equal linear offsets at both radii keep the gap parallel.\n if (rp > EPSILON) {\n let p0 = asin((rp / r0) * Math.sin(ap))\n let p1 = asin((rp / r1) * Math.sin(ap))\n da0 -= p0 * 2\n if (da0 > EPSILON) {\n p0 *= cw ? 1 : -1\n a00 += p0\n a10 -= p0\n } else {\n da0 = 0\n a00 = a10 = (a0 + a1) / 2\n }\n da1 -= p1 * 2\n if (da1 > EPSILON) {\n p1 *= cw ? 1 : -1\n a01 += p1\n a11 -= p1\n } else {\n da1 = 0\n a01 = a11 = (a0 + a1) / 2\n }\n }\n\n const x01 = r1 * Math.cos(a01)\n const y01 = r1 * Math.sin(a01)\n const x10 = r0 * Math.cos(a10)\n const y10 = r0 * Math.sin(a10)\n const x11 = r1 * Math.cos(a11)\n const y11 = r1 * Math.sin(a11)\n const x00 = r0 * Math.cos(a00)\n const y00 = r0 * Math.sin(a00)\n\n // Restrict the corner radius for narrow sectors, where corners would overlap.\n if (rc > EPSILON && da < PI) {\n const oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)\n if (oc) {\n const ax = x01 - oc[0]\n const ay = y01 - oc[1]\n const bx = x11 - oc[0]\n const by = y11 - oc[1]\n const cos =\n (ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))\n const kc = 1 / Math.sin(acos(cos) / 2)\n const lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1])\n rc0 = Math.min(rc, (r0 - lc) / (kc - 1))\n rc1 = Math.min(rc, (r1 - lc) / (kc + 1))\n } else {\n rc0 = rc1 = 0\n }\n }\n return { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10, x11, y11, x00, y00 }\n}\n\n/** SVG path data of an annular sector (a pie slice when `innerRadius` is 0). */\nexport function arcPath(options: ArcOptions): string {\n const path = new ArcPath(options.precision ?? 2)\n let r0 = Math.max(0, options.innerRadius)\n let r1 = Math.max(0, options.outerRadius)\n if (r1 < r0) [r0, r1] = [r1, r0]\n const a0 = options.startAngle - HALF_PI\n const a1 = options.endAngle - HALF_PI\n const da = Math.abs(a1 - a0)\n const cw = a1 > a0\n\n if (!(r1 > EPSILON)) {\n path.moveTo(0, 0)\n } else if (da > TAU - EPSILON) {\n // A full ring (or disc).\n path.moveTo(r1 * Math.cos(a0), r1 * Math.sin(a0))\n path.arc(0, 0, r1, a0, a1, !cw)\n if (r0 > EPSILON) {\n path.moveTo(r0 * Math.cos(a1), r0 * Math.sin(a1))\n path.arc(0, 0, r0, a1, a0, cw)\n }\n } else {\n const g = sector(options, r0, r1, a0, a1, da, cw)\n const { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10 } = g\n\n // Outer ring.\n if (!(da1 > EPSILON)) {\n path.moveTo(x01, y01)\n } else if (rc1 > EPSILON) {\n const { x00, y00, x11, y11 } = g\n const t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw)\n const t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw)\n path.moveTo(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc1 < rc) {\n path.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw)\n } else {\n path.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw)\n path.arc(\n 0,\n 0,\n r1,\n Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11),\n Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11),\n !cw,\n )\n path.arc(t1.cx, t1.cy, rc1, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw)\n }\n } else {\n path.moveTo(x01, y01)\n path.arc(0, 0, r1, a01, a11, !cw)\n }\n\n // Inner ring (or the center of a pie slice).\n if (!(r0 > EPSILON) || !(da0 > EPSILON)) {\n path.lineTo(x10, y10)\n } else if (rc0 > EPSILON) {\n const { x00, y00, x11, y11 } = g\n const t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw)\n const t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw)\n path.lineTo(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc0 < rc) {\n path.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw)\n } else {\n path.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw)\n path.arc(\n 0,\n 0,\n r0,\n Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11),\n Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11),\n cw,\n )\n path.arc(t1.cx, t1.cy, rc0, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw)\n }\n } else {\n path.arc(0, 0, r0, a10, a00, cw)\n }\n }\n\n path.closePath()\n return path.d\n}\n\n/** Midpoint of an arc, e.g. to anchor a tooltip or label (like d3's `arc.centroid`). */\nexport function arcCentroid(options: ArcOptions): [number, number] {\n const r = (options.innerRadius + options.outerRadius) / 2\n const a = (options.startAngle + options.endAngle) / 2 - HALF_PI\n return [Math.cos(a) * r, Math.sin(a) * r]\n}\n\n/** Pad angle giving a constant `gap` (in pixels) between arcs of a ring. */\nexport function padAngleForGap(gap: number, innerRadius: number, outerRadius: number): number {\n const rp = Math.sqrt(innerRadius * innerRadius + outerRadius * outerRadius)\n return rp > 0 ? 2 * Math.asin(Math.min(1, gap / 2 / rp)) : 0\n}\n\n/** Angle of a point around the origin. */\nconst angleOf = (x: number, y: number): number => Math.atan2(y, x)\n\n/**\n * The same sector as {@link arcPath}, drawn with a fixed command structure:\n * every corner is always present (zero length when there is none) and each\n * ring is split into two half arcs, so the large-arc flag never flips.\n * Paths of different angles therefore keep their commands while an arc is\n * redrawn frame by frame, turning to its new angles (see `sweep`).\n */\nexport function arcPathStable(options: ArcOptions): string {\n const k = 10 ** Math.max(0, Math.min(12, Math.floor(options.precision ?? 2)))\n const n = (v: number): string => {\n const r = Math.round(v * k) / k\n return String(r === 0 ? 0 : r)\n }\n let d = ''\n const move = (x: number, y: number) => {\n d += `M${n(x)},${n(y)}`\n }\n const line = (x: number, y: number) => {\n d += `L${n(x)},${n(y)}`\n }\n const arc = (r: number, sweep: 0 | 1, x: number, y: number) => {\n d += `A${n(r)},${n(r)},0,0,${sweep},${n(x)},${n(y)}`\n }\n /** Two half arcs of radius `r` around the origin from angle `a0` to `a1`. */\n const ring = (r: number, a0: number, a1: number, ccw: boolean) => {\n let delta = ccw ? a0 - a1 : a1 - a0\n delta = ((delta % TAU) + TAU) % TAU\n if (delta < EPSILON && Math.abs(a1 - a0) > EPSILON) delta = TAU\n const mid = ccw ? a0 - delta / 2 : a0 + delta / 2\n const sweep: 0 | 1 = ccw ? 0 : 1\n arc(r, sweep, r * Math.cos(mid), r * Math.sin(mid))\n arc(r, sweep, r * Math.cos(a1), r * Math.sin(a1))\n }\n\n let r0 = Math.max(0, options.innerRadius)\n let r1 = Math.max(0, options.outerRadius)\n if (r1 < r0) [r0, r1] = [r1, r0]\n const a0 = options.startAngle - HALF_PI\n const a1 = options.endAngle - HALF_PI\n const da = Math.abs(a1 - a0)\n const cw = a1 > a0\n const outerSweep: 0 | 1 = cw ? 1 : 0\n\n if (!(r1 > EPSILON)) {\n // A point: eleven no-op commands at the origin.\n move(0, 0)\n for (let i = 0; i < 4; i++) arc(0, outerSweep, 0, 0)\n line(0, 0)\n for (let i = 0; i < 4; i++) arc(0, outerSweep, 0, 0)\n return `${d}Z`\n }\n\n if (da > TAU - EPSILON) {\n // A full ring (or disc): the seam between the two rings closes the path.\n const ox = r1 * Math.cos(a0)\n const oy = r1 * Math.sin(a0)\n move(ox, oy)\n arc(r1, outerSweep, ox, oy)\n ring(r1, a0, a0 + (cw ? TAU : -TAU) * (1 - 1e-9), !cw)\n arc(r1, outerSweep, ox, oy)\n const ix = r0 * Math.cos(a0)\n const iy = r0 * Math.sin(a0)\n line(ix, iy)\n arc(r0, outerSweep, ix, iy)\n if (r0 > EPSILON) ring(r0, a0, a0 + (cw ? -TAU : TAU) * (1 - 1e-9), cw)\n else for (let i = 0; i < 2; i++) arc(0, outerSweep, 0, 0)\n arc(r0, outerSweep, ix, iy)\n return `${d}Z`\n }\n\n const { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10, x11, y11, x00, y00 } =\n sector(options, r0, r1, a0, a1, da, cw)\n\n // Outer edge: corner, two ring halves, corner.\n if (da1 > EPSILON && rc1 > EPSILON) {\n const t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw)\n const t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw)\n move(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc1 < rc) {\n // Corners merged: one corner arc covers the edge, the rest is empty.\n const ex = t1.cx + t1.x01\n const ey = t1.cy + t1.y01\n arc(rc1, outerSweep, ex, ey)\n arc(r1, outerSweep, ex, ey)\n arc(r1, outerSweep, ex, ey)\n arc(rc1, outerSweep, ex, ey)\n } else {\n arc(rc1, outerSweep, t0.cx + t0.x11, t0.cy + t0.y11)\n ring(\n r1,\n angleOf(t0.cx + t0.x11, t0.cy + t0.y11),\n angleOf(t1.cx + t1.x11, t1.cy + t1.y11),\n !cw,\n )\n arc(rc1, outerSweep, t1.cx + t1.x01, t1.cy + t1.y01)\n }\n } else {\n move(x01, y01)\n arc(r1, outerSweep, x01, y01)\n if (da1 > EPSILON) ring(r1, a01, a11, !cw)\n else for (let i = 0; i < 2; i++) arc(r1, outerSweep, x01, y01)\n arc(r1, outerSweep, x11, y11)\n }\n\n // Inner edge (or the center of a pie slice): corner, two ring halves, corner.\n if (!(r0 > EPSILON) || !(da0 > EPSILON)) {\n line(x10, y10)\n for (let i = 0; i < 4; i++) arc(r0, outerSweep, x10, y10)\n } else if (rc0 > EPSILON) {\n const t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw)\n const t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw)\n line(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc0 < rc) {\n const ex = t1.cx + t1.x01\n const ey = t1.cy + t1.y01\n arc(rc0, outerSweep, ex, ey)\n arc(r0, outerSweep, ex, ey)\n arc(r0, outerSweep, ex, ey)\n arc(rc0, outerSweep, ex, ey)\n } else {\n arc(rc0, outerSweep, t0.cx + t0.x11, t0.cy + t0.y11)\n ring(r0, angleOf(t0.cx + t0.x11, t0.cy + t0.y11), angleOf(t1.cx + t1.x11, t1.cy + t1.y11), cw)\n arc(rc0, outerSweep, t1.cx + t1.x01, t1.cy + t1.y01)\n }\n } else {\n line(x10, y10)\n arc(r0, outerSweep, x10, y10)\n ring(r0, a10, a00, cw)\n arc(r0, outerSweep, x00, y00)\n }\n return `${d}Z`\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,UAAU;AAChB,MAAM,KAAK,KAAK;AAChB,MAAM,UAAU,KAAK;AACrB,MAAM,MAAM,IAAI;;AAGhB,MAAa,MAAc,KAAK,KAAK;AAMrC,MAAM,QAAQ,MAAuB,KAAK,IAAI,UAAU,KAAK,K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;EACrB,IAAI,IAAI,YAAY,KAAK,GAAG;CAC9B;CACA,OAAO,GAAG,EAAE;AACd"}
|
|
1
|
+
{"version":3,"file":"arc-B3V5IR0w.js","names":[],"sources":["../src/shapes/arc.ts"],"sourcesContent":["/**\n * Annular sector paths with padding and rounded corners, ported from\n * d3-shape's `arc()` (ISC license, Mike Bostock) so geometry matches d3.\n *\n * Angles are in radians, clockwise from 12 o'clock; paths are centered on\n * the origin (translate the group to place them).\n */\n\nconst EPSILON = 1e-12\nconst PI = Math.PI\nconst HALF_PI = PI / 2\nconst TAU = 2 * PI\n\n/** Degrees to radians. */\nexport const DEG: number = Math.PI / 180\n\n/** Room kept around pies and gauges for the halo of the hovered arc, in pixels. */\nexport const HALO = 8\n\n// Clamped like d3-shape's math helpers, so out-of-range inputs saturate instead of NaN.\nconst asin = (x: number): number => (x >= 1 ? HALF_PI : x <= -1 ? -HALF_PI : Math.asin(x))\nconst acos = (x: number): number => (x > 1 ? 0 : x < -1 ? PI : Math.acos(x))\n\nexport interface ArcOptions {\n innerRadius: number\n outerRadius: number\n startAngle: number\n endAngle: number\n /** Angle removed between adjacent arcs, split between both ends. Defaults to `0`. */\n padAngle?: number\n /** Radius the pad angle is measured at. Defaults to `sqrt(inner² + outer²)` like d3. */\n padRadius?: number\n /** Radius of the rounded corners, clamped to half the ring thickness. Defaults to `0`. */\n cornerRadius?: number\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\n/** Canvas-like path builder emitting SVG path data (after d3-path). */\nclass ArcPath {\n d = ''\n #x0: number | null = null\n #y0: number | null = null\n #x1: number | null = null\n #y1: number | null = null\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n moveTo(x: number, y: number): void {\n this.#x0 = this.#x1 = x\n this.#y0 = this.#y1 = y\n this.d += `M${this.#n(x)},${this.#n(y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.#x1 = x\n this.#y1 = y\n this.d += `L${this.#n(x)},${this.#n(y)}`\n }\n\n closePath(): void {\n if (this.#x1 !== null) {\n this.#x1 = this.#x0\n this.#y1 = this.#y0\n this.d += 'Z'\n }\n }\n\n arc(x: number, y: number, r: number, a0: number, a1: number, ccw: boolean): void {\n const dx = r * Math.cos(a0)\n const dy = r * Math.sin(a0)\n const x0 = x + dx\n const y0 = y + dy\n const cw = ccw ? 0 : 1\n let da = ccw ? a0 - a1 : a1 - a0\n\n if (this.#x1 === null || this.#y1 === null) {\n this.d += `M${this.#n(x0)},${this.#n(y0)}`\n this.#x0 = x0\n this.#y0 = y0\n } else if (Math.abs(this.#x1 - x0) > EPSILON || Math.abs(this.#y1 - y0) > EPSILON) {\n this.d += `L${this.#n(x0)},${this.#n(y0)}`\n }\n this.#x1 = x0\n this.#y1 = y0\n if (!r) return\n\n if (da < 0) da = (da % TAU) + TAU\n const rr = this.#n(r)\n if (da > TAU - EPSILON) {\n // A complete circle: two half arcs.\n this.d += `A${rr},${rr},0,1,${cw},${this.#n(x - dx)},${this.#n(y - dy)}`\n this.d += `A${rr},${rr},0,1,${cw},${this.#n(x0)},${this.#n(y0)}`\n } else if (da > EPSILON) {\n this.#x1 = x + r * Math.cos(a1)\n this.#y1 = y + r * Math.sin(a1)\n this.d += `A${rr},${rr},0,${da >= PI ? 1 : 0},${cw},${this.#n(this.#x1)},${this.#n(this.#y1)}`\n }\n }\n}\n\nfunction intersect(\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number,\n): [number, number] | undefined {\n const x10 = x1 - x0\n const y10 = y1 - y0\n const x32 = x3 - x2\n const y32 = y3 - y2\n let t = y32 * x10 - x32 * y10\n if (t * t < EPSILON) return undefined\n t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t\n return [x0 + t * x10, y0 + t * y10]\n}\n\n/** Center and tangent points of a rounded corner between a radial edge and an arc. */\nfunction cornerTangents(\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n r1: number,\n rc: number,\n cw: boolean,\n) {\n const x01 = x0 - x1\n const y01 = y0 - y1\n const lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01)\n const ox = lo * y01\n const oy = -lo * x01\n const x11 = x0 + ox\n const y11 = y0 + oy\n const x10 = x1 + ox\n const y10 = y1 + oy\n const x00 = (x11 + x10) / 2\n const y00 = (y11 + y10) / 2\n const dx = x10 - x11\n const dy = y10 - y11\n const d2 = dx * dx + dy * dy\n const r = r1 - rc\n const D = x11 * y10 - x10 * y11\n const d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D))\n let cx0 = (D * dy - dx * d) / d2\n let cy0 = (-D * dx - dy * d) / d2\n const cx1 = (D * dy + dx * d) / d2\n const cy1 = (-D * dx + dy * d) / d2\n const dx0 = cx0 - x00\n const dy0 = cy0 - y00\n const dx1 = cx1 - x00\n const dy1 = cy1 - y00\n // Pick the intersection closest to the edge midpoint.\n if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {\n cx0 = cx1\n cy0 = cy1\n }\n return {\n cx: cx0,\n cy: cy0,\n x01: -ox,\n y01: -oy,\n x11: cx0 * (r1 / r - 1),\n y11: cy0 * (r1 / r - 1),\n }\n}\n\n/**\n * Padded angles, clamped corner radii and edge points of a partial sector,\n * shared by both path generators so they agree exactly.\n */\nfunction sector(\n options: ArcOptions,\n r0: number,\n r1: number,\n a0: number,\n a1: number,\n da: number,\n cw: boolean,\n) {\n let a01 = a0\n let a11 = a1\n let a00 = a0\n let a10 = a1\n let da0 = da\n let da1 = da\n const ap = (options.padAngle ?? 0) / 2\n const rp = ap > EPSILON ? (options.padRadius ?? Math.sqrt(r0 * r0 + r1 * r1)) : 0\n const rc = Math.min(Math.abs(r1 - r0) / 2, options.cornerRadius ?? 0)\n let rc0 = rc\n let rc1 = rc\n\n // Apply padding: equal linear offsets at both radii keep the gap parallel.\n if (rp > EPSILON) {\n let p0 = asin((rp / r0) * Math.sin(ap))\n let p1 = asin((rp / r1) * Math.sin(ap))\n da0 -= p0 * 2\n if (da0 > EPSILON) {\n p0 *= cw ? 1 : -1\n a00 += p0\n a10 -= p0\n } else {\n da0 = 0\n a00 = a10 = (a0 + a1) / 2\n }\n da1 -= p1 * 2\n if (da1 > EPSILON) {\n p1 *= cw ? 1 : -1\n a01 += p1\n a11 -= p1\n } else {\n da1 = 0\n a01 = a11 = (a0 + a1) / 2\n }\n }\n\n const x01 = r1 * Math.cos(a01)\n const y01 = r1 * Math.sin(a01)\n const x10 = r0 * Math.cos(a10)\n const y10 = r0 * Math.sin(a10)\n const x11 = r1 * Math.cos(a11)\n const y11 = r1 * Math.sin(a11)\n const x00 = r0 * Math.cos(a00)\n const y00 = r0 * Math.sin(a00)\n\n // Restrict the corner radius for narrow sectors, where corners would overlap.\n if (rc > EPSILON && da < PI) {\n const oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)\n if (oc) {\n const ax = x01 - oc[0]\n const ay = y01 - oc[1]\n const bx = x11 - oc[0]\n const by = y11 - oc[1]\n const cos =\n (ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))\n const kc = 1 / Math.sin(acos(cos) / 2)\n const lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1])\n rc0 = Math.min(rc, (r0 - lc) / (kc - 1))\n rc1 = Math.min(rc, (r1 - lc) / (kc + 1))\n } else {\n rc0 = rc1 = 0\n }\n }\n return { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10, x11, y11, x00, y00 }\n}\n\n/** SVG path data of an annular sector (a pie slice when `innerRadius` is 0). */\nexport function arcPath(options: ArcOptions): string {\n const path = new ArcPath(options.precision ?? 2)\n let r0 = Math.max(0, options.innerRadius)\n let r1 = Math.max(0, options.outerRadius)\n if (r1 < r0) [r0, r1] = [r1, r0]\n const a0 = options.startAngle - HALF_PI\n const a1 = options.endAngle - HALF_PI\n const da = Math.abs(a1 - a0)\n const cw = a1 > a0\n\n if (!(r1 > EPSILON)) {\n path.moveTo(0, 0)\n } else if (da > TAU - EPSILON) {\n // A full ring (or disc).\n path.moveTo(r1 * Math.cos(a0), r1 * Math.sin(a0))\n path.arc(0, 0, r1, a0, a1, !cw)\n if (r0 > EPSILON) {\n path.moveTo(r0 * Math.cos(a1), r0 * Math.sin(a1))\n path.arc(0, 0, r0, a1, a0, cw)\n }\n } else {\n const g = sector(options, r0, r1, a0, a1, da, cw)\n const { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10 } = g\n\n // Outer ring.\n if (!(da1 > EPSILON)) {\n path.moveTo(x01, y01)\n } else if (rc1 > EPSILON) {\n const { x00, y00, x11, y11 } = g\n const t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw)\n const t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw)\n path.moveTo(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc1 < rc) {\n path.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw)\n } else {\n path.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw)\n path.arc(\n 0,\n 0,\n r1,\n Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11),\n Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11),\n !cw,\n )\n path.arc(t1.cx, t1.cy, rc1, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw)\n }\n } else {\n path.moveTo(x01, y01)\n path.arc(0, 0, r1, a01, a11, !cw)\n }\n\n // Inner ring (or the center of a pie slice).\n if (!(r0 > EPSILON) || !(da0 > EPSILON)) {\n path.lineTo(x10, y10)\n } else if (rc0 > EPSILON) {\n const { x00, y00, x11, y11 } = g\n const t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw)\n const t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw)\n path.lineTo(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc0 < rc) {\n path.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw)\n } else {\n path.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw)\n path.arc(\n 0,\n 0,\n r0,\n Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11),\n Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11),\n cw,\n )\n path.arc(t1.cx, t1.cy, rc0, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw)\n }\n } else {\n path.arc(0, 0, r0, a10, a00, cw)\n }\n }\n\n path.closePath()\n return path.d\n}\n\n/** Midpoint of an arc, e.g. to anchor a tooltip or label (like d3's `arc.centroid`). */\nexport function arcCentroid(options: ArcOptions): [number, number] {\n const r = (options.innerRadius + options.outerRadius) / 2\n const a = (options.startAngle + options.endAngle) / 2 - HALF_PI\n return [Math.cos(a) * r, Math.sin(a) * r]\n}\n\n/** Pad angle giving a constant `gap` (in pixels) between arcs of a ring. */\nexport function padAngleForGap(gap: number, innerRadius: number, outerRadius: number): number {\n const rp = Math.sqrt(innerRadius * innerRadius + outerRadius * outerRadius)\n return rp > 0 ? 2 * Math.asin(Math.min(1, gap / 2 / rp)) : 0\n}\n\n/** Angle of a point around the origin. */\nconst angleOf = (x: number, y: number): number => Math.atan2(y, x)\n\n/**\n * The same sector as {@link arcPath}, drawn with a fixed command structure:\n * every corner is always present (zero length when there is none) and each\n * ring is split into two half arcs, so the large-arc flag never flips.\n * Paths of different angles therefore keep their commands while an arc is\n * redrawn frame by frame, turning to its new angles (see `sweep`).\n */\nexport function arcPathStable(options: ArcOptions): string {\n const k = 10 ** Math.max(0, Math.min(12, Math.floor(options.precision ?? 2)))\n const n = (v: number): string => {\n const r = Math.round(v * k) / k\n return String(r === 0 ? 0 : r)\n }\n let d = ''\n const move = (x: number, y: number) => {\n d += `M${n(x)},${n(y)}`\n }\n const line = (x: number, y: number) => {\n d += `L${n(x)},${n(y)}`\n }\n const arc = (r: number, sweep: 0 | 1, x: number, y: number) => {\n d += `A${n(r)},${n(r)},0,0,${sweep},${n(x)},${n(y)}`\n }\n /** Two half arcs of radius `r` around the origin from angle `a0` to `a1`. */\n const ring = (r: number, a0: number, a1: number, ccw: boolean) => {\n let delta = ccw ? a0 - a1 : a1 - a0\n delta = ((delta % TAU) + TAU) % TAU\n if (delta < EPSILON && Math.abs(a1 - a0) > EPSILON) delta = TAU\n const mid = ccw ? a0 - delta / 2 : a0 + delta / 2\n const sweep: 0 | 1 = ccw ? 0 : 1\n arc(r, sweep, r * Math.cos(mid), r * Math.sin(mid))\n arc(r, sweep, r * Math.cos(a1), r * Math.sin(a1))\n }\n\n let r0 = Math.max(0, options.innerRadius)\n let r1 = Math.max(0, options.outerRadius)\n if (r1 < r0) [r0, r1] = [r1, r0]\n const a0 = options.startAngle - HALF_PI\n const a1 = options.endAngle - HALF_PI\n const da = Math.abs(a1 - a0)\n const cw = a1 > a0\n const outerSweep: 0 | 1 = cw ? 1 : 0\n\n if (!(r1 > EPSILON)) {\n // A point: eleven no-op commands at the origin.\n move(0, 0)\n for (let i = 0; i < 4; i++) arc(0, outerSweep, 0, 0)\n line(0, 0)\n for (let i = 0; i < 4; i++) arc(0, outerSweep, 0, 0)\n return `${d}Z`\n }\n\n if (da > TAU - EPSILON) {\n // A full ring (or disc): the seam between the two rings closes the path.\n const ox = r1 * Math.cos(a0)\n const oy = r1 * Math.sin(a0)\n move(ox, oy)\n arc(r1, outerSweep, ox, oy)\n ring(r1, a0, a0 + (cw ? TAU : -TAU) * (1 - 1e-9), !cw)\n arc(r1, outerSweep, ox, oy)\n const ix = r0 * Math.cos(a0)\n const iy = r0 * Math.sin(a0)\n line(ix, iy)\n arc(r0, outerSweep, ix, iy)\n if (r0 > EPSILON) ring(r0, a0, a0 + (cw ? -TAU : TAU) * (1 - 1e-9), cw)\n else for (let i = 0; i < 2; i++) arc(0, outerSweep, 0, 0)\n arc(r0, outerSweep, ix, iy)\n return `${d}Z`\n }\n\n const { a00, a01, a10, a11, da0, da1, rc, rc0, rc1, x01, y01, x10, y10, x11, y11, x00, y00 } =\n sector(options, r0, r1, a0, a1, da, cw)\n\n // Outer edge: corner, two ring halves, corner.\n if (da1 > EPSILON && rc1 > EPSILON) {\n const t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw)\n const t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw)\n move(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc1 < rc) {\n // Corners merged: one corner arc covers the edge, the rest is empty.\n const ex = t1.cx + t1.x01\n const ey = t1.cy + t1.y01\n arc(rc1, outerSweep, ex, ey)\n arc(r1, outerSweep, ex, ey)\n arc(r1, outerSweep, ex, ey)\n arc(rc1, outerSweep, ex, ey)\n } else {\n arc(rc1, outerSweep, t0.cx + t0.x11, t0.cy + t0.y11)\n ring(\n r1,\n angleOf(t0.cx + t0.x11, t0.cy + t0.y11),\n angleOf(t1.cx + t1.x11, t1.cy + t1.y11),\n !cw,\n )\n arc(rc1, outerSweep, t1.cx + t1.x01, t1.cy + t1.y01)\n }\n } else {\n move(x01, y01)\n arc(r1, outerSweep, x01, y01)\n if (da1 > EPSILON) ring(r1, a01, a11, !cw)\n else for (let i = 0; i < 2; i++) arc(r1, outerSweep, x01, y01)\n arc(r1, outerSweep, x11, y11)\n }\n\n // Inner edge (or the center of a pie slice): corner, two ring halves, corner.\n if (!(r0 > EPSILON) || !(da0 > EPSILON)) {\n line(x10, y10)\n for (let i = 0; i < 4; i++) arc(r0, outerSweep, x10, y10)\n } else if (rc0 > EPSILON) {\n const t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw)\n const t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw)\n line(t0.cx + t0.x01, t0.cy + t0.y01)\n if (rc0 < rc) {\n const ex = t1.cx + t1.x01\n const ey = t1.cy + t1.y01\n arc(rc0, outerSweep, ex, ey)\n arc(r0, outerSweep, ex, ey)\n arc(r0, outerSweep, ex, ey)\n arc(rc0, outerSweep, ex, ey)\n } else {\n arc(rc0, outerSweep, t0.cx + t0.x11, t0.cy + t0.y11)\n ring(r0, angleOf(t0.cx + t0.x11, t0.cy + t0.y11), angleOf(t1.cx + t1.x11, t1.cy + t1.y11), cw)\n arc(rc0, outerSweep, t1.cx + t1.x01, t1.cy + t1.y01)\n }\n } else {\n line(x10, y10)\n arc(r0, outerSweep, x10, y10)\n ring(r0, a10, a00, cw)\n arc(r0, outerSweep, x00, y00)\n }\n return `${d}Z`\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,UAAU;AAChB,MAAM,KAAK,KAAK;AAChB,MAAM,UAAU,KAAK;AACrB,MAAM,MAAM,IAAI;;AAGhB,MAAa,MAAc,KAAK,KAAK;AAMrC,MAAM,QAAQ,MAAuB,KAAK,IAAI,UAAU,KAAK,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC;AACxF,MAAM,QAAQ,MAAuB,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,CAAC;AAwF1E,SAAS,UACP,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IAC8B;CAC9B,MAAM,MAAM,KAAK;CACjB,MAAM,MAAM,KAAK;CACjB,MAAM,MAAM,KAAK;CACjB,MAAM,MAAM,KAAK;CACjB,IAAI,IAAI,MAAM,MAAM,MAAM;CAC1B,IAAI,IAAI,IAAI,SAAS,OAAO,KAAA;CAC5B,KAAK,OAAO,KAAK,MAAM,OAAO,KAAK,OAAO;CAC1C,OAAO,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG;AACpC;;AAGA,SAAS,eACP,IACA,IACA,IACA,IACA,IACA,IACA,IACA;CACA,MAAM,MAAM,KAAK;CACjB,MAAM,MAAM,KAAK;CACjB,MA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