@tabler/charts 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -17
- package/dist/{annotations-DdRdeBUB.cjs → annotations--m-HzMBM.cjs} +87 -11
- package/dist/annotations--m-HzMBM.cjs.map +1 -0
- package/dist/{annotations-B02GR_KU.d.ts → annotations-CCDUC1lW.d.ts} +16 -30
- package/dist/{annotations-CHafaGd4.d.cts → annotations-CqZM1z9R.d.cts} +16 -30
- package/dist/{annotations-D0YQ0IoA.js → annotations-DGITy6th.js} +87 -11
- package/dist/annotations-DGITy6th.js.map +1 -0
- package/dist/annotations.cjs +2 -2
- package/dist/annotations.d.cts +1 -1
- package/dist/annotations.d.ts +1 -1
- package/dist/annotations.js +2 -2
- package/dist/{area-0-L1bG9B.js → area-BN0uE9R0.js} +4 -3
- package/dist/area-BN0uE9R0.js.map +1 -0
- package/dist/{area-CJX9219z.d.cts → area-D6LNLk3r.d.cts} +2 -2
- package/dist/{area-d11XePuw.d.ts → area-DEFL-Yun.d.ts} +2 -2
- package/dist/{area-4eRs3c0K.cjs → area-D_N8b4Ng.cjs} +4 -3
- package/dist/area-D_N8b4Ng.cjs.map +1 -0
- package/dist/area.cjs +1 -1
- package/dist/area.d.cts +1 -1
- package/dist/area.d.ts +1 -1
- package/dist/area.js +1 -1
- package/dist/axis-BzBkkC5X.cjs +305 -0
- package/dist/axis-BzBkkC5X.cjs.map +1 -0
- package/dist/axis-C5obgdJt.js +240 -0
- package/dist/axis-C5obgdJt.js.map +1 -0
- package/dist/{bar-Da6dE_nI.cjs → bar-BrmfXugT.cjs} +77 -58
- package/dist/bar-BrmfXugT.cjs.map +1 -0
- package/dist/{bar-XwzM6Pb0.d.ts → bar-Bs_rPqgR.d.ts} +1 -1
- package/dist/{bar-BDLR4p9c.d.cts → bar-CEt8YRxf.d.cts} +2 -2
- package/dist/{bar-B5n2oq9-.js → bar-CgpC2EpX.js} +2 -2
- package/dist/{bar-B5n2oq9-.js.map → bar-CgpC2EpX.js.map} +1 -1
- package/dist/{bar-BNZ3GhIw.js → bar-D_KKd2fL.js} +75 -56
- package/dist/bar-D_KKd2fL.js.map +1 -0
- package/dist/{bar-LYIF8MEz.cjs → bar-wVykm1us.cjs} +2 -2
- package/dist/{bar-LYIF8MEz.cjs.map → bar-wVykm1us.cjs.map} +1 -1
- package/dist/bar.cjs +1 -1
- package/dist/bar.d.cts +1 -1
- package/dist/bar.d.ts +1 -1
- package/dist/bar.js +1 -1
- package/dist/calendar-B7843sQu.d.cts +106 -0
- package/dist/calendar-BG_q_NC_.cjs +507 -0
- package/dist/calendar-BG_q_NC_.cjs.map +1 -0
- package/dist/calendar-CF3gfDQk.js +502 -0
- package/dist/calendar-CF3gfDQk.js.map +1 -0
- package/dist/calendar-D10_ki1S.d.ts +106 -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-BHQkQfxH.js → candlestick-B1onjo1o.js} +17 -14
- package/dist/candlestick-B1onjo1o.js.map +1 -0
- package/dist/{candlestick-Dq7qp-F0.d.cts → candlestick-B7YXUVVh.d.cts} +4 -3
- package/dist/{candlestick-CYCQXgky.cjs → candlestick-BwrFKak_.cjs} +17 -14
- package/dist/candlestick-BwrFKak_.cjs.map +1 -0
- package/dist/{candlestick-D0xKkdqd.d.ts → candlestick-XpqJvarq.d.ts} +4 -3
- package/dist/candlestick.cjs +3 -3
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +3 -3
- package/dist/{cartesian-DV02PsBe.cjs → cartesian-B9CrasFJ.cjs} +190 -310
- package/dist/cartesian-B9CrasFJ.cjs.map +1 -0
- package/dist/{cartesian-CI2x6N7N.js → cartesian-COglz544.js} +161 -251
- package/dist/cartesian-COglz544.js.map +1 -0
- package/dist/{chart-DWn9v6qw.js → chart-B97FBRCd.js} +114 -72
- package/dist/chart-B97FBRCd.js.map +1 -0
- package/dist/{chart-QilhWP8Z.d.ts → chart-CE9EVbfV.d.ts} +427 -112
- package/dist/{chart-kqFMEwDo.d.cts → chart-Dz4geQZy.d.cts} +427 -112
- package/dist/{chart-e2VqomCI.cjs → chart-GUmmjJ7S.cjs} +132 -78
- package/dist/chart-GUmmjJ7S.cjs.map +1 -0
- package/dist/{core-BKRQvPAT.js → core-7fgM3su0.js} +188 -73
- package/dist/core-7fgM3su0.js.map +1 -0
- package/dist/{core-DRUCk67j.d.ts → core-BUQzLsRJ.d.ts} +26 -10
- package/dist/{core-DIOC61up.cjs → core-BZTrsPxc.cjs} +200 -73
- package/dist/core-BZTrsPxc.cjs.map +1 -0
- package/dist/{core-PAX5ogLk.d.cts → core-Ck5uHcW8.d.cts} +45 -24
- package/dist/core.cjs +45 -31
- package/dist/core.d.cts +23 -18
- package/dist/core.d.ts +23 -18
- package/dist/core.js +28 -23
- package/dist/{dates-DurEr9WT.cjs → dates-0YNY49KQ.cjs} +2 -2
- package/dist/{dates-DurEr9WT.cjs.map → dates-0YNY49KQ.cjs.map} +1 -1
- package/dist/{dates-C2RzY3rE.js → dates-CKDRgpin.js} +2 -2
- package/dist/{dates-C2RzY3rE.js.map → dates-CKDRgpin.js.map} +1 -1
- package/dist/decimate.cjs +1 -1
- package/dist/decimate.js +1 -1
- package/dist/{dom-D_g13XWY.cjs → dom-C33zvtPo.cjs} +3 -7
- package/dist/dom-C33zvtPo.cjs.map +1 -0
- package/dist/{dom-CuceR8gt.js → dom-CTse6Rvd.js} +3 -7
- package/dist/dom-CTse6Rvd.js.map +1 -0
- package/dist/end-labels-B3oRvjxw.js +114 -0
- package/dist/end-labels-B3oRvjxw.js.map +1 -0
- package/dist/end-labels-CS-fnpp-.cjs +119 -0
- package/dist/end-labels-CS-fnpp-.cjs.map +1 -0
- package/dist/end-labels.cjs +11 -0
- package/dist/end-labels.cjs.map +1 -0
- package/dist/end-labels.d.cts +6 -0
- package/dist/end-labels.d.ts +6 -0
- package/dist/end-labels.js +11 -0
- package/dist/end-labels.js.map +1 -0
- package/dist/{export-chart-83UYH48t.js → export-chart-BOH_nfcH.js} +92 -15
- package/dist/export-chart-BOH_nfcH.js.map +1 -0
- package/dist/{export-chart-mYgEfK-L.cjs → export-chart-Be4T9J3m.cjs} +97 -14
- package/dist/export-chart-Be4T9J3m.cjs.map +1 -0
- package/dist/export.cjs +5 -3
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +4 -3
- package/dist/export.d.ts +4 -3
- package/dist/export.js +5 -4
- package/dist/export.js.map +1 -1
- package/dist/{fade-GGxcBdss.js → fade-CDrQjnDz.js} +56 -78
- package/dist/fade-CDrQjnDz.js.map +1 -0
- package/dist/{fade-DVTkhrFU.cjs → fade-CRqcKMWY.cjs} +56 -78
- package/dist/fade-CRqcKMWY.cjs.map +1 -0
- package/dist/{features-BMxkqCyS.js → features-B55rwpQC.js} +4 -2
- package/dist/features-B55rwpQC.js.map +1 -0
- package/dist/{features-DCXEvoya.cjs → features-DEDP5CEQ.cjs} +9 -1
- 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/funnel-B9ridzNx.d.cts +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-FogM8flk.d.ts +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-DXkjXNCD.cjs → gauge-6HfDcLMJ.cjs} +28 -28
- package/dist/gauge-6HfDcLMJ.cjs.map +1 -0
- package/dist/{gauge-BSist7My.d.cts → gauge-BScJ7U6O.d.cts} +2 -2
- package/dist/{gauge-0VJuAHWF.d.ts → gauge-D78oq1Lx.d.ts} +2 -2
- package/dist/{gauge-ts0kqN1-.js → gauge-DiTk5aWO.js} +28 -28
- package/dist/gauge-DiTk5aWO.js.map +1 -0
- package/dist/gauge.cjs +1 -1
- package/dist/gauge.d.cts +1 -1
- package/dist/gauge.d.ts +1 -1
- package/dist/gauge.js +1 -1
- package/dist/heat-Bsqq4zw9.js +38 -0
- package/dist/heat-Bsqq4zw9.js.map +1 -0
- package/dist/heat-DYsivvDq.cjs +49 -0
- package/dist/heat-DYsivvDq.cjs.map +1 -0
- package/dist/{heatmap-CXhlrLTl.cjs → heatmap-Dyzrd4Fd.cjs} +39 -37
- package/dist/heatmap-Dyzrd4Fd.cjs.map +1 -0
- package/dist/{heatmap-19BGJTKF.js → heatmap-J7fxG7MM.js} +35 -33
- package/dist/heatmap-J7fxG7MM.js.map +1 -0
- package/dist/{heatmap-Dp_oyEe0.d.cts → heatmap-Jvwo7iFW.d.cts} +2 -2
- package/dist/{heatmap-59lmClj9.d.ts → heatmap-mFCnP6aB.d.ts} +2 -2
- package/dist/heatmap.cjs +1 -1
- package/dist/heatmap.d.cts +1 -1
- package/dist/heatmap.d.ts +1 -1
- package/dist/heatmap.js +1 -1
- package/dist/{hydrate-OA6R2_Pn.js → hydrate-BB3MlR36.js} +2 -2
- package/dist/{hydrate-OA6R2_Pn.js.map → hydrate-BB3MlR36.js.map} +1 -1
- package/dist/{hydrate-CmN1k8Mo.cjs → hydrate-m0I5m6ue.cjs} +2 -2
- package/dist/{hydrate-CmN1k8Mo.cjs.map → hydrate-m0I5m6ue.cjs.map} +1 -1
- package/dist/hydrate.cjs +2 -2
- package/dist/hydrate.js +2 -2
- package/dist/index.cjs +69 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -19
- package/dist/index.d.ts +24 -19
- package/dist/index.js +51 -37
- 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-CYerDebD.d.cts +29 -0
- package/dist/layout-CYerDebD.d.ts +29 -0
- package/dist/{layout-JY2aR-yE.cjs → layout-Cfg9x1k2.cjs} +32 -1
- package/dist/layout-Cfg9x1k2.cjs.map +1 -0
- package/dist/{layout-DmrrLjwN.js → layout-DqAte3H8.js} +27 -2
- package/dist/layout-DqAte3H8.js.map +1 -0
- package/dist/{line-DO66LtwH.js → line-CXH0L10d.js} +84 -37
- package/dist/line-CXH0L10d.js.map +1 -0
- package/dist/{line-_rNdeKmS.d.cts → line-Cu9ctpbv.d.cts} +9 -3
- package/dist/{line-Dbt6KFRK.cjs → line-DHbYCQy4.cjs} +84 -37
- package/dist/line-DHbYCQy4.cjs.map +1 -0
- package/dist/{line-DtSh7HQU.d.ts → line-TkzA7wMK.d.ts} +8 -1
- package/dist/line.cjs +3 -3
- package/dist/line.d.cts +1 -1
- package/dist/line.d.ts +1 -1
- package/dist/line.js +3 -3
- package/dist/log.cjs +1 -1
- package/dist/log.js +1 -1
- package/dist/map-BirylCmT.d.cts +156 -0
- package/dist/map-CYp6x-uS.js +784 -0
- package/dist/map-CYp6x-uS.js.map +1 -0
- package/dist/map-ChwSgooH.cjs +795 -0
- package/dist/map-ChwSgooH.cjs.map +1 -0
- package/dist/map-DNqog2Xs.d.ts +156 -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-9_LJL0ra.cjs → morph-3I1Nf_tR.cjs} +2 -2
- package/dist/{morph-9_LJL0ra.cjs.map → morph-3I1Nf_tR.cjs.map} +1 -1
- package/dist/{morph-DnRxuwR-.js → morph-GfBab-b3.js} +2 -2
- package/dist/{morph-DnRxuwR-.js.map → morph-GfBab-b3.js.map} +1 -1
- package/dist/morph.cjs +2 -2
- package/dist/morph.js +2 -2
- package/dist/others-CuNdpvjd.d.cts +31 -0
- package/dist/{others-J7NCAMA0.js → others-DBIGE6jr.js} +11 -3
- package/dist/others-DBIGE6jr.js.map +1 -0
- package/dist/others-DBO4Kjwl.d.ts +29 -0
- package/dist/{others-DWdK7vKp.cjs → others-WfjCsjqT.cjs} +14 -6
- package/dist/others-WfjCsjqT.cjs.map +1 -0
- package/dist/{parliament-Cru4IcuM.js → parliament-BKN6ikBJ.js} +30 -29
- package/dist/parliament-BKN6ikBJ.js.map +1 -0
- package/dist/{parliament-CLCI7tUO.d.ts → parliament-CHdf13XU.d.ts} +2 -2
- package/dist/{parliament-CgsVnWEe.d.cts → parliament-CsYgh4N2.d.cts} +2 -2
- package/dist/{parliament-x5hcFaQ3.cjs → parliament-DhxAaIZ3.cjs} +30 -29
- package/dist/parliament-DhxAaIZ3.cjs.map +1 -0
- package/dist/parliament.cjs +1 -1
- package/dist/parliament.d.cts +1 -1
- package/dist/parliament.d.ts +1 -1
- package/dist/parliament.js +1 -1
- package/dist/{patterns-D3-wQagb.cjs → patterns-BPN1c9qe.cjs} +2 -2
- package/dist/{patterns-D3-wQagb.cjs.map → patterns-BPN1c9qe.cjs.map} +1 -1
- package/dist/{patterns-CufKZYhm.js → patterns-CVrLrJXg.js} +2 -2
- package/dist/{patterns-CufKZYhm.js.map → patterns-CVrLrJXg.js.map} +1 -1
- package/dist/patterns.cjs +2 -2
- package/dist/patterns.d.cts +1 -1
- package/dist/patterns.d.ts +1 -1
- package/dist/patterns.js +2 -2
- package/dist/{percentage-bar-ybNS3goo.cjs → percentage-bar-BChkTRoz.cjs} +37 -35
- package/dist/percentage-bar-BChkTRoz.cjs.map +1 -0
- package/dist/{percentage-bar-nhTeakD_.d.ts → percentage-bar-CSAbzDOn.d.ts} +11 -15
- package/dist/{percentage-bar-B6tNOqNn.js → percentage-bar-CaInxrL8.js} +37 -35
- package/dist/percentage-bar-CaInxrL8.js.map +1 -0
- package/dist/{percentage-bar-tepMr7Hd.d.cts → percentage-bar-UZHCRvlK.d.cts} +11 -15
- package/dist/percentage-bar.cjs +1 -1
- package/dist/percentage-bar.d.cts +1 -1
- package/dist/percentage-bar.d.ts +1 -1
- package/dist/percentage-bar.js +1 -1
- package/dist/{pie-BXg2gNpb.d.cts → pie-AFedsDcF.d.cts} +17 -14
- package/dist/{pie-CVsc-6qD.js → pie-Ch6Bx0ih.js} +68 -52
- package/dist/pie-Ch6Bx0ih.js.map +1 -0
- package/dist/{pie-BpjvSPnz.cjs → pie-Cll1OrVZ.cjs} +68 -52
- package/dist/pie-Cll1OrVZ.cjs.map +1 -0
- package/dist/{pie-CFptILSm.d.ts → pie-Cn2H3pz8.d.ts} +17 -14
- package/dist/pie.cjs +1 -1
- package/dist/pie.d.cts +1 -1
- package/dist/pie.d.ts +1 -1
- package/dist/pie.js +1 -1
- package/dist/{point-shapes--_gmdTyK.cjs → point-shapes-BRawRM78.cjs} +23 -22
- package/dist/point-shapes-BRawRM78.cjs.map +1 -0
- package/dist/{point-shapes-DD2Ektzm.js → point-shapes-DI6GhcI7.js} +18 -23
- package/dist/point-shapes-DI6GhcI7.js.map +1 -0
- package/dist/point-shapes.cjs +6 -4
- package/dist/point-shapes.cjs.map +1 -1
- package/dist/point-shapes.d.cts +2 -2
- package/dist/point-shapes.d.ts +2 -2
- package/dist/point-shapes.js +7 -5
- package/dist/point-shapes.js.map +1 -1
- package/dist/{radar-BR-mumDd.js → radar-Bg-IiIWB.js} +21 -22
- package/dist/radar-Bg-IiIWB.js.map +1 -0
- package/dist/{radar-BC9Skgpj.d.ts → radar-DEer2jjd.d.ts} +2 -2
- package/dist/{radar-D1-lItDy.d.cts → radar-DxmjXhMc.d.cts} +2 -2
- package/dist/{radar-HPDrIdzc.cjs → radar-wDyX17S3.cjs} +22 -23
- package/dist/radar-wDyX17S3.cjs.map +1 -0
- package/dist/radar.cjs +1 -1
- package/dist/radar.d.cts +1 -1
- package/dist/radar.d.ts +1 -1
- package/dist/radar.js +1 -1
- package/dist/range-bar-BnKjJP89.cjs +348 -0
- package/dist/range-bar-BnKjJP89.cjs.map +1 -0
- package/dist/range-bar-C4cRaaQE.d.ts +123 -0
- package/dist/range-bar-D32dIQOY.d.cts +123 -0
- package/dist/range-bar-Dx6ce0J1.js +343 -0
- package/dist/range-bar-Dx6ce0J1.js.map +1 -0
- package/dist/range-bar.cjs +3 -0
- package/dist/range-bar.d.cts +3 -0
- package/dist/range-bar.d.ts +3 -0
- package/dist/range-bar.js +1 -0
- package/dist/{rect-DSVmUZrD.js → rect-CZTNvMlf.js} +2 -2
- package/dist/{rect-DSVmUZrD.js.map → rect-CZTNvMlf.js.map} +1 -1
- package/dist/{rect-D6VhynBM.cjs → rect-DPr9QRxl.cjs} +2 -2
- package/dist/{rect-D6VhynBM.cjs.map → rect-DPr9QRxl.cjs.map} +1 -1
- package/dist/{sankey-fCoo1cpz.cjs → sankey-0CSp_Er9.cjs} +72 -71
- package/dist/sankey-0CSp_Er9.cjs.map +1 -0
- package/dist/{sankey-Dk7jUt8x.d.cts → sankey-D-8ATwBT.d.cts} +2 -2
- package/dist/{sankey-D6JeZfK5.js → sankey-Dp4CuLVe.js} +72 -71
- package/dist/sankey-Dp4CuLVe.js.map +1 -0
- package/dist/{sankey-D_v7KxnJ.d.ts → sankey-DpYJsOI4.d.ts} +2 -2
- package/dist/sankey.cjs +1 -1
- package/dist/sankey.d.cts +1 -1
- package/dist/sankey.d.ts +1 -1
- package/dist/sankey.js +1 -1
- package/dist/{scatter-C0TWjFpW.js → scatter-0Z7K_YUz.js} +94 -46
- package/dist/scatter-0Z7K_YUz.js.map +1 -0
- package/dist/{scatter-CXEsioOJ.d.ts → scatter-BAL5K9_4.d.ts} +28 -9
- package/dist/{scatter-DZeEIfyo.d.cts → scatter-BUGbnRzM.d.cts} +28 -9
- package/dist/{scatter-DVqB_fP9.cjs → scatter-CZ8do3Up.cjs} +95 -47
- package/dist/scatter-CZ8do3Up.cjs.map +1 -0
- package/dist/scatter.cjs +1 -1
- package/dist/scatter.d.cts +2 -2
- package/dist/scatter.d.ts +2 -2
- package/dist/scatter.js +1 -1
- package/dist/slice-labels-1TBq7p3q.d.cts +28 -0
- package/dist/slice-labels-C9ucsBVW.js +88 -0
- package/dist/slice-labels-C9ucsBVW.js.map +1 -0
- package/dist/slice-labels-CbFiy46l.cjs +93 -0
- package/dist/slice-labels-CbFiy46l.cjs.map +1 -0
- package/dist/slice-labels-Cm5CyV7B.d.ts +28 -0
- package/dist/slice-labels.cjs +11 -0
- package/dist/slice-labels.cjs.map +1 -0
- package/dist/slice-labels.d.cts +6 -0
- package/dist/slice-labels.d.ts +6 -0
- package/dist/slice-labels.js +11 -0
- package/dist/slice-labels.js.map +1 -0
- package/dist/{sparkline-cbvRkWqS.d.ts → sparkline-CtoBJe-a.d.ts} +2 -2
- package/dist/{sparkline-B39NA0Mi.cjs → sparkline-DjR-V6BI.cjs} +13 -15
- package/dist/sparkline-DjR-V6BI.cjs.map +1 -0
- package/dist/{sparkline-DAP6jtzw.d.cts → sparkline-DwHJfeZz.d.cts} +2 -2
- package/dist/{sparkline-XO_TqCNP.js → sparkline-_dxwtdli.js} +13 -15
- package/dist/sparkline-_dxwtdli.js.map +1 -0
- package/dist/sparkline.cjs +1 -1
- package/dist/sparkline.d.cts +1 -1
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.js +1 -1
- package/dist/{stack-Dagxq7l2.d.cts → stack-CcmyALx0.d.cts} +1 -1
- package/dist/{stack-2H2Gfs1Q.js → stack-CyVlS7Fr.js} +2 -2
- package/dist/{stack-2H2Gfs1Q.js.map → stack-CyVlS7Fr.js.map} +1 -1
- package/dist/{stack-BgPzoQmv.cjs → stack-DBhmYNat.cjs} +2 -2
- package/dist/{stack-BgPzoQmv.cjs.map → stack-DBhmYNat.cjs.map} +1 -1
- package/dist/style.css +1 -1
- package/dist/{time-axis-BjZ1bYTK.cjs → time-axis-CVKjQKSS.cjs} +4 -3
- package/dist/{time-axis-BjZ1bYTK.cjs.map → time-axis-CVKjQKSS.cjs.map} +1 -1
- package/dist/{time-axis-FLONo54E.js → time-axis-CkmbAw4Z.js} +3 -2
- package/dist/{time-axis-FLONo54E.js.map → time-axis-CkmbAw4Z.js.map} +1 -1
- package/dist/time.cjs +3 -3
- package/dist/time.js +3 -3
- package/dist/{treemap-BAkhmVQc.d.cts → treemap-C2maqerU.d.cts} +37 -5
- package/dist/{treemap-BNpxFBao.d.ts → treemap-D_zbubo3.d.ts} +37 -5
- package/dist/{treemap-BWpEUlDh.cjs → treemap-PulGXZv0.cjs} +58 -33
- package/dist/treemap-PulGXZv0.cjs.map +1 -0
- package/dist/{treemap-CQdavQ9u.js → treemap-lbYxb-7h.js} +57 -32
- package/dist/treemap-lbYxb-7h.js.map +1 -0
- package/dist/treemap.cjs +1 -1
- package/dist/treemap.d.cts +1 -1
- package/dist/treemap.d.ts +1 -1
- package/dist/treemap.js +1 -1
- package/dist/{value-labels-BBuSi4i0.js → value-labels-B0VeheyE.js} +29 -8
- package/dist/value-labels-B0VeheyE.js.map +1 -0
- package/dist/{value-labels-BV9keAuL.cjs → value-labels-Dcyk3GIY.cjs} +29 -8
- package/dist/value-labels-Dcyk3GIY.cjs.map +1 -0
- package/dist/value-labels.cjs +2 -2
- package/dist/value-labels.d.cts +1 -1
- package/dist/value-labels.d.ts +1 -1
- package/dist/value-labels.js +2 -2
- package/dist/zoom.cjs +810 -0
- package/dist/zoom.cjs.map +1 -0
- package/dist/zoom.d.cts +34 -0
- package/dist/zoom.d.ts +34 -0
- package/dist/zoom.js +806 -0
- package/dist/zoom.js.map +1 -0
- package/package.json +120 -235
- package/dist/annotations-D0YQ0IoA.js.map +0 -1
- package/dist/annotations-DdRdeBUB.cjs.map +0 -1
- package/dist/area-0-L1bG9B.js.map +0 -1
- package/dist/area-4eRs3c0K.cjs.map +0 -1
- package/dist/bar-BNZ3GhIw.js.map +0 -1
- package/dist/bar-Da6dE_nI.cjs.map +0 -1
- package/dist/candlestick-BHQkQfxH.js.map +0 -1
- package/dist/candlestick-CYCQXgky.cjs.map +0 -1
- package/dist/cartesian-CI2x6N7N.js.map +0 -1
- package/dist/cartesian-DV02PsBe.cjs.map +0 -1
- package/dist/chart-DWn9v6qw.js.map +0 -1
- package/dist/chart-e2VqomCI.cjs.map +0 -1
- package/dist/core-BKRQvPAT.js.map +0 -1
- package/dist/core-DIOC61up.cjs.map +0 -1
- package/dist/dom-CuceR8gt.js.map +0 -1
- package/dist/dom-D_g13XWY.cjs.map +0 -1
- package/dist/export-chart-83UYH48t.js.map +0 -1
- package/dist/export-chart-mYgEfK-L.cjs.map +0 -1
- package/dist/fade-DVTkhrFU.cjs.map +0 -1
- package/dist/fade-GGxcBdss.js.map +0 -1
- package/dist/features-BMxkqCyS.js.map +0 -1
- package/dist/features-DCXEvoya.cjs.map +0 -1
- package/dist/gauge-DXkjXNCD.cjs.map +0 -1
- package/dist/gauge-ts0kqN1-.js.map +0 -1
- package/dist/heatmap-19BGJTKF.js.map +0 -1
- package/dist/heatmap-CXhlrLTl.cjs.map +0 -1
- package/dist/layout-DmrrLjwN.js.map +0 -1
- package/dist/layout-JY2aR-yE.cjs.map +0 -1
- package/dist/line-DO66LtwH.js.map +0 -1
- package/dist/line-Dbt6KFRK.cjs.map +0 -1
- package/dist/others-DWdK7vKp.cjs.map +0 -1
- package/dist/others-J7NCAMA0.js.map +0 -1
- package/dist/parliament-Cru4IcuM.js.map +0 -1
- package/dist/parliament-x5hcFaQ3.cjs.map +0 -1
- package/dist/percentage-bar-B6tNOqNn.js.map +0 -1
- package/dist/percentage-bar-ybNS3goo.cjs.map +0 -1
- package/dist/pie-BpjvSPnz.cjs.map +0 -1
- package/dist/pie-CVsc-6qD.js.map +0 -1
- package/dist/point-shapes--_gmdTyK.cjs.map +0 -1
- package/dist/point-shapes-DD2Ektzm.js.map +0 -1
- package/dist/radar-BR-mumDd.js.map +0 -1
- package/dist/radar-HPDrIdzc.cjs.map +0 -1
- package/dist/sankey-D6JeZfK5.js.map +0 -1
- package/dist/sankey-fCoo1cpz.cjs.map +0 -1
- package/dist/scatter-C0TWjFpW.js.map +0 -1
- package/dist/scatter-DVqB_fP9.cjs.map +0 -1
- package/dist/sparkline-B39NA0Mi.cjs.map +0 -1
- package/dist/sparkline-XO_TqCNP.js.map +0 -1
- package/dist/treemap-BWpEUlDh.cjs.map +0 -1
- package/dist/treemap-CQdavQ9u.js.map +0 -1
- package/dist/value-labels-BBuSi4i0.js.map +0 -1
- package/dist/value-labels-BV9keAuL.cjs.map +0 -1
package/dist/zoom.cjs
ADDED
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
|
|
3
|
+
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
4
|
+
const require_features = require("./features-DEDP5CEQ.cjs");
|
|
5
|
+
const require_layout = require("./layout-Cfg9x1k2.cjs");
|
|
6
|
+
const require_interaction = require("./interaction-DXYSjgnP.cjs");
|
|
7
|
+
// src/charts/view.ts
|
|
8
|
+
/** How many categories the data of a chart has (candles, or labels). */
|
|
9
|
+
const categoryCount = (data) => Array.isArray(data) ? data.length : require_cartesian.resolveLabels(data).length;
|
|
10
|
+
/** The first and last index of a view over `count` categories, within the data. */
|
|
11
|
+
function viewRange(view, count) {
|
|
12
|
+
const last = Math.max(0, count - 1);
|
|
13
|
+
const within = (value, low) => Math.min(last, Math.max(low, Math.round(value)));
|
|
14
|
+
const start = within(require_clean.finite(view?.start) ?? 0, 0);
|
|
15
|
+
return [start, within(require_clean.finite(view?.end) ?? last, start)];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The options of a chart with only the categories of its `view`: the chart
|
|
19
|
+
* type then draws them like any other data, so axes, stacks, tooltips and
|
|
20
|
+
* the table all follow the range shown.
|
|
21
|
+
*/
|
|
22
|
+
function viewWindow(options) {
|
|
23
|
+
const { data, view, x } = options;
|
|
24
|
+
const [start, end] = viewRange(view, categoryCount(data));
|
|
25
|
+
if (start === 0 && end >= categoryCount(data) - 1) return options;
|
|
26
|
+
const cut = (list) => list.slice(start, end + 1);
|
|
27
|
+
const out = { ...options };
|
|
28
|
+
const format = x?.format;
|
|
29
|
+
if (format) out.x = {
|
|
30
|
+
...x,
|
|
31
|
+
format: (label, index) => format(label, index + start)
|
|
32
|
+
};
|
|
33
|
+
if (Array.isArray(data)) {
|
|
34
|
+
out.data = cut(data);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
const all = data;
|
|
38
|
+
const labels = require_cartesian.resolveLabels(all);
|
|
39
|
+
const keys = labels.map(require_cartesian.labelKey);
|
|
40
|
+
out.data = {
|
|
41
|
+
...all,
|
|
42
|
+
labels: cut(labels),
|
|
43
|
+
series: all.series.map((series) => {
|
|
44
|
+
const next = {
|
|
45
|
+
...series,
|
|
46
|
+
values: cut(series.values)
|
|
47
|
+
};
|
|
48
|
+
const from = series.dashFrom == null ? -1 : keys.indexOf(require_cartesian.labelKey(series.dashFrom));
|
|
49
|
+
if (from >= 0 && from < start) next.dashFrom = labels[start];
|
|
50
|
+
return next;
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
// src/plugins/plot.ts
|
|
56
|
+
/** The chart types whose categories can be zoomed and brushed. */
|
|
57
|
+
const TYPES = /* @__PURE__ */ new Set([
|
|
58
|
+
"line",
|
|
59
|
+
"area",
|
|
60
|
+
"bar",
|
|
61
|
+
"candlestick"
|
|
62
|
+
]);
|
|
63
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
64
|
+
function plotTools(chart) {
|
|
65
|
+
const host = chart.element;
|
|
66
|
+
const svg = () => host.querySelector(":scope > svg.tc-chart");
|
|
67
|
+
/** The plot area and the direction of its categories, in chart pixels. */
|
|
68
|
+
const plot = () => {
|
|
69
|
+
const interaction = chart.interaction;
|
|
70
|
+
const hit = interaction?.hitIndex(0);
|
|
71
|
+
if (!hit || !interaction) return void 0;
|
|
72
|
+
const vertical = hit.axis === "y";
|
|
73
|
+
const along = (h) => vertical ? h.y : h.x;
|
|
74
|
+
const last = interaction.count - 1;
|
|
75
|
+
const end = interaction.hitIndex(last);
|
|
76
|
+
const step = end && last > 0 && Math.abs(along(end) - along(hit)) / last || (vertical ? hit.area.height : hit.area.width) || 1;
|
|
77
|
+
return {
|
|
78
|
+
area: hit.area,
|
|
79
|
+
vertical,
|
|
80
|
+
reversed: !!interaction.reversed,
|
|
81
|
+
step,
|
|
82
|
+
at: (index) => {
|
|
83
|
+
const at = interaction.hitIndex(index);
|
|
84
|
+
return at ? along(at) : void 0;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** A point of the screen in chart pixels, and whether it is on the plot. */
|
|
89
|
+
const locate = (x, y) => {
|
|
90
|
+
const el = svg();
|
|
91
|
+
const area = plot()?.area;
|
|
92
|
+
if (!el || !area) return void 0;
|
|
93
|
+
const { width, height } = chart.size;
|
|
94
|
+
const p = require_interaction.toChartPoint(el, x, y, width, height);
|
|
95
|
+
const inside = p.x >= area.x && p.x <= area.x + area.width && p.y >= area.y && p.y <= area.y + area.height;
|
|
96
|
+
const within = (value, low, size) => Math.min(low + size, Math.max(low, value));
|
|
97
|
+
return {
|
|
98
|
+
at: [within(p.x, area.x, area.width), within(p.y, area.y, area.height)],
|
|
99
|
+
inside
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/** Whether an event happened on the plot of the chart, not on a control over it. */
|
|
103
|
+
const onPlot = (event) => event.target?.closest?.("svg.tc-chart") === svg() && !!locate(event.clientX, event.clientY)?.inside;
|
|
104
|
+
return {
|
|
105
|
+
svg,
|
|
106
|
+
plot,
|
|
107
|
+
locate,
|
|
108
|
+
onPlot
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// src/plugins/brush.ts
|
|
112
|
+
/** The charts of each `sync` group that can pass a range on. */
|
|
113
|
+
const groups = /* @__PURE__ */ new Map();
|
|
114
|
+
const configOf = (chart) => chart.config;
|
|
115
|
+
const isBrush = (chart) => !!configOf(chart).brush;
|
|
116
|
+
/** The option a chart keeps its range in: the mark of a brush, the view of any other chart. */
|
|
117
|
+
const rangeKey = (chart) => isBrush(chart) ? "selection" : "view";
|
|
118
|
+
const countOf = (chart) => categoryCount(configOf(chart).data);
|
|
119
|
+
const rangeOf = (chart) => viewRange(configOf(chart)[rangeKey(chart)], countOf(chart));
|
|
120
|
+
const whole = (chart, [start, end]) => start === 0 && end >= countOf(chart) - 1;
|
|
121
|
+
/** How each chart of a group with a brush lines its plot up with the others. */
|
|
122
|
+
const aligners = /* @__PURE__ */ new WeakMap();
|
|
123
|
+
/** What that adds to the padding of a chart, before and after its plot. */
|
|
124
|
+
const extra = /* @__PURE__ */ new WeakMap();
|
|
125
|
+
/** Whether the categories of a chart run along y; `undefined` before it has a plot. */
|
|
126
|
+
const flow = (chart) => plotTools(chart).plot()?.vertical;
|
|
127
|
+
/** Whether a chart takes part: every zoomable chart, but a brush with `align: false`. */
|
|
128
|
+
const aligns = (chart) => {
|
|
129
|
+
const { brush } = configOf(chart);
|
|
130
|
+
return TYPES.has(chart.config.type.name) && !(typeof brush === "object" && brush.align === false);
|
|
131
|
+
};
|
|
132
|
+
/** The space before and after the plot of a chart along its categories, without what was added. */
|
|
133
|
+
function natural(chart, vertical) {
|
|
134
|
+
const area = plotTools(chart).plot()?.area;
|
|
135
|
+
if (!area) return void 0;
|
|
136
|
+
const { width, height } = chart.size;
|
|
137
|
+
return (vertical ? [area.y, height - area.y - area.height] : [area.x, width - area.x - area.width]).map((space, i) => space - (extra.get(chart)?.[i] ?? 0));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The range each chart last passed on or was given, so that only a range
|
|
141
|
+
* that changed is passed on, and never back to where it came from.
|
|
142
|
+
*/
|
|
143
|
+
const passed = /* @__PURE__ */ new WeakMap();
|
|
144
|
+
const rangeText = (chart) => `${rangeKey(chart)} ${rangeOf(chart)}`;
|
|
145
|
+
/** The keys of a chart's labels, in order, once per data. */
|
|
146
|
+
const keys = /* @__PURE__ */ new WeakMap();
|
|
147
|
+
function labelKeys(chart) {
|
|
148
|
+
const { data } = configOf(chart);
|
|
149
|
+
let list = keys.get(data);
|
|
150
|
+
if (!list) {
|
|
151
|
+
list = (Array.isArray(data) ? data.map((candle) => candle.x) : require_cartesian.resolveLabels(data)).map(require_cartesian.labelKey);
|
|
152
|
+
keys.set(data, list);
|
|
153
|
+
}
|
|
154
|
+
return list;
|
|
155
|
+
}
|
|
156
|
+
/** Sets the range of a chart, when it is not the one it has. */
|
|
157
|
+
function setRange(chart, [start, end]) {
|
|
158
|
+
const [was, wasEnd] = rangeOf(chart);
|
|
159
|
+
if (start === was && end === wasEnd) return;
|
|
160
|
+
const range = whole(chart, [start, end]) ? void 0 : {
|
|
161
|
+
start,
|
|
162
|
+
end
|
|
163
|
+
};
|
|
164
|
+
chart.update({ [rangeKey(chart)]: range });
|
|
165
|
+
}
|
|
166
|
+
/** The range of `from` in the categories of `to`: the same labels, or else the same indexes. */
|
|
167
|
+
function mapRange(from, to, range) {
|
|
168
|
+
if (whole(from, range)) return void 0;
|
|
169
|
+
const source = labelKeys(from);
|
|
170
|
+
const target = labelKeys(to);
|
|
171
|
+
const at = (index) => {
|
|
172
|
+
const found = target.indexOf(source[index]);
|
|
173
|
+
return found < 0 ? index : found;
|
|
174
|
+
};
|
|
175
|
+
return viewRange({
|
|
176
|
+
start: at(range[0]),
|
|
177
|
+
end: at(range[1])
|
|
178
|
+
}, target.length);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The brush (`brush: true`): a chart that shows all its data with a range
|
|
182
|
+
* marked on it. Dragging the range moves it, dragging one of its ends
|
|
183
|
+
* resizes it, dragging elsewhere draws a new one, a double click (or `0`)
|
|
184
|
+
* marks everything, and Shift with an arrow key moves it by one category.
|
|
185
|
+
* Charts in the same `sync` group take the range as their `view`, and a
|
|
186
|
+
* chart of the group that is zoomed moves the range of the brush. Like the
|
|
187
|
+
* zoom it keeps no state: the range lives in the `selection` option.
|
|
188
|
+
*/
|
|
189
|
+
const installBrush = (chart) => {
|
|
190
|
+
const host = chart.element;
|
|
191
|
+
if (typeof host.addEventListener !== "function") return {};
|
|
192
|
+
const doc = host.ownerDocument;
|
|
193
|
+
const { svg, plot, locate, onPlot } = plotTools(chart);
|
|
194
|
+
const cartesian = () => TYPES.has(chart.config.type.name);
|
|
195
|
+
const on = () => cartesian() && isBrush(chart);
|
|
196
|
+
const least = () => {
|
|
197
|
+
const { brush } = configOf(chart);
|
|
198
|
+
const min = typeof brush === "object" ? require_clean.finite(brush.min) : null;
|
|
199
|
+
return Math.max(0, Math.min(countOf(chart), Math.round(min ?? 2)) - 1);
|
|
200
|
+
};
|
|
201
|
+
/** Marks the categories from `start` to `end`, kept within the data and the smallest range. */
|
|
202
|
+
const mark = (start, end) => {
|
|
203
|
+
const last = Math.max(0, countOf(chart) - 1);
|
|
204
|
+
const size = Math.min(last, Math.max(least(), end - start));
|
|
205
|
+
const from = Math.min(last - size, Math.max(0, start));
|
|
206
|
+
setRange(chart, [from, from + size]);
|
|
207
|
+
};
|
|
208
|
+
let group;
|
|
209
|
+
let joined;
|
|
210
|
+
const leave = () => {
|
|
211
|
+
group?.delete(chart);
|
|
212
|
+
if (joined && group?.size === 0 && groups.get(joined) === group) groups.delete(joined);
|
|
213
|
+
group = void 0;
|
|
214
|
+
};
|
|
215
|
+
const join = () => {
|
|
216
|
+
const name = cartesian() ? configOf(chart).sync : void 0;
|
|
217
|
+
if (name === joined && group) return;
|
|
218
|
+
leave();
|
|
219
|
+
joined = name;
|
|
220
|
+
if (!name) return;
|
|
221
|
+
group = groups.get(name) ?? /* @__PURE__ */ new Set();
|
|
222
|
+
group.add(chart);
|
|
223
|
+
groups.set(name, group);
|
|
224
|
+
};
|
|
225
|
+
/** Gives a range that changed to the other side: a brush to the charts, a chart to the brushes. */
|
|
226
|
+
const pass = () => {
|
|
227
|
+
join();
|
|
228
|
+
if (!group) return;
|
|
229
|
+
const range = rangeOf(chart);
|
|
230
|
+
const key = rangeText(chart);
|
|
231
|
+
const first = !passed.has(chart);
|
|
232
|
+
if (key === passed.get(chart)) return;
|
|
233
|
+
passed.set(chart, key);
|
|
234
|
+
const others = [...group].filter((other) => isBrush(other) !== isBrush(chart));
|
|
235
|
+
if (first && whole(chart, range)) {
|
|
236
|
+
for (const other of others) {
|
|
237
|
+
const given = mapRange(other, chart, rangeOf(other));
|
|
238
|
+
if (given) return setRange(chart, given);
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
for (const other of others) {
|
|
243
|
+
setRange(other, mapRange(chart, other, range) ?? [0, countOf(other) - 1]);
|
|
244
|
+
if (!isBrush(other)) passed.set(other, rangeText(other));
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
/** The padding the chart was given, and the one set here in its place. */
|
|
248
|
+
let own = configOf(chart).padding;
|
|
249
|
+
let given = own;
|
|
250
|
+
/** What the padding set here adds, until the chart is drawn with it. */
|
|
251
|
+
let pending;
|
|
252
|
+
const align = (drawn) => {
|
|
253
|
+
const changed = configOf(chart).padding !== given;
|
|
254
|
+
if (!drawn && (pending || changed)) return;
|
|
255
|
+
if (changed) {
|
|
256
|
+
own = configOf(chart).padding;
|
|
257
|
+
given = own;
|
|
258
|
+
extra.delete(chart);
|
|
259
|
+
} else if (pending) extra.set(chart, pending);
|
|
260
|
+
pending = void 0;
|
|
261
|
+
const added = extra.get(chart) ?? [0, 0];
|
|
262
|
+
const vertical = aligns(chart) ? plot()?.vertical : void 0;
|
|
263
|
+
let next = [0, 0];
|
|
264
|
+
if (vertical !== void 0 && group) {
|
|
265
|
+
const all = [...group].filter((other) => aligns(other) && flow(other) === vertical);
|
|
266
|
+
const mine = natural(chart, vertical);
|
|
267
|
+
if (mine && all.some(isBrush)) {
|
|
268
|
+
const spaces = all.map((other) => natural(other, vertical));
|
|
269
|
+
next = mine.map((space, i) => Math.max(0, ...spaces.map((other) => other ? other[i] - space : 0)));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (next.every((space, i) => Math.abs(space - added[i]) < .5)) return;
|
|
273
|
+
pending = next;
|
|
274
|
+
const base = require_layout.insets(own);
|
|
275
|
+
const [a, b] = vertical ? ["top", "bottom"] : ["left", "right"];
|
|
276
|
+
given = next.some(Boolean) ? {
|
|
277
|
+
...base,
|
|
278
|
+
[a]: base[a] + next[0],
|
|
279
|
+
[b]: base[b] + next[1]
|
|
280
|
+
} : own;
|
|
281
|
+
chart.update({ padding: given });
|
|
282
|
+
};
|
|
283
|
+
aligners.set(chart, align);
|
|
284
|
+
let nodes;
|
|
285
|
+
const clearMark = () => {
|
|
286
|
+
nodes?.[0].remove();
|
|
287
|
+
nodes = void 0;
|
|
288
|
+
};
|
|
289
|
+
const drawMark = () => {
|
|
290
|
+
const el = svg();
|
|
291
|
+
const p = plot();
|
|
292
|
+
if (!on() || !el || !p) {
|
|
293
|
+
clearMark();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (!nodes) {
|
|
297
|
+
const rect = (name) => {
|
|
298
|
+
const node = doc.createElementNS(SVG_NS, "rect");
|
|
299
|
+
node.setAttribute("class", name);
|
|
300
|
+
return node;
|
|
301
|
+
};
|
|
302
|
+
const g = doc.createElementNS(SVG_NS, "g");
|
|
303
|
+
g.setAttribute("class", "tc-brush");
|
|
304
|
+
nodes = [
|
|
305
|
+
g,
|
|
306
|
+
rect("tc-brush-selection"),
|
|
307
|
+
rect("tc-brush-handle"),
|
|
308
|
+
rect("tc-brush-handle")
|
|
309
|
+
];
|
|
310
|
+
g.append(nodes[1], nodes[2], nodes[3]);
|
|
311
|
+
}
|
|
312
|
+
if (nodes[0].parentNode !== el) el.append(nodes[0]);
|
|
313
|
+
const [start, end] = rangeOf(chart);
|
|
314
|
+
const low = p.vertical ? p.area.y : p.area.x;
|
|
315
|
+
const length = p.vertical ? p.area.height : p.area.width;
|
|
316
|
+
const within = (value) => Math.min(low + length, Math.max(low, value));
|
|
317
|
+
const a = p.at(start) ?? low;
|
|
318
|
+
const b = p.at(end) ?? low + length;
|
|
319
|
+
const from = within(Math.min(a, b) - p.step / 2);
|
|
320
|
+
const to = within(Math.max(a, b) + p.step / 2);
|
|
321
|
+
const box = (node, at, size) => {
|
|
322
|
+
const attrs = p.vertical ? {
|
|
323
|
+
x: p.area.x,
|
|
324
|
+
y: at,
|
|
325
|
+
width: p.area.width,
|
|
326
|
+
height: size
|
|
327
|
+
} : {
|
|
328
|
+
x: at,
|
|
329
|
+
y: p.area.y,
|
|
330
|
+
width: size,
|
|
331
|
+
height: p.area.height
|
|
332
|
+
};
|
|
333
|
+
for (const [name, value] of Object.entries(attrs)) node.setAttribute(name, `${value}`);
|
|
334
|
+
};
|
|
335
|
+
box(nodes[1], from, to - from);
|
|
336
|
+
const ends = a <= b ? [from, to] : [to, from];
|
|
337
|
+
box(nodes[2], ends[0] - 3, 6);
|
|
338
|
+
box(nodes[3], ends[1] - 3, 6);
|
|
339
|
+
};
|
|
340
|
+
let press;
|
|
341
|
+
let pointer;
|
|
342
|
+
/** Whether the pointer that is down has moved: the click that ends a drag is no click. */
|
|
343
|
+
let dragged = false;
|
|
344
|
+
const indexAt = ([x, y]) => chart.interaction?.hitTest(x, y)?.index;
|
|
345
|
+
const onPointerEnd = (event) => {
|
|
346
|
+
if (event.pointerId !== pointer) return;
|
|
347
|
+
press = void 0;
|
|
348
|
+
pointer = void 0;
|
|
349
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
350
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
351
|
+
};
|
|
352
|
+
const onPointerDown = (event) => {
|
|
353
|
+
if (!on() || press || !onPlot(event)) return;
|
|
354
|
+
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
355
|
+
const at = locate(event.clientX, event.clientY)?.at;
|
|
356
|
+
const index = at && indexAt(at);
|
|
357
|
+
if (!at || index === void 0) return;
|
|
358
|
+
const target = event.target;
|
|
359
|
+
const mode = target === nodes?.[2] ? 0 : target === nodes?.[3] ? 1 : target === nodes?.[1] ? "move" : "new";
|
|
360
|
+
press = {
|
|
361
|
+
from: at,
|
|
362
|
+
range: rangeOf(chart),
|
|
363
|
+
mode,
|
|
364
|
+
index
|
|
365
|
+
};
|
|
366
|
+
pointer = event.pointerId;
|
|
367
|
+
dragged = false;
|
|
368
|
+
doc.addEventListener("pointerup", onPointerEnd);
|
|
369
|
+
doc.addEventListener("pointercancel", onPointerEnd);
|
|
370
|
+
};
|
|
371
|
+
const onPointerMove = (event) => {
|
|
372
|
+
const p = plot();
|
|
373
|
+
const now = press && event.pointerId === pointer && locate(event.clientX, event.clientY)?.at;
|
|
374
|
+
if (!press || !now || !p) return;
|
|
375
|
+
const i = p.vertical ? 1 : 0;
|
|
376
|
+
if (!dragged) {
|
|
377
|
+
if (Math.abs(now[i] - press.from[i]) < 4) return;
|
|
378
|
+
dragged = true;
|
|
379
|
+
try {
|
|
380
|
+
svg()?.setPointerCapture(event.pointerId);
|
|
381
|
+
} catch {}
|
|
382
|
+
}
|
|
383
|
+
event.stopPropagation();
|
|
384
|
+
chart.clearHighlight();
|
|
385
|
+
const [start, end] = press.range;
|
|
386
|
+
const index = indexAt(now);
|
|
387
|
+
if (press.mode === "move") {
|
|
388
|
+
const moved = (now[i] - press.from[i]) / p.step;
|
|
389
|
+
const by = Math.round(p.reversed ? -moved : moved);
|
|
390
|
+
const last = Math.max(0, countOf(chart) - 1);
|
|
391
|
+
const shift = Math.min(last - end, Math.max(-start, by));
|
|
392
|
+
mark(start + shift, end + shift);
|
|
393
|
+
} else if (index === void 0) return;
|
|
394
|
+
else if (press.mode === "new") mark(Math.min(press.index, index), Math.max(press.index, index));
|
|
395
|
+
else if (press.mode === 0) mark(Math.min(index, end - least()), end);
|
|
396
|
+
else mark(start, Math.max(index, start + least()));
|
|
397
|
+
};
|
|
398
|
+
/** The click that ends a drag is not a click on the chart. */
|
|
399
|
+
const onClickCapture = (event) => {
|
|
400
|
+
if (dragged) event.stopPropagation();
|
|
401
|
+
dragged = false;
|
|
402
|
+
};
|
|
403
|
+
const onDoubleClick = (event) => {
|
|
404
|
+
if (on() && onPlot(event)) mark(0, countOf(chart) - 1);
|
|
405
|
+
};
|
|
406
|
+
const onKey = (event) => {
|
|
407
|
+
if (event.target !== svg() || !on()) return;
|
|
408
|
+
const { key } = event;
|
|
409
|
+
const arrow = key === "ArrowLeft" ? -1 : key === "ArrowRight" ? 1 : 0;
|
|
410
|
+
const [start, end] = rangeOf(chart);
|
|
411
|
+
if (key === "0") mark(0, countOf(chart) - 1);
|
|
412
|
+
else if (event.shiftKey && arrow) {
|
|
413
|
+
const by = plot()?.reversed ? -arrow : arrow;
|
|
414
|
+
const last = Math.max(0, countOf(chart) - 1);
|
|
415
|
+
const shift = Math.min(last - end, Math.max(-start, by));
|
|
416
|
+
mark(start + shift, end + shift);
|
|
417
|
+
} else return;
|
|
418
|
+
event.stopPropagation();
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
};
|
|
421
|
+
host.addEventListener("pointermove", onPointerMove, true);
|
|
422
|
+
host.addEventListener("click", onClickCapture, true);
|
|
423
|
+
host.addEventListener("keydown", onKey, true);
|
|
424
|
+
host.addEventListener("pointerdown", onPointerDown);
|
|
425
|
+
host.addEventListener("dblclick", onDoubleClick);
|
|
426
|
+
return {
|
|
427
|
+
svgAttrs: () => on() ? { "data-zoom-axis": plot()?.vertical ? "y" : "x" } : void 0,
|
|
428
|
+
afterRender() {
|
|
429
|
+
drawMark();
|
|
430
|
+
pass();
|
|
431
|
+
for (const other of group ?? [chart]) aligners.get(other)?.(other === chart);
|
|
432
|
+
},
|
|
433
|
+
destroy() {
|
|
434
|
+
host.removeEventListener("pointermove", onPointerMove, true);
|
|
435
|
+
host.removeEventListener("click", onClickCapture, true);
|
|
436
|
+
host.removeEventListener("keydown", onKey, true);
|
|
437
|
+
host.removeEventListener("pointerdown", onPointerDown);
|
|
438
|
+
host.removeEventListener("dblclick", onDoubleClick);
|
|
439
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
440
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
441
|
+
clearMark();
|
|
442
|
+
const rest = group;
|
|
443
|
+
leave();
|
|
444
|
+
for (const other of rest ?? []) aligners.get(other)?.();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
// src/plugins/zoom.ts
|
|
449
|
+
/** One step of a button or a key. */
|
|
450
|
+
const ZOOM_STEP = 2;
|
|
451
|
+
/** How much one unit of wheel movement magnifies; a pinch on a trackpad comes with `ctrlKey` and smaller numbers. */
|
|
452
|
+
const WHEEL_SPEED = .002;
|
|
453
|
+
const WHEEL_SPEED_PINCH = .01;
|
|
454
|
+
const BUTTONS = [
|
|
455
|
+
[
|
|
456
|
+
"in",
|
|
457
|
+
"Zoom in",
|
|
458
|
+
"M12 5v14M5 12h14"
|
|
459
|
+
],
|
|
460
|
+
[
|
|
461
|
+
"out",
|
|
462
|
+
"Zoom out",
|
|
463
|
+
"M5 12h14"
|
|
464
|
+
],
|
|
465
|
+
[
|
|
466
|
+
"reset",
|
|
467
|
+
"Reset zoom",
|
|
468
|
+
"M20 11a8.1 8.1 0 0 0-15.5-2M4 5v4h4M4 13a8.1 8.1 0 0 0 15.5 2M20 19v-4h-4"
|
|
469
|
+
]
|
|
470
|
+
];
|
|
471
|
+
/**
|
|
472
|
+
* Zoom along the categories of line, area, bar and candlestick charts
|
|
473
|
+
* (`zoom: true`): the wheel and a pinch magnify around the pointer, a drag
|
|
474
|
+
* over the plot picks the range to show, the buttons and the `+`, `-` and
|
|
475
|
+
* `0` keys zoom in, out and back to everything, and Shift with a drag, the
|
|
476
|
+
* wheel or an arrow key moves the range. It keeps no state: the range shown
|
|
477
|
+
* lives in the `view` option, which the chart types cut their data to.
|
|
478
|
+
* `@tabler/charts/zoom` registers it; the `zoom()` plugin installs it.
|
|
479
|
+
*/
|
|
480
|
+
const installZoom = (chart) => {
|
|
481
|
+
const host = chart.element;
|
|
482
|
+
if (typeof host.addEventListener !== "function") return {};
|
|
483
|
+
const doc = host.ownerDocument;
|
|
484
|
+
const config = () => chart.config;
|
|
485
|
+
const on = () => TYPES.has(chart.config.type.name) && !!config().zoom && !config().brush;
|
|
486
|
+
const options = () => {
|
|
487
|
+
const { zoom } = config();
|
|
488
|
+
return typeof zoom === "object" ? zoom : {};
|
|
489
|
+
};
|
|
490
|
+
const count = () => categoryCount(config().data);
|
|
491
|
+
const range = () => viewRange(config().view, count());
|
|
492
|
+
/** The fewest categories shown, less one: the smallest distance from start to end. */
|
|
493
|
+
const least = () => Math.max(0, Math.min(count(), Math.round(require_clean.finite(options().min) ?? 2)) - 1);
|
|
494
|
+
const { svg, plot, locate, onPlot } = plotTools(chart);
|
|
495
|
+
/**
|
|
496
|
+
* The range the chart was last drawn with. Its hits count from there,
|
|
497
|
+
* and a few events can come before the next range is drawn.
|
|
498
|
+
*/
|
|
499
|
+
let drawn = [0, 0];
|
|
500
|
+
/** The index, in the whole data, of the category at a point of the plot. */
|
|
501
|
+
const indexAt = ([x, y]) => {
|
|
502
|
+
const hit = chart.interaction?.hitTest(x, y);
|
|
503
|
+
return hit ? drawn[0] + hit.index : void 0;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* The range as fractions of categories, with the whole categories it
|
|
507
|
+
* stands for: small steps of the wheel add up instead of rounding away.
|
|
508
|
+
*/
|
|
509
|
+
let fine;
|
|
510
|
+
const edges = () => {
|
|
511
|
+
const [start, end] = range();
|
|
512
|
+
if (fine?.start !== start || fine.end !== end) fine = {
|
|
513
|
+
a: start,
|
|
514
|
+
b: end,
|
|
515
|
+
start,
|
|
516
|
+
end
|
|
517
|
+
};
|
|
518
|
+
return [fine.a, fine.b];
|
|
519
|
+
};
|
|
520
|
+
/** Shows the categories from `a` to `b`, kept within the data and the smallest range. */
|
|
521
|
+
const show = (a, b) => {
|
|
522
|
+
const last = Math.max(0, count() - 1);
|
|
523
|
+
const size = Math.min(last, Math.max(least(), b - a));
|
|
524
|
+
a += (b - a - size) / 2;
|
|
525
|
+
a = Math.min(last - size, Math.max(0, a));
|
|
526
|
+
b = a + size;
|
|
527
|
+
let start = Math.round(a);
|
|
528
|
+
let end = Math.round(b);
|
|
529
|
+
if (end - start < least()) {
|
|
530
|
+
end = Math.min(last, start + least());
|
|
531
|
+
start = end - least();
|
|
532
|
+
}
|
|
533
|
+
const [was, wasEnd] = range();
|
|
534
|
+
fine = {
|
|
535
|
+
a,
|
|
536
|
+
b,
|
|
537
|
+
start,
|
|
538
|
+
end
|
|
539
|
+
};
|
|
540
|
+
if (start === was && end === wasEnd) return false;
|
|
541
|
+
chart.update({ view: start === 0 && end === last ? void 0 : {
|
|
542
|
+
start,
|
|
543
|
+
end
|
|
544
|
+
} });
|
|
545
|
+
return true;
|
|
546
|
+
};
|
|
547
|
+
/** Magnifies by a factor around a category, which stays where it is. */
|
|
548
|
+
const zoomBy = (factor, anchor) => {
|
|
549
|
+
const [a, b] = edges();
|
|
550
|
+
const active = chart.active;
|
|
551
|
+
const center = anchor ?? (active ? drawn[0] + active.index : (a + b) / 2);
|
|
552
|
+
return show(center - (center - a) / factor, center + (b - center) / factor);
|
|
553
|
+
};
|
|
554
|
+
const panBy = (categories) => {
|
|
555
|
+
const [a, b] = edges();
|
|
556
|
+
const last = Math.max(0, count() - 1);
|
|
557
|
+
const by = Math.min(last - b, Math.max(-a, categories));
|
|
558
|
+
return show(a + by, b + by);
|
|
559
|
+
};
|
|
560
|
+
const reset = () => show(0, count() - 1);
|
|
561
|
+
/** Pointers that are down on the plot, with where each was last seen. */
|
|
562
|
+
const pointers = /* @__PURE__ */ new Map();
|
|
563
|
+
let press;
|
|
564
|
+
/** Whether the pointers that are down have moved: the click that ends a drag is no click. */
|
|
565
|
+
let dragged = false;
|
|
566
|
+
let selection;
|
|
567
|
+
let controls;
|
|
568
|
+
const addedClass = !host.classList.contains("tc-container");
|
|
569
|
+
const clearSelection = () => {
|
|
570
|
+
selection?.remove();
|
|
571
|
+
selection = void 0;
|
|
572
|
+
};
|
|
573
|
+
/** The rectangle over the categories of a drag, across the plot. */
|
|
574
|
+
const drawSelection = (from, to) => {
|
|
575
|
+
const el = svg();
|
|
576
|
+
const p = plot();
|
|
577
|
+
if (!el || !p) return;
|
|
578
|
+
if (!selection) {
|
|
579
|
+
selection = doc.createElementNS(SVG_NS, "rect");
|
|
580
|
+
selection.setAttribute("class", "tc-zoom-selection");
|
|
581
|
+
}
|
|
582
|
+
if (selection.parentNode !== el) el.append(selection);
|
|
583
|
+
const i = p.vertical ? 1 : 0;
|
|
584
|
+
const low = Math.min(from[i], to[i]);
|
|
585
|
+
const size = Math.abs(from[i] - to[i]);
|
|
586
|
+
const box = p.vertical ? {
|
|
587
|
+
x: p.area.x,
|
|
588
|
+
y: low,
|
|
589
|
+
width: p.area.width,
|
|
590
|
+
height: size
|
|
591
|
+
} : {
|
|
592
|
+
x: low,
|
|
593
|
+
y: p.area.y,
|
|
594
|
+
width: size,
|
|
595
|
+
height: p.area.height
|
|
596
|
+
};
|
|
597
|
+
for (const [name, value] of Object.entries(box)) selection.setAttribute(name, `${value}`);
|
|
598
|
+
};
|
|
599
|
+
const onPointerEnd = (event) => {
|
|
600
|
+
const last = pointers.get(event.pointerId);
|
|
601
|
+
pointers.delete(event.pointerId);
|
|
602
|
+
if (press && !press.pan && dragged && last && event.type === "pointerup") {
|
|
603
|
+
const from = indexAt(press.from);
|
|
604
|
+
const to = indexAt(last);
|
|
605
|
+
if (from !== void 0 && to !== void 0 && from !== to) show(Math.min(from, to), Math.max(from, to));
|
|
606
|
+
}
|
|
607
|
+
if (pointers.size === 0) {
|
|
608
|
+
press = void 0;
|
|
609
|
+
clearSelection();
|
|
610
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
611
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
const onPointerDown = (event) => {
|
|
615
|
+
if (!on() || !onPlot(event) || event.pointerType === "mouse" && event.button !== 0) return;
|
|
616
|
+
const at = locate(event.clientX, event.clientY)?.at;
|
|
617
|
+
if (!at) return;
|
|
618
|
+
if (pointers.size === 0) {
|
|
619
|
+
dragged = false;
|
|
620
|
+
press = {
|
|
621
|
+
from: at,
|
|
622
|
+
range: drawn,
|
|
623
|
+
pan: event.shiftKey
|
|
624
|
+
};
|
|
625
|
+
} else {
|
|
626
|
+
press = void 0;
|
|
627
|
+
clearSelection();
|
|
628
|
+
}
|
|
629
|
+
pointers.set(event.pointerId, at);
|
|
630
|
+
doc.addEventListener("pointerup", onPointerEnd);
|
|
631
|
+
doc.addEventListener("pointercancel", onPointerEnd);
|
|
632
|
+
};
|
|
633
|
+
/** One pointer picks a range (or moves it, with Shift), two pinch. */
|
|
634
|
+
const onPointerMove = (event) => {
|
|
635
|
+
const previous = pointers.get(event.pointerId);
|
|
636
|
+
const now = locate(event.clientX, event.clientY)?.at;
|
|
637
|
+
const p = plot();
|
|
638
|
+
if (!previous || !now || !p) return;
|
|
639
|
+
const i = p.vertical ? 1 : 0;
|
|
640
|
+
if (!dragged) {
|
|
641
|
+
if (pointers.size === 1 && Math.abs(now[i] - previous[i]) < 4) return;
|
|
642
|
+
dragged = true;
|
|
643
|
+
try {
|
|
644
|
+
svg()?.setPointerCapture(event.pointerId);
|
|
645
|
+
} catch {}
|
|
646
|
+
}
|
|
647
|
+
event.stopPropagation();
|
|
648
|
+
chart.clearHighlight();
|
|
649
|
+
pointers.set(event.pointerId, now);
|
|
650
|
+
if (pointers.size > 1) {
|
|
651
|
+
const other = [...pointers].find(([id]) => id !== event.pointerId)?.[1];
|
|
652
|
+
if (!other) return;
|
|
653
|
+
const before = Math.abs(previous[i] - other[i]);
|
|
654
|
+
const after = Math.abs(now[i] - other[i]);
|
|
655
|
+
if (before > 0 && after > 0) zoomBy(after / before, indexAt([(now[0] + other[0]) / 2, (now[1] + other[1]) / 2]));
|
|
656
|
+
} else if (press?.pan) {
|
|
657
|
+
const [start, end] = press.range;
|
|
658
|
+
const moved = (now[i] - press.from[i]) / p.step;
|
|
659
|
+
const by = Math.round(p.reversed ? moved : -moved);
|
|
660
|
+
const last = Math.max(0, count() - 1);
|
|
661
|
+
const shift = Math.min(last - end, Math.max(-start, by));
|
|
662
|
+
show(start + shift, end + shift);
|
|
663
|
+
} else if (press) drawSelection(press.from, now);
|
|
664
|
+
};
|
|
665
|
+
const onWheel = (event) => {
|
|
666
|
+
if (!on() || options().wheel === false || !onPlot(event)) return;
|
|
667
|
+
const p = plot();
|
|
668
|
+
const at = locate(event.clientX, event.clientY)?.at;
|
|
669
|
+
if (!p || !at) return;
|
|
670
|
+
const [a, b] = edges();
|
|
671
|
+
const sideways = event.shiftKey || Math.abs(event.deltaX) > Math.abs(event.deltaY);
|
|
672
|
+
const delta = sideways ? event.deltaX || event.deltaY : event.deltaY;
|
|
673
|
+
const changed = sideways ? panBy((p.reversed ? -delta : delta) / p.step) : zoomBy(Math.exp(-delta * (event.ctrlKey ? WHEEL_SPEED_PINCH : WHEEL_SPEED)), indexAt(at));
|
|
674
|
+
const moved = fine && (fine.a !== a || fine.b !== b);
|
|
675
|
+
if (changed || moved) event.preventDefault();
|
|
676
|
+
};
|
|
677
|
+
const onDoubleClick = (event) => {
|
|
678
|
+
if (on() && onPlot(event)) reset();
|
|
679
|
+
};
|
|
680
|
+
/** The click that ends a drag is not a click on the chart. */
|
|
681
|
+
const onClickCapture = (event) => {
|
|
682
|
+
if (dragged) event.stopPropagation();
|
|
683
|
+
dragged = false;
|
|
684
|
+
};
|
|
685
|
+
const onKey = (event) => {
|
|
686
|
+
if (event.target !== svg() || !on()) return;
|
|
687
|
+
const { key } = event;
|
|
688
|
+
const arrow = key === "ArrowLeft" ? -1 : key === "ArrowRight" ? 1 : 0;
|
|
689
|
+
if (key === "+" || key === "=") zoomBy(ZOOM_STEP);
|
|
690
|
+
else if (key === "-") zoomBy(1 / ZOOM_STEP);
|
|
691
|
+
else if (key === "0") reset();
|
|
692
|
+
else if (event.shiftKey && arrow) panBy(plot()?.reversed ? -arrow : arrow);
|
|
693
|
+
else return;
|
|
694
|
+
event.stopPropagation();
|
|
695
|
+
event.preventDefault();
|
|
696
|
+
};
|
|
697
|
+
const onControl = (event) => {
|
|
698
|
+
const value = event.target.closest("button")?.value;
|
|
699
|
+
if (value === "reset") reset();
|
|
700
|
+
else if (value) zoomBy(value === "in" ? ZOOM_STEP : 1 / ZOOM_STEP);
|
|
701
|
+
};
|
|
702
|
+
host.addEventListener("pointermove", onPointerMove, true);
|
|
703
|
+
host.addEventListener("click", onClickCapture, true);
|
|
704
|
+
host.addEventListener("keydown", onKey, true);
|
|
705
|
+
host.addEventListener("pointerdown", onPointerDown);
|
|
706
|
+
host.addEventListener("wheel", onWheel, { passive: false });
|
|
707
|
+
host.addEventListener("dblclick", onDoubleClick);
|
|
708
|
+
/** The zoom buttons, laid over a corner of the chart. */
|
|
709
|
+
const renderControls = () => {
|
|
710
|
+
if (!on() || options().controls === false) {
|
|
711
|
+
controls?.remove();
|
|
712
|
+
controls = void 0;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
if (!controls) {
|
|
716
|
+
controls = doc.createElement("div");
|
|
717
|
+
controls.className = "tc-zoom";
|
|
718
|
+
for (const [value, , d] of BUTTONS) {
|
|
719
|
+
const button = doc.createElement("button");
|
|
720
|
+
button.type = "button";
|
|
721
|
+
button.className = "tc-download-toggle";
|
|
722
|
+
button.value = value;
|
|
723
|
+
const icon = doc.createElementNS(SVG_NS, "svg");
|
|
724
|
+
icon.setAttribute("viewBox", "0 0 24 24");
|
|
725
|
+
icon.setAttribute("width", "16");
|
|
726
|
+
icon.setAttribute("height", "16");
|
|
727
|
+
icon.setAttribute("aria-hidden", "true");
|
|
728
|
+
const path = doc.createElementNS(SVG_NS, "path");
|
|
729
|
+
path.setAttribute("d", d);
|
|
730
|
+
icon.append(path);
|
|
731
|
+
button.append(icon);
|
|
732
|
+
controls.append(button);
|
|
733
|
+
}
|
|
734
|
+
controls.addEventListener("click", onControl);
|
|
735
|
+
host.classList.add("tc-container");
|
|
736
|
+
}
|
|
737
|
+
if (!controls.isConnected) host.append(controls);
|
|
738
|
+
controls.dir = chart.rtl ? "rtl" : "";
|
|
739
|
+
const [start, end] = range();
|
|
740
|
+
const whole = start === 0 && end >= count() - 1;
|
|
741
|
+
const disabled = {
|
|
742
|
+
in: end - start <= least(),
|
|
743
|
+
out: whole,
|
|
744
|
+
reset: whole
|
|
745
|
+
};
|
|
746
|
+
const labels = options().labels;
|
|
747
|
+
for (const [i, button] of [...controls.querySelectorAll("button")].entries()) {
|
|
748
|
+
const [value, name] = BUTTONS[i];
|
|
749
|
+
button.setAttribute("aria-label", labels?.[value] ?? name);
|
|
750
|
+
button.disabled = disabled[value];
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
return {
|
|
754
|
+
svgAttrs: () => on() ? { "data-zoom-axis": plot()?.vertical ? "y" : "x" } : void 0,
|
|
755
|
+
afterRender() {
|
|
756
|
+
if (on()) drawn = range();
|
|
757
|
+
if (selection) svg()?.append(selection);
|
|
758
|
+
renderControls();
|
|
759
|
+
},
|
|
760
|
+
destroy() {
|
|
761
|
+
host.removeEventListener("pointermove", onPointerMove, true);
|
|
762
|
+
host.removeEventListener("click", onClickCapture, true);
|
|
763
|
+
host.removeEventListener("keydown", onKey, true);
|
|
764
|
+
host.removeEventListener("pointerdown", onPointerDown);
|
|
765
|
+
host.removeEventListener("wheel", onWheel);
|
|
766
|
+
host.removeEventListener("dblclick", onDoubleClick);
|
|
767
|
+
doc.removeEventListener("pointerup", onPointerEnd);
|
|
768
|
+
doc.removeEventListener("pointercancel", onPointerEnd);
|
|
769
|
+
clearSelection();
|
|
770
|
+
controls?.remove();
|
|
771
|
+
if (controls && addedClass) host.classList.remove("tc-container");
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
// src/zoom.ts
|
|
776
|
+
/**
|
|
777
|
+
* Standalone entry: `import '@tabler/charts/zoom'` enables `view` (a range
|
|
778
|
+
* of categories), `zoom: true` and `brush: true` in line, area, bar and
|
|
779
|
+
* candlestick charts.
|
|
780
|
+
* The default `Chart` then needs nothing else; on the core, add the plugin:
|
|
781
|
+
*
|
|
782
|
+
* ```ts
|
|
783
|
+
* import { Chart, zoom } from '@tabler/charts/core'
|
|
784
|
+
* import '@tabler/charts/zoom'
|
|
785
|
+
* new Chart(el, { type: line, data, zoom: true, plugins: [zoom()] })
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
/** The zoom and the brush of a chart, as one plugin. */
|
|
789
|
+
const install = (chart) => {
|
|
790
|
+
const parts = [installZoom(chart), installBrush(chart)];
|
|
791
|
+
return {
|
|
792
|
+
svgAttrs: (config) => parts[0]?.svgAttrs?.(config) ?? parts[1]?.svgAttrs?.(config),
|
|
793
|
+
afterRender(state) {
|
|
794
|
+
for (const part of parts) part.afterRender?.(state);
|
|
795
|
+
},
|
|
796
|
+
destroy() {
|
|
797
|
+
for (const part of parts) part.destroy?.();
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
require_features.register({ zoom: {
|
|
802
|
+
window: viewWindow,
|
|
803
|
+
install
|
|
804
|
+
} });
|
|
805
|
+
exports.installBrush = installBrush;
|
|
806
|
+
exports.installZoom = installZoom;
|
|
807
|
+
exports.viewRange = viewRange;
|
|
808
|
+
exports.viewWindow = viewWindow;
|
|
809
|
+
|
|
810
|
+
//# sourceMappingURL=zoom.cjs.map
|