@tabler/charts 0.1.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.
Files changed (378) hide show
  1. package/README.md +19 -1
  2. package/dist/{annotations-Bp7HwtF5.d.ts → annotations-B02GR_KU.d.ts} +3 -8
  3. package/dist/{annotations-lyt0I3HU.d.cts → annotations-CHafaGd4.d.cts} +3 -8
  4. package/dist/{annotations-BszTTjf9.js → annotations-D0YQ0IoA.js} +6 -7
  5. package/dist/{annotations-BszTTjf9.js.map → annotations-D0YQ0IoA.js.map} +1 -1
  6. package/dist/{annotations-DpETO8dE.cjs → annotations-DdRdeBUB.cjs} +6 -7
  7. package/dist/{annotations-DpETO8dE.cjs.map → annotations-DdRdeBUB.cjs.map} +1 -1
  8. package/dist/annotations.cjs +3 -5
  9. package/dist/annotations.cjs.map +1 -1
  10. package/dist/annotations.d.cts +2 -1
  11. package/dist/annotations.d.ts +2 -1
  12. package/dist/annotations.js +3 -4
  13. package/dist/{arc-a1tRTEw7.js → arc-B3V5IR0w.js} +2 -3
  14. package/dist/{arc-a1tRTEw7.js.map → arc-B3V5IR0w.js.map} +1 -1
  15. package/dist/{arc-BXpLrt9b.cjs → arc-CYhI62kO.cjs} +2 -3
  16. package/dist/{arc-BXpLrt9b.cjs.map → arc-CYhI62kO.cjs.map} +1 -1
  17. package/dist/{area-DQsLERhx.js → area-0-L1bG9B.js} +5 -6
  18. package/dist/{area-DQsLERhx.js.map → area-0-L1bG9B.js.map} +1 -1
  19. package/dist/{area-sHCE3pg5.cjs → area-4eRs3c0K.cjs} +5 -6
  20. package/dist/{area-sHCE3pg5.cjs.map → area-4eRs3c0K.cjs.map} +1 -1
  21. package/dist/{area-CF__HOwL.d.ts → area-CJX9219z.d.cts} +3 -6
  22. package/dist/{area-DIxaAbYZ.d.cts → area-d11XePuw.d.ts} +3 -6
  23. package/dist/area.cjs +1 -1
  24. package/dist/area.d.cts +2 -1
  25. package/dist/area.d.ts +2 -1
  26. package/dist/area.js +1 -2
  27. package/dist/{band-DTcNDAFO.d.ts → band-CNKvdnTC.d.cts} +1 -4
  28. package/dist/{band-DTcNDAFO.d.cts → band-CNKvdnTC.d.ts} +1 -4
  29. package/dist/{bar-DM16NUvV.js → bar-B5n2oq9-.js} +3 -4
  30. package/dist/{bar-DM16NUvV.js.map → bar-B5n2oq9-.js.map} +1 -1
  31. package/dist/{bar-BBM8RhoL.d.ts → bar-BDLR4p9c.d.cts} +4 -7
  32. package/dist/{bar-jZEoao74.js → bar-BNZ3GhIw.js} +20 -20
  33. package/dist/bar-BNZ3GhIw.js.map +1 -0
  34. package/dist/{bar-C-7zR2qp.cjs → bar-Da6dE_nI.cjs} +20 -20
  35. package/dist/bar-Da6dE_nI.cjs.map +1 -0
  36. package/dist/{bar-DGuUN3nc.cjs → bar-LYIF8MEz.cjs} +3 -4
  37. package/dist/{bar-DGuUN3nc.cjs.map → bar-LYIF8MEz.cjs.map} +1 -1
  38. package/dist/{bar-CRKLDg98.d.cts → bar-XwzM6Pb0.d.ts} +4 -7
  39. package/dist/bar.cjs +1 -1
  40. package/dist/bar.d.cts +2 -1
  41. package/dist/bar.d.ts +2 -1
  42. package/dist/bar.js +1 -2
  43. package/dist/{candlestick-DuXwAFID.js → candlestick-BHQkQfxH.js} +6 -7
  44. package/dist/{candlestick-DuXwAFID.js.map → candlestick-BHQkQfxH.js.map} +1 -1
  45. package/dist/{candlestick-B5r1w3kc.cjs → candlestick-CYCQXgky.cjs} +6 -7
  46. package/dist/{candlestick-B5r1w3kc.cjs.map → candlestick-CYCQXgky.cjs.map} +1 -1
  47. package/dist/{candlestick-D_vV0_XZ.d.ts → candlestick-D0xKkdqd.d.ts} +3 -6
  48. package/dist/{candlestick-__pXl_pV.d.cts → candlestick-Dq7qp-F0.d.cts} +3 -6
  49. package/dist/candlestick.cjs +4 -5
  50. package/dist/candlestick.d.cts +1 -1
  51. package/dist/candlestick.d.ts +1 -1
  52. package/dist/candlestick.js +4 -6
  53. package/dist/{cartesian-Cr0AF0nG.js → cartesian-CI2x6N7N.js} +27 -27
  54. package/dist/cartesian-CI2x6N7N.js.map +1 -0
  55. package/dist/{cartesian-BoDfgBCV.cjs → cartesian-DV02PsBe.cjs} +27 -27
  56. package/dist/cartesian-DV02PsBe.cjs.map +1 -0
  57. package/dist/{chart-BF2CK9I_.js → chart-DWn9v6qw.js} +35 -24
  58. package/dist/chart-DWn9v6qw.js.map +1 -0
  59. package/dist/{chart-DyN7bcx8.d.ts → chart-QilhWP8Z.d.ts} +32 -49
  60. package/dist/{chart-CowF_lWY.cjs → chart-e2VqomCI.cjs} +35 -24
  61. package/dist/chart-e2VqomCI.cjs.map +1 -0
  62. package/dist/{chart-D7ooEFnk.d.cts → chart-kqFMEwDo.d.cts} +58 -49
  63. package/dist/{circle-BQMuAfls.cjs → circle-Bwxy5j7B.cjs} +2 -3
  64. package/dist/{circle-BQMuAfls.cjs.map → circle-Bwxy5j7B.cjs.map} +1 -1
  65. package/dist/{circle-Z7YfCoCM.js → circle-YRDaOBpk.js} +2 -3
  66. package/dist/{circle-Z7YfCoCM.js.map → circle-YRDaOBpk.js.map} +1 -1
  67. package/dist/{clean-o1vDEhFV.js → clean-CkoQobGv.js} +3 -4
  68. package/dist/{clean-o1vDEhFV.js.map → clean-CkoQobGv.js.map} +1 -1
  69. package/dist/{clean-Byl6kzf0.cjs → clean-Die2iCNc.cjs} +8 -3
  70. package/dist/{clean-Byl6kzf0.cjs.map → clean-Die2iCNc.cjs.map} +1 -1
  71. package/dist/{core-CegR_j55.js → core-BKRQvPAT.js} +33 -41
  72. package/dist/core-BKRQvPAT.js.map +1 -0
  73. package/dist/{core-RzS9IQO5.cjs → core-DIOC61up.cjs} +33 -41
  74. package/dist/core-DIOC61up.cjs.map +1 -0
  75. package/dist/{core-DcbemzGf.d.ts → core-DRUCk67j.d.ts} +4 -41
  76. package/dist/{core-D1vO1LrC.d.cts → core-PAX5ogLk.d.cts} +22 -67
  77. package/dist/core.cjs +28 -24
  78. package/dist/core.d.cts +23 -21
  79. package/dist/core.d.ts +23 -21
  80. package/dist/core.js +27 -25
  81. package/dist/{dates-CG-FvioW.js → dates-C2RzY3rE.js} +4 -5
  82. package/dist/{dates-CG-FvioW.js.map → dates-C2RzY3rE.js.map} +1 -1
  83. package/dist/{dates-Btm7Zm6W.cjs → dates-DurEr9WT.cjs} +4 -5
  84. package/dist/{dates-Btm7Zm6W.cjs.map → dates-DurEr9WT.cjs.map} +1 -1
  85. package/dist/{decimate-tLhDk1ys.cjs → decimate-BS3x8g-f.cjs} +2 -3
  86. package/dist/{decimate-tLhDk1ys.cjs.map → decimate-BS3x8g-f.cjs.map} +1 -1
  87. package/dist/{decimate-BGg9XgF0.d.ts → decimate-BxxYBJJk.d.cts} +2 -5
  88. package/dist/{decimate-C87cl_Sp.js → decimate-CapfgiDY.js} +2 -3
  89. package/dist/{decimate-C87cl_Sp.js.map → decimate-CapfgiDY.js.map} +1 -1
  90. package/dist/{decimate-CNSpgGa5.d.cts → decimate-Du87fMLG.d.ts} +2 -5
  91. package/dist/decimate.cjs +3 -4
  92. package/dist/decimate.d.cts +1 -1
  93. package/dist/decimate.d.ts +1 -1
  94. package/dist/decimate.js +3 -4
  95. package/dist/{dom-vP3IcMak.js → dom-CuceR8gt.js} +4 -6
  96. package/dist/{dom-vP3IcMak.js.map → dom-CuceR8gt.js.map} +1 -1
  97. package/dist/{dom-CLF868Qs.cjs → dom-D_g13XWY.cjs} +4 -6
  98. package/dist/{dom-CLF868Qs.cjs.map → dom-D_g13XWY.cjs.map} +1 -1
  99. package/dist/{export-chart-9w8t3rjZ.js → export-chart-83UYH48t.js} +3 -4
  100. package/dist/{export-chart-9w8t3rjZ.js.map → export-chart-83UYH48t.js.map} +1 -1
  101. package/dist/{export-chart-BhhYgksr.cjs → export-chart-mYgEfK-L.cjs} +3 -4
  102. package/dist/{export-chart-BhhYgksr.cjs.map → export-chart-mYgEfK-L.cjs.map} +1 -1
  103. package/dist/export.cjs +3 -5
  104. package/dist/export.cjs.map +1 -1
  105. package/dist/export.d.cts +8 -1
  106. package/dist/export.d.ts +8 -1
  107. package/dist/export.js +3 -4
  108. package/dist/{extent-BAMZo0Nq.js → extent-DOV8rs-6.js} +2 -3
  109. package/dist/{extent-BAMZo0Nq.js.map → extent-DOV8rs-6.js.map} +1 -1
  110. package/dist/{extent-DsFWvAHJ.cjs → extent-DuYDcvM9.cjs} +2 -3
  111. package/dist/{extent-DsFWvAHJ.cjs.map → extent-DuYDcvM9.cjs.map} +1 -1
  112. package/dist/{fade-Cs74puQS.cjs → fade-DVTkhrFU.cjs} +4 -6
  113. package/dist/{fade-Cs74puQS.cjs.map → fade-DVTkhrFU.cjs.map} +1 -1
  114. package/dist/{fade-D3NxH5Qg.js → fade-GGxcBdss.js} +4 -6
  115. package/dist/{fade-D3NxH5Qg.js.map → fade-GGxcBdss.js.map} +1 -1
  116. package/dist/{features-wASyHGic.js → features-BMxkqCyS.js} +2 -3
  117. package/dist/{features-wASyHGic.js.map → features-BMxkqCyS.js.map} +1 -1
  118. package/dist/{features-BclHgg2W.cjs → features-DCXEvoya.cjs} +2 -3
  119. package/dist/{features-BclHgg2W.cjs.map → features-DCXEvoya.cjs.map} +1 -1
  120. package/dist/{format-B0yKXBTH.cjs → format-CAE5ruy6.cjs} +2 -3
  121. package/dist/{format-B0yKXBTH.cjs.map → format-CAE5ruy6.cjs.map} +1 -1
  122. package/dist/{format-lStwuc1L.js → format-it1kepFG.js} +2 -3
  123. package/dist/{format-lStwuc1L.js.map → format-it1kepFG.js.map} +1 -1
  124. package/dist/{gauge-zpia05t2.d.ts → gauge-0VJuAHWF.d.ts} +5 -8
  125. package/dist/{gauge-DP_EB2z3.d.cts → gauge-BSist7My.d.cts} +5 -8
  126. package/dist/{gauge-D-FYhuds.cjs → gauge-DXkjXNCD.cjs} +10 -11
  127. package/dist/gauge-DXkjXNCD.cjs.map +1 -0
  128. package/dist/{gauge-Dh423FHh.js → gauge-ts0kqN1-.js} +10 -11
  129. package/dist/{gauge-Dh423FHh.js.map → gauge-ts0kqN1-.js.map} +1 -1
  130. package/dist/gauge.cjs +1 -1
  131. package/dist/gauge.d.cts +2 -1
  132. package/dist/gauge.d.ts +2 -1
  133. package/dist/gauge.js +1 -2
  134. package/dist/{heatmap-DSZ2bVIa.js → heatmap-19BGJTKF.js} +20 -22
  135. package/dist/heatmap-19BGJTKF.js.map +1 -0
  136. package/dist/{heatmap-BectCEeE.d.ts → heatmap-59lmClj9.d.ts} +4 -7
  137. package/dist/{heatmap-BK18EBgJ.cjs → heatmap-CXhlrLTl.cjs} +20 -22
  138. package/dist/heatmap-CXhlrLTl.cjs.map +1 -0
  139. package/dist/{heatmap-CCso6m61.d.cts → heatmap-Dp_oyEe0.d.cts} +4 -7
  140. package/dist/heatmap.cjs +1 -1
  141. package/dist/heatmap.d.cts +2 -1
  142. package/dist/heatmap.d.ts +2 -1
  143. package/dist/heatmap.js +1 -2
  144. package/dist/{hydrate-CzfxLfTv.d.ts → hydrate-BtAZf_5K.d.cts} +2 -5
  145. package/dist/{hydrate-CxwTXDqO.cjs → hydrate-CmN1k8Mo.cjs} +3 -4
  146. package/dist/hydrate-CmN1k8Mo.cjs.map +1 -0
  147. package/dist/{hydrate-DDNIHYv_.js → hydrate-OA6R2_Pn.js} +3 -4
  148. package/dist/{hydrate-DDNIHYv_.js.map → hydrate-OA6R2_Pn.js.map} +1 -1
  149. package/dist/{hydrate-CTTmQy0x.d.cts → hydrate-OjM1pIUG.d.ts} +2 -5
  150. package/dist/hydrate.cjs +3 -4
  151. package/dist/hydrate.cjs.map +1 -1
  152. package/dist/hydrate.d.cts +1 -1
  153. package/dist/hydrate.d.ts +1 -1
  154. package/dist/hydrate.js +3 -4
  155. package/dist/index.cjs +49 -46
  156. package/dist/index.cjs.map +1 -1
  157. package/dist/index.d.cts +24 -27
  158. package/dist/index.d.ts +24 -27
  159. package/dist/index.js +44 -43
  160. package/dist/index.js.map +1 -1
  161. package/dist/{layout-B3hiqVEw.js → layout-DmrrLjwN.js} +9 -4
  162. package/dist/layout-DmrrLjwN.js.map +1 -0
  163. package/dist/{layout-CtMBhNd9.cjs → layout-JY2aR-yE.cjs} +14 -3
  164. package/dist/layout-JY2aR-yE.cjs.map +1 -0
  165. package/dist/{line-B3Ed6u7j.js → line-DO66LtwH.js} +9 -10
  166. package/dist/{line-B3Ed6u7j.js.map → line-DO66LtwH.js.map} +1 -1
  167. package/dist/{line-fQbtP_jL.cjs → line-Dbt6KFRK.cjs} +9 -10
  168. package/dist/{line-fQbtP_jL.cjs.map → line-Dbt6KFRK.cjs.map} +1 -1
  169. package/dist/{line-CN4uZ9ZX.d.ts → line-DtSh7HQU.d.ts} +4 -7
  170. package/dist/{line-W7VD_qs1.d.cts → line-_rNdeKmS.d.cts} +5 -7
  171. package/dist/line.cjs +4 -5
  172. package/dist/line.cjs.map +1 -1
  173. package/dist/line.d.cts +1 -1
  174. package/dist/line.d.ts +1 -1
  175. package/dist/line.js +4 -6
  176. package/dist/{log-CaofN3-n.d.ts → log-CI41TmcU.d.cts} +1 -6
  177. package/dist/{log-CaofN3-n.d.cts → log-CI41TmcU.d.ts} +1 -6
  178. package/dist/{log-axis-83rSpvL5.cjs → log-axis-DdRNyAq8.cjs} +6 -8
  179. package/dist/{log-axis-83rSpvL5.cjs.map → log-axis-DdRNyAq8.cjs.map} +1 -1
  180. package/dist/{log-axis-B_uvvOFc.js → log-axis-DhthtHFk.js} +6 -8
  181. package/dist/{log-axis-B_uvvOFc.js.map → log-axis-DhthtHFk.js.map} +1 -1
  182. package/dist/log.cjs +3 -5
  183. package/dist/log.cjs.map +1 -1
  184. package/dist/log.d.cts +1 -1
  185. package/dist/log.d.ts +1 -1
  186. package/dist/log.js +3 -4
  187. package/dist/{morph-CqYDu1bY.cjs → morph-9_LJL0ra.cjs} +4 -5
  188. package/dist/morph-9_LJL0ra.cjs.map +1 -0
  189. package/dist/{morph-BMxz3X2b.d.ts → morph-Dh7gJkV4.d.cts} +1 -4
  190. package/dist/{morph-BMxz3X2b.d.cts → morph-Dh7gJkV4.d.ts} +1 -4
  191. package/dist/{morph-Bgg-24l8.js → morph-DnRxuwR-.js} +4 -5
  192. package/dist/{morph-Bgg-24l8.js.map → morph-DnRxuwR-.js.map} +1 -1
  193. package/dist/morph.cjs +3 -4
  194. package/dist/morph.cjs.map +1 -1
  195. package/dist/morph.d.cts +1 -1
  196. package/dist/morph.d.ts +1 -1
  197. package/dist/morph.js +3 -4
  198. package/dist/{named-BWWb5LQJ.cjs → named-BBASc8dW.cjs} +2 -3
  199. package/dist/{named-BWWb5LQJ.cjs.map → named-BBASc8dW.cjs.map} +1 -1
  200. package/dist/{named-DE15TOgh.js → named-BOiBah6I.js} +2 -3
  201. package/dist/{named-DE15TOgh.js.map → named-BOiBah6I.js.map} +1 -1
  202. package/dist/others-DWdK7vKp.cjs +60 -0
  203. package/dist/others-DWdK7vKp.cjs.map +1 -0
  204. package/dist/others-J7NCAMA0.js +49 -0
  205. package/dist/others-J7NCAMA0.js.map +1 -0
  206. package/dist/{parliament-1Zv2Xh0D.d.ts → parliament-CLCI7tUO.d.ts} +5 -8
  207. package/dist/{parliament-DdrLVZwt.d.cts → parliament-CgsVnWEe.d.cts} +5 -8
  208. package/dist/{parliament-Dw0sOERi.js → parliament-Cru4IcuM.js} +8 -9
  209. package/dist/parliament-Cru4IcuM.js.map +1 -0
  210. package/dist/{parliament-CpWnoEvG.cjs → parliament-x5hcFaQ3.cjs} +8 -9
  211. package/dist/parliament-x5hcFaQ3.cjs.map +1 -0
  212. package/dist/parliament.cjs +1 -1
  213. package/dist/parliament.d.cts +2 -1
  214. package/dist/parliament.d.ts +2 -1
  215. package/dist/parliament.js +1 -2
  216. package/dist/{path-CwB28da0.d.ts → path-YeUiOfG8.d.cts} +1 -4
  217. package/dist/{path-CwB28da0.d.cts → path-YeUiOfG8.d.ts} +1 -4
  218. package/dist/{patterns-DtgcnA8o.js → patterns-CufKZYhm.js} +4 -5
  219. package/dist/{patterns-DtgcnA8o.js.map → patterns-CufKZYhm.js.map} +1 -1
  220. package/dist/{patterns-LfcQAWCy.cjs → patterns-D3-wQagb.cjs} +4 -5
  221. package/dist/{patterns-LfcQAWCy.cjs.map → patterns-D3-wQagb.cjs.map} +1 -1
  222. package/dist/patterns.cjs +3 -5
  223. package/dist/patterns.cjs.map +1 -1
  224. package/dist/patterns.d.cts +5 -1
  225. package/dist/patterns.d.ts +5 -1
  226. package/dist/patterns.js +3 -4
  227. package/dist/percentage-bar-B6tNOqNn.js +157 -0
  228. package/dist/percentage-bar-B6tNOqNn.js.map +1 -0
  229. package/dist/percentage-bar-nhTeakD_.d.ts +62 -0
  230. package/dist/percentage-bar-tepMr7Hd.d.cts +62 -0
  231. package/dist/percentage-bar-ybNS3goo.cjs +162 -0
  232. package/dist/percentage-bar-ybNS3goo.cjs.map +1 -0
  233. package/dist/percentage-bar.cjs +3 -0
  234. package/dist/percentage-bar.d.cts +3 -0
  235. package/dist/percentage-bar.d.ts +3 -0
  236. package/dist/percentage-bar.js +1 -0
  237. package/dist/{pie-5z1fDdKO.d.ts → pie-BXg2gNpb.d.cts} +14 -8
  238. package/dist/{pie-BxTZt6Go.cjs → pie-BpjvSPnz.cjs} +13 -17
  239. package/dist/pie-BpjvSPnz.cjs.map +1 -0
  240. package/dist/{pie-BF9yI5mE.d.cts → pie-CFptILSm.d.ts} +14 -8
  241. package/dist/{pie-DzUXDTcn.js → pie-CVsc-6qD.js} +13 -17
  242. package/dist/pie-CVsc-6qD.js.map +1 -0
  243. package/dist/pie.cjs +1 -1
  244. package/dist/pie.d.cts +2 -1
  245. package/dist/pie.d.ts +2 -1
  246. package/dist/pie.js +1 -2
  247. package/dist/{point-shapes-CGl4dugc.cjs → point-shapes--_gmdTyK.cjs} +3 -4
  248. package/dist/{point-shapes-CGl4dugc.cjs.map → point-shapes--_gmdTyK.cjs.map} +1 -1
  249. package/dist/{point-shapes-DI84NNpI.js → point-shapes-DD2Ektzm.js} +3 -4
  250. package/dist/{point-shapes-DI84NNpI.js.map → point-shapes-DD2Ektzm.js.map} +1 -1
  251. package/dist/point-shapes.cjs +3 -4
  252. package/dist/point-shapes.d.cts +5 -1
  253. package/dist/point-shapes.d.ts +5 -1
  254. package/dist/point-shapes.js +3 -4
  255. package/dist/{radar-1-EryihA.d.ts → radar-BC9Skgpj.d.ts} +4 -7
  256. package/dist/{radar-CYPab_I4.js → radar-BR-mumDd.js} +7 -8
  257. package/dist/{radar-CYPab_I4.js.map → radar-BR-mumDd.js.map} +1 -1
  258. package/dist/{radar-DBW4O0Vt.d.cts → radar-D1-lItDy.d.cts} +4 -7
  259. package/dist/{radar-CoGUNNSb.cjs → radar-HPDrIdzc.cjs} +7 -8
  260. package/dist/{radar-CoGUNNSb.cjs.map → radar-HPDrIdzc.cjs.map} +1 -1
  261. package/dist/radar.cjs +1 -1
  262. package/dist/radar.d.cts +2 -1
  263. package/dist/radar.d.ts +2 -1
  264. package/dist/radar.js +1 -2
  265. package/dist/rect-D6VhynBM.cjs +16 -0
  266. package/dist/rect-D6VhynBM.cjs.map +1 -0
  267. package/dist/rect-DSVmUZrD.js +11 -0
  268. package/dist/rect-DSVmUZrD.js.map +1 -0
  269. package/dist/{sankey-B4PNKusJ.js → sankey-D6JeZfK5.js} +33 -29
  270. package/dist/sankey-D6JeZfK5.js.map +1 -0
  271. package/dist/{sankey-OV_WoPrl.d.ts → sankey-D_v7KxnJ.d.ts} +4 -7
  272. package/dist/{sankey-DuGI3Qc5.d.cts → sankey-Dk7jUt8x.d.cts} +4 -7
  273. package/dist/{sankey-Bacx4fVe.cjs → sankey-fCoo1cpz.cjs} +33 -29
  274. package/dist/sankey-fCoo1cpz.cjs.map +1 -0
  275. package/dist/sankey.cjs +1 -1
  276. package/dist/sankey.d.cts +2 -1
  277. package/dist/sankey.d.ts +2 -1
  278. package/dist/sankey.js +1 -2
  279. package/dist/{scatter-kgtgR318.js → scatter-C0TWjFpW.js} +21 -18
  280. package/dist/scatter-C0TWjFpW.js.map +1 -0
  281. package/dist/{scatter-BqzgJqdX.d.ts → scatter-CXEsioOJ.d.ts} +8 -9
  282. package/dist/{scatter-DgMN9zRy.cjs → scatter-DVqB_fP9.cjs} +21 -18
  283. package/dist/scatter-DVqB_fP9.cjs.map +1 -0
  284. package/dist/{scatter-DbxLyZX0.d.cts → scatter-DZeEIfyo.d.cts} +8 -9
  285. package/dist/scatter.cjs +1 -1
  286. package/dist/scatter.d.cts +2 -1
  287. package/dist/scatter.d.ts +2 -1
  288. package/dist/scatter.js +1 -2
  289. package/dist/{sparkline-BS9-hltA.cjs → sparkline-B39NA0Mi.cjs} +14 -13
  290. package/dist/sparkline-B39NA0Mi.cjs.map +1 -0
  291. package/dist/{sparkline-CWlJDKyh.d.cts → sparkline-DAP6jtzw.d.cts} +5 -8
  292. package/dist/{sparkline-BQzt27Fr.js → sparkline-XO_TqCNP.js} +14 -13
  293. package/dist/sparkline-XO_TqCNP.js.map +1 -0
  294. package/dist/{sparkline-BfyO_oNM.d.ts → sparkline-cbvRkWqS.d.ts} +5 -8
  295. package/dist/sparkline.cjs +1 -1
  296. package/dist/sparkline.d.cts +2 -1
  297. package/dist/sparkline.d.ts +2 -1
  298. package/dist/sparkline.js +1 -2
  299. package/dist/{stack-DRbwTeF3.js → stack-2H2Gfs1Q.js} +3 -4
  300. package/dist/{stack-DRbwTeF3.js.map → stack-2H2Gfs1Q.js.map} +1 -1
  301. package/dist/{stack-DVhJWaki.cjs → stack-BgPzoQmv.cjs} +3 -4
  302. package/dist/{stack-DVhJWaki.cjs.map → stack-BgPzoQmv.cjs.map} +1 -1
  303. package/dist/{stack-CpR6RGKd.d.ts → stack-DR0eQTsB.d.ts} +1 -4
  304. package/dist/{stack-CpR6RGKd.d.cts → stack-Dagxq7l2.d.cts} +2 -4
  305. package/dist/style.css +1 -1
  306. package/dist/{sweep-CbfR7--d.js → sweep-BpRPlhs6.js} +5 -6
  307. package/dist/{sweep-CbfR7--d.js.map → sweep-BpRPlhs6.js.map} +1 -1
  308. package/dist/{sweep-DaTEDDuC.cjs → sweep-Dnp6LDBz.cjs} +5 -6
  309. package/dist/sweep-Dnp6LDBz.cjs.map +1 -0
  310. package/dist/{time-CNVnt-B2.d.cts → time-B4oxWHQI.d.cts} +2 -7
  311. package/dist/{time-CHjiY9Q4.d.ts → time-DRIDgv2a.d.ts} +2 -7
  312. package/dist/{time-axis-VSX34_Tb.cjs → time-axis-BjZ1bYTK.cjs} +9 -10
  313. package/dist/{time-axis-VSX34_Tb.cjs.map → time-axis-BjZ1bYTK.cjs.map} +1 -1
  314. package/dist/{time-axis-Bc9eHX1r.js → time-axis-FLONo54E.js} +9 -10
  315. package/dist/{time-axis-Bc9eHX1r.js.map → time-axis-FLONo54E.js.map} +1 -1
  316. package/dist/time.cjs +4 -6
  317. package/dist/time.cjs.map +1 -1
  318. package/dist/time.d.cts +1 -1
  319. package/dist/time.d.ts +1 -1
  320. package/dist/time.js +4 -5
  321. package/dist/treemap-BAkhmVQc.d.cts +55 -0
  322. package/dist/treemap-BNpxFBao.d.ts +55 -0
  323. package/dist/treemap-BWpEUlDh.cjs +303 -0
  324. package/dist/treemap-BWpEUlDh.cjs.map +1 -0
  325. package/dist/treemap-CQdavQ9u.js +298 -0
  326. package/dist/treemap-CQdavQ9u.js.map +1 -0
  327. package/dist/treemap.cjs +3 -0
  328. package/dist/treemap.d.cts +3 -0
  329. package/dist/treemap.d.ts +3 -0
  330. package/dist/treemap.js +1 -0
  331. package/dist/{tween-BCYd0RTY.js → tween-BdQqUmmv.js} +2 -3
  332. package/dist/{tween-BCYd0RTY.js.map → tween-BdQqUmmv.js.map} +1 -1
  333. package/dist/{tween-CIGBlryn.cjs → tween-c3aOmfKE.cjs} +2 -3
  334. package/dist/{tween-CIGBlryn.cjs.map → tween-c3aOmfKE.cjs.map} +1 -1
  335. package/dist/{value-labels-IZIQPhfk.js → value-labels-BBuSi4i0.js} +7 -7
  336. package/dist/value-labels-BBuSi4i0.js.map +1 -0
  337. package/dist/{value-labels-B0WJoJ7x.cjs → value-labels-BV9keAuL.cjs} +7 -7
  338. package/dist/value-labels-BV9keAuL.cjs.map +1 -0
  339. package/dist/value-labels.cjs +3 -5
  340. package/dist/value-labels.cjs.map +1 -1
  341. package/dist/value-labels.d.cts +5 -1
  342. package/dist/value-labels.d.ts +5 -1
  343. package/dist/value-labels.js +3 -4
  344. package/dist/{vnode-CkQ27Cxe.cjs → vnode-ClAiw28x.cjs} +2 -3
  345. package/dist/{vnode-CkQ27Cxe.cjs.map → vnode-ClAiw28x.cjs.map} +1 -1
  346. package/dist/{vnode-BUflsBsa.d.ts → vnode-Du2cC8Fm.d.cts} +1 -4
  347. package/dist/{vnode-BUflsBsa.d.cts → vnode-Du2cC8Fm.d.ts} +1 -4
  348. package/dist/{vnode-tCWItoUH.js → vnode-_EMUqysL.js} +2 -3
  349. package/dist/{vnode-tCWItoUH.js.map → vnode-_EMUqysL.js.map} +1 -1
  350. package/package.json +21 -1
  351. package/dist/bar-C-7zR2qp.cjs.map +0 -1
  352. package/dist/bar-jZEoao74.js.map +0 -1
  353. package/dist/cartesian-BoDfgBCV.cjs.map +0 -1
  354. package/dist/cartesian-Cr0AF0nG.js.map +0 -1
  355. package/dist/chart-BF2CK9I_.js.map +0 -1
  356. package/dist/chart-CowF_lWY.cjs.map +0 -1
  357. package/dist/core-CegR_j55.js.map +0 -1
  358. package/dist/core-RzS9IQO5.cjs.map +0 -1
  359. package/dist/gauge-D-FYhuds.cjs.map +0 -1
  360. package/dist/heatmap-BK18EBgJ.cjs.map +0 -1
  361. package/dist/heatmap-DSZ2bVIa.js.map +0 -1
  362. package/dist/hydrate-CxwTXDqO.cjs.map +0 -1
  363. package/dist/layout-B3hiqVEw.js.map +0 -1
  364. package/dist/layout-CtMBhNd9.cjs.map +0 -1
  365. package/dist/morph-CqYDu1bY.cjs.map +0 -1
  366. package/dist/parliament-CpWnoEvG.cjs.map +0 -1
  367. package/dist/parliament-Dw0sOERi.js.map +0 -1
  368. package/dist/pie-BxTZt6Go.cjs.map +0 -1
  369. package/dist/pie-DzUXDTcn.js.map +0 -1
  370. package/dist/sankey-B4PNKusJ.js.map +0 -1
  371. package/dist/sankey-Bacx4fVe.cjs.map +0 -1
  372. package/dist/scatter-DgMN9zRy.cjs.map +0 -1
  373. package/dist/scatter-kgtgR318.js.map +0 -1
  374. package/dist/sparkline-BQzt27Fr.js.map +0 -1
  375. package/dist/sparkline-BS9-hltA.cjs.map +0 -1
  376. package/dist/sweep-DaTEDDuC.cjs.map +0 -1
  377. package/dist/value-labels-B0WJoJ7x.cjs.map +0 -1
  378. package/dist/value-labels-IZIQPhfk.js.map +0 -1
@@ -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,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;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBAAuB;CAClF,IAAI,CAAC,KAAK,MAAM,IAAI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ACpC,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;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBAAuB;CAClF,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,8CAA8C;CACxE,OAAO;AACT;;AAGA,SAAS,YAAY,OAAgD;CACnE,MAAM,QAAQ,MAAM;CACpB,IAAI,CAAC,SAAS,UAAU,QAAQ,OAAO,KAAA;CAEvC,MAAM,MAAM,MAAM,QAAQ,OAAO,EAAE;CACnC,IAAI,IAAI,WAAW,WAAW,GAAG,OAAO;CACxC,MAAM,CAAC,KAAK,GAAG,KAAK,MAA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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-BhhYgksr.cjs.map
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,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;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBA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B,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;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;CAAW;CAAW;AAAU,CAAC;AAE3F,SAAS,OAAO,QAAqC;CACnD,MAAM,KAAK,aAAa,UAAU,EAAE,kBAAkB,WAAW,OAAO,UAAU;CAClF,MAAM,MAAM,GAAG,cAAc,QAAQ,KAAK,GAAG,cAAc,uBAAuB;CAClF,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,8CAA8C;CACxE,OAAO;AACT;;AAGA,SAAS,YAAY,OAAgD;CACnE,MAAM,QAAQ,MAAM;CACpB,IAAI,CAAC,SAAS,UAAU,QAAQ,OAAO,KAAA;CAEvC,MAAM,MAAM,MAAM,QAAQ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,IAAI,GAAG,GAAI;AACvD"}
package/dist/export.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_features = require("./features-BclHgg2W.cjs");
3
- const require_export_chart = require("./export-chart-BhhYgksr.cjs");
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
- require_features.register({ export: require_export_chart.downloadChart });
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;
@@ -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":";;;;;;;;;;;AAWAA,iBAAAA,SAAS,EAAE,QAAQC,qBAAAA,cAAc,CAAC"}
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
- import { B as downloadChart, H as exportSVG, I as DownloadOptions, L as ExportOptions, R as ExportTarget, V as exportImage, z as ImageOptions } from "./chart-D7ooEFnk.cjs";
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
- import { B as downloadChart, H as exportSVG, I as DownloadOptions, L as ExportOptions, R as ExportTarget, V as exportImage, z as ImageOptions } from "./chart-DyN7bcx8.js";
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 { i as register } from "./features-wASyHGic.js";
2
- import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-chart-9w8t3rjZ.js";
3
- //#region src/export.ts
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
- //#region src/scales/extent.ts
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-BAMZo0Nq.js.map
18
+ //# sourceMappingURL=extent-DOV8rs-6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extent-BAMZo0Nq.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"}
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"}
@@ -1,4 +1,4 @@
1
- //#region src/scales/extent.ts
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
  Object.defineProperty(exports, "extent", {
18
17
  enumerable: true,
19
18
  get: function() {
@@ -21,4 +20,4 @@ Object.defineProperty(exports, "extent", {
21
20
  }
22
21
  });
23
22
 
24
- //# sourceMappingURL=extent-DsFWvAHJ.cjs.map
23
+ //# sourceMappingURL=extent-DuYDcvM9.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extent-DsFWvAHJ.cjs","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"}
1
+ {"version":3,"file":"extent-DuYDcvM9.cjs","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"}
@@ -1,5 +1,5 @@
1
- const require_vnode = require("./vnode-CkQ27Cxe.cjs");
2
- //#region src/shapes/path.ts
1
+ const require_vnode = require("./vnode-ClAiw28x.cjs");
2
+ // src/shapes/path.ts
3
3
  /** Accumulates SVG path commands with rounded coordinates. */
4
4
  var PathBuilder = class {
5
5
  d = "";
@@ -165,8 +165,7 @@ function areaPath(points, baseline, options = {}) {
165
165
  }
166
166
  return path.d;
167
167
  }
168
- //#endregion
169
- //#region src/components/fade.ts
168
+ // src/components/fade.ts
170
169
  /**
171
170
  * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their
172
171
  * series color from CSS; the mask only fades them, with stop opacities read
@@ -194,7 +193,6 @@ function fadeMask(id) {
194
193
  fill: `url(#${id}-gradient)`
195
194
  }));
196
195
  }
197
- //#endregion
198
196
  Object.defineProperty(exports, "areaPath", {
199
197
  enumerable: true,
200
198
  get: function() {
@@ -214,4 +212,4 @@ Object.defineProperty(exports, "linePath", {
214
212
  }
215
213
  });
216
214
 
217
- //# sourceMappingURL=fade-Cs74puQS.cjs.map
215
+ //# sourceMappingURL=fade-DVTkhrFU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fade-Cs74puQS.cjs","names":["h"],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACJ;CAEA,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,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GAAG,KAAK,MAAM;CAE9B,OAAO,KAAK;AACd;;;;;;AAOA,SAAgB,SACd,QACA,UACA,UAAuB,CAAC,GAChB;CACR,MAAM,EAAE,QAAQ,UAAU,YAAY,MAAM;CAC5C,MAAM,OAAO,IAAI,YAAY,SAAS;CACtC,MAAM,UAAU,MACd,OAAO,aAAa,WAAW,WAAY,SAAS,MAAM;CAE5D,KAAK,MAAM,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAOA,cAAAA,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5CA,cAAAA,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnDA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/CA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACAA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
1
+ {"version":3,"file":"fade-DVTkhrFU.cjs","names":["h"],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACK;CAET,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,QAAQ,IAAY,IAAY,IAAY,IAAY,GAAW,GAAiB;EAClF,KA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AS;CACtC,MAAM,UAAU,MACd,OAAO,aAAa,WAAW,WAAY,SAAS,MAAM;CAE5D,KAAK,MAAM,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAOA,cAAAA,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5CA,cAAAA,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnDA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/CA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACAA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
@@ -1,5 +1,5 @@
1
- import { t as h } from "./vnode-tCWItoUH.js";
2
- //#region src/shapes/path.ts
1
+ import { t as h } from "./vnode-_EMUqysL.js";
2
+ // src/shapes/path.ts
3
3
  /** Accumulates SVG path commands with rounded coordinates. */
4
4
  var PathBuilder = class {
5
5
  d = "";
@@ -165,8 +165,7 @@ function areaPath(points, baseline, options = {}) {
165
165
  }
166
166
  return path.d;
167
167
  }
168
- //#endregion
169
- //#region src/components/fade.ts
168
+ // src/components/fade.ts
170
169
  /**
171
170
  * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their
172
171
  * series color from CSS; the mask only fades them, with stop opacities read
@@ -194,7 +193,6 @@ function fadeMask(id) {
194
193
  fill: `url(#${id}-gradient)`
195
194
  }));
196
195
  }
197
- //#endregion
198
196
  export { areaPath as n, linePath as r, fadeMask as t };
199
197
 
200
- //# sourceMappingURL=fade-D3NxH5Qg.js.map
198
+ //# sourceMappingURL=fade-GGxcBdss.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fade-D3NxH5Qg.js","names":[],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACJ;CAEA,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;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G,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
1
+ {"version":3,"file":"fade-GGxcBdss.js","names":[],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACK;CAET,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAA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Z,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IAEM,MAAM,GAAG,KAAK,MAAM;CAE9B,OAAO,KAAK;AACd;;;;;;AAOA,SAAgB,SACd,QACA,UACA,UAAuB,CAAC,GAChB;CACR,MAAM,EAAE,QAAQ,UAAU,YAAY,MAAM;CAC5C,MAAM,OAAO,IAAI,YAAY,SAAS;CACtC,MAAM,UAAU,MACd,OAAO,aAAa,WAAW,WAAY,SAAS,MAAM;CAE5D,KAAK,MAAM,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAO,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5C,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnD,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/C,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
@@ -1,4 +1,4 @@
1
- //#region src/features.ts
1
+ // src/features.ts
2
2
  const features = {};
3
3
  /** Register optional features (idempotent). */
4
4
  function register(added) {
@@ -19,7 +19,6 @@ function feature(name) {
19
19
  if (!found) throw new Error(`@tabler/charts: Import "@tabler/charts/${name === "dates" ? "time" : name}" for ${name}.`);
20
20
  return found;
21
21
  }
22
- //#endregion
23
22
  export { register as i, feature as n, features as r, addPost as t };
24
23
 
25
- //# sourceMappingURL=features-wASyHGic.js.map
24
+ //# sourceMappingURL=features-BMxkqCyS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features-wASyHGic.js","names":[],"sources":["../src/features.ts"],"sourcesContent":["import type { ChartConfig, RenderContext } from './chart.ts'\nimport type { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport type { dateLabels } from './charts/dates.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"features-BMxkqCyS.js","names":[],"sources":["../src/features.ts"],"sourcesContent":["import type { ChartConfig, RenderContext } from './chart.ts'\nimport type { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport type { dateLabels } from './charts/dates.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- //#region src/features.ts
1
+ // src/features.ts
2
2
  const features = {};
3
3
  /** Register optional features (idempotent). */
4
4
  function register(added) {
@@ -19,7 +19,6 @@ function feature(name) {
19
19
  if (!found) throw new Error(`@tabler/charts: Import "@tabler/charts/${name === "dates" ? "time" : name}" for ${name}.`);
20
20
  return found;
21
21
  }
22
- //#endregion
23
22
  Object.defineProperty(exports, "addPost", {
24
23
  enumerable: true,
25
24
  get: function() {
@@ -45,4 +44,4 @@ Object.defineProperty(exports, "register", {
45
44
  }
46
45
  });
47
46
 
48
- //# sourceMappingURL=features-BclHgg2W.cjs.map
47
+ //# sourceMappingURL=features-DCXEvoya.cjs.map