@tabler/charts 0.0.1-alpha.0 → 0.2.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 +33 -5
- package/dist/{annotations-Bp7HwtF5.d.ts → annotations-B02GR_KU.d.ts} +3 -8
- package/dist/{annotations-lyt0I3HU.d.cts → annotations-CHafaGd4.d.cts} +3 -8
- package/dist/{annotations-BszTTjf9.js → annotations-D0YQ0IoA.js} +6 -7
- package/dist/{annotations-BszTTjf9.js.map → annotations-D0YQ0IoA.js.map} +1 -1
- package/dist/{annotations-DpETO8dE.cjs → annotations-DdRdeBUB.cjs} +6 -7
- package/dist/{annotations-DpETO8dE.cjs.map → annotations-DdRdeBUB.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/{sweep-WSgn2etB.js → arc-B3V5IR0w.js} +3 -60
- package/dist/arc-B3V5IR0w.js.map +1 -0
- package/dist/{sweep-Duowaput.cjs → arc-CYhI62kO.cjs} +2 -71
- package/dist/arc-CYhI62kO.cjs.map +1 -0
- package/dist/{area-DQsLERhx.js → area-0-L1bG9B.js} +5 -6
- package/dist/{area-DQsLERhx.js.map → area-0-L1bG9B.js.map} +1 -1
- package/dist/{area-sHCE3pg5.cjs → area-4eRs3c0K.cjs} +5 -6
- package/dist/{area-sHCE3pg5.cjs.map → area-4eRs3c0K.cjs.map} +1 -1
- package/dist/{area-DaO4MQl4.d.ts → area-CJX9219z.d.cts} +3 -6
- package/dist/{area-BFvkc-ZM.d.cts → area-d11XePuw.d.ts} +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/{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-DM16NUvV.js → bar-B5n2oq9-.js} +3 -4
- package/dist/{bar-DM16NUvV.js.map → bar-B5n2oq9-.js.map} +1 -1
- package/dist/{bar-DdsDxk3W.d.ts → bar-BDLR4p9c.d.cts} +4 -7
- package/dist/{bar-jZEoao74.js → bar-BNZ3GhIw.js} +20 -20
- package/dist/bar-BNZ3GhIw.js.map +1 -0
- package/dist/{bar-C-7zR2qp.cjs → bar-Da6dE_nI.cjs} +20 -20
- package/dist/bar-Da6dE_nI.cjs.map +1 -0
- package/dist/{bar-DGuUN3nc.cjs → bar-LYIF8MEz.cjs} +3 -4
- package/dist/{bar-DGuUN3nc.cjs.map → bar-LYIF8MEz.cjs.map} +1 -1
- package/dist/{bar-a0h9KC8A.d.cts → bar-XwzM6Pb0.d.ts} +4 -7
- 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/{candlestick-DuXwAFID.js → candlestick-BHQkQfxH.js} +6 -7
- package/dist/{candlestick-DuXwAFID.js.map → candlestick-BHQkQfxH.js.map} +1 -1
- package/dist/{candlestick-B5r1w3kc.cjs → candlestick-CYCQXgky.cjs} +6 -7
- package/dist/{candlestick-B5r1w3kc.cjs.map → candlestick-CYCQXgky.cjs.map} +1 -1
- package/dist/{candlestick-BnUG1SGi.d.ts → candlestick-D0xKkdqd.d.ts} +3 -6
- package/dist/{candlestick-BKdPyorY.d.cts → candlestick-Dq7qp-F0.d.cts} +3 -6
- 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-CI2x6N7N.js} +27 -27
- package/dist/cartesian-CI2x6N7N.js.map +1 -0
- package/dist/{cartesian-BoDfgBCV.cjs → cartesian-DV02PsBe.cjs} +27 -27
- package/dist/cartesian-DV02PsBe.cjs.map +1 -0
- package/dist/{chart-BF2CK9I_.js → chart-DWn9v6qw.js} +35 -24
- package/dist/chart-DWn9v6qw.js.map +1 -0
- package/dist/{chart-iJGxMz9z.d.ts → chart-QilhWP8Z.d.ts} +38 -49
- package/dist/{chart-CowF_lWY.cjs → chart-e2VqomCI.cjs} +35 -24
- package/dist/chart-e2VqomCI.cjs.map +1 -0
- package/dist/{chart-Qa417fJo.d.cts → chart-kqFMEwDo.d.cts} +64 -49
- 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-plobgBC7.js → core-BKRQvPAT.js} +47 -46
- package/dist/core-BKRQvPAT.js.map +1 -0
- package/dist/{core-C7fPm6t7.cjs → core-DIOC61up.cjs} +47 -46
- package/dist/core-DIOC61up.cjs.map +1 -0
- package/dist/{core-CjgbhS_v.d.ts → core-DRUCk67j.d.ts} +6 -42
- package/dist/{core-CnGFKojH.d.cts → core-PAX5ogLk.d.cts} +24 -68
- package/dist/core.cjs +32 -26
- package/dist/core.d.cts +23 -20
- package/dist/core.d.ts +23 -20
- package/dist/core.js +27 -24
- package/dist/{dates-CG-FvioW.js → dates-C2RzY3rE.js} +4 -5
- package/dist/{dates-CG-FvioW.js.map → dates-C2RzY3rE.js.map} +1 -1
- package/dist/{dates-Btm7Zm6W.cjs → dates-DurEr9WT.cjs} +4 -5
- package/dist/{dates-Btm7Zm6W.cjs.map → dates-DurEr9WT.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-vP3IcMak.js → dom-CuceR8gt.js} +4 -6
- package/dist/{dom-vP3IcMak.js.map → dom-CuceR8gt.js.map} +1 -1
- package/dist/{dom-CLF868Qs.cjs → dom-D_g13XWY.cjs} +4 -6
- package/dist/{dom-CLF868Qs.cjs.map → dom-D_g13XWY.cjs.map} +1 -1
- package/dist/{export-chart-9w8t3rjZ.js → export-chart-83UYH48t.js} +3 -4
- package/dist/{export-chart-9w8t3rjZ.js.map → export-chart-83UYH48t.js.map} +1 -1
- package/dist/{export-chart-BhhYgksr.cjs → export-chart-mYgEfK-L.cjs} +3 -4
- package/dist/{export-chart-BhhYgksr.cjs.map → export-chart-mYgEfK-L.cjs.map} +1 -1
- 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-Cs74puQS.cjs → fade-DVTkhrFU.cjs} +4 -6
- package/dist/{fade-Cs74puQS.cjs.map → fade-DVTkhrFU.cjs.map} +1 -1
- package/dist/{fade-D3NxH5Qg.js → fade-GGxcBdss.js} +4 -6
- package/dist/{fade-D3NxH5Qg.js.map → fade-GGxcBdss.js.map} +1 -1
- package/dist/{features-wASyHGic.js → features-BMxkqCyS.js} +2 -3
- package/dist/{features-wASyHGic.js.map → features-BMxkqCyS.js.map} +1 -1
- package/dist/{features-BclHgg2W.cjs → features-DCXEvoya.cjs} +2 -3
- package/dist/{features-BclHgg2W.cjs.map → features-DCXEvoya.cjs.map} +1 -1
- 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/{gauge-Cu9jttC0.d.ts → gauge-0VJuAHWF.d.ts} +5 -8
- package/dist/{gauge-Cu_OFxBd.d.cts → gauge-BSist7My.d.cts} +5 -8
- package/dist/{gauge-CEfkWXSu.cjs → gauge-DXkjXNCD.cjs} +14 -14
- package/dist/gauge-DXkjXNCD.cjs.map +1 -0
- package/dist/{gauge-_ljQHrMN.js → gauge-ts0kqN1-.js} +10 -10
- package/dist/{gauge-_ljQHrMN.js.map → gauge-ts0kqN1-.js.map} +1 -1
- 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-19BGJTKF.js} +20 -22
- package/dist/heatmap-19BGJTKF.js.map +1 -0
- package/dist/{heatmap-PhLPXIg1.d.ts → heatmap-59lmClj9.d.ts} +4 -7
- package/dist/{heatmap-BK18EBgJ.cjs → heatmap-CXhlrLTl.cjs} +20 -22
- package/dist/heatmap-CXhlrLTl.cjs.map +1 -0
- package/dist/{heatmap-BwS-y0c6.d.cts → heatmap-Dp_oyEe0.d.cts} +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-CzfxLfTv.d.ts → hydrate-BtAZf_5K.d.cts} +2 -5
- package/dist/{hydrate-CxwTXDqO.cjs → hydrate-CmN1k8Mo.cjs} +3 -4
- package/dist/hydrate-CmN1k8Mo.cjs.map +1 -0
- package/dist/{hydrate-DDNIHYv_.js → hydrate-OA6R2_Pn.js} +3 -4
- package/dist/{hydrate-DDNIHYv_.js.map → hydrate-OA6R2_Pn.js.map} +1 -1
- package/dist/{hydrate-CTTmQy0x.d.cts → hydrate-OjM1pIUG.d.ts} +2 -5
- 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 +54 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -26
- package/dist/index.d.ts +24 -26
- package/dist/index.js +45 -42
- package/dist/index.js.map +1 -1
- package/dist/{layout-B3hiqVEw.js → layout-DmrrLjwN.js} +9 -4
- package/dist/layout-DmrrLjwN.js.map +1 -0
- package/dist/{layout-CtMBhNd9.cjs → layout-JY2aR-yE.cjs} +14 -3
- package/dist/layout-JY2aR-yE.cjs.map +1 -0
- package/dist/{line-B3Ed6u7j.js → line-DO66LtwH.js} +9 -10
- package/dist/{line-B3Ed6u7j.js.map → line-DO66LtwH.js.map} +1 -1
- package/dist/{line-fQbtP_jL.cjs → line-Dbt6KFRK.cjs} +9 -10
- package/dist/{line-fQbtP_jL.cjs.map → line-Dbt6KFRK.cjs.map} +1 -1
- package/dist/{line-CMDGH6q5.d.cts → line-DtSh7HQU.d.ts} +4 -7
- package/dist/{line-D5kb8e6w.d.ts → line-_rNdeKmS.d.cts} +5 -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/{morph-CqYDu1bY.cjs → morph-9_LJL0ra.cjs} +4 -5
- package/dist/morph-9_LJL0ra.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-DnRxuwR-.js} +4 -5
- package/dist/{morph-Bgg-24l8.js.map → morph-DnRxuwR-.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-DWdK7vKp.cjs +60 -0
- package/dist/others-DWdK7vKp.cjs.map +1 -0
- package/dist/others-J7NCAMA0.js +49 -0
- package/dist/others-J7NCAMA0.js.map +1 -0
- package/dist/parliament-CLCI7tUO.d.ts +66 -0
- package/dist/parliament-CgsVnWEe.d.cts +66 -0
- package/dist/parliament-Cru4IcuM.js +302 -0
- package/dist/parliament-Cru4IcuM.js.map +1 -0
- package/dist/parliament-x5hcFaQ3.cjs +307 -0
- package/dist/parliament-x5hcFaQ3.cjs.map +1 -0
- package/dist/parliament.cjs +3 -0
- package/dist/parliament.d.cts +3 -0
- package/dist/parliament.d.ts +3 -0
- package/dist/parliament.js +1 -0
- 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-CufKZYhm.js} +4 -5
- package/dist/{patterns-DtgcnA8o.js.map → patterns-CufKZYhm.js.map} +1 -1
- package/dist/{patterns-LfcQAWCy.cjs → patterns-D3-wQagb.cjs} +4 -5
- package/dist/{patterns-LfcQAWCy.cjs.map → patterns-D3-wQagb.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-B6tNOqNn.js +157 -0
- package/dist/percentage-bar-B6tNOqNn.js.map +1 -0
- package/dist/percentage-bar-nhTeakD_.d.ts +62 -0
- package/dist/percentage-bar-tepMr7Hd.d.cts +62 -0
- package/dist/percentage-bar-ybNS3goo.cjs +162 -0
- package/dist/percentage-bar-ybNS3goo.cjs.map +1 -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-B8UlOZiq.d.ts → pie-BXg2gNpb.d.cts} +14 -8
- package/dist/{pie-C1Pa6W_l.cjs → pie-BpjvSPnz.cjs} +19 -22
- package/dist/pie-BpjvSPnz.cjs.map +1 -0
- package/dist/{pie-DnQQmxkk.d.cts → pie-CFptILSm.d.ts} +14 -8
- package/dist/{pie-RnMTQWMS.js → pie-CVsc-6qD.js} +13 -16
- package/dist/pie-CVsc-6qD.js.map +1 -0
- 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--_gmdTyK.cjs} +3 -4
- package/dist/{point-shapes-CGl4dugc.cjs.map → point-shapes--_gmdTyK.cjs.map} +1 -1
- package/dist/{point-shapes-DI84NNpI.js → point-shapes-DD2Ektzm.js} +3 -4
- package/dist/{point-shapes-DI84NNpI.js.map → point-shapes-DD2Ektzm.js.map} +1 -1
- package/dist/point-shapes.cjs +3 -4
- package/dist/point-shapes.d.cts +5 -1
- package/dist/point-shapes.d.ts +5 -1
- package/dist/point-shapes.js +3 -4
- package/dist/{radar-pFI6fvOq.d.ts → radar-BC9Skgpj.d.ts} +4 -7
- package/dist/{radar-CYPab_I4.js → radar-BR-mumDd.js} +7 -8
- package/dist/{radar-CYPab_I4.js.map → radar-BR-mumDd.js.map} +1 -1
- package/dist/{radar-BB13CGmq.d.cts → radar-D1-lItDy.d.cts} +4 -7
- package/dist/{radar-CoGUNNSb.cjs → radar-HPDrIdzc.cjs} +7 -8
- package/dist/{radar-CoGUNNSb.cjs.map → radar-HPDrIdzc.cjs.map} +1 -1
- 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-D6VhynBM.cjs +16 -0
- package/dist/rect-D6VhynBM.cjs.map +1 -0
- package/dist/rect-DSVmUZrD.js +11 -0
- package/dist/rect-DSVmUZrD.js.map +1 -0
- package/dist/{sankey-B4PNKusJ.js → sankey-D6JeZfK5.js} +33 -29
- package/dist/sankey-D6JeZfK5.js.map +1 -0
- package/dist/{sankey-Bm518bqL.d.ts → sankey-D_v7KxnJ.d.ts} +4 -7
- package/dist/{sankey-B9JYnx7e.d.cts → sankey-Dk7jUt8x.d.cts} +4 -7
- package/dist/{sankey-Bacx4fVe.cjs → sankey-fCoo1cpz.cjs} +33 -29
- package/dist/sankey-fCoo1cpz.cjs.map +1 -0
- 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-kgtgR318.js → scatter-C0TWjFpW.js} +21 -18
- package/dist/scatter-C0TWjFpW.js.map +1 -0
- package/dist/{scatter-Bl7nasE6.d.ts → scatter-CXEsioOJ.d.ts} +8 -9
- package/dist/{scatter-DgMN9zRy.cjs → scatter-DVqB_fP9.cjs} +21 -18
- package/dist/scatter-DVqB_fP9.cjs.map +1 -0
- package/dist/{scatter-DrJ8xYz4.d.cts → scatter-DZeEIfyo.d.cts} +8 -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-BS9-hltA.cjs → sparkline-B39NA0Mi.cjs} +14 -13
- package/dist/sparkline-B39NA0Mi.cjs.map +1 -0
- package/dist/{sparkline-BG13V4Pz.d.cts → sparkline-DAP6jtzw.d.cts} +5 -8
- package/dist/{sparkline-BQzt27Fr.js → sparkline-XO_TqCNP.js} +14 -13
- package/dist/sparkline-XO_TqCNP.js.map +1 -0
- package/dist/{sparkline-iWuXbKpd.d.ts → sparkline-cbvRkWqS.d.ts} +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-DRbwTeF3.js → stack-2H2Gfs1Q.js} +3 -4
- package/dist/{stack-DRbwTeF3.js.map → stack-2H2Gfs1Q.js.map} +1 -1
- package/dist/{stack-DVhJWaki.cjs → stack-BgPzoQmv.cjs} +3 -4
- package/dist/{stack-DVhJWaki.cjs.map → stack-BgPzoQmv.cjs.map} +1 -1
- package/dist/{stack-CpR6RGKd.d.ts → stack-DR0eQTsB.d.ts} +1 -4
- package/dist/{stack-CpR6RGKd.d.cts → stack-Dagxq7l2.d.cts} +2 -4
- package/dist/style.css +1 -1
- package/dist/sweep-BpRPlhs6.js +59 -0
- package/dist/sweep-BpRPlhs6.js.map +1 -0
- package/dist/sweep-Dnp6LDBz.cjs +70 -0
- 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-BjZ1bYTK.cjs} +9 -10
- package/dist/{time-axis-VSX34_Tb.cjs.map → time-axis-BjZ1bYTK.cjs.map} +1 -1
- package/dist/{time-axis-Bc9eHX1r.js → time-axis-FLONo54E.js} +9 -10
- package/dist/{time-axis-Bc9eHX1r.js.map → time-axis-FLONo54E.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-BAkhmVQc.d.cts +55 -0
- package/dist/treemap-BNpxFBao.d.ts +55 -0
- package/dist/treemap-BWpEUlDh.cjs +303 -0
- package/dist/treemap-BWpEUlDh.cjs.map +1 -0
- package/dist/treemap-CQdavQ9u.js +298 -0
- package/dist/treemap-CQdavQ9u.js.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-BBuSi4i0.js} +7 -7
- package/dist/value-labels-BBuSi4i0.js.map +1 -0
- package/dist/{value-labels-B0WJoJ7x.cjs → value-labels-BV9keAuL.cjs} +7 -7
- package/dist/value-labels-BV9keAuL.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 +31 -1
- 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-C7fPm6t7.cjs.map +0 -1
- package/dist/core-plobgBC7.js.map +0 -1
- package/dist/gauge-CEfkWXSu.cjs.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/morph-CqYDu1bY.cjs.map +0 -1
- package/dist/pie-C1Pa6W_l.cjs.map +0 -1
- package/dist/pie-RnMTQWMS.js.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-Duowaput.cjs.map +0 -1
- package/dist/sweep-WSgn2etB.js.map +0 -1
- package/dist/value-labels-B0WJoJ7x.cjs.map +0 -1
- package/dist/value-labels-IZIQPhfk.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimate-
|
|
1
|
+
{"version":3,"file":"decimate-CapfgiDY.js","names":[],"sources":["../src/shapes/decimate.ts"],"sourcesContent":["import type { Point } from './path.ts'\n\n/**\n * Largest-Triangle-Three-Buckets downsampling (Sveinn Steinarsson, 2013):\n * keep roughly `threshold` points that preserve the visual shape of a line,\n * including its peaks and valleys.\n *\n * Returns the indices to keep, in order. Gaps (`null` points) are kept as\n * gap markers and every run between gaps is sampled on its own, so the\n * result lines up with any per-index data (e.g. stacked baselines).\n */\nexport function lttbIndices(points: readonly Point[], threshold: number): number[] {\n const n = points.length\n if (!(threshold >= 3) || n <= threshold) return points.map((_, i) => i)\n\n // Split into runs of valid points.\n const runs: [number, number][] = []\n let start = -1\n for (let i = 0; i < n; i++) {\n const valid = points[i] != null\n if (valid && start === -1) start = i\n if (!valid && start !== -1) {\n runs.push([start, i])\n start = -1\n }\n }\n if (start !== -1) runs.push([start, n])\n const valid = runs.reduce((sum, [a, b]) => sum + (b - a), 0)\n\n const out: number[] = []\n let last = 0\n for (const [a, b] of runs) {\n // One gap marker between runs; everything else in the gap is dropped.\n if (a > last) out.push(last)\n // Each run gets a share of the budget (at least its two ends).\n const budget = Math.max(2, Math.round((threshold * (b - a)) / valid))\n sampleRun(points, a, b, budget, out)\n last = b\n }\n if (last < n) out.push(last)\n return out\n}\n\n/** LTTB over `points[from, to)`, pushing kept indices to `out`. */\nfunction sampleRun(\n points: readonly Point[],\n from: number,\n to: number,\n budget: number,\n out: number[],\n): void {\n const n = to - from\n if (n <= budget) {\n for (let i = from; i < to; i++) out.push(i)\n return\n }\n const at = (i: number) => points[i] as readonly [number, number]\n const bucketSize = (n - 2) / (budget - 2)\n let a = from\n out.push(a)\n\n for (let bucket = 0; bucket < budget - 2; bucket++) {\n // Average of the next bucket is the third corner of every candidate triangle.\n const nextStart = from + 1 + Math.floor((bucket + 1) * bucketSize)\n const nextEnd = Math.min(to, from + 1 + Math.floor((bucket + 2) * bucketSize))\n let avgX = 0\n let avgY = 0\n for (let i = nextStart; i < nextEnd; i++) {\n avgX += at(i)[0]\n avgY += at(i)[1]\n }\n const count = Math.max(1, nextEnd - nextStart)\n avgX /= count\n avgY /= count\n\n // The point of this bucket forming the largest triangle with `a` and the average.\n const rangeStart = from + 1 + Math.floor(bucket * bucketSize)\n const rangeEnd = Math.min(to - 1, from + 1 + Math.floor((bucket + 1) * bucketSize))\n const [ax, ay] = at(a)\n let best = rangeStart\n let bestArea = -1\n for (let i = rangeStart; i < rangeEnd; i++) {\n const [x, y] = at(i)\n const area = Math.abs((ax - avgX) * (y - ay) - (ax - x) * (avgY - ay))\n if (area > bestArea) {\n bestArea = area\n best = i\n }\n }\n out.push(best)\n a = best\n }\n out.push(to - 1)\n}\n\n/** The points kept by {@link lttbIndices}, gaps included. */\nexport function lttb(points: readonly Point[], threshold: number): Point[] {\n return lttbIndices(points, threshold).map((i) => points[i])\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,YAAY,QAA0B,WAA6B;CACjF,MAAM,IAAI,OAAO;CACjB,IAAI,EAAE,aAAa,MAAM,KAAK,WAAW,OAAO,OAAO,KAAK,GAAG,MAAM,CAAC;CAGtE,MAAM,OAA2B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AAI,SAAS,KAAK;GACxC,QAAQ,GAAG,CAAC,CAAC,CAAC;GACd,QAAQ,GAAG,CAAC,CAAC,CAAC;EAChB;EACA,MAAM,QAAQ,KAAK,IAAI,GAAG,UAAU,SAAS;EAC7C,QAAQ;EACR,QAAQ;EAGR,MAAM,aAAa,OAAO,IAAI,KAAK,MAAM,SAAS,UAAU;EAC5D,MAAM,WAAW,KAAK,IAAI,KAAK,GAAG,OAAO,IAAI,KAAK,OAAO,SAAS,KAAK,UAAU,CAAC;EAClF,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;EACrB,IAAI,OAAO;EACX,IAAI,WAAW;EACf,KAAK,IAAI,IAAI,YAAY,IAAI,UAAU,KAAK;GAC1C,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC;GACnB,MAAM,OAAO,KAAK,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,MAAM,OAAO,GAAG;GACrE,IAAI,OAAO,UAAU;IACnB,WAAW;IACX,OAAO;GACT;EACF;EACA,IAAI,KAAK,IAAI;EACb,IAAI;CACN;CACA,IAAI,KAAK,KAAK,CAAC;AACjB;;AAGA,SAAgB,KAAK,QAA0B,WAA4B;CACzE,OAAO,YAAY,QAAQ,SAAS,CAAC,CAAC,KAAK,MAAM,OAAO,EAAE;AAC5D"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { r as Point } from "./path-
|
|
2
|
-
//#region src/shapes/decimate.d.ts
|
|
1
|
+
import { r as Point } from "./path-YeUiOfG8.js";
|
|
3
2
|
/**
|
|
4
3
|
* Largest-Triangle-Three-Buckets downsampling (Sveinn Steinarsson, 2013):
|
|
5
4
|
* keep roughly `threshold` points that preserve the visual shape of a line,
|
|
@@ -12,6 +11,4 @@ import { r as Point } from "./path-CwB28da0.cjs";
|
|
|
12
11
|
declare function lttbIndices(points: readonly Point[], threshold: number): number[];
|
|
13
12
|
/** The points kept by {@link lttbIndices}, gaps included. */
|
|
14
13
|
declare function lttb(points: readonly Point[], threshold: number): Point[];
|
|
15
|
-
|
|
16
|
-
export { lttbIndices as n, lttb as t };
|
|
17
|
-
//# sourceMappingURL=decimate-CNSpgGa5.d.cts.map
|
|
14
|
+
export { lttbIndices as n, lttb as t };
|
package/dist/decimate.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_features = require("./features-
|
|
3
|
-
const require_decimate = require("./decimate-
|
|
4
|
-
|
|
2
|
+
const require_features = require("./features-DCXEvoya.cjs");
|
|
3
|
+
const require_decimate = require("./decimate-BS3x8g-f.cjs");
|
|
4
|
+
// src/decimate.ts
|
|
5
5
|
/**
|
|
6
6
|
* Registers LTTB downsampling (`decimate: N` on line and area charts):
|
|
7
7
|
* `import '@tabler/charts/decimate'`. Also exports the algorithm itself.
|
|
8
8
|
*/
|
|
9
9
|
require_features.register({ decimate: require_decimate.lttbIndices });
|
|
10
|
-
//#endregion
|
|
11
10
|
exports.lttb = require_decimate.lttb;
|
|
12
11
|
exports.lttbIndices = require_decimate.lttbIndices;
|
|
13
12
|
|
package/dist/decimate.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as lttbIndices, t as lttb } from "./decimate-
|
|
1
|
+
import { n as lttbIndices, t as lttb } from "./decimate-BxxYBJJk.cjs";
|
|
2
2
|
export { lttb, lttbIndices };
|
package/dist/decimate.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as lttbIndices, t as lttb } from "./decimate-
|
|
1
|
+
import { n as lttbIndices, t as lttb } from "./decimate-Du87fMLG.js";
|
|
2
2
|
export { lttb, lttbIndices };
|
package/dist/decimate.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { i as register } from "./features-
|
|
2
|
-
import { n as lttbIndices, t as lttb } from "./decimate-
|
|
3
|
-
|
|
1
|
+
import { i as register } from "./features-BMxkqCyS.js";
|
|
2
|
+
import { n as lttbIndices, t as lttb } from "./decimate-CapfgiDY.js";
|
|
3
|
+
// src/decimate.ts
|
|
4
4
|
/**
|
|
5
5
|
* Registers LTTB downsampling (`decimate: N` on line and area charts):
|
|
6
6
|
* `import '@tabler/charts/decimate'`. Also exports the algorithm itself.
|
|
7
7
|
*/
|
|
8
8
|
register({ decimate: lttbIndices });
|
|
9
|
-
//#endregion
|
|
10
9
|
export { lttb, lttbIndices };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=decimate.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as features } from "./features-
|
|
2
|
-
|
|
1
|
+
import { r as features } from "./features-BMxkqCyS.js";
|
|
2
|
+
// src/render/attrs.ts
|
|
3
3
|
/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */
|
|
4
4
|
const NAME_RE = /^[a-zA-Z_][\w:.-]*$/;
|
|
5
5
|
/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */
|
|
@@ -12,8 +12,7 @@ function isValidTag(name) {
|
|
|
12
12
|
function isValidAttr(name) {
|
|
13
13
|
return NAME_RE.test(name) && !EVENT_RE.test(name);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
//#region src/render/dom.ts
|
|
15
|
+
// src/render/dom.ts
|
|
17
16
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
18
17
|
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
19
18
|
/** VNode each rendered DOM node was last patched with. */
|
|
@@ -169,7 +168,6 @@ function patchChildren(parent, next) {
|
|
|
169
168
|
anchor = node;
|
|
170
169
|
}
|
|
171
170
|
}
|
|
172
|
-
//#endregion
|
|
173
171
|
export { render as a, isValidTag as c, patchAttrs as i, childNamespace as n, rendered as o, createNode as r, isValidAttr as s, SVG_NS as t };
|
|
174
172
|
|
|
175
|
-
//# sourceMappingURL=dom-
|
|
173
|
+
//# sourceMappingURL=dom-CuceR8gt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-vP3IcMak.js","names":[],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== anchor) {\n parent.insertBefore(node, anchor)\n }\n anchor = node\n }\n}\n"],"mappings":";;;AACA,MAAM,UAAU;;AAGhB,MAAM,WAAW;;AAGjB,SAAgB,WAAW,MAAuB;CAChD,OAAO,QAAQ,KAAK,IAAI;AAC1B;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,QAAQ,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;AAClD;;;ACVA,MAAa,SAAS;AACtB,MAAM,UAAU;;AAGhB,MAAa,2BAAiD,IAAI,QAAqB;;AAGvF,MAAM,wBAAwB,IAAI,QAA0B;;;;;;;;;;;;;;;;AAiB5D,SAAgB,OACd,WACA,OACA,SACgB;CAChB,MAAM,OAAO,MAAM,IAAI,SAAS,MAAM,SAAS,eAAe,YAAY,UAAU,KAAA;CAEpF,IAAI,UAAU,QAAQ,CAAC,WAAW,MAAM,GAAG,GAAG;EAC5C,IAAI,MAAM;GACR,KAAK,OAAO;GACZ,MAAM,OAAO,SAAS;EACxB;EACA,OAAO;CACT;CAEA,IAAI,QAAQ,SAAS,MAAM,KAAK,GAAG;EACjC,aAAa,MAAM,KAAK;EACxB,MAAM,IAAI,WAAW,IAAI;EACzB,OAAO;CACT;CAEA,IAAI,QAAQ,SAAS,UAAU,MAAM,OAAO,aAAa,WAAW,MAAM,GAAG,CAAC,GAAG;EAC/E,MAAM,IAAI,WAAW,IAAI;EACzB,OAAO;CACT;CAEA,MAAM,KAAK,cAAc,OAAO,aAAa,WAAW,MAAM,GAAG,GAAG,UAAU,aAAa;CAC3F,IAAI,MAAM,KAAK,YAAY,EAAE;MACxB,UAAU,YAAY,EAAE;CAC7B,MAAM,IAAI,WAAW,EAAE;CACvB,OAAO;AACT;AA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,KAAA,GAAW,MAAM,IAAI,MAAM,KAAK,IAAI;OAC9E,QAAQ,KAAK,IAAI;CACxB;CAGA,MAAM,UAAU,IAAI,MAAwB,KAAK,MAAM;CACvD,MAAM,uBAAO,IAAI,IAAU;CAC3B,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,QAAQ,KAAK;EACnB,IAAI;EACJ,IAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAA,GAC7C,YAAY,MAAM,IAAI,MAAM,GAAG;OAC1B,IAAI,SAAS,QAAQ,QAC1B,YAAY,QAAQ;EAEtB,IAAI,aAAa,CAAC,KAAK,IAAI,SAAS,KAAK,SAAS,WAAW,KAAK,GAAG;GACnE,QAAQ,KAAK;GACb,KAAK,IAAI,SAAS;GAClB,IAAI,cAAc,QAAQ,SAAS;EACrC;CACF;CAGA,KAAK,MAAM,QAAQ,UACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,OAAO,YAAY,IAAI;CAI9C,MAAM,KAAK,eAAe,MAAM;CAChC,MAAM,MAAM,OAAO;CACnB,IAAI,SAAsB;CAC1B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"dom-CuceR8gt.js","names":[],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== an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,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,QAAQ,KAAK;EACnB,IAAI;EACJ,IAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAA,GAC7C,YAAY,MAAM,IAAI,MAAM,GAAG;OAC1B,IAAI,SAAS,QAAQ,QAC1B,YAAY,QAAQ;EAEtB,IAAI,aAAa,CAAC,KAAK,IAAI,SAAS,KAAK,SAAS,WAAW,KAAK,GAAG;GACnE,QAAQ,KAAK;GACb,KAAK,IAAI,SAAS;GAClB,IAAI,cAAc,QAAQ,SAAS;EACrC;CACF;CAGA,KAAK,MAAM,QAAQ,UACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,OAAO,YAAY,IAAI;CAI9C,MAAM,KAAK,eAAe,MAAM;CAChC,MAAM,MAAM,OAAO;CACnB,IAAI,SAAsB;CAC1B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_features = require("./features-
|
|
2
|
-
|
|
1
|
+
const require_features = require("./features-DCXEvoya.cjs");
|
|
2
|
+
// src/render/attrs.ts
|
|
3
3
|
/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */
|
|
4
4
|
const NAME_RE = /^[a-zA-Z_][\w:.-]*$/;
|
|
5
5
|
/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */
|
|
@@ -12,8 +12,7 @@ function isValidTag(name) {
|
|
|
12
12
|
function isValidAttr(name) {
|
|
13
13
|
return NAME_RE.test(name) && !EVENT_RE.test(name);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
//#region src/render/dom.ts
|
|
15
|
+
// src/render/dom.ts
|
|
17
16
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
18
17
|
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
19
18
|
/** VNode each rendered DOM node was last patched with. */
|
|
@@ -169,7 +168,6 @@ function patchChildren(parent, next) {
|
|
|
169
168
|
anchor = node;
|
|
170
169
|
}
|
|
171
170
|
}
|
|
172
|
-
//#endregion
|
|
173
171
|
Object.defineProperty(exports, "SVG_NS", {
|
|
174
172
|
enumerable: true,
|
|
175
173
|
get: function() {
|
|
@@ -219,4 +217,4 @@ Object.defineProperty(exports, "rendered", {
|
|
|
219
217
|
}
|
|
220
218
|
});
|
|
221
219
|
|
|
222
|
-
//# sourceMappingURL=dom-
|
|
220
|
+
//# sourceMappingURL=dom-D_g13XWY.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-CLF868Qs.cjs","names":["features"],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== anchor) {\n parent.insertBefore(node, anchor)\n }\n anchor = node\n }\n}\n"],"mappings":";;;AACA,MAAM,UAAU;;AAGhB,MAAM,WAAW;;AAGjB,SAAgB,WAAW,MAAuB;CAChD,OAAO,QAAQ,KAAK,IAAI;AAC1B;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,QAAQ,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;AAClD;;;ACVA,MAAa,SAAS;AACtB,MAAM,UAAU;;AAGhB,MAAa,2BAAiD,IAAI,QAAqB;;AAGvF,MAAM,wBAAwB,IAAI,QAA0B;;;;;;;;;;;;;;;;AAiB5D,SAAgB,OACd,WACA,OACA,SACgB;C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,QAAQ,UACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,OAAO,YAAY,IAAI;CAI9C,MAAM,KAAK,eAAe,MAAM;CAChC,MAAM,MAAM,OAAO;CACnB,IAAI,SAAsB;CAC1B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"dom-D_g13XWY.cjs","names":["features"],"sources":["../src/render/attrs.ts","../src/render/dom.ts"],"sourcesContent":["/** Valid XML-ish tag and attribute names; anything else is skipped by renderers. */\nconst NAME_RE = /^[a-zA-Z_][\\w:.-]*$/\n\n/** Inline event handler attributes (`onclick`, `onLoad`…) are never rendered. */\nconst EVENT_RE = /^on/i\n\n/** Whether a tag name is safe to render. */\nexport function isValidTag(name: string): boolean {\n return NAME_RE.test(name)\n}\n\n/** Whether an attribute name is safe to render. */\nexport function isValidAttr(name: string): boolean {\n return NAME_RE.test(name) && !EVENT_RE.test(name)\n}\n","import { features } from '../features.ts'\nimport type { Attrs, Child, VNode } from '../vnode.ts'\nimport { isValidAttr, isValidTag } from './attrs.ts'\n\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\nconst HTML_NS = 'http://www.w3.org/1999/xhtml'\n\n/** VNode each rendered DOM node was last patched with. */\nexport const rendered: WeakMap<Node, Child> = /* @__PURE__ */ new WeakMap<Node, Child>()\n\n/** Root element rendered into each container. */\nconst roots = /* @__PURE__ */ new WeakMap<Element, Element>()\n\n/**\n * Render a VNode tree into `container`.\n *\n * The first call mounts the tree; later calls patch the existing DOM in place,\n * reusing nodes matched by `key` (or by position for unkeyed children), so CSS\n * transitions on changed attributes keep working. Passing `null` unmounts.\n *\n * The rendered root is appended to `container`; other content of the\n * container is left untouched. On the first call, `replace` names an element\n * already in the container (e.g. server-rendered markup) for the root: when\n * it has the root's tag and `@tabler/charts/hydrate` is loaded (it is part\n * of `@tabler/charts`), its nodes are hydrated: reused and patched to the\n * tree, so nothing is re-created and entrance animations do not run again.\n * Otherwise the root takes its place.\n */\nexport function render(\n container: Element,\n vnode: VNode | null,\n replace?: Element | null,\n): Element | null {\n const prev = roots.get(container) ?? (replace?.parentNode === container ? replace : undefined)\n\n if (vnode === null || !isValidTag(vnode.tag)) {\n if (prev) {\n prev.remove()\n roots.delete(container)\n }\n return null\n }\n\n if (prev && canPatch(prev, vnode)) {\n patchElement(prev, vnode)\n roots.set(container, prev)\n return prev\n }\n\n if (prev && features.hydrate?.(prev, vnode, namespaceFor(container, vnode.tag))) {\n roots.set(container, prev)\n return prev\n }\n\n const el = createElement(vnode, namespaceFor(container, vnode.tag), container.ownerDocument)\n if (prev) prev.replaceWith(el)\n else container.appendChild(el)\n roots.set(container, el)\n return el\n}\n\nfunction namespaceFor(parent: Element, tag: string): string {\n if (tag === 'svg') return SVG_NS\n if (parent.namespaceURI === SVG_NS && parent.localName !== 'foreignObject') return SVG_NS\n return HTML_NS\n}\n\nexport function childNamespace(el: Element): string {\n return el.namespaceURI === SVG_NS && el.localName !== 'foreignObject' ? SVG_NS : HTML_NS\n}\n\nexport function createNode(child: Child, ns: string, doc: Document): Node | null {\n if (typeof child === 'string') {\n const text = doc.createTextNode(child)\n rendered.set(text, child)\n return text\n }\n if (!isValidTag(child.tag)) return null\n return createElement(child, child.tag === 'svg' ? SVG_NS : ns, doc)\n}\n\n/**\n * Styles go through the CSSOM: a strict CSP (`style-src` without\n * 'unsafe-inline') blocks style attributes set with setAttribute, not these.\n */\nfunction setAttr(el: Element, name: string, value: string): void {\n if (name === 'style') (el as HTMLElement).style.cssText = value\n else el.setAttribute(name, value)\n}\n\nfunction createElement(vnode: VNode, ns: string, doc: Document): Element {\n const el = doc.createElementNS(ns, vnode.tag)\n const { attrs } = vnode\n for (const name in attrs) {\n if (isValidAttr(name)) setAttr(el, name, String(attrs[name]))\n }\n const childNs = childNamespace(el)\n for (const child of vnode.children) {\n const node = createNode(child, childNs, doc)\n if (node) el.appendChild(node)\n }\n rendered.set(el, vnode)\n return el\n}\n\nfunction canPatch(node: Node, next: Child): boolean {\n const prev = rendered.get(node)\n if (prev === undefined) return false\n if (typeof next === 'string') return typeof prev === 'string'\n return typeof prev !== 'string' && prev.tag === next.tag && prev.key === next.key\n}\n\nfunction patchNode(node: Node, next: Child): void {\n if (typeof next === 'string') {\n if (rendered.get(node) !== next) {\n ;(node as Text).data = next\n rendered.set(node, next)\n }\n return\n }\n patchElement(node as Element, next)\n}\n\nfunction patchElement(el: Element, next: VNode): void {\n const prev = rendered.get(el) as VNode\n if (prev === next) return\n // An arc sweeps to its new angles, setting its `d` itself on the way: the\n // sweep feature then says what is left to patch.\n patchAttrs(el, prev.attrs, features.sweep?.(el, prev, next) ?? next.attrs, true)\n patchChildren(el, next.children)\n rendered.set(el, next)\n}\n\nexport function patchAttrs(el: Element, prev: Attrs, next: Attrs, update = false): void {\n for (const name in next) {\n const value = next[name] as string | number\n if (prev[name] === value || !isValidAttr(name)) continue\n // Where CSS cannot transition `d` (Safari), the morph feature animates it.\n if (update && name === 'd' && features.morph?.(el, String(prev[name] ?? ''), String(value))) {\n continue\n }\n setAttr(el, name, String(value))\n }\n for (const name in prev) {\n if (!(name in next) && isValidAttr(name)) el.removeAttribute(name)\n }\n}\n\nfunction patchChildren(parent: Element, next: Child[]): void {\n if (next.length === 0 && parent.firstChild === null) return\n\n const oldNodes = Array.from(parent.childNodes)\n const keyed = new Map<unknown, Node>()\n const unkeyed: Node[] = []\n\n for (const node of oldNodes) {\n const vnode = rendered.get(node)\n if (vnode === undefined) continue\n if (typeof vnode !== 'string' && vnode.key !== undefined) keyed.set(vnode.key, node)\n else unkeyed.push(node)\n }\n\n // Match new children against existing nodes.\n const matched = new Array<Node | undefined>(next.length)\n const used = new Set<Node>()\n let cursor = 0\n for (let i = 0; i < next.length; i++) {\n const child = next[i] as Child\n let candidate: Node | undefined\n if (typeof child !== 'string' && child.key !== undefined) {\n candidate = keyed.get(child.key)\n } else if (cursor < unkeyed.length) {\n candidate = unkeyed[cursor]\n }\n if (candidate && !used.has(candidate) && canPatch(candidate, child)) {\n matched[i] = candidate\n used.add(candidate)\n if (candidate === unkeyed[cursor]) cursor++\n }\n }\n\n // Remove unmatched nodes first, so placing the rest needs as few moves as possible.\n for (const node of oldNodes) {\n if (!used.has(node)) parent.removeChild(node)\n }\n\n // Patch or create, then place from the end using the next sibling as anchor.\n const ns = childNamespace(parent)\n const doc = parent.ownerDocument\n let anchor: Node | null = null\n for (let i = next.length - 1; i >= 0; i--) {\n const child = next[i] as Child\n let node = matched[i]\n if (node) {\n patchNode(node, child)\n } else {\n node = createNode(child, ns, doc) ?? undefined\n if (!node) continue\n }\n if (node.parentNode !== parent || node.nextSibling !== anchor) {\n parent.insertBefore(node, anchor)\n }\n anchor = node\n }\n}\n"],"mappings":";;;AACA,MAAM,UAAU;;AAGhB,MAAM,WAAW;;AAGjB,SAAgB,WAAW,MAAuB;CAChD,OAAO,QAAQ,KAAK,IAAI;AAC1B;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,QAAQ,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;AAClD;;ACVA,MAAa,SAAS;AACtB,MAAM,UAAU;;AAGhB,MAAa,2BAAiD,IAAI,QAAqB;;AAGvF,MAAM,wBAAwB,IAAI,QAA0B;;;;;;;;;;;;;;;;AAiB5D,SAAgB,OACd,WACA,OACA,SACgB;CAChB,MAAM,OAAO,MAAM,IAAI,SAAS,MAAM,SAAS,eAAe,YAAY,UAAU,KAAA;CAEpF,IAAI,UAAU,QAAQ,CAAC,WAAW,MAAM,GAAG,GAAG;EAC5C,IAAI,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B;CAC1B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,QAAQ;EACnB,IAAI,MACF,UAAU,MAAM,KAAK;OAChB;GACL,OAAO,WAAW,OAAO,IAAI,GAAG,KAAK,KAAA;GACrC,IAAI,CAAC,MAAM;EACb;EACA,IAAI,KAAK,eAAe,UAAU,KAAK,gBAAgB,QACrD,OAAO,aAAa,MAAM,MAAM;EAElC,SAAS;CACX;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { o as round } from "./layout-DmrrLjwN.js";
|
|
2
|
+
// src/export-chart.ts
|
|
3
3
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
4
4
|
/** Properties copied from the computed style, with the values they can be left out at. */
|
|
5
5
|
const SHAPE = {
|
|
@@ -226,7 +226,6 @@ async function downloadChart(target, options = {}) {
|
|
|
226
226
|
link.click();
|
|
227
227
|
setTimeout(() => URL.revokeObjectURL(link.href), 1e3);
|
|
228
228
|
}
|
|
229
|
-
//#endregion
|
|
230
229
|
export { exportImage as n, exportSVG as r, downloadChart as t };
|
|
231
230
|
|
|
232
|
-
//# sourceMappingURL=export-chart-
|
|
231
|
+
//# sourceMappingURL=export-chart-83UYH48t.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-chart-9w8t3rjZ.js","names":[],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,mBAAmB;CACnB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;AACA,MA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;;AASA,eAAsB,cACpB,QACA,UAA2B,CAAC,GACb;CACf,MAAM,EAAE,SAAS,UAAU;CAC3B,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,OACJ,WAAW,QACP,IAAI,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,IAChE,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAS,MAAM,SAAS;CAAS,CAAC;CACvE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
|
|
1
|
+
{"version":3,"file":"export-chart-83UYH48t.js","names":[],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,mBAAmB;CACnB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;AACA,MAAM,OAA+B;CACnC,GAAG;CACH,eAAe;CACf,aAAa;CACb,eAAe;CACf,cAAc;CACd,wBAAwB;CACxB,kBAAkB;AACpB;AACA,MAAM,OAA+B;CAAE,cAAc;CAAI,gBAAgB;AAAI;AAC7E,MAAM,QAAgC,EAAE,SAAS,IAAI;AACrD,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAU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AAM,SAAS;CAAS,CAAC;CACvE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_layout = require("./layout-
|
|
2
|
-
|
|
1
|
+
const require_layout = require("./layout-JY2aR-yE.cjs");
|
|
2
|
+
// src/export-chart.ts
|
|
3
3
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
4
4
|
/** Properties copied from the computed style, with the values they can be left out at. */
|
|
5
5
|
const SHAPE = {
|
|
@@ -226,7 +226,6 @@ async function downloadChart(target, options = {}) {
|
|
|
226
226
|
link.click();
|
|
227
227
|
setTimeout(() => URL.revokeObjectURL(link.href), 1e3);
|
|
228
228
|
}
|
|
229
|
-
//#endregion
|
|
230
229
|
Object.defineProperty(exports, "downloadChart", {
|
|
231
230
|
enumerable: true,
|
|
232
231
|
get: function() {
|
|
@@ -246,4 +245,4 @@ Object.defineProperty(exports, "exportSVG", {
|
|
|
246
245
|
}
|
|
247
246
|
});
|
|
248
247
|
|
|
249
|
-
//# sourceMappingURL=export-chart-
|
|
248
|
+
//# sourceMappingURL=export-chart-mYgEfK-L.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-chart-BhhYgksr.cjs","names":["round"],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAA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QAAQ,UAAU,OAAO,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM;CAC1D,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,OAAO,QACJ,SAAU,OAAO,QAAQ,IAAI,IAAI,uBAAO,IAAI,MAAM,mCAAmC,CAAC,GACvF,MACA,OACF;CACF,CAAC;AACH;;;;;;;;AASA,eAAsB,cACpB,QACA,UAA2B,CAAC,GACb;CACf,MAAM,EAAE,SAAS,UAAU;CAC3B,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,OACJ,WAAW,QACP,IAAI,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,IAChE,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAS,MAAM,SAAS;CAAS,CAAC;CACvE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
|
|
1
|
+
{"version":3,"file":"export-chart-mYgEfK-L.cjs","names":["round"],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(\n container: Element,\n): { svg: Element; height: number; margin: number; bottom: boolean } | undefined {\n const legend = container.querySelector(':scope > .tc-legend')\n const items = legend ? Array.from(legend.querySelectorAll('.tc-legend-item')) : []\n if (!legend || !items.length) return undefined\n const doc = container.ownerDocument\n const patterned = container.querySelector(':scope > svg.tc-patterned')\n const box = legend.getBoundingClientRect()\n const g = doc.createElementNS(SVG_NS, 'g')\n for (const item of items) {\n const swatch = item.querySelector('.tc-legend-swatch')\n const name = item.querySelector('.tc-legend-name')\n if (!swatch || !name) continue\n const s = swatch.getBoundingClientRect()\n const n = name.getBoundingClientRect()\n const color = getComputedStyle(swatch).getPropertyValue('--tc-series-color').trim()\n // A chart that wears its patterns has them in the copied svg: the swatch takes its slot's.\n const slot = /\\btc-series-([1-8])\\b/.exec(item.getAttribute('class') ?? '')?.[1] ?? 'other'\n const fill = patterned\n ? getComputedStyle(patterned).getPropertyValue(`--tc-pattern-${slot}`).trim()\n : ''\n const hidden = item.classList.contains('tc-legend-item-hidden')\n const dot = doc.createElementNS(SVG_NS, 'circle')\n dot.setAttribute('cx', String(round(s.left - box.left + s.width / 2)))\n dot.setAttribute('cy', String(round(s.top - box.top + s.height / 2)))\n dot.setAttribute('r', String(round(s.width / 2 - (hidden ? 0.75 : 0))))\n dot.setAttribute(\n 'style',\n hidden\n ? `fill:none;stroke:${color};stroke-width:1.5px`\n : `fill:${fill.startsWith('url(') ? fill : color}`,\n )\n const text = getComputedStyle(name)\n const label = doc.createElementNS(SVG_NS, 'text')\n label.setAttribute('x', String(round(n.left - box.left)))\n label.setAttribute('y', String(round(n.top - box.top + n.height / 2)))\n label.setAttribute('dy', '0.35em')\n label.setAttribute(\n 'style',\n `fill:${text.color};font-family:${text.fontFamily};font-size:${text.fontSize};font-weight:${text.fontWeight}`,\n )\n label.textContent = name.textContent\n g.append(dot, label)\n }\n const bottom = legend.getAttribute('data-position') === 'bottom'\n const margin =\n Number.parseFloat(getComputedStyle(legend)[bottom ? 'marginTop' : 'marginBottom']) || 0\n return { svg: g, height: round(box.height + margin), margin, bottom }\n}\n\n/**\n * The chart as a standalone SVG document: the computed styles are inlined,\n * hover marks left out and running animations finished first.\n *\n * ```ts\n * const svg = exportSVG(chart)\n * ```\n */\nexport function exportSVG(target: ExportTarget, options: ExportOptions = {}): string {\n const svg = rootOf(target)\n // Read the resting state, not a frame in the middle of an entrance or update.\n for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) animation.finish()\n const copy = svg.cloneNode(true) as SVGSVGElement\n inline(svg, copy)\n const doc = svg.ownerDocument\n const width = Number(svg.getAttribute('width'))\n const height = Number(svg.getAttribute('height'))\n copy.setAttribute('xmlns', SVG_NS)\n copy.removeAttribute('class')\n copy.removeAttribute('tabindex')\n copy.removeAttribute('data-resizing')\n copy.removeAttribute('aria-describedby')\n copy.removeAttribute('aria-activedescendant')\n\n const chartStyle = getComputedStyle(svg)\n const container = svg.parentElement\n const legend = options.legend !== false && container ? legendLayer(container) : undefined\n let total = height\n if (legend) {\n // The chart moves down below a top legend; a bottom one goes under it.\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n if (legend.bottom) {\n legend.svg.setAttribute('transform', `translate(0 ${height + legend.margin})`)\n } else {\n wrap.setAttribute('transform', `translate(0 ${legend.height})`)\n }\n copy.append(wrap, legend.svg)\n total = height + legend.height\n }\n copy.setAttribute('width', String(width))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${width} ${total}`)\n\n // A name for the file itself, besides the aria-label.\n const name = svg.getAttribute('aria-label')\n if (name) {\n const title = doc.createElementNS(SVG_NS, 'title')\n title.textContent = name\n copy.prepend(title)\n }\n\n const background =\n options.background === undefined || options.background === 'auto'\n ? chartStyle.getPropertyValue('--tc-surface').trim() || undefined\n : options.background || undefined\n if (background) {\n const rect = doc.createElementNS(SVG_NS, 'rect')\n rect.setAttribute('width', '100%')\n rect.setAttribute('height', '100%')\n rect.setAttribute('fill', background)\n copy.insertBefore(rect, copy.querySelector(':scope > title')?.nextSibling ?? copy.firstChild)\n }\n return new XMLSerializer().serializeToString(copy)\n}\n\n/**\n * The chart as an image (PNG by default), drawn from `exportSVG()` at\n * `scale` pixels per chart pixel.\n *\n * ```ts\n * const blob = await exportImage(chart, { scale: 3 })\n * ```\n */\nexport async function exportImage(target: ExportTarget, options: ImageOptions = {}): Promise<Blob> {\n const { type = 'image/png', scale = 2, quality } = options\n const markup = exportSVG(target, {\n ...options,\n // JPEG has no transparency: without a background it would turn black.\n ...(type === 'image/jpeg' && options.background === false ? { background: '#fff' } : {}),\n })\n const doc = rootOf(target).ownerDocument\n const image = new Image()\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`\n await image.decode()\n const canvas = doc.createElement('canvas')\n canvas.width = Math.round(image.width * scale)\n canvas.height = Math.round(image.height * scale)\n const context = canvas.getContext('2d')\n if (!context) throw new Error('@tabler/charts: no 2d canvas to draw the image.')\n context.drawImage(image, 0, 0, canvas.width, canvas.height)\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) => (blob ? resolve(blob) : reject(new Error('@tabler/charts: could not encode.'))),\n type,\n quality,\n )\n })\n}\n\n/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => URL.revokeObjectURL(link.href), 1000)\n}\n"],"mappings":";;AAeA,MAAM,SAAS;;AAgCf,MAAM,QAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,gBAAgB;CAChB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CAClB,mBAAmB;CACnB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;AACA,MAAM,OAA+B;CACnC,GAAG;CACH,eAAe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CAAC;AACH;;;;;;;;AASA,eAAsB,cACpB,QACA,UAA2B,CAAC,GACb;CACf,MAAM,EAAE,SAAS,UAAU;CAC3B,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,OACJ,WAAW,QACP,IAAI,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,IAChE,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAS,MAAM,SAAS;CAAS,CAAC;CACvE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
|
package/dist/export.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
//#region src/export.ts
|
|
2
|
+
const require_export_chart = require("./export-chart-mYgEfK-L.cjs");
|
|
3
|
+
// src/export.ts
|
|
5
4
|
/**
|
|
6
5
|
* Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
|
|
7
6
|
* saves a rendered chart as a standalone SVG or an image. Importing it also
|
|
@@ -9,8 +8,7 @@ const require_export_chart = require("./export-chart-BhhYgksr.cjs");
|
|
|
9
8
|
* `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
|
|
10
9
|
* plugin installed on the core.
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
11
|
+
require("./features-DCXEvoya.cjs").register({ export: require_export_chart.downloadChart });
|
|
14
12
|
exports.downloadChart = require_export_chart.downloadChart;
|
|
15
13
|
exports.exportImage = require_export_chart.exportImage;
|
|
16
14
|
exports.exportSVG = require_export_chart.exportSVG;
|
package/dist/export.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.cjs","names":["register","downloadChart"],"sources":["../src/export.ts"],"sourcesContent":["/**\n * Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`\n * saves a rendered chart as a standalone SVG or an image. Importing it also\n * enables the `download` option (a menu on the chart that saves it): with the\n * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the\n * plugin installed on the core.\n */\nimport { downloadChart, exportImage, exportSVG } from './export-chart.ts'\nimport { register } from './features.ts'\n\n// Registered here, in the entry itself, so no bundler can shake it away.\nregister({ export: downloadChart })\n\nexport type {\n DownloadOptions,\n ExportOptions,\n ExportTarget,\n ImageOptions,\n} from './export-chart.ts'\nexport { downloadChart, exportImage, exportSVG }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.cjs","names":["register","downloadChart"],"sources":["../src/export.ts"],"sourcesContent":["/**\n * Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`\n * saves a rendered chart as a standalone SVG or an image. Importing it also\n * enables the `download` option (a menu on the chart that saves it): with the\n * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the\n * plugin installed on the core.\n */\nimport { downloadChart, exportImage, exportSVG } from './export-chart.ts'\nimport { register } from './features.ts'\n\n// Registered here, in the entry itself, so no bundler can shake it away.\nregister({ export: downloadChart })\n\nexport type {\n DownloadOptions,\n ExportOptions,\n ExportTarget,\n ImageOptions,\n} from './export-chart.ts'\nexport { downloadChart, exportImage, exportSVG }\n"],"mappings":";;;;;;;;;;A,iCAWAA,CAAAA,CAAAA,SAAS,EAAE,QAAQC,qBAAAA,cAAc,CAAC"}
|
package/dist/export.d.cts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
|
|
3
|
+
* saves a rendered chart as a standalone SVG or an image. Importing it also
|
|
4
|
+
* enables the `download` option (a menu on the chart that saves it): with the
|
|
5
|
+
* `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
|
|
6
|
+
* plugin installed on the core.
|
|
7
|
+
*/
|
|
8
|
+
import { B as DownloadOptions, G as exportImage, H as ExportTarget, K as exportSVG, U as ImageOptions, V as ExportOptions, W as downloadChart } from "./chart-kqFMEwDo.cjs";
|
|
2
9
|
export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
|
package/dist/export.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
|
|
3
|
+
* saves a rendered chart as a standalone SVG or an image. Importing it also
|
|
4
|
+
* enables the `download` option (a menu on the chart that saves it): with the
|
|
5
|
+
* `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
|
|
6
|
+
* plugin installed on the core.
|
|
7
|
+
*/
|
|
8
|
+
import { B as downloadChart, H as exportSVG, I as DownloadOptions, L as ExportOptions, R as ExportTarget, V as exportImage, z as ImageOptions } from "./chart-QilhWP8Z.js";
|
|
2
9
|
export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
|
package/dist/export.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-chart-83UYH48t.js";
|
|
2
|
+
import { i as register } from "./features-BMxkqCyS.js";
|
|
3
|
+
// src/export.ts
|
|
4
4
|
/**
|
|
5
5
|
* Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
|
|
6
6
|
* saves a rendered chart as a standalone SVG or an image. Importing it also
|
|
@@ -9,7 +9,6 @@ import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-c
|
|
|
9
9
|
* plugin installed on the core.
|
|
10
10
|
*/
|
|
11
11
|
register({ export: downloadChart });
|
|
12
|
-
//#endregion
|
|
13
12
|
export { downloadChart, exportImage, exportSVG };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=export.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/scales/extent.ts
|
|
2
2
|
/**
|
|
3
3
|
* Minimum and maximum of `values`, skipping `null`, `undefined` and
|
|
4
4
|
* non-finite numbers. Returns `undefined` when nothing is left.
|
|
@@ -13,7 +13,6 @@ function extent(values) {
|
|
|
13
13
|
}
|
|
14
14
|
return min <= max ? [min, max] : void 0;
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { extent as t };
|
|
18
17
|
|
|
19
|
-
//# sourceMappingURL=extent-
|
|
18
|
+
//# sourceMappingURL=extent-DOV8rs-6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extent-
|
|
1
|
+
{"version":3,"file":"extent-DOV8rs-6.js","names":[],"sources":["../src/scales/extent.ts"],"sourcesContent":["/**\n * Minimum and maximum of `values`, skipping `null`, `undefined` and\n * non-finite numbers. Returns `undefined` when nothing is left.\n */\nexport function extent(values: Iterable<number | null | undefined>): [number, number] | undefined {\n let min = Number.POSITIVE_INFINITY\n let max = Number.NEGATIVE_INFINITY\n for (const value of values) {\n if (value == null || !Number.isFinite(value)) continue\n if (value < min) min = value\n if (value > max) max = value\n }\n return min <= max ? [min, max] : undefined\n}\n"],"mappings":";;;;;AAIA,SAAgB,OAAO,QAA2E;CAChG,IAAI,MAAM,OAAO;CACjB,IAAI,MAAM,OAAO;CACjB,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,SAAS,QAAQ,CAAC,OAAO,SAAS,KAAK,GAAG;EAC9C,IAAI,QAAQ,KAAK,MAAM;EACvB,IAAI,QAAQ,KAAK,MAAM;CACzB;CACA,OAAO,OAAO,MAAM,CAAC,KAAK,GAAG,IAAI,KAAA;AACnC"}
|