@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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const require_format = require("./format-CAE5ruy6.cjs");
|
|
2
|
+
const require_layout = require("./layout-JY2aR-yE.cjs");
|
|
3
|
+
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
4
|
+
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
5
|
+
const require_named = require("./named-BBASc8dW.cjs");
|
|
6
|
+
const require_others = require("./others-DWdK7vKp.cjs");
|
|
7
|
+
// src/charts/percentage-bar.ts
|
|
8
|
+
/** Height of the chart when neither `height` nor `aspectRatio` is set: a strip. */
|
|
9
|
+
const HEIGHT = 16;
|
|
10
|
+
/** The segments of the data: nine at most by default, the one for the rest included. */
|
|
11
|
+
const group = (options) => require_others.groupSlices(options.data, options.maxSlices, options.othersLabel);
|
|
12
|
+
/** The visible segments in their order along the bar, and their sum. */
|
|
13
|
+
function segmentsOf(options, hidden) {
|
|
14
|
+
const count = options.data.length;
|
|
15
|
+
const segments = group(options).filter((segment) => !hidden.has(require_named.keyOf(segment.data)));
|
|
16
|
+
if (options.order === "size") segments.sort((a, b) => Number(a.index >= count) - Number(b.index >= count) || b.value - a.value || a.index - b.index);
|
|
17
|
+
return {
|
|
18
|
+
segments,
|
|
19
|
+
total: segments.reduce((sum, segment) => sum + segment.value, 0)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function renderPercentageBar(options, ctx) {
|
|
23
|
+
const { width, height, locale } = ctx;
|
|
24
|
+
const gap = Math.max(0, options.gap ?? 2);
|
|
25
|
+
const radius = Math.max(0, options.radius ?? 4);
|
|
26
|
+
const area = require_layout.innerRect(width, height, require_layout.insets(options.padding, 0));
|
|
27
|
+
const { segments, total } = segmentsOf(options, ctx.hidden);
|
|
28
|
+
const drawn = segments.filter((segment) => segment.value > 0);
|
|
29
|
+
let offset = area.x;
|
|
30
|
+
const boxes = drawn.map((segment, position) => {
|
|
31
|
+
const length = segment.value / total * area.width;
|
|
32
|
+
const left = position === 0 ? 0 : gap / 2;
|
|
33
|
+
const right = position === drawn.length - 1 ? 0 : gap / 2;
|
|
34
|
+
const box = {
|
|
35
|
+
x: offset + left,
|
|
36
|
+
y: area.y,
|
|
37
|
+
width: Math.max(0, length - left - right),
|
|
38
|
+
height: area.height
|
|
39
|
+
};
|
|
40
|
+
offset += length;
|
|
41
|
+
return box;
|
|
42
|
+
});
|
|
43
|
+
const value = require_format.formatNumber(options.format, locale);
|
|
44
|
+
const share = require_format.getNumberFormat(locale, {
|
|
45
|
+
style: "percent",
|
|
46
|
+
maximumFractionDigits: 1
|
|
47
|
+
});
|
|
48
|
+
const hitFor = (position) => {
|
|
49
|
+
const segment = drawn[position];
|
|
50
|
+
const box = boxes[position];
|
|
51
|
+
const x = box.x + box.width / 2;
|
|
52
|
+
const item = {
|
|
53
|
+
name: segment.data.name,
|
|
54
|
+
seriesIndex: segment.index,
|
|
55
|
+
value: segment.value,
|
|
56
|
+
text: `${value(segment.value)} (${share.format(segment.value / total)})`,
|
|
57
|
+
x,
|
|
58
|
+
y: box.y + box.height / 2,
|
|
59
|
+
box
|
|
60
|
+
};
|
|
61
|
+
if (segment.data.color) item.color = segment.data.color;
|
|
62
|
+
const n = require_layout.round;
|
|
63
|
+
return {
|
|
64
|
+
index: position,
|
|
65
|
+
label: segment.data.name,
|
|
66
|
+
title: "",
|
|
67
|
+
x,
|
|
68
|
+
area,
|
|
69
|
+
items: [item],
|
|
70
|
+
seriesIndex: segment.index,
|
|
71
|
+
mark: {
|
|
72
|
+
d: `M${n(box.x + 1)},${n(box.y + 1)}h${n(box.width - 2)}v${n(box.height - 2)}h${n(2 - box.width)}Z`,
|
|
73
|
+
x: 0,
|
|
74
|
+
y: 0
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const interaction = {
|
|
79
|
+
count: drawn.length,
|
|
80
|
+
hitIndex: (position) => drawn[position] ? hitFor(position) : null,
|
|
81
|
+
hitTest(px, py) {
|
|
82
|
+
if (py < area.y || py > area.y + area.height) return null;
|
|
83
|
+
const position = boxes.findIndex((box) => px >= box.x - gap / 2 && px <= box.x + box.width + gap / 2);
|
|
84
|
+
return position < 0 ? null : hitFor(position);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
ctx.onHitTest(interaction);
|
|
88
|
+
return require_vnode.h("g", { class: "tc-percentage-bar" }, drawn.length === 0 && require_vnode.h("rect", {
|
|
89
|
+
key: "track",
|
|
90
|
+
class: "tc-percentage-bar-track",
|
|
91
|
+
x: require_layout.round(area.x),
|
|
92
|
+
y: require_layout.round(area.y),
|
|
93
|
+
width: require_layout.round(area.width),
|
|
94
|
+
height: require_layout.round(area.height),
|
|
95
|
+
rx: require_layout.round(Math.min(radius, area.width / 2, area.height / 2))
|
|
96
|
+
}), segments.map((segment) => {
|
|
97
|
+
const box = boxes[drawn.indexOf(segment)];
|
|
98
|
+
return require_vnode.h("g", require_named.groupAttrs(segment.data, segment.index), box && require_vnode.h("rect", {
|
|
99
|
+
class: "tc-segment",
|
|
100
|
+
x: require_layout.round(box.x),
|
|
101
|
+
y: require_layout.round(box.y),
|
|
102
|
+
width: require_layout.round(box.width),
|
|
103
|
+
height: require_layout.round(box.height),
|
|
104
|
+
rx: require_layout.round(Math.min(radius, box.width / 2, box.height / 2))
|
|
105
|
+
}));
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
function percentageBarTable(options, ctx) {
|
|
109
|
+
const { segments, total } = segmentsOf(options, ctx.hidden);
|
|
110
|
+
const value = require_format.formatNumber(options.format, ctx.locale);
|
|
111
|
+
const share = require_format.getNumberFormat(ctx.locale, {
|
|
112
|
+
style: "percent",
|
|
113
|
+
maximumFractionDigits: 1
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
columns: [
|
|
117
|
+
"",
|
|
118
|
+
"Value",
|
|
119
|
+
"Share"
|
|
120
|
+
],
|
|
121
|
+
rows: segments.map((segment) => [
|
|
122
|
+
segment.data.name,
|
|
123
|
+
value(segment.value),
|
|
124
|
+
share.format(total > 0 ? segment.value / total : 0)
|
|
125
|
+
])
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Percentage bar: parts of a whole as segments of one horizontal bar, each as
|
|
130
|
+
* wide as its share (a donut's ring unrolled, for a strip under a number).
|
|
131
|
+
* The chart is a strip 16 pixels tall unless `height` or `aspectRatio` is set.
|
|
132
|
+
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* new Chart('#el', {
|
|
135
|
+
* type: percentageBar,
|
|
136
|
+
* data: [{ name: 'Paid', value: 62 }, { name: 'Open', value: 27 }, { name: 'Overdue', value: 11 }],
|
|
137
|
+
* })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
const percentageBar = {
|
|
141
|
+
name: "percentage-bar",
|
|
142
|
+
clean: (options) => {
|
|
143
|
+
const config = options;
|
|
144
|
+
return {
|
|
145
|
+
...config,
|
|
146
|
+
data: require_clean.cleanItems(config.data),
|
|
147
|
+
height: config.height ?? (config.aspectRatio ? void 0 : HEIGHT)
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
render: renderPercentageBar,
|
|
151
|
+
legend: (options) => require_others.groupLegend(group(options)),
|
|
152
|
+
table: percentageBarTable,
|
|
153
|
+
valueLabels: { marks: "cell" }
|
|
154
|
+
};
|
|
155
|
+
Object.defineProperty(exports, "percentageBar", {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function() {
|
|
158
|
+
return percentageBar;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=percentage-bar-ybNS3goo.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"percentage-bar-ybNS3goo.cjs","names":["groupSlices","keyOf","innerRect","insets","formatNumber","getNumberFormat","round","h","groupAttrs","cleanItems","groupLegend"],"sources":["../src/charts/percentage-bar.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets, round } from '../layout.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf } from './named.ts'\nimport { type Grouped, groupLegend, groupSlices } from './others.ts'\n\n/** One segment of a percentage bar. */\nexport interface PercentageBarSegment {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the segment group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PercentageBarOptions {\n data: readonly PercentageBarSegment[]\n /**\n * Order of the segments along the bar: as in the data (`'data'`, the\n * default) or the largest first (`'size'`). Colors follow the data either\n * way, and the segment of the rest always comes last.\n */\n order?: 'data' | 'size'\n /**\n * The most segments drawn, the one for the rest included: with more entries\n * than that, the largest `maxSlices - 1` keep a segment of their own and\n * the others share one, named by `othersLabel`, at the end of the bar.\n * Defaults to `9` (the eight palette colors and the rest); `0` never\n * groups.\n */\n maxSlices?: number\n /** Name of the segment that groups the rest. Defaults to `'Others'`. */\n othersLabel?: string\n /** Space between segments in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the segments. Defaults to `4`. */\n radius?: number\n /** Format of the values (tooltip, table). */\n format?: NumberFormat\n /** Extra space around the bar, in pixels. */\n padding?: InsetsInput\n}\n\n/** Height of the chart when neither `height` nor `aspectRatio` is set: a strip. */\nconst HEIGHT = 16\n\ntype Segment = Grouped<PercentageBarSegment>\n\n/** The segments of the data: nine at most by default, the one for the rest included. */\nconst group = (options: PercentageBarOptions): Segment[] =>\n groupSlices(options.data, options.maxSlices, options.othersLabel)\n\n/** The visible segments in their order along the bar, and their sum. */\nfunction segmentsOf(\n options: PercentageBarOptions,\n hidden: ReadonlySet<string>,\n): { segments: Segment[]; total: number } {\n const count = options.data.length\n const segments = group(options).filter((segment) => !hidden.has(keyOf(segment.data)))\n if (options.order === 'size') {\n // (The rest stays last, whatever its size.)\n segments.sort(\n (a, b) =>\n Number(a.index >= count) - Number(b.index >= count) ||\n b.value - a.value ||\n a.index - b.index,\n )\n }\n return { segments, total: segments.reduce((sum, segment) => sum + segment.value, 0) }\n}\n\nfunction renderPercentageBar(options: PercentageBarOptions, ctx: RenderContext): ChildInput {\n const { width, height, locale } = ctx\n const gap = Math.max(0, options.gap ?? 2)\n const radius = Math.max(0, options.radius ?? 4)\n const area = innerRect(width, height, insets(options.padding, 0))\n const { segments, total } = segmentsOf(options, ctx.hidden)\n const drawn = segments.filter((segment) => segment.value > 0)\n\n // Every segment gives up half a gap on each side but the ends of the bar.\n let offset = area.x\n const boxes = drawn.map((segment, position) => {\n const length = (segment.value / total) * area.width\n const left = position === 0 ? 0 : gap / 2\n const right = position === drawn.length - 1 ? 0 : gap / 2\n const box = {\n x: offset + left,\n y: area.y,\n width: Math.max(0, length - left - right),\n height: area.height,\n }\n offset += length\n return box\n })\n\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n const hitFor = (position: number): Hit => {\n const segment = drawn[position] as Segment\n const box = boxes[position] as (typeof boxes)[number]\n const x = box.x + box.width / 2\n const item: HitItem = {\n name: segment.data.name,\n seriesIndex: segment.index,\n value: segment.value,\n text: `${value(segment.value)} (${share.format(segment.value / total)})`,\n x,\n y: box.y + box.height / 2,\n box,\n }\n if (segment.data.color) item.color = segment.data.color\n const n = round\n return {\n index: position,\n label: segment.data.name,\n title: '',\n x,\n area,\n items: [item],\n seriesIndex: segment.index,\n // A ring just inside the hovered segment.\n mark: {\n d: `M${n(box.x + 1)},${n(box.y + 1)}h${n(box.width - 2)}v${n(box.height - 2)}h${n(2 - box.width)}Z`,\n x: 0,\n y: 0,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => (drawn[position] ? hitFor(position) : null),\n hitTest(px, py) {\n if (py < area.y || py > area.y + area.height) return null\n const position = boxes.findIndex(\n (box) => px >= box.x - gap / 2 && px <= box.x + box.width + gap / 2,\n )\n return position < 0 ? null : hitFor(position)\n },\n }\n ctx.onHitTest(interaction)\n\n return h(\n 'g',\n { class: 'tc-percentage-bar' },\n // Empty: the track alone, so the chart keeps its place.\n drawn.length === 0 &&\n h('rect', {\n key: 'track',\n class: 'tc-percentage-bar-track',\n x: round(area.x),\n y: round(area.y),\n width: round(area.width),\n height: round(area.height),\n rx: round(Math.min(radius, area.width / 2, area.height / 2)),\n }),\n segments.map((segment) => {\n const box = boxes[drawn.indexOf(segment)]\n return h(\n 'g',\n groupAttrs(segment.data, segment.index),\n box &&\n h('rect', {\n class: 'tc-segment',\n x: round(box.x),\n y: round(box.y),\n width: round(box.width),\n height: round(box.height),\n rx: round(Math.min(radius, box.width / 2, box.height / 2)),\n }),\n )\n }),\n )\n}\n\nfunction percentageBarTable(options: PercentageBarOptions, ctx: RenderContext): DataTable {\n const { segments, total } = segmentsOf(options, ctx.hidden)\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: segments.map((segment) => [\n segment.data.name,\n value(segment.value),\n share.format(total > 0 ? segment.value / total : 0),\n ]),\n }\n}\n\n/**\n * Percentage bar: parts of a whole as segments of one horizontal bar, each as\n * wide as its share (a donut's ring unrolled, for a strip under a number).\n * The chart is a strip 16 pixels tall unless `height` or `aspectRatio` is set.\n *\n * ```ts\n * new Chart('#el', {\n * type: percentageBar,\n * data: [{ name: 'Paid', value: 62 }, { name: 'Open', value: 27 }, { name: 'Overdue', value: 11 }],\n * })\n * ```\n */\nexport const percentageBar: ChartType<PercentageBarOptions> = {\n name: 'percentage-bar',\n // (The options come with the whole config: its size is defaulted here.)\n clean: (options) => {\n const config = options as PercentageBarOptions & { height?: unknown; aspectRatio?: unknown }\n return {\n ...config,\n data: cleanItems(config.data),\n height: config.height ?? (config.aspectRatio ? undefined : HEIGHT),\n }\n },\n render: renderPercentageBar,\n legend: (options) => groupLegend(group(options)),\n table: percentageBarTable,\n valueLabels: { marks: 'cell' },\n}\n"],"mappings":";;;;;;;;AAyDA,MAAM,SAAS;;AAKf,MAAM,SAAS,YACbA,eAAAA,YAAY,QAAQ,MAAM,QAAQ,WAAW,QAAQ,WAAW;;AAGlE,SAAS,WACP,SACA,QACwC;CACxC,MAAM,QAAQ,QAAQ,KAAK;CAC3B,MAAM,WAAW,MAAM,OAAO,CAAC,CAAC,QAAQ,YAAY,CAAC,OAAO,IAAIC,cAAAA,MAAM,QAAQ,IAAI,CAAC,CAAC;CACpF,IAAI,QAAQ,UAAU,QAEpB,SAAS,MACN,GAAG,MACF,OAAO,EAAE,SAAS,KAAK,IAAI,OAAO,EAAE,SAAS,KAAK,KAClD,EAAE,QAAQ,EAAE,SACZ,EAAE,QAAQ,EAAE,KAChB;CAEF,OAAO;EAAE;EAAU,OAAO,SAAS,QAAQ,K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
|
+
/** Standalone entry: `import { percentageBar } from '@tabler/charts/percentage-bar'`. */
|
|
2
|
+
import { n as PercentageBarSegment, r as percentageBar, t as PercentageBarOptions } from "./percentage-bar-tepMr7Hd.cjs";
|
|
3
|
+
export { type PercentageBarOptions, type PercentageBarSegment, percentageBar };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Standalone entry: `import { percentageBar } from '@tabler/charts/percentage-bar'`. */
|
|
2
|
+
import { n as PercentageBarSegment, r as percentageBar, t as PercentageBarOptions } from "./percentage-bar-nhTeakD_.js";
|
|
3
|
+
export { type PercentageBarOptions, type PercentageBarSegment, percentageBar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as percentageBar } from "./percentage-bar-B6tNOqNn.js";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
//#region src/charts/pie.d.ts
|
|
1
|
+
import { a as ChartType } from "./chart-kqFMEwDo.cjs";
|
|
2
|
+
import { c as NumberFormat } from "./time-B4oxWHQI.cjs";
|
|
3
|
+
import { a as InsetsInput } from "./annotations-CHafaGd4.cjs";
|
|
4
|
+
import { a as ClassValue } from "./vnode-Du2cC8Fm.cjs";
|
|
6
5
|
/** One slice of a pie or donut. */
|
|
7
6
|
interface PieSlice {
|
|
8
7
|
name: string;
|
|
@@ -22,6 +21,15 @@ interface PieSlice {
|
|
|
22
21
|
}
|
|
23
22
|
interface PieOptions {
|
|
24
23
|
data: readonly PieSlice[];
|
|
24
|
+
/**
|
|
25
|
+
* The most slices drawn, the one for the rest included: with more entries
|
|
26
|
+
* than that, the largest `maxSlices - 1` keep a slice of their own and the
|
|
27
|
+
* others share one, named by `othersLabel`, after them. Defaults to `9`
|
|
28
|
+
* (the eight palette colors and the rest); `0` never groups.
|
|
29
|
+
*/
|
|
30
|
+
maxSlices?: number;
|
|
31
|
+
/** Name of the slice that groups the rest. Defaults to `'Others'`. */
|
|
32
|
+
othersLabel?: string;
|
|
25
33
|
/** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */
|
|
26
34
|
innerRadius?: number;
|
|
27
35
|
/** Gap between slices in pixels, drawn as surface. Defaults to `2`. */
|
|
@@ -53,6 +61,4 @@ interface PieOptions {
|
|
|
53
61
|
declare const pie: ChartType<PieOptions>;
|
|
54
62
|
/** Donut chart: a pie with a hole showing the total (or your own `center`). */
|
|
55
63
|
declare const donut: ChartType<PieOptions>;
|
|
56
|
-
|
|
57
|
-
export { pie as i, PieSlice as n, donut as r, PieOptions as t };
|
|
58
|
-
//# sourceMappingURL=pie-B8UlOZiq.d.ts.map
|
|
64
|
+
export { pie as i, PieSlice as n, donut as r, PieOptions as t };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
1
|
+
const require_features = require("./features-DCXEvoya.cjs");
|
|
2
|
+
const require_format = require("./format-CAE5ruy6.cjs");
|
|
3
|
+
const require_layout = require("./layout-JY2aR-yE.cjs");
|
|
4
|
+
const require_sweep = require("./sweep-Dnp6LDBz.cjs");
|
|
5
|
+
const require_arc = require("./arc-CYhI62kO.cjs");
|
|
6
|
+
const require_vnode = require("./vnode-ClAiw28x.cjs");
|
|
7
|
+
const require_clean = require("./clean-Die2iCNc.cjs");
|
|
8
|
+
const require_named = require("./named-BBASc8dW.cjs");
|
|
9
|
+
const require_others = require("./others-DWdK7vKp.cjs");
|
|
10
|
+
// src/charts/pie.ts
|
|
9
11
|
/** Angles of the visible slices, clockwise from `startAngle`. */
|
|
10
12
|
function layoutSlices(options, hidden) {
|
|
11
|
-
const visible = options.data.
|
|
12
|
-
data,
|
|
13
|
-
index,
|
|
14
|
-
value: Math.max(0, data.value || 0)
|
|
15
|
-
})).filter((slice) => !hidden.has(require_named.keyOf(slice.data)));
|
|
13
|
+
const visible = require_others.groupSlices(options.data, options.maxSlices, options.othersLabel).filter((slice) => !hidden.has(require_named.keyOf(slice.data)));
|
|
16
14
|
const total = visible.reduce((sum, slice) => sum + slice.value, 0);
|
|
17
|
-
let angle = (options.startAngle ?? 0) *
|
|
15
|
+
let angle = (options.startAngle ?? 0) * require_arc.DEG;
|
|
18
16
|
return {
|
|
19
17
|
slices: visible.map((slice) => {
|
|
20
18
|
const sweep = total > 0 ? slice.value / total * Math.PI * 2 : 0;
|
|
@@ -41,7 +39,7 @@ function renderPie(options, ctx, defaults) {
|
|
|
41
39
|
const { slices, total } = layoutSlices(options, ctx.hidden);
|
|
42
40
|
const drawn = slices.filter((slice) => slice.value > 0);
|
|
43
41
|
const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0;
|
|
44
|
-
const padAngle = inner > 0 && drawn.length > 1 ?
|
|
42
|
+
const padAngle = inner > 0 && drawn.length > 1 ? require_arc.padAngleForGap(gap, inner, outer) : 0;
|
|
45
43
|
const value = require_format.formatNumber(options.format, locale);
|
|
46
44
|
const share = require_format.getNumberFormat(locale, {
|
|
47
45
|
style: "percent",
|
|
@@ -56,7 +54,7 @@ function renderPie(options, ctx, defaults) {
|
|
|
56
54
|
cornerRadius
|
|
57
55
|
});
|
|
58
56
|
const hitFor = (slice, position) => {
|
|
59
|
-
const [x, y] =
|
|
57
|
+
const [x, y] = require_arc.arcCentroid(geometry(slice));
|
|
60
58
|
const item = {
|
|
61
59
|
name: slice.data.name,
|
|
62
60
|
seriesIndex: slice.index,
|
|
@@ -80,7 +78,7 @@ function renderPie(options, ctx, defaults) {
|
|
|
80
78
|
items: [item],
|
|
81
79
|
seriesIndex: slice.index,
|
|
82
80
|
mark: {
|
|
83
|
-
d:
|
|
81
|
+
d: require_arc.arcPathStable({
|
|
84
82
|
...geometry(slice, outer + 2, outer + 6),
|
|
85
83
|
cornerRadius: 2
|
|
86
84
|
}),
|
|
@@ -100,7 +98,7 @@ function renderPie(options, ctx, defaults) {
|
|
|
100
98
|
const dy = py - cy;
|
|
101
99
|
const r = Math.hypot(dx, dy);
|
|
102
100
|
if (r < inner - 2 || r > outer + 8) return null;
|
|
103
|
-
const start = (options.startAngle ?? 0) *
|
|
101
|
+
const start = (options.startAngle ?? 0) * require_arc.DEG;
|
|
104
102
|
const turn = Math.PI * 2;
|
|
105
103
|
let angle = Math.atan2(dx, -dy);
|
|
106
104
|
angle = start + ((angle - start) % turn + turn) % turn;
|
|
@@ -119,7 +117,7 @@ function renderPie(options, ctx, defaults) {
|
|
|
119
117
|
style: `transform:translate(${cx}px,${cy}px)`
|
|
120
118
|
}, total === 0 && require_vnode.h("path", {
|
|
121
119
|
class: "tc-pie-track",
|
|
122
|
-
d:
|
|
120
|
+
d: require_arc.arcPathStable({
|
|
123
121
|
innerRadius: inner,
|
|
124
122
|
outerRadius: outer,
|
|
125
123
|
startAngle: 0,
|
|
@@ -173,7 +171,7 @@ function pieType(name, defaults) {
|
|
|
173
171
|
require_features.features.sweep = require_sweep.sweep;
|
|
174
172
|
return renderPie(options, ctx, defaults);
|
|
175
173
|
},
|
|
176
|
-
legend: (options) =>
|
|
174
|
+
legend: (options) => require_others.groupLegend(require_others.groupSlices(options.data, options.maxSlices, options.othersLabel)),
|
|
177
175
|
table: pieTable,
|
|
178
176
|
valueLabels: { marks: "slice" }
|
|
179
177
|
};
|
|
@@ -194,7 +192,6 @@ const donut = pieType("donut", {
|
|
|
194
192
|
inner: .62,
|
|
195
193
|
corner: 4
|
|
196
194
|
});
|
|
197
|
-
//#endregion
|
|
198
195
|
Object.defineProperty(exports, "donut", {
|
|
199
196
|
enumerable: true,
|
|
200
197
|
get: function() {
|
|
@@ -208,4 +205,4 @@ Object.defineProperty(exports, "pie", {
|
|
|
208
205
|
}
|
|
209
206
|
});
|
|
210
207
|
|
|
211
|
-
//# sourceMappingURL=pie-
|
|
208
|
+
//# sourceMappingURL=pie-BpjvSPnz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-BpjvSPnz.cjs","names":["groupSlices","keyOf","DEG","innerRect","insets","padAngleForGap","formatNumber","getNumberFormat","arcCentroid","arcPathStable","h","groupAttrs","arcNode","cleanData","cleanItems","features","sweep","groupLegend"],"sources":["../src/charts/pie.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { features } from '../features.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets } from '../layout.ts'\nimport { arcNode, sweep } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO, padAngleForGap } from '../shapes/arc.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf } from './named.ts'\nimport { groupLegend, groupSlices } from './others.ts'\n\n/** One slice of a pie or donut. */\nexport interface PieSlice {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the slice group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PieOptions {\n data: readonly PieSlice[]\n /**\n * The most slices drawn, the one for the rest included: with more entries\n * than that, the largest `maxSlices - 1` keep a slice of their own and the\n * others share one, named by `othersLabel`, after them. Defaults to `9`\n * (the eight palette colors and the rest); `0` never groups.\n */\n maxSlices?: number\n /** Name of the slice that groups the rest. Defaults to `'Others'`. */\n othersLabel?: string\n /** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */\n innerRadius?: number\n /** Gap between slices in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */\n cornerRadius?: number\n /** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Format of the values (tooltip, table, donut total). */\n format?: NumberFormat\n /**\n * Text in the donut hole: the total by default; `false` hides it, or give\n * your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the pie, in pixels. */\n padding?: InsetsInput\n}\n\ninterface Slice {\n data: PieSlice\n index: number\n value: number\n startAngle: number\n endAngle: number\n}\n\n/** Angles of the visible slices, clockwise from `startAngle`. */\nfunction layoutSlices(\n options: PieOptions,\n hidden: ReadonlySet<string>,\n): { slices: Slice[]; total: number } {\n const visible = groupSlices(options.data, options.maxSlices, options.othersLabel).filter(\n (slice) => !hidden.has(keyOf(slice.data)),\n )\n const total = visible.reduce((sum, slice) => sum + slice.value, 0)\n let angle = (options.startAngle ?? 0) * DEG\n const slices = visible.map((slice) => {\n const sweep = total > 0 ? (slice.value / total) * Math.PI * 2 : 0\n const out: Slice = { ...slice, startAngle: angle, endAngle: angle + sweep }\n angle += sweep\n return out\n })\n return { slices, total }\n}\n\nfunction renderPie(\n options: PieOptions,\n ctx: RenderContext,\n defaults: { inner: number; corner: number },\n) {\n const { width, height, locale } = ctx\n const gap = options.gap ?? 2\n const area = innerRect(width, height, insets(options.padding, 0))\n const outer = Math.max(0, Math.min(area.width, area.height) / 2 - HALO)\n const ratio = Math.min(0.95, Math.max(0, options.innerRadius ?? defaults.inner))\n const inner = outer * ratio\n const cornerRadius = options.cornerRadius ?? defaults.corner\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const drawn = slices.filter((slice) => slice.value > 0)\n // A single slice is a full ring: no gap to cut.\n // Rings get a pad angle, which keeps a constant gap width along the whole\n // edge. In a full pie every slice meets at the center, so a pad angle would\n // widen into a wedge: the gap is a surface-colored stroke instead.\n const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0\n const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const geometry = (slice: Slice, r0 = inner, r1 = outer) => ({\n innerRadius: r0,\n outerRadius: r1,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n padAngle,\n cornerRadius,\n })\n\n const hitFor = (slice: Slice, position: number): Hit => {\n const [x, y] = arcCentroid(geometry(slice))\n const item: HitItem = {\n name: slice.data.name,\n seriesIndex: slice.index,\n value: slice.value,\n text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,\n x: cx + x,\n y: cy + y,\n }\n if (slice.data.color) item.color = slice.data.color\n return {\n index: position,\n label: slice.data.name,\n title: '',\n x: cx + x,\n area: { x: cx - outer, y: cy - outer, width: outer * 2, height: outer * 2 },\n items: [item],\n seriesIndex: slice.index,\n // A thin halo just outside the slice.\n mark: {\n d: arcPathStable({ ...geometry(slice, outer + 2, outer + 6), cornerRadius: 2 }),\n x: cx,\n y: cy,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => {\n const slice = drawn[position]\n return slice ? hitFor(slice, position) : null\n },\n hitTest(px, py) {\n const dx = px - cx\n const dy = py - cy\n const r = Math.hypot(dx, dy)\n if (r < inner - 2 || r > outer + HALO) return null\n const start = (options.startAngle ?? 0) * DEG\n const turn = Math.PI * 2\n // Clockwise angle from 12 o'clock, normalized into [start, start + turn).\n let angle = Math.atan2(dx, -dy)\n angle = start + ((((angle - start) % turn) + turn) % turn)\n const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle)\n return position === -1 ? null : hitFor(drawn[position] as Slice, position)\n },\n }\n ctx.onHitTest(interaction)\n\n const groups = slices.map((slice) =>\n h(\n 'g',\n groupAttrs(slice.data, slice.index),\n // The path keeps its arc, so new data sweeps slices around the center\n // (see `sweep`). An empty slice keeps its path, a line with no area in\n // the gap between its neighbors, to grow from there.\n arcNode('tc-slice', geometry(slice)),\n ),\n )\n\n const center = options.center\n const showCenter = inner > 0 && center !== false\n const centerValue = showCenter ? (center?.value ?? value(total)) : ''\n const centerLabel = showCenter ? center?.label : undefined\n\n return [\n h(\n 'g',\n { class: 'tc-pie', style: `transform:translate(${cx}px,${cy}px)` },\n total === 0 &&\n h('path', {\n class: 'tc-pie-track',\n d: arcPathStable({\n innerRadius: inner,\n outerRadius: outer,\n startAngle: 0,\n endAngle: Math.PI * 2,\n }),\n }),\n h(\n 'g',\n {\n class: 'tc-pie-slices',\n style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : undefined,\n },\n groups,\n ),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-pie-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-pie-value',\n x: cx,\n y: cy,\n dy: centerLabel ? '0' : '0.35em',\n 'text-anchor': 'middle',\n },\n centerValue,\n ),\n centerLabel &&\n h(\n 'text',\n { class: 'tc-pie-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n}\n\nfunction pieTable(options: PieOptions, ctx: RenderContext): DataTable {\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: slices.map((slice) => [\n slice.data.name,\n value(slice.value),\n share.format(total > 0 ? slice.value / total : 0),\n ]),\n }\n}\n\nfunction pieType(name: string, defaults: { inner: number; corner: number }): ChartType<PieOptions> {\n return {\n name,\n clean: cleanData(cleanItems),\n render: (options, ctx): ChildInput => {\n // Set here, not as the module loads: a module with side effects would\n // stay in every bundle that imports another chart type next to it.\n features.sweep = sweep\n return renderPie(options, ctx, defaults)\n },\n legend: (options) =>\n groupLegend(groupSlices(options.data, options.maxSlices, options.othersLabel)),\n table: pieTable,\n valueLabels: { marks: 'slice' },\n }\n}\n\n/**\n * Pie chart: parts of a whole as slices, in data order, clockwise from the top.\n *\n * ```ts\n * new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })\n * ```\n */\nexport const pie: ChartType<PieOptions> = pieType('pie', { inner: 0, corner: 0 })\n\n/** Donut chart: a pie with a hole showing the total (or your own `center`). */\nexport const donut: ChartType<PieOptions> = pieType('donut', { inner: 0.62, corner: 4 })\n"],"mappings":";;;;;;;;;;;AAsEA,SAAS,aACP,SACA,QACoC;CACpC,MAAM,UAAUA,eAAAA,YAAY,QAAQ,MAAM,QAAQ,WAAW,QAAQ,WAAW,CAAC,CAAC,QAC/E,UAAU,CAAC,OAAO,IAAIC,cAAAA,MAAM,MAAM,IAAI,CAAC,CAC1C;CACA,MAAM,QAAQ,QAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;CACjE,IAAI,SAAS,QAAQ,cAAc,KAAKC,YAAAA;CAOxC,OAAO;EAAE,QANM,QAAQ,KAAK,UAAU;GACpC,MAAM,QAAQ,QAAQ,IAAK,MAAM,QAAQ,QAAS,KAAK,KAAK,IAAI;GAChE,MAAM,MAAa;IAAE,GAAG;IAAO,YAAY;IAAO,UAAU,QAAQ;GAAM;GAC1E,SAAS;GACT,OAAO;EACT,CACc;EAAG;CAAM;AACzB;AAEA,SAAS,UACP,SACA,KACA,UACA;CACA,MAAM,EAAE,OAAO,QAAQ,WAAW;CAClC,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,OAAOC,eAAAA,UAAU,OAAO,QAAQC,eAAAA,OAAO,QAAQ,SAAS,CAAC,CAAC;CAChE,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,OAAO,KAAK,MAAM,IAAI,IAAA,CAAQ;CAEtE,MAAM,QAAQ,QADA,KAAK,IAAI,KAAM,KAAK,IAAI,GAAG,QAAQ,eAAe,SAAS,KAAK,CACpD;CAC1B,MAAM,eAAe,QAAQ,gBAAgB,SAAS;C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O,QAAQ;CAChC;AACF;;;;;;;;AASA,MAAa,MAA6B,QAAQ,OAAO;CAAE,OAAO;CAAG,QAAQ;AAAE,CAAC;;AAGhF,MAAa,QAA+B,QAAQ,SAAS;CAAE,OAAO;CAAM,QAAQ;AAAE,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
//#region src/charts/pie.d.ts
|
|
1
|
+
import { a as ChartType } from "./chart-QilhWP8Z.js";
|
|
2
|
+
import { c as NumberFormat } from "./time-DRIDgv2a.js";
|
|
3
|
+
import { a as InsetsInput } from "./annotations-B02GR_KU.js";
|
|
4
|
+
import { a as ClassValue } from "./vnode-Du2cC8Fm.js";
|
|
6
5
|
/** One slice of a pie or donut. */
|
|
7
6
|
interface PieSlice {
|
|
8
7
|
name: string;
|
|
@@ -22,6 +21,15 @@ interface PieSlice {
|
|
|
22
21
|
}
|
|
23
22
|
interface PieOptions {
|
|
24
23
|
data: readonly PieSlice[];
|
|
24
|
+
/**
|
|
25
|
+
* The most slices drawn, the one for the rest included: with more entries
|
|
26
|
+
* than that, the largest `maxSlices - 1` keep a slice of their own and the
|
|
27
|
+
* others share one, named by `othersLabel`, after them. Defaults to `9`
|
|
28
|
+
* (the eight palette colors and the rest); `0` never groups.
|
|
29
|
+
*/
|
|
30
|
+
maxSlices?: number;
|
|
31
|
+
/** Name of the slice that groups the rest. Defaults to `'Others'`. */
|
|
32
|
+
othersLabel?: string;
|
|
25
33
|
/** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */
|
|
26
34
|
innerRadius?: number;
|
|
27
35
|
/** Gap between slices in pixels, drawn as surface. Defaults to `2`. */
|
|
@@ -53,6 +61,4 @@ interface PieOptions {
|
|
|
53
61
|
declare const pie: ChartType<PieOptions>;
|
|
54
62
|
/** Donut chart: a pie with a hole showing the total (or your own `center`). */
|
|
55
63
|
declare const donut: ChartType<PieOptions>;
|
|
56
|
-
|
|
57
|
-
export { pie as i, PieSlice as n, donut as r, PieOptions as t };
|
|
58
|
-
//# sourceMappingURL=pie-DnQQmxkk.d.cts.map
|
|
64
|
+
export { pie as i, PieSlice as n, donut as r, PieOptions as t };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { r as features } from "./features-BMxkqCyS.js";
|
|
2
|
+
import { o as getNumberFormat, r as formatNumber } from "./format-it1kepFG.js";
|
|
3
|
+
import { i as insets, r as innerRect } from "./layout-DmrrLjwN.js";
|
|
4
|
+
import { n as sweep, t as arcNode } from "./sweep-BpRPlhs6.js";
|
|
5
|
+
import { i as padAngleForGap, n as arcCentroid, r as arcPathStable, t as DEG } from "./arc-B3V5IR0w.js";
|
|
6
|
+
import { t as h } from "./vnode-_EMUqysL.js";
|
|
7
|
+
import { n as cleanItems, t as cleanData } from "./clean-CkoQobGv.js";
|
|
8
|
+
import { n as keyOf, t as groupAttrs } from "./named-BOiBah6I.js";
|
|
9
|
+
import { n as groupSlices, t as groupLegend } from "./others-J7NCAMA0.js";
|
|
10
|
+
// src/charts/pie.ts
|
|
9
11
|
/** Angles of the visible slices, clockwise from `startAngle`. */
|
|
10
12
|
function layoutSlices(options, hidden) {
|
|
11
|
-
const visible = options.data.
|
|
12
|
-
data,
|
|
13
|
-
index,
|
|
14
|
-
value: Math.max(0, data.value || 0)
|
|
15
|
-
})).filter((slice) => !hidden.has(keyOf(slice.data)));
|
|
13
|
+
const visible = groupSlices(options.data, options.maxSlices, options.othersLabel).filter((slice) => !hidden.has(keyOf(slice.data)));
|
|
16
14
|
const total = visible.reduce((sum, slice) => sum + slice.value, 0);
|
|
17
15
|
let angle = (options.startAngle ?? 0) * DEG;
|
|
18
16
|
return {
|
|
@@ -173,7 +171,7 @@ function pieType(name, defaults) {
|
|
|
173
171
|
features.sweep = sweep;
|
|
174
172
|
return renderPie(options, ctx, defaults);
|
|
175
173
|
},
|
|
176
|
-
legend: (options) =>
|
|
174
|
+
legend: (options) => groupLegend(groupSlices(options.data, options.maxSlices, options.othersLabel)),
|
|
177
175
|
table: pieTable,
|
|
178
176
|
valueLabels: { marks: "slice" }
|
|
179
177
|
};
|
|
@@ -194,7 +192,6 @@ const donut = pieType("donut", {
|
|
|
194
192
|
inner: .62,
|
|
195
193
|
corner: 4
|
|
196
194
|
});
|
|
197
|
-
//#endregion
|
|
198
195
|
export { pie as n, donut as t };
|
|
199
196
|
|
|
200
|
-
//# sourceMappingURL=pie-
|
|
197
|
+
//# sourceMappingURL=pie-CVsc-6qD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-CVsc-6qD.js","names":[],"sources":["../src/charts/pie.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport { features } from '../features.ts'\nimport { formatNumber, getNumberFormat, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { type InsetsInput, innerRect, insets } from '../layout.ts'\nimport { arcNode, sweep } from '../render/sweep.ts'\nimport { arcCentroid, arcPathStable, DEG, HALO, padAngleForGap } from '../shapes/arc.ts'\nimport { type ChildInput, type ClassValue, h } from '../vnode.ts'\nimport { cleanData, cleanItems } from './clean.ts'\nimport { groupAttrs, keyOf } from './named.ts'\nimport { groupLegend, groupSlices } from './others.ts'\n\n/** One slice of a pie or donut. */\nexport interface PieSlice {\n name: string\n /** Non-negative value; negative values count as zero. */\n value: number\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the slice group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n}\n\nexport interface PieOptions {\n data: readonly PieSlice[]\n /**\n * The most slices drawn, the one for the rest included: with more entries\n * than that, the largest `maxSlices - 1` keep a slice of their own and the\n * others share one, named by `othersLabel`, after them. Defaults to `9`\n * (the eight palette colors and the rest); `0` never groups.\n */\n maxSlices?: number\n /** Name of the slice that groups the rest. Defaults to `'Others'`. */\n othersLabel?: string\n /** Hole size relative to the radius, `0…0.95`. Defaults to `0` (`0.62` for `donut`). */\n innerRadius?: number\n /** Gap between slices in pixels, drawn as surface. Defaults to `2`. */\n gap?: number\n /** Corner radius of the slices. Defaults to `0` (`4` for `donut`). */\n cornerRadius?: number\n /** Where the first slice starts, in degrees clockwise from 12 o'clock. Defaults to `0`. */\n startAngle?: number\n /** Format of the values (tooltip, table, donut total). */\n format?: NumberFormat\n /**\n * Text in the donut hole: the total by default; `false` hides it, or give\n * your own `value` / `label`.\n */\n center?: false | { value?: string; label?: string }\n /** Extra space around the pie, in pixels. */\n padding?: InsetsInput\n}\n\ninterface Slice {\n data: PieSlice\n index: number\n value: number\n startAngle: number\n endAngle: number\n}\n\n/** Angles of the visible slices, clockwise from `startAngle`. */\nfunction layoutSlices(\n options: PieOptions,\n hidden: ReadonlySet<string>,\n): { slices: Slice[]; total: number } {\n const visible = groupSlices(options.data, options.maxSlices, options.othersLabel).filter(\n (slice) => !hidden.has(keyOf(slice.data)),\n )\n const total = visible.reduce((sum, slice) => sum + slice.value, 0)\n let angle = (options.startAngle ?? 0) * DEG\n const slices = visible.map((slice) => {\n const sweep = total > 0 ? (slice.value / total) * Math.PI * 2 : 0\n const out: Slice = { ...slice, startAngle: angle, endAngle: angle + sweep }\n angle += sweep\n return out\n })\n return { slices, total }\n}\n\nfunction renderPie(\n options: PieOptions,\n ctx: RenderContext,\n defaults: { inner: number; corner: number },\n) {\n const { width, height, locale } = ctx\n const gap = options.gap ?? 2\n const area = innerRect(width, height, insets(options.padding, 0))\n const outer = Math.max(0, Math.min(area.width, area.height) / 2 - HALO)\n const ratio = Math.min(0.95, Math.max(0, options.innerRadius ?? defaults.inner))\n const inner = outer * ratio\n const cornerRadius = options.cornerRadius ?? defaults.corner\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const drawn = slices.filter((slice) => slice.value > 0)\n // A single slice is a full ring: no gap to cut.\n // Rings get a pad angle, which keeps a constant gap width along the whole\n // edge. In a full pie every slice meets at the center, so a pad angle would\n // widen into a wedge: the gap is a surface-colored stroke instead.\n const strokeGap = inner === 0 && drawn.length > 1 ? gap : 0\n const padAngle = inner > 0 && drawn.length > 1 ? padAngleForGap(gap, inner, outer) : 0\n const value = formatNumber(options.format, locale)\n const share = getNumberFormat(locale, { style: 'percent', maximumFractionDigits: 1 })\n\n const geometry = (slice: Slice, r0 = inner, r1 = outer) => ({\n innerRadius: r0,\n outerRadius: r1,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n padAngle,\n cornerRadius,\n })\n\n const hitFor = (slice: Slice, position: number): Hit => {\n const [x, y] = arcCentroid(geometry(slice))\n const item: HitItem = {\n name: slice.data.name,\n seriesIndex: slice.index,\n value: slice.value,\n text: `${value(slice.value)} (${share.format(total > 0 ? slice.value / total : 0)})`,\n x: cx + x,\n y: cy + y,\n }\n if (slice.data.color) item.color = slice.data.color\n return {\n index: position,\n label: slice.data.name,\n title: '',\n x: cx + x,\n area: { x: cx - outer, y: cy - outer, width: outer * 2, height: outer * 2 },\n items: [item],\n seriesIndex: slice.index,\n // A thin halo just outside the slice.\n mark: {\n d: arcPathStable({ ...geometry(slice, outer + 2, outer + 6), cornerRadius: 2 }),\n x: cx,\n y: cy,\n },\n }\n }\n\n const interaction: Interaction = {\n count: drawn.length,\n hitIndex: (position) => {\n const slice = drawn[position]\n return slice ? hitFor(slice, position) : null\n },\n hitTest(px, py) {\n const dx = px - cx\n const dy = py - cy\n const r = Math.hypot(dx, dy)\n if (r < inner - 2 || r > outer + HALO) return null\n const start = (options.startAngle ?? 0) * DEG\n const turn = Math.PI * 2\n // Clockwise angle from 12 o'clock, normalized into [start, start + turn).\n let angle = Math.atan2(dx, -dy)\n angle = start + ((((angle - start) % turn) + turn) % turn)\n const position = drawn.findIndex((s) => angle >= s.startAngle && angle < s.endAngle)\n return position === -1 ? null : hitFor(drawn[position] as Slice, position)\n },\n }\n ctx.onHitTest(interaction)\n\n const groups = slices.map((slice) =>\n h(\n 'g',\n groupAttrs(slice.data, slice.index),\n // The path keeps its arc, so new data sweeps slices around the center\n // (see `sweep`). An empty slice keeps its path, a line with no area in\n // the gap between its neighbors, to grow from there.\n arcNode('tc-slice', geometry(slice)),\n ),\n )\n\n const center = options.center\n const showCenter = inner > 0 && center !== false\n const centerValue = showCenter ? (center?.value ?? value(total)) : ''\n const centerLabel = showCenter ? center?.label : undefined\n\n return [\n h(\n 'g',\n { class: 'tc-pie', style: `transform:translate(${cx}px,${cy}px)` },\n total === 0 &&\n h('path', {\n class: 'tc-pie-track',\n d: arcPathStable({\n innerRadius: inner,\n outerRadius: outer,\n startAngle: 0,\n endAngle: Math.PI * 2,\n }),\n }),\n h(\n 'g',\n {\n class: 'tc-pie-slices',\n style: strokeGap > 0 ? `--tc-pie-gap:${strokeGap}px` : undefined,\n },\n groups,\n ),\n ),\n showCenter &&\n h(\n 'g',\n { class: 'tc-pie-center', 'aria-hidden': 'true' },\n h(\n 'text',\n {\n class: 'tc-pie-value',\n x: cx,\n y: cy,\n dy: centerLabel ? '0' : '0.35em',\n 'text-anchor': 'middle',\n },\n centerValue,\n ),\n centerLabel &&\n h(\n 'text',\n { class: 'tc-pie-label', x: cx, y: cy, dy: '1.6em', 'text-anchor': 'middle' },\n centerLabel,\n ),\n ),\n ]\n}\n\nfunction pieTable(options: PieOptions, ctx: RenderContext): DataTable {\n const { slices, total } = layoutSlices(options, ctx.hidden)\n const value = formatNumber(options.format, ctx.locale)\n const share = getNumberFormat(ctx.locale, { style: 'percent', maximumFractionDigits: 1 })\n return {\n columns: ['', 'Value', 'Share'],\n rows: slices.map((slice) => [\n slice.data.name,\n value(slice.value),\n share.format(total > 0 ? slice.value / total : 0),\n ]),\n }\n}\n\nfunction pieType(name: string, defaults: { inner: number; corner: number }): ChartType<PieOptions> {\n return {\n name,\n clean: cleanData(cleanItems),\n render: (options, ctx): ChildInput => {\n // Set here, not as the module loads: a module with side effects would\n // stay in every bundle that imports another chart type next to it.\n features.sweep = sweep\n return renderPie(options, ctx, defaults)\n },\n legend: (options) =>\n groupLegend(groupSlices(options.data, options.maxSlices, options.othersLabel)),\n table: pieTable,\n valueLabels: { marks: 'slice' },\n }\n}\n\n/**\n * Pie chart: parts of a whole as slices, in data order, clockwise from the top.\n *\n * ```ts\n * new Chart('#el', { type: pie, data: [{ name: 'Direct', value: 42 }, { name: 'Search', value: 31 }] })\n * ```\n */\nexport const pie: ChartType<PieOptions> = pieType('pie', { inner: 0, corner: 0 })\n\n/** Donut chart: a pie with a hole showing the total (or your own `center`). */\nexport const donut: ChartType<PieOptions> = pieType('donut', { inner: 0.62, corner: 4 })\n"],"mappings":";;;;;;;;;;;AAsEA,SAAS,aACP,SACA,QACoC;CACpC,MAAM,UAAU,YAAY,QAAQ,MAAM,QAAQ,WAAW,QAAQ,WAAW,CAAC,CAAC,QAC/E,UAAU,CAAC,OAAO,IAAI,MAAM,MAAM,IAAI,CAAC,CAC1C;CACA,MAAM,QAAQ,QAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;CACjE,IAAI,SAAS,QAAQ,cAAc,KAAK;CAOxC,OAAO;EAAE,QANM,QAAQ,KAAK,UAAU;GACpC,MAAM,QAAQ,QAAQ,IAAK,MAAM,QAAQ,QAAS,KAAK,KAAK,IAAI;GAChE,MAAM,MAAa;IAAE,GAAG;IAAO,YAAY;IAAO,UAAU,QAAQ;GAAM;GAC1E,SAAS;GACT,OAAO;EACT,CACc;EAAG;CAAM;AACzB;AAEA,SAAS,UACP,SACA,KACA,UACA;CACA,MAAM,EAAE,O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,OAAO,UAAU,SAAS,KAAK,QAAQ;EACzC;EACA,SAAS,YACP,YAAY,YAAY,QAAQ,MAAM,QAAQ,WAAW,QAAQ,WAAW,CAAC;EAC/E,OAAO;EACP,aAAa,EAAE,OAAO,QAAQ;CAChC;AACF;;;;;;;;AASA,MAAa,MAA6B,QAAQ,OAAO;CAAE,OAAO;CAAG,QAAQ;AAAE,CAAC;;AAGhF,MAAa,QAA+B,QAAQ,SAAS;CAAE,OAAO;CAAM,QAAQ;AAAE,CAAC"}
|
package/dist/pie.cjs
CHANGED
package/dist/pie.d.cts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
/** Standalone entry: `import { pie, donut } from '@tabler/charts/pie'`. */
|
|
2
|
+
import { i as pie, n as PieSlice, r as donut, t as PieOptions } from "./pie-BXg2gNpb.cjs";
|
|
2
3
|
export { type PieOptions, type PieSlice, donut, pie };
|
package/dist/pie.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
/** Standalone entry: `import { pie, donut } from '@tabler/charts/pie'`. */
|
|
2
|
+
import { i as pie, n as PieSlice, r as donut, t as PieOptions } from "./pie-CFptILSm.js";
|
|
2
3
|
export { type PieOptions, type PieSlice, donut, pie };
|
package/dist/pie.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { donut, pie };
|
|
1
|
+
export { t as donut, n as pie } from "./pie-CVsc-6qD.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_layout = require("./layout-
|
|
2
|
-
|
|
1
|
+
const require_layout = require("./layout-JY2aR-yE.cjs");
|
|
2
|
+
// src/charts/point-shapes.ts
|
|
3
3
|
/**
|
|
4
4
|
* Outlines by color slot (0-based), as x, y pairs in units of the radius,
|
|
5
5
|
* sized so the shapes weigh about the same as the circle of slot 0 (and of
|
|
@@ -149,7 +149,6 @@ function reshape(child, slot) {
|
|
|
149
149
|
}
|
|
150
150
|
/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */
|
|
151
151
|
const shapesStep = (config, content) => config.shapes ?? config.patterns === true ? reshape(content, -1) : content;
|
|
152
|
-
//#endregion
|
|
153
152
|
Object.defineProperty(exports, "markerPath", {
|
|
154
153
|
enumerable: true,
|
|
155
154
|
get: function() {
|
|
@@ -163,4 +162,4 @@ Object.defineProperty(exports, "shapesStep", {
|
|
|
163
162
|
}
|
|
164
163
|
});
|
|
165
164
|
|
|
166
|
-
//# sourceMappingURL=point-shapes
|
|
165
|
+
//# sourceMappingURL=point-shapes--_gmdTyK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point-shapes
|
|
1
|
+
{"version":3,"file":"point-shapes--_gmdTyK.cjs","names":["round"],"sources":["../src/charts/point-shapes.ts"],"sourcesContent":["/**\n * Marker shapes, so the points of series do not depend on color alone\n * (color vision deficiency, grayscale print): one shape per color slot,\n * for line, radar and scatter points and the active points of the hover.\n * On with `shapes: true`, and with `patterns: true` unless `shapes` says\n * otherwise. Legend and tooltip swatches take the same shapes in CSS.\n */\nimport type { PostStep } from '../features.ts'\nimport { round } from '../layout.ts'\nimport type { Child, ChildInput, VNode } from '../vnode.ts'\n\n/**\n * Outlines by color slot (0-based), as x, y pairs in units of the radius,\n * sized so the shapes weigh about the same as the circle of slot 0 (and of\n * slots 9 and up).\n */\nconst SHAPES: readonly (readonly number[])[] = [\n [],\n // Square.\n [-0.9, -0.9, 0.9, -0.9, 0.9, 0.9, -0.9, 0.9],\n // Triangle.\n [0, -1.3, 1.2, 0.9, -1.2, 0.9],\n // Diamond.\n [0, -1.3, 1.3, 0, 0, 1.3, -1.3, 0],\n // Triangle, pointing down.\n [-1.2, -0.9, 1.2, -0.9, 0, 1.3],\n // Plus.\n [\n -0.4, -1.2, 0.4, -1.2, 0.4, -0.4, 1.2, -0.4, 1.2, 0.4, 0.4, 0.4, 0.4, 1.2, -0.4, 1.2, -0.4, 0.4,\n -1.2, 0.4, -1.2, -0.4, -0.4, -0.4,\n ],\n // Cross.\n [\n -0.7, -1.2, 0, -0.5, 0.7, -1.2, 1.2, -0.7, 0.5, 0, 1.2, 0.7, 0.7, 1.2, 0, 0.5, -0.7, 1.2, -1.2,\n 0.7, -0.5, 0, -1.2, -0.7,\n ],\n // Star.\n [\n 0, -1.4, 0.32, -0.44, 1.33, -0.43, 0.52, 0.17, 0.82, 1.13, 0, 0.55, -0.82, 1.13, -0.52, 0.17,\n -1.33, -0.43, -0.32, -0.44,\n ],\n]\n\n/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */\nexport function markerPath(slot: number, x: number, y: number, r: number): string {\n const shape = SHAPES[slot] ?? []\n if (!shape.length) {\n return `M${round(x - r)},${round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`\n }\n let d = ''\n for (let i = 0; i < shape.length; i += 2) {\n d += `${i ? 'L' : 'M'}${round(x + (shape[i] as number) * r)},${round(y + (shape[i + 1] as number) * r)}`\n }\n return `${d}Z`\n}\n\n/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */\nfunction reshape(child: ChildInput, slot: number): ChildInput {\n if (Array.isArray(child)) return child.map((c) => reshape(c, slot))\n if (!child || typeof child !== 'object') return child\n const { attrs } = child\n const cls = String(attrs.class ?? '')\n const group = /\\btc-series-(\\d+)\\b/.exec(cls)\n if (\n child.tag === 'circle' &&\n slot >= 0 &&\n /\\btc-point\\b/.test(cls) &&\n !/\\btc-bubble\\b/.test(cls)\n ) {\n const shaped: VNode = {\n tag: 'path',\n attrs: {\n class: `${cls} tc-marker`,\n d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0)),\n },\n children: [],\n key: child.key,\n }\n return shaped\n }\n return {\n ...child,\n children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot) as Child),\n }\n}\n\n/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */\nexport const shapesStep: Post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AM,IAAI,KAAgB,CAAC;CAEvG,OAAO,GAAG,EAAE;AACd;;AAGA,SAAS,QAAQ,OAAmB,MAA0B;CAC5D,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,MAAM,QAAQ,GAAG,IAAI,CAAC;CAClE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,EAAE,UAAU;CAClB,MAAM,MAAM,OAAO,MAAM,SAAS,EAAE;CACpC,MAAM,QAAQ,sBAAsB,KAAK,GAAG;CAC5C,IACE,MAAM,QAAQ,YACd,QAAQ,KACR,eAAe,KAAK,GAAG,KACvB,CAAC,gBAAgB,KAAK,GAAG,GAWzB,OAAO;EARL,KAAK;EACL,OAAO;GACL,OAAO,GAAG,IAAI;GACd,GAAG,WAAW,MAAM,EAAE,MAAM,MAAM,IAAI,EAAE,MAAM,MAAM,IAAI,EAAE,MAAM,KAAK,EAAE;EACzE;EACA,UAAU,CAAC;EACX,KAAK,MAAM;CAED;CAEd,OAAO;EACL,GAAG;EACH,UAAU,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAG,QAAQ,OAAO,MAAM,EAAE,IAAI,IAAI,IAAI,CAAU;CAC9F;AACF;;AAGA,MAAa,cAAwB,QAAQ,YAC1C,OAAO,UAAU,OAAO,aAAa,OAAQ,QAAQ,SAAS,EAAE,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { o as round } from "./layout-DmrrLjwN.js";
|
|
2
|
+
// src/charts/point-shapes.ts
|
|
3
3
|
/**
|
|
4
4
|
* Outlines by color slot (0-based), as x, y pairs in units of the radius,
|
|
5
5
|
* sized so the shapes weigh about the same as the circle of slot 0 (and of
|
|
@@ -149,7 +149,6 @@ function reshape(child, slot) {
|
|
|
149
149
|
}
|
|
150
150
|
/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */
|
|
151
151
|
const shapesStep = (config, content) => config.shapes ?? config.patterns === true ? reshape(content, -1) : content;
|
|
152
|
-
//#endregion
|
|
153
152
|
export { shapesStep as n, markerPath as t };
|
|
154
153
|
|
|
155
|
-
//# sourceMappingURL=point-shapes-
|
|
154
|
+
//# sourceMappingURL=point-shapes-DD2Ektzm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point-shapes-
|
|
1
|
+
{"version":3,"file":"point-shapes-DD2Ektzm.js","names":[],"sources":["../src/charts/point-shapes.ts"],"sourcesContent":["/**\n * Marker shapes, so the points of series do not depend on color alone\n * (color vision deficiency, grayscale print): one shape per color slot,\n * for line, radar and scatter points and the active points of the hover.\n * On with `shapes: true`, and with `patterns: true` unless `shapes` says\n * otherwise. Legend and tooltip swatches take the same shapes in CSS.\n */\nimport type { PostStep } from '../features.ts'\nimport { round } from '../layout.ts'\nimport type { Child, ChildInput, VNode } from '../vnode.ts'\n\n/**\n * Outlines by color slot (0-based), as x, y pairs in units of the radius,\n * sized so the shapes weigh about the same as the circle of slot 0 (and of\n * slots 9 and up).\n */\nconst SHAPES: readonly (readonly number[])[] = [\n [],\n // Square.\n [-0.9, -0.9, 0.9, -0.9, 0.9, 0.9, -0.9, 0.9],\n // Triangle.\n [0, -1.3, 1.2, 0.9, -1.2, 0.9],\n // Diamond.\n [0, -1.3, 1.3, 0, 0, 1.3, -1.3, 0],\n // Triangle, pointing down.\n [-1.2, -0.9, 1.2, -0.9, 0, 1.3],\n // Plus.\n [\n -0.4, -1.2, 0.4, -1.2, 0.4, -0.4, 1.2, -0.4, 1.2, 0.4, 0.4, 0.4, 0.4, 1.2, -0.4, 1.2, -0.4, 0.4,\n -1.2, 0.4, -1.2, -0.4, -0.4, -0.4,\n ],\n // Cross.\n [\n -0.7, -1.2, 0, -0.5, 0.7, -1.2, 1.2, -0.7, 0.5, 0, 1.2, 0.7, 0.7, 1.2, 0, 0.5, -0.7, 1.2, -1.2,\n 0.7, -0.5, 0, -1.2, -0.7,\n ],\n // Star.\n [\n 0, -1.4, 0.32, -0.44, 1.33, -0.43, 0.52, 0.17, 0.82, 1.13, 0, 0.55, -0.82, 1.13, -0.52, 0.17,\n -1.33, -0.43, -0.32, -0.44,\n ],\n]\n\n/** The path of slot `slot`'s marker of radius `r` around (`x`, `y`). */\nexport function markerPath(slot: number, x: number, y: number, r: number): string {\n const shape = SHAPES[slot] ?? []\n if (!shape.length) {\n return `M${round(x - r)},${round(y)}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0Z`\n }\n let d = ''\n for (let i = 0; i < shape.length; i += 2) {\n d += `${i ? 'L' : 'M'}${round(x + (shape[i] as number) * r)},${round(y + (shape[i + 1] as number) * r)}`\n }\n return `${d}Z`\n}\n\n/** The content with the point circles of each series group (`.tc-series-N`) in its slot's shape. */\nfunction reshape(child: ChildInput, slot: number): ChildInput {\n if (Array.isArray(child)) return child.map((c) => reshape(c, slot))\n if (!child || typeof child !== 'object') return child\n const { attrs } = child\n const cls = String(attrs.class ?? '')\n const group = /\\btc-series-(\\d+)\\b/.exec(cls)\n if (\n child.tag === 'circle' &&\n slot >= 0 &&\n /\\btc-point\\b/.test(cls) &&\n !/\\btc-bubble\\b/.test(cls)\n ) {\n const shaped: VNode = {\n tag: 'path',\n attrs: {\n class: `${cls} tc-marker`,\n d: markerPath(slot, +(attrs.cx ?? 0), +(attrs.cy ?? 0), +(attrs.r ?? 0)),\n },\n children: [],\n key: child.key,\n }\n return shaped\n }\n return {\n ...child,\n children: child.children.map((c) => reshape(c, group ? Number(group[1]) - 1 : slot) as Child),\n }\n}\n\n/** The step that gives the points of charts with `shapes` (or `patterns: true`) their shapes. */\nexport const shapesStep: PostStep = (config, content) =>\n (config.shapes ?? config.patterns === true) ? reshape(content, -1) : content\n"],"mappings":";;;;;;;AAgBA,MAAM,SAAyC;CAC7C,CAAC;CAED;EAAC;EAAM;EAAM;EAAK;EAAM;EAAK;EAAK;EAAM;CAAG;CAE3C;EAAC;EAAG;EAAM;EAAK;EAAK;EAAM;CAAG;C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