@tabler/charts 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/README.md +94 -16
  2. package/dist/{annotations-CpCWA29b.cjs → annotations--m-HzMBM.cjs} +86 -10
  3. package/dist/annotations--m-HzMBM.cjs.map +1 -0
  4. package/dist/{annotations-B02GR_KU.d.ts → annotations-CCDUC1lW.d.ts} +16 -30
  5. package/dist/{annotations-CHafaGd4.d.cts → annotations-CqZM1z9R.d.cts} +16 -30
  6. package/dist/{annotations-BQ8l-qHs.js → annotations-DGITy6th.js} +86 -10
  7. package/dist/annotations-DGITy6th.js.map +1 -0
  8. package/dist/annotations.cjs +1 -1
  9. package/dist/annotations.d.cts +1 -1
  10. package/dist/annotations.d.ts +1 -1
  11. package/dist/annotations.js +1 -1
  12. package/dist/{area-WdtfqvhX.js → area-BN0uE9R0.js} +4 -3
  13. package/dist/area-BN0uE9R0.js.map +1 -0
  14. package/dist/{area-h_FvieFb.d.cts → area-D6LNLk3r.d.cts} +2 -2
  15. package/dist/{area-DEFQm_SQ.d.ts → area-DEFL-Yun.d.ts} +2 -2
  16. package/dist/{area-DYdQ_sMV.cjs → area-D_N8b4Ng.cjs} +4 -3
  17. package/dist/area-D_N8b4Ng.cjs.map +1 -0
  18. package/dist/area.cjs +1 -1
  19. package/dist/area.d.cts +1 -1
  20. package/dist/area.d.ts +1 -1
  21. package/dist/area.js +1 -1
  22. package/dist/{axis-YfAerNBA.cjs → axis-BzBkkC5X.cjs} +12 -7
  23. package/dist/axis-BzBkkC5X.cjs.map +1 -0
  24. package/dist/{axis-MMaVoSWB.js → axis-C5obgdJt.js} +12 -7
  25. package/dist/axis-C5obgdJt.js.map +1 -0
  26. package/dist/{bar-CVkOJ7WA.cjs → bar-BrmfXugT.cjs} +5 -4
  27. package/dist/bar-BrmfXugT.cjs.map +1 -0
  28. package/dist/{bar-D9B_arKf.d.ts → bar-Bs_rPqgR.d.ts} +1 -1
  29. package/dist/{bar-DZCQ-kyf.d.cts → bar-CEt8YRxf.d.cts} +2 -2
  30. package/dist/{bar-BOcRcArc.js → bar-D_KKd2fL.js} +5 -4
  31. package/dist/bar-D_KKd2fL.js.map +1 -0
  32. package/dist/bar.cjs +1 -1
  33. package/dist/bar.d.cts +1 -1
  34. package/dist/bar.d.ts +1 -1
  35. package/dist/bar.js +1 -1
  36. package/dist/{calendar-BSvO8nRb.d.cts → calendar-B7843sQu.d.cts} +2 -2
  37. package/dist/{calendar-DAFXjV99.cjs → calendar-BG_q_NC_.cjs} +2 -2
  38. package/dist/{calendar-DAFXjV99.cjs.map → calendar-BG_q_NC_.cjs.map} +1 -1
  39. package/dist/{calendar-BXgIX5H1.js → calendar-CF3gfDQk.js} +2 -2
  40. package/dist/{calendar-BXgIX5H1.js.map → calendar-CF3gfDQk.js.map} +1 -1
  41. package/dist/{calendar-Bq3vFzPl.d.ts → calendar-D10_ki1S.d.ts} +2 -2
  42. package/dist/calendar.cjs +1 -1
  43. package/dist/calendar.d.cts +1 -1
  44. package/dist/calendar.d.ts +1 -1
  45. package/dist/calendar.js +1 -1
  46. package/dist/{candlestick-BtT9glp9.js → candlestick-B1onjo1o.js} +3 -2
  47. package/dist/candlestick-B1onjo1o.js.map +1 -0
  48. package/dist/{candlestick-BcomxeVG.d.cts → candlestick-B7YXUVVh.d.cts} +4 -3
  49. package/dist/{candlestick-CSmRuZ4v.cjs → candlestick-BwrFKak_.cjs} +3 -2
  50. package/dist/candlestick-BwrFKak_.cjs.map +1 -0
  51. package/dist/{candlestick-B3WcLzph.d.ts → candlestick-XpqJvarq.d.ts} +4 -3
  52. package/dist/candlestick.cjs +2 -2
  53. package/dist/candlestick.d.cts +1 -1
  54. package/dist/candlestick.d.ts +1 -1
  55. package/dist/candlestick.js +2 -2
  56. package/dist/{cartesian-DRSXHxWe.cjs → cartesian-B9CrasFJ.cjs} +49 -7
  57. package/dist/cartesian-B9CrasFJ.cjs.map +1 -0
  58. package/dist/{cartesian-BrPqb5Qn.js → cartesian-COglz544.js} +45 -9
  59. package/dist/cartesian-COglz544.js.map +1 -0
  60. package/dist/{chart-B6TTY4Kr.js → chart-B97FBRCd.js} +22 -12
  61. package/dist/chart-B97FBRCd.js.map +1 -0
  62. package/dist/{chart-CYrrUCi3.d.ts → chart-CE9EVbfV.d.ts} +240 -62
  63. package/dist/{chart-CbPzP5Dp.d.cts → chart-Dz4geQZy.d.cts} +240 -62
  64. package/dist/{chart-D_lyOy-M.cjs → chart-GUmmjJ7S.cjs} +27 -11
  65. package/dist/chart-GUmmjJ7S.cjs.map +1 -0
  66. package/dist/{core-CQ0FaJ4G.js → core-7fgM3su0.js} +84 -16
  67. package/dist/core-7fgM3su0.js.map +1 -0
  68. package/dist/{core-C3qEppSm.d.ts → core-BUQzLsRJ.d.ts} +21 -6
  69. package/dist/{core-D2PSked3.cjs → core-BZTrsPxc.cjs} +93 -13
  70. package/dist/core-BZTrsPxc.cjs.map +1 -0
  71. package/dist/{core-9BnLEW4K.d.cts → core-Ck5uHcW8.d.cts} +40 -23
  72. package/dist/core.cjs +20 -16
  73. package/dist/core.d.cts +23 -21
  74. package/dist/core.d.ts +23 -21
  75. package/dist/core.js +18 -17
  76. package/dist/{dates-DerXTb1J.cjs → dates-0YNY49KQ.cjs} +2 -2
  77. package/dist/{dates-DerXTb1J.cjs.map → dates-0YNY49KQ.cjs.map} +1 -1
  78. package/dist/{dates-DLe2Ww64.js → dates-CKDRgpin.js} +2 -2
  79. package/dist/{dates-DLe2Ww64.js.map → dates-CKDRgpin.js.map} +1 -1
  80. package/dist/end-labels-B3oRvjxw.js +114 -0
  81. package/dist/end-labels-B3oRvjxw.js.map +1 -0
  82. package/dist/end-labels-CS-fnpp-.cjs +119 -0
  83. package/dist/end-labels-CS-fnpp-.cjs.map +1 -0
  84. package/dist/end-labels.cjs +11 -0
  85. package/dist/end-labels.cjs.map +1 -0
  86. package/dist/end-labels.d.cts +6 -0
  87. package/dist/end-labels.d.ts +6 -0
  88. package/dist/end-labels.js +11 -0
  89. package/dist/end-labels.js.map +1 -0
  90. package/dist/{export-chart-DoeiAyR2.js → export-chart-BOH_nfcH.js} +76 -4
  91. package/dist/export-chart-BOH_nfcH.js.map +1 -0
  92. package/dist/{export-chart-CPtXmZvi.cjs → export-chart-Be4T9J3m.cjs} +81 -3
  93. package/dist/export-chart-Be4T9J3m.cjs.map +1 -0
  94. package/dist/export.cjs +4 -2
  95. package/dist/export.cjs.map +1 -1
  96. package/dist/export.d.cts +4 -3
  97. package/dist/export.d.ts +4 -3
  98. package/dist/export.js +4 -3
  99. package/dist/export.js.map +1 -1
  100. package/dist/features-B55rwpQC.js.map +1 -1
  101. package/dist/features-DEDP5CEQ.cjs.map +1 -1
  102. package/dist/{funnel-CarOh8w_.d.cts → funnel-B9ridzNx.d.cts} +2 -2
  103. package/dist/{funnel-BdcfUkb5.d.ts → funnel-FogM8flk.d.ts} +2 -2
  104. package/dist/funnel.d.cts +1 -1
  105. package/dist/funnel.d.ts +1 -1
  106. package/dist/{gauge-Ds9k1UV2.d.cts → gauge-BScJ7U6O.d.cts} +2 -2
  107. package/dist/{gauge-Zy25jfps.d.ts → gauge-D78oq1Lx.d.ts} +2 -2
  108. package/dist/gauge.d.cts +1 -1
  109. package/dist/gauge.d.ts +1 -1
  110. package/dist/heat-Bsqq4zw9.js +38 -0
  111. package/dist/heat-Bsqq4zw9.js.map +1 -0
  112. package/dist/heat-DYsivvDq.cjs +49 -0
  113. package/dist/heat-DYsivvDq.cjs.map +1 -0
  114. package/dist/{heatmap-Dcc_bsoQ.cjs → heatmap-Dyzrd4Fd.cjs} +3 -3
  115. package/dist/{heatmap-Dcc_bsoQ.cjs.map → heatmap-Dyzrd4Fd.cjs.map} +1 -1
  116. package/dist/{heatmap-C1v8bwpq.js → heatmap-J7fxG7MM.js} +3 -3
  117. package/dist/{heatmap-C1v8bwpq.js.map → heatmap-J7fxG7MM.js.map} +1 -1
  118. package/dist/{heatmap-CJ-0dfhJ.d.cts → heatmap-Jvwo7iFW.d.cts} +2 -2
  119. package/dist/{heatmap-Jp5sHRTo.d.ts → heatmap-mFCnP6aB.d.ts} +2 -2
  120. package/dist/heatmap.cjs +1 -1
  121. package/dist/heatmap.d.cts +1 -1
  122. package/dist/heatmap.d.ts +1 -1
  123. package/dist/heatmap.js +1 -1
  124. package/dist/index.cjs +37 -26
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.d.cts +23 -21
  127. package/dist/index.d.ts +23 -21
  128. package/dist/index.js +34 -27
  129. package/dist/index.js.map +1 -1
  130. package/dist/interaction-DXYSjgnP.cjs.map +1 -1
  131. package/dist/interaction-En1KlwFO.js.map +1 -1
  132. package/dist/layout-CYerDebD.d.cts +29 -0
  133. package/dist/layout-CYerDebD.d.ts +29 -0
  134. package/dist/{line-CxR4tg1Q.js → line-CXH0L10d.js} +43 -8
  135. package/dist/line-CXH0L10d.js.map +1 -0
  136. package/dist/{line-vyWO030v.d.cts → line-Cu9ctpbv.d.cts} +9 -2
  137. package/dist/{line-YiCuhVMI.cjs → line-DHbYCQy4.cjs} +43 -8
  138. package/dist/line-DHbYCQy4.cjs.map +1 -0
  139. package/dist/{line-Bpr5uVLQ.d.ts → line-TkzA7wMK.d.ts} +8 -1
  140. package/dist/line.cjs +1 -1
  141. package/dist/line.d.cts +1 -1
  142. package/dist/line.d.ts +1 -1
  143. package/dist/line.js +1 -1
  144. package/dist/{map-49FcfdmJ.d.cts → map-BirylCmT.d.cts} +2 -2
  145. package/dist/{map-C15NC7kW.js → map-CYp6x-uS.js} +3 -26
  146. package/dist/map-CYp6x-uS.js.map +1 -0
  147. package/dist/{map-BqrZ80vT.cjs → map-ChwSgooH.cjs} +4 -27
  148. package/dist/map-ChwSgooH.cjs.map +1 -0
  149. package/dist/{map-BMC61J-P.d.ts → map-DNqog2Xs.d.ts} +2 -2
  150. package/dist/map.cjs +1 -1
  151. package/dist/map.d.cts +1 -1
  152. package/dist/map.d.ts +1 -1
  153. package/dist/map.js +1 -1
  154. package/dist/maps/world.d.cts +1 -1
  155. package/dist/maps/world.d.ts +1 -1
  156. package/dist/{others-ls5eKtZ4.d.cts → others-CuNdpvjd.d.cts} +1 -1
  157. package/dist/{parliament-Cz9n_DoK.d.ts → parliament-CHdf13XU.d.ts} +2 -2
  158. package/dist/{parliament-C7V8UJj1.d.cts → parliament-CsYgh4N2.d.cts} +2 -2
  159. package/dist/parliament.d.cts +1 -1
  160. package/dist/parliament.d.ts +1 -1
  161. package/dist/{patterns-Dw7OMD_2.cjs → patterns-BPN1c9qe.cjs} +2 -2
  162. package/dist/{patterns-Dw7OMD_2.cjs.map → patterns-BPN1c9qe.cjs.map} +1 -1
  163. package/dist/{patterns-BMUINoka.js → patterns-CVrLrJXg.js} +2 -2
  164. package/dist/{patterns-BMUINoka.js.map → patterns-CVrLrJXg.js.map} +1 -1
  165. package/dist/patterns.cjs +1 -1
  166. package/dist/patterns.d.cts +1 -1
  167. package/dist/patterns.d.ts +1 -1
  168. package/dist/patterns.js +1 -1
  169. package/dist/{percentage-bar-cSeiLdwU.d.ts → percentage-bar-CSAbzDOn.d.ts} +2 -2
  170. package/dist/{percentage-bar-R1--2grK.d.cts → percentage-bar-UZHCRvlK.d.cts} +3 -3
  171. package/dist/percentage-bar.d.cts +1 -1
  172. package/dist/percentage-bar.d.ts +1 -1
  173. package/dist/{pie-vD5-g8je.d.cts → pie-AFedsDcF.d.cts} +12 -3
  174. package/dist/{pie-Bd8wyrtY.js → pie-Ch6Bx0ih.js} +54 -39
  175. package/dist/pie-Ch6Bx0ih.js.map +1 -0
  176. package/dist/{pie-BseZlCgP.cjs → pie-Cll1OrVZ.cjs} +54 -39
  177. package/dist/pie-Cll1OrVZ.cjs.map +1 -0
  178. package/dist/{pie-BQQkvy1N.d.ts → pie-Cn2H3pz8.d.ts} +11 -2
  179. package/dist/pie.cjs +1 -1
  180. package/dist/pie.d.cts +1 -1
  181. package/dist/pie.d.ts +1 -1
  182. package/dist/pie.js +1 -1
  183. package/dist/point-shapes.d.cts +1 -1
  184. package/dist/point-shapes.d.ts +1 -1
  185. package/dist/{radar-D6XqkFWQ.js → radar-Bg-IiIWB.js} +3 -3
  186. package/dist/{radar-D6XqkFWQ.js.map → radar-Bg-IiIWB.js.map} +1 -1
  187. package/dist/{radar-vLxilcr4.d.ts → radar-DEer2jjd.d.ts} +2 -2
  188. package/dist/{radar-7I6hsY_h.d.cts → radar-DxmjXhMc.d.cts} +2 -2
  189. package/dist/{radar-DjISDnSf.cjs → radar-wDyX17S3.cjs} +3 -3
  190. package/dist/{radar-DjISDnSf.cjs.map → radar-wDyX17S3.cjs.map} +1 -1
  191. package/dist/radar.cjs +1 -1
  192. package/dist/radar.d.cts +1 -1
  193. package/dist/radar.d.ts +1 -1
  194. package/dist/radar.js +1 -1
  195. package/dist/range-bar-BnKjJP89.cjs +348 -0
  196. package/dist/range-bar-BnKjJP89.cjs.map +1 -0
  197. package/dist/range-bar-C4cRaaQE.d.ts +123 -0
  198. package/dist/range-bar-D32dIQOY.d.cts +123 -0
  199. package/dist/range-bar-Dx6ce0J1.js +343 -0
  200. package/dist/range-bar-Dx6ce0J1.js.map +1 -0
  201. package/dist/range-bar.cjs +3 -0
  202. package/dist/range-bar.d.cts +3 -0
  203. package/dist/range-bar.d.ts +3 -0
  204. package/dist/range-bar.js +1 -0
  205. package/dist/{sankey-DqiuxUx7.d.cts → sankey-D-8ATwBT.d.cts} +2 -2
  206. package/dist/{sankey-7As41Fo4.d.ts → sankey-DpYJsOI4.d.ts} +2 -2
  207. package/dist/sankey.d.cts +1 -1
  208. package/dist/sankey.d.ts +1 -1
  209. package/dist/{scatter-DCMAtt5L.js → scatter-0Z7K_YUz.js} +65 -19
  210. package/dist/scatter-0Z7K_YUz.js.map +1 -0
  211. package/dist/{scatter-BXkXGgM_.d.ts → scatter-BAL5K9_4.d.ts} +22 -9
  212. package/dist/{scatter-DL0zAV09.d.cts → scatter-BUGbnRzM.d.cts} +22 -9
  213. package/dist/{scatter-Bwkblr4L.cjs → scatter-CZ8do3Up.cjs} +65 -19
  214. package/dist/scatter-CZ8do3Up.cjs.map +1 -0
  215. package/dist/scatter.cjs +1 -1
  216. package/dist/scatter.d.cts +2 -2
  217. package/dist/scatter.d.ts +2 -2
  218. package/dist/scatter.js +1 -1
  219. package/dist/slice-labels-1TBq7p3q.d.cts +28 -0
  220. package/dist/slice-labels-C9ucsBVW.js +88 -0
  221. package/dist/slice-labels-C9ucsBVW.js.map +1 -0
  222. package/dist/slice-labels-CbFiy46l.cjs +93 -0
  223. package/dist/slice-labels-CbFiy46l.cjs.map +1 -0
  224. package/dist/slice-labels-Cm5CyV7B.d.ts +28 -0
  225. package/dist/slice-labels.cjs +11 -0
  226. package/dist/slice-labels.cjs.map +1 -0
  227. package/dist/slice-labels.d.cts +6 -0
  228. package/dist/slice-labels.d.ts +6 -0
  229. package/dist/slice-labels.js +11 -0
  230. package/dist/slice-labels.js.map +1 -0
  231. package/dist/{sparkline-BElUSd0r.d.ts → sparkline-CtoBJe-a.d.ts} +2 -2
  232. package/dist/{sparkline-BMSuEPHP.cjs → sparkline-DjR-V6BI.cjs} +2 -2
  233. package/dist/{sparkline-BMSuEPHP.cjs.map → sparkline-DjR-V6BI.cjs.map} +1 -1
  234. package/dist/{sparkline-RYly7bR0.d.cts → sparkline-DwHJfeZz.d.cts} +2 -2
  235. package/dist/{sparkline-NDmq90kP.js → sparkline-_dxwtdli.js} +2 -2
  236. package/dist/{sparkline-NDmq90kP.js.map → sparkline-_dxwtdli.js.map} +1 -1
  237. package/dist/sparkline.cjs +1 -1
  238. package/dist/sparkline.d.cts +1 -1
  239. package/dist/sparkline.d.ts +1 -1
  240. package/dist/sparkline.js +1 -1
  241. package/dist/{stack-BTWYIwLO.d.cts → stack-CcmyALx0.d.cts} +1 -1
  242. package/dist/{stack-jVKvg2x_.js → stack-CyVlS7Fr.js} +2 -2
  243. package/dist/{stack-jVKvg2x_.js.map → stack-CyVlS7Fr.js.map} +1 -1
  244. package/dist/{stack-BO4624CY.cjs → stack-DBhmYNat.cjs} +2 -2
  245. package/dist/{stack-BO4624CY.cjs.map → stack-DBhmYNat.cjs.map} +1 -1
  246. package/dist/style.css +1 -1
  247. package/dist/{time-axis-B3VekUfX.cjs → time-axis-CVKjQKSS.cjs} +3 -3
  248. package/dist/{time-axis-B3VekUfX.cjs.map → time-axis-CVKjQKSS.cjs.map} +1 -1
  249. package/dist/{time-axis-CLjqOakA.js → time-axis-CkmbAw4Z.js} +3 -3
  250. package/dist/{time-axis-CLjqOakA.js.map → time-axis-CkmbAw4Z.js.map} +1 -1
  251. package/dist/time.cjs +2 -2
  252. package/dist/time.js +2 -2
  253. package/dist/{treemap-25vHO_UK.d.cts → treemap-C2maqerU.d.cts} +26 -4
  254. package/dist/{treemap-BCXUbixd.d.ts → treemap-D_zbubo3.d.ts} +26 -4
  255. package/dist/{treemap-CZk8kKFD.cjs → treemap-PulGXZv0.cjs} +38 -8
  256. package/dist/treemap-PulGXZv0.cjs.map +1 -0
  257. package/dist/{treemap-C4glsx-g.js → treemap-lbYxb-7h.js} +38 -8
  258. package/dist/treemap-lbYxb-7h.js.map +1 -0
  259. package/dist/treemap.cjs +1 -1
  260. package/dist/treemap.d.cts +1 -1
  261. package/dist/treemap.d.ts +1 -1
  262. package/dist/treemap.js +1 -1
  263. package/dist/{value-labels-C7GrhOXJ.js → value-labels-B0VeheyE.js} +5 -4
  264. package/dist/value-labels-B0VeheyE.js.map +1 -0
  265. package/dist/{value-labels-DzaKIWKp.cjs → value-labels-Dcyk3GIY.cjs} +5 -4
  266. package/dist/value-labels-Dcyk3GIY.cjs.map +1 -0
  267. package/dist/value-labels.cjs +1 -1
  268. package/dist/value-labels.d.cts +1 -1
  269. package/dist/value-labels.d.ts +1 -1
  270. package/dist/value-labels.js +1 -1
  271. package/dist/zoom.cjs +810 -0
  272. package/dist/zoom.cjs.map +1 -0
  273. package/dist/zoom.d.cts +34 -0
  274. package/dist/zoom.d.ts +34 -0
  275. package/dist/zoom.js +806 -0
  276. package/dist/zoom.js.map +1 -0
  277. package/package.json +27 -2
  278. package/dist/annotations-BQ8l-qHs.js.map +0 -1
  279. package/dist/annotations-CpCWA29b.cjs.map +0 -1
  280. package/dist/area-DYdQ_sMV.cjs.map +0 -1
  281. package/dist/area-WdtfqvhX.js.map +0 -1
  282. package/dist/axis-MMaVoSWB.js.map +0 -1
  283. package/dist/axis-YfAerNBA.cjs.map +0 -1
  284. package/dist/bar-BOcRcArc.js.map +0 -1
  285. package/dist/bar-CVkOJ7WA.cjs.map +0 -1
  286. package/dist/candlestick-BtT9glp9.js.map +0 -1
  287. package/dist/candlestick-CSmRuZ4v.cjs.map +0 -1
  288. package/dist/cartesian-BrPqb5Qn.js.map +0 -1
  289. package/dist/cartesian-DRSXHxWe.cjs.map +0 -1
  290. package/dist/chart-B6TTY4Kr.js.map +0 -1
  291. package/dist/chart-D_lyOy-M.cjs.map +0 -1
  292. package/dist/core-CQ0FaJ4G.js.map +0 -1
  293. package/dist/core-D2PSked3.cjs.map +0 -1
  294. package/dist/export-chart-CPtXmZvi.cjs.map +0 -1
  295. package/dist/export-chart-DoeiAyR2.js.map +0 -1
  296. package/dist/line-CxR4tg1Q.js.map +0 -1
  297. package/dist/line-YiCuhVMI.cjs.map +0 -1
  298. package/dist/map-BqrZ80vT.cjs.map +0 -1
  299. package/dist/map-C15NC7kW.js.map +0 -1
  300. package/dist/pie-Bd8wyrtY.js.map +0 -1
  301. package/dist/pie-BseZlCgP.cjs.map +0 -1
  302. package/dist/scatter-Bwkblr4L.cjs.map +0 -1
  303. package/dist/scatter-DCMAtt5L.js.map +0 -1
  304. package/dist/treemap-C4glsx-g.js.map +0 -1
  305. package/dist/treemap-CZk8kKFD.cjs.map +0 -1
  306. package/dist/value-labels-C7GrhOXJ.js.map +0 -1
  307. package/dist/value-labels-DzaKIWKp.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-chart-BOH_nfcH.js","names":[],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image, or its data as CSV\n * (`exportSVG()`, `exportImage()`, `exportCSV()`, `downloadChart()` of\n * `@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, chartModel } 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 CSVOptions {\n /** Separator of the values. Defaults to `','`. */\n delimiter?: string\n}\n\nexport interface DownloadOptions extends ImageOptions, CSVOptions {\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' | 'csv'\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(container: Element): { svg: Element; box: DOMRect } | 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 return { svg: g, box }\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 totalWidth = width\n let total = height\n if (legend) {\n // Chart and legend where the page shows them (above, below or beside),\n // with the gap between them, in one image as large as both.\n const { box } = legend\n const at = svg.getBoundingClientRect()\n const left = Math.min(at.left, box.left)\n const top = Math.min(at.top, box.top)\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n const move = (el: Element, x: number, y: number) => {\n if (x || y) el.setAttribute('transform', `translate(${round(x)} ${round(y)})`)\n }\n move(wrap, at.left - left, at.top - top)\n move(legend.svg, box.left - left, box.top - top)\n copy.append(wrap, legend.svg)\n totalWidth = round(Math.max(at.left + width, box.right) - left)\n total = round(Math.max(at.top + height, box.bottom) - top)\n }\n copy.setAttribute('width', String(totalWidth))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${totalWidth} ${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/** The rows of a chart with `{ labels, series }` data, values as they are. */\nfunction seriesRows(chart: Chart<object>): string[][] | undefined {\n const { config, interaction } = chart\n const { data, x } = config as {\n data?: { labels?: readonly unknown[]; series?: unknown }\n x?: { type?: string }\n }\n const series = data?.series\n if (!interaction || !Array.isArray(series) || !series.every((s) => Array.isArray(s?.values))) {\n return undefined\n }\n // From the hits, as the tooltip has them: the hidden series are left out.\n const hits = Array.from({ length: interaction.count }, (_, i) => interaction.hitIndex(i))\n const names = new Map<number, string>()\n for (const hit of hits)\n for (const item of hit?.items ?? []) names.set(item.seriesIndex, item.name)\n const order = [...names.keys()].sort((a, b) => a - b)\n const rows = [['', ...order.map((index) => names.get(index) as string)]]\n for (const hit of hits) {\n if (!hit) continue\n const label = data?.labels?.[hit.index]\n const date =\n label instanceof Date\n ? label\n : x?.type === 'time' && typeof hit.label === 'number' && new Date(hit.label)\n rows.push([\n date && Number.isFinite(date.getTime()) ? date.toISOString() : String(hit.label),\n ...order.map((index) => {\n const value = hit.items.find((item) => item.seriesIndex === index)?.value\n return value == null ? '' : String(value)\n }),\n ])\n }\n return rows\n}\n\n/** The rows of any other chart: the text of its data table, every row of it. */\nfunction tableRows(chart: Chart<object>): string[][] {\n const { config } = chart\n const model = chartModel(config)\n const hidden = new Set(\n (config.type.legend?.(model) ?? [])\n .map((item) => item.key)\n .filter((key) => chart.isHidden(key)),\n )\n const table = config.type.table?.(\n model,\n { locale: config.locale, hidden, rtl: chart.rtl },\n Number.POSITIVE_INFINITY,\n )\n if (!table) throw new Error('@tabler/charts: this chart type has no data for a CSV.')\n return [table.columns, ...table.rows]\n}\n\n/**\n * The chart's data as CSV (RFC 4180): one row per category with a column per\n * visible series, as in the chart's data table but with every row. Line,\n * area, bar, heatmap and radar charts give plain values (numbers without\n * their format, dates in ISO 8601, gaps empty); the other types give the\n * text of their table. Text that a spreadsheet would run as a formula (`=`,\n * `+`, `-` or `@` first) is prefixed with `'`. Takes the rendered chart\n * itself, not its element.\n *\n * ```ts\n * const csv = exportCSV(chart)\n * ```\n */\nexport function exportCSV(chart: Chart<object>, options: CSVOptions = {}): string {\n if (!chart?.config?.type) {\n throw new Error('@tabler/charts: exportCSV() takes the chart, not its element.')\n }\n const delimiter = options.delimiter ?? ','\n const cell = (text: string): string => {\n // No formulas from the data: only numbers may start with a sign.\n const safe = /^[=+\\-@\\t\\r]/.test(text) && !Number.isFinite(Number(text)) ? `'${text}` : text\n return safe.includes(delimiter) || /[\"\\r\\n]/.test(safe) ? `\"${safe.replace(/\"/g, '\"\"')}\"` : safe\n }\n return (seriesRows(chart) ?? tableRows(chart))\n .map((row) => row.map(cell).join(delimiter))\n .join('\\r\\n')\n}\n\n/**\n * Save the chart as a file: PNG by default, SVG, JPEG or WebP, or its data\n * as CSV (which needs the chart itself, not its element).\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 === 'csv'\n ? // With a byte order mark, so spreadsheets read it as UTF-8.\n new Blob([`${exportCSV(target as Chart<object>, options)}`], {\n type: 'text/csv;charset=utf-8',\n })\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":";;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS;;AAqCf,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,IAA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AI,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,IAChE,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAS,MAAM,SAAS;CAAS,CAAC;CACzE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
@@ -1,5 +1,19 @@
1
+ const require_chart = require("./chart-GUmmjJ7S.cjs");
1
2
  const require_layout = require("./layout-Cfg9x1k2.cjs");
2
3
  // src/export-chart.ts
4
+ /**
5
+ * Export a rendered chart as a standalone SVG or an image, or its data as CSV
6
+ * (`exportSVG()`, `exportImage()`, `exportCSV()`, `downloadChart()` of
7
+ * `@tabler/charts/export`).
8
+ *
9
+ * Charts are styled by CSS, so the export copies the computed styles of
10
+ * every mark into the SVG: the file looks the same anywhere, without the
11
+ * stylesheet or the page's custom properties. Browser only.
12
+ *
13
+ * Kept free of side effects, so `@tabler/charts` can re-export the functions
14
+ * without carrying them into every bundle: the `/export` entry registers the
15
+ * `download` menu's saver on top.
16
+ */
3
17
  const SVG_NS = "http://www.w3.org/2000/svg";
4
18
  /** Properties copied from the computed style, with the values they can be left out at. */
5
19
  const SHAPE = {
@@ -210,8 +224,66 @@ async function exportImage(target, options = {}) {
210
224
  canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("@tabler/charts: could not encode.")), type, quality);
211
225
  });
212
226
  }
227
+ /** The rows of a chart with `{ labels, series }` data, values as they are. */
228
+ function seriesRows(chart) {
229
+ const { config, interaction } = chart;
230
+ const { data, x } = config;
231
+ const series = data?.series;
232
+ if (!interaction || !Array.isArray(series) || !series.every((s) => Array.isArray(s?.values))) return;
233
+ const hits = Array.from({ length: interaction.count }, (_, i) => interaction.hitIndex(i));
234
+ const names = /* @__PURE__ */ new Map();
235
+ for (const hit of hits) for (const item of hit?.items ?? []) names.set(item.seriesIndex, item.name);
236
+ const order = [...names.keys()].sort((a, b) => a - b);
237
+ const rows = [["", ...order.map((index) => names.get(index))]];
238
+ for (const hit of hits) {
239
+ if (!hit) continue;
240
+ const label = data?.labels?.[hit.index];
241
+ const date = label instanceof Date ? label : x?.type === "time" && typeof hit.label === "number" && new Date(hit.label);
242
+ rows.push([date && Number.isFinite(date.getTime()) ? date.toISOString() : String(hit.label), ...order.map((index) => {
243
+ const value = hit.items.find((item) => item.seriesIndex === index)?.value;
244
+ return value == null ? "" : String(value);
245
+ })]);
246
+ }
247
+ return rows;
248
+ }
249
+ /** The rows of any other chart: the text of its data table, every row of it. */
250
+ function tableRows(chart) {
251
+ const { config } = chart;
252
+ const model = require_chart.chartModel(config);
253
+ const hidden = new Set((config.type.legend?.(model) ?? []).map((item) => item.key).filter((key) => chart.isHidden(key)));
254
+ const table = config.type.table?.(model, {
255
+ locale: config.locale,
256
+ hidden,
257
+ rtl: chart.rtl
258
+ }, Number.POSITIVE_INFINITY);
259
+ if (!table) throw new Error("@tabler/charts: this chart type has no data for a CSV.");
260
+ return [table.columns, ...table.rows];
261
+ }
262
+ /**
263
+ * The chart's data as CSV (RFC 4180): one row per category with a column per
264
+ * visible series, as in the chart's data table but with every row. Line,
265
+ * area, bar, heatmap and radar charts give plain values (numbers without
266
+ * their format, dates in ISO 8601, gaps empty); the other types give the
267
+ * text of their table. Text that a spreadsheet would run as a formula (`=`,
268
+ * `+`, `-` or `@` first) is prefixed with `'`. Takes the rendered chart
269
+ * itself, not its element.
270
+ *
271
+ * ```ts
272
+ * const csv = exportCSV(chart)
273
+ * ```
274
+ */
275
+ function exportCSV(chart, options = {}) {
276
+ if (!chart?.config?.type) throw new Error("@tabler/charts: exportCSV() takes the chart, not its element.");
277
+ const delimiter = options.delimiter ?? ",";
278
+ const cell = (text) => {
279
+ const safe = /^[=+\-@\t\r]/.test(text) && !Number.isFinite(Number(text)) ? `'${text}` : text;
280
+ return safe.includes(delimiter) || /["\r\n]/.test(safe) ? `"${safe.replace(/"/g, "\"\"")}"` : safe;
281
+ };
282
+ return (seriesRows(chart) ?? tableRows(chart)).map((row) => row.map(cell).join(delimiter)).join("\r\n");
283
+ }
213
284
  /**
214
- * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.
285
+ * Save the chart as a file: PNG by default, SVG, JPEG or WebP, or its data
286
+ * as CSV (which needs the chart itself, not its element).
215
287
  *
216
288
  * ```ts
217
289
  * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })
@@ -220,7 +292,7 @@ async function exportImage(target, options = {}) {
220
292
  async function downloadChart(target, options = {}) {
221
293
  const { format = "png" } = options;
222
294
  const svg = rootOf(target);
223
- const blob = format === "svg" ? new Blob([exportSVG(target, options)], { type: "image/svg+xml" }) : await exportImage(target, {
295
+ const blob = format === "csv" ? new Blob([`${exportCSV(target, options)}`], { type: "text/csv;charset=utf-8" }) : format === "svg" ? new Blob([exportSVG(target, options)], { type: "image/svg+xml" }) : await exportImage(target, {
224
296
  ...options,
225
297
  type: `image/${format}`
226
298
  });
@@ -237,6 +309,12 @@ Object.defineProperty(exports, "downloadChart", {
237
309
  return downloadChart;
238
310
  }
239
311
  });
312
+ Object.defineProperty(exports, "exportCSV", {
313
+ enumerable: true,
314
+ get: function() {
315
+ return exportCSV;
316
+ }
317
+ });
240
318
  Object.defineProperty(exports, "exportImage", {
241
319
  enumerable: true,
242
320
  get: function() {
@@ -250,4 +328,4 @@ Object.defineProperty(exports, "exportSVG", {
250
328
  }
251
329
  });
252
330
 
253
- //# sourceMappingURL=export-chart-CPtXmZvi.cjs.map
331
+ //# sourceMappingURL=export-chart-Be4T9J3m.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-chart-Be4T9J3m.cjs","names":["round","chartModel"],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image, or its data as CSV\n * (`exportSVG()`, `exportImage()`, `exportCSV()`, `downloadChart()` of\n * `@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, chartModel } 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 CSVOptions {\n /** Separator of the values. Defaults to `','`. */\n delimiter?: string\n}\n\nexport interface DownloadOptions extends ImageOptions, CSVOptions {\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' | 'csv'\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(container: Element): { svg: Element; box: DOMRect } | 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 return { svg: g, box }\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 totalWidth = width\n let total = height\n if (legend) {\n // Chart and legend where the page shows them (above, below or beside),\n // with the gap between them, in one image as large as both.\n const { box } = legend\n const at = svg.getBoundingClientRect()\n const left = Math.min(at.left, box.left)\n const top = Math.min(at.top, box.top)\n const wrap = doc.createElementNS(SVG_NS, 'g')\n wrap.append(...Array.from(copy.childNodes))\n const move = (el: Element, x: number, y: number) => {\n if (x || y) el.setAttribute('transform', `translate(${round(x)} ${round(y)})`)\n }\n move(wrap, at.left - left, at.top - top)\n move(legend.svg, box.left - left, box.top - top)\n copy.append(wrap, legend.svg)\n totalWidth = round(Math.max(at.left + width, box.right) - left)\n total = round(Math.max(at.top + height, box.bottom) - top)\n }\n copy.setAttribute('width', String(totalWidth))\n copy.setAttribute('height', String(total))\n copy.setAttribute('viewBox', `0 0 ${totalWidth} ${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/** The rows of a chart with `{ labels, series }` data, values as they are. */\nfunction seriesRows(chart: Chart<object>): string[][] | undefined {\n const { config, interaction } = chart\n const { data, x } = config as {\n data?: { labels?: readonly unknown[]; series?: unknown }\n x?: { type?: string }\n }\n const series = data?.series\n if (!interaction || !Array.isArray(series) || !series.every((s) => Array.isArray(s?.values))) {\n return undefined\n }\n // From the hits, as the tooltip has them: the hidden series are left out.\n const hits = Array.from({ length: interaction.count }, (_, i) => interaction.hitIndex(i))\n const names = new Map<number, string>()\n for (const hit of hits)\n for (const item of hit?.items ?? []) names.set(item.seriesIndex, item.name)\n const order = [...names.keys()].sort((a, b) => a - b)\n const rows = [['', ...order.map((index) => names.get(index) as string)]]\n for (const hit of hits) {\n if (!hit) continue\n const label = data?.labels?.[hit.index]\n const date =\n label instanceof Date\n ? label\n : x?.type === 'time' && typeof hit.label === 'number' && new Date(hit.label)\n rows.push([\n date && Number.isFinite(date.getTime()) ? date.toISOString() : String(hit.label),\n ...order.map((index) => {\n const value = hit.items.find((item) => item.seriesIndex === index)?.value\n return value == null ? '' : String(value)\n }),\n ])\n }\n return rows\n}\n\n/** The rows of any other chart: the text of its data table, every row of it. */\nfunction tableRows(chart: Chart<object>): string[][] {\n const { config } = chart\n const model = chartModel(config)\n const hidden = new Set(\n (config.type.legend?.(model) ?? [])\n .map((item) => item.key)\n .filter((key) => chart.isHidden(key)),\n )\n const table = config.type.table?.(\n model,\n { locale: config.locale, hidden, rtl: chart.rtl },\n Number.POSITIVE_INFINITY,\n )\n if (!table) throw new Error('@tabler/charts: this chart type has no data for a CSV.')\n return [table.columns, ...table.rows]\n}\n\n/**\n * The chart's data as CSV (RFC 4180): one row per category with a column per\n * visible series, as in the chart's data table but with every row. Line,\n * area, bar, heatmap and radar charts give plain values (numbers without\n * their format, dates in ISO 8601, gaps empty); the other types give the\n * text of their table. Text that a spreadsheet would run as a formula (`=`,\n * `+`, `-` or `@` first) is prefixed with `'`. Takes the rendered chart\n * itself, not its element.\n *\n * ```ts\n * const csv = exportCSV(chart)\n * ```\n */\nexport function exportCSV(chart: Chart<object>, options: CSVOptions = {}): string {\n if (!chart?.config?.type) {\n throw new Error('@tabler/charts: exportCSV() takes the chart, not its element.')\n }\n const delimiter = options.delimiter ?? ','\n const cell = (text: string): string => {\n // No formulas from the data: only numbers may start with a sign.\n const safe = /^[=+\\-@\\t\\r]/.test(text) && !Number.isFinite(Number(text)) ? `'${text}` : text\n return safe.includes(delimiter) || /[\"\\r\\n]/.test(safe) ? `\"${safe.replace(/\"/g, '\"\"')}\"` : safe\n }\n return (seriesRows(chart) ?? tableRows(chart))\n .map((row) => row.map(cell).join(delimiter))\n .join('\\r\\n')\n}\n\n/**\n * Save the chart as a file: PNG by default, SVG, JPEG or WebP, or its data\n * as CSV (which needs the chart itself, not its element).\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 === 'csv'\n ? // With a byte order mark, so spreadsheets read it as UTF-8.\n new Blob([`${exportCSV(target as Chart<object>, options)}`], {\n type: 'text/csv;charset=utf-8',\n })\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":";;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS;;AAqCf,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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AC3B,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,OACJ,WAAW,QAEP,IAAI,KAAK,CAAC,IAAI,UAAU,QAAyB,OAAO,GAAG,GAAG,EAC5D,MAAM,yBACR,CAAC,IACD,WAAW,QACT,IAAI,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,IAChE,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAS,MAAM,SAAS;CAAS,CAAC;CACzE,MAAM,QAAQ,QAAQ,YAAY,IAAI,aAAa,YAAY,KAAK,QAAA,CACjE,QAAQ,kBAAkB,EAAE,CAAC,CAC7B,KAAK;CACR,MAAM,OAAO,IAAI,cAAc,cAAc,GAAG;CAChD,KAAK,OAAO,IAAI,gBAAgB,IAAI;CACpC,KAAK,WAAW,GAAG,QAAQ,QAAQ,GAAG,WAAW,SAAS,QAAQ;CAClE,KAAK,MAAM;CAEX,iBAAiB,IAAI,gBAAgB,KAAK,IAAI,GAAG,GAAI;AACvD"}
package/dist/export.cjs CHANGED
@@ -1,15 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_export_chart = require("./export-chart-CPtXmZvi.cjs");
2
+ const require_export_chart = require("./export-chart-Be4T9J3m.cjs");
3
3
  // src/export.ts
4
4
  /**
5
5
  * Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
6
- * saves a rendered chart as a standalone SVG or an image. Importing it also
6
+ * saves a rendered chart as a standalone SVG or an image, and `exportCSV`
7
+ * gives its data as CSV. Importing it also
7
8
  * enables the `download` option (a menu on the chart that saves it): with the
8
9
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
9
10
  * plugin installed on the core.
10
11
  */
11
12
  require("./features-DEDP5CEQ.cjs").register({ export: require_export_chart.downloadChart });
12
13
  exports.downloadChart = require_export_chart.downloadChart;
14
+ exports.exportCSV = require_export_chart.exportCSV;
13
15
  exports.exportImage = require_export_chart.exportImage;
14
16
  exports.exportSVG = require_export_chart.exportSVG;
15
17
 
@@ -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":";;;;;;;;;;A,iCAWAA,CAAAA,CAAAA,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, and `exportCSV`\n * gives its data as CSV. 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, exportCSV, 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 CSVOptions,\n DownloadOptions,\n ExportOptions,\n ExportTarget,\n ImageOptions,\n} from './export-chart.ts'\nexport { downloadChart, exportCSV, exportImage, exportSVG }\n"],"mappings":";;;;;;;;;;;A,iCAYAA,CAAAA,CAAAA,SAAS,EAAE,QAAQC,qBAAAA,cAAc,CAAC"}
package/dist/export.d.cts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
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
3
+ * saves a rendered chart as a standalone SVG or an image, and `exportCSV`
4
+ * gives its data as CSV. Importing it also
4
5
  * enables the `download` option (a menu on the chart that saves it): with the
5
6
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
6
7
  * plugin installed on the core.
7
8
  */
8
- import { J as ExportTarget, K as DownloadOptions, Q as exportSVG, X as downloadChart, Y as ImageOptions, Z as exportImage, q as ExportOptions } from "./chart-CbPzP5Dp.cjs";
9
- export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
9
+ import { $ as exportCSV, J as DownloadOptions, Q as downloadChart, X as ExportTarget, Y as ExportOptions, Z as ImageOptions, et as exportImage, q as CSVOptions, tt as exportSVG } from "./chart-Dz4geQZy.cjs";
10
+ export { type CSVOptions, type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportCSV, exportImage, exportSVG };
package/dist/export.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
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
3
+ * saves a rendered chart as a standalone SVG or an image, and `exportCSV`
4
+ * gives its data as CSV. Importing it also
4
5
  * enables the `download` option (a menu on the chart that saves it): with the
5
6
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
6
7
  * plugin installed on the core.
7
8
  */
8
- import { G as ImageOptions, H as DownloadOptions, J as exportSVG, K as downloadChart, U as ExportOptions, W as ExportTarget, q as exportImage } from "./chart-CYrrUCi3.js";
9
- export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
9
+ import { G as ExportOptions, J as downloadChart, K as ExportTarget, U as CSVOptions, W as DownloadOptions, X as exportImage, Y as exportCSV, Z as exportSVG, q as ImageOptions } from "./chart-CE9EVbfV.js";
10
+ export { type CSVOptions, type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportCSV, exportImage, exportSVG };
package/dist/export.js CHANGED
@@ -1,14 +1,15 @@
1
- import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-chart-DoeiAyR2.js";
1
+ import { i as exportSVG, n as exportCSV, r as exportImage, t as downloadChart } from "./export-chart-BOH_nfcH.js";
2
2
  import { i as register } from "./features-B55rwpQC.js";
3
3
  // src/export.ts
4
4
  /**
5
5
  * Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
6
- * saves a rendered chart as a standalone SVG or an image. Importing it also
6
+ * saves a rendered chart as a standalone SVG or an image, and `exportCSV`
7
+ * gives its data as CSV. Importing it also
7
8
  * enables the `download` option (a menu on the chart that saves it): with the
8
9
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
9
10
  * plugin installed on the core.
10
11
  */
11
12
  register({ export: downloadChart });
12
- export { downloadChart, exportImage, exportSVG };
13
+ export { downloadChart, exportCSV, exportImage, exportSVG };
13
14
 
14
15
  //# sourceMappingURL=export.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","names":[],"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":";;;;;;;;;;AAWA,SAAS,EAAE,QAAQ,cAAc,CAAC"}
1
+ {"version":3,"file":"export.js","names":[],"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, and `exportCSV`\n * gives its data as CSV. 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, exportCSV, 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 CSVOptions,\n DownloadOptions,\n ExportOptions,\n ExportTarget,\n ImageOptions,\n} from './export-chart.ts'\nexport { downloadChart, exportCSV, exportImage, exportSVG }\n"],"mappings":";;;;;;;;;;;AAYA,SAAS,EAAE,QAAQ,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"features-B55rwpQC.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 { markerClip, 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 (installed by a chart whose type has `sweep`). */\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 /** The same shapes for legend and tooltip swatches, as CSS shapes. */\n swatch?: typeof markerClip\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/**\n * Inline style that gives the swatch of a legend or tooltip entry the point\n * shape of its color slot (the stylesheet applies it when points are drawn).\n */\nexport type SwatchShape = (slot: number) => Record<string, string | number> | undefined\n\n/** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */\nexport const swatchShape = (config: ChartConfig<object>): SwatchShape | undefined =>\n (config.shapes ?? config.patterns === true) ? features.swatch : undefined\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":";AA4DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;;AASA,MAAa,eAAe,WACzB,OAAO,UAAU,OAAO,aAAa,OAAQ,SAAS,SAAS,KAAA;AAUlE,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-B55rwpQC.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 { endLabels } from './charts/end-labels.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerClip, markerPath } from './charts/point-shapes.ts'\nimport type { sliceLabels } from './charts/slice-labels.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { viewWindow } from './charts/view.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { ChartPlugin } from './plugin.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`, `/end-labels`, `/slice-labels`, `/zoom`) 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 (installed by a chart whose type has `sweep`). */\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 /** Names and last values at the end of lines, behind `endLabels`. */\n 'end-labels'?: typeof endLabels\n /** Names beside the slices of a pie, behind its `labels`. */\n 'slice-labels'?: typeof sliceLabels\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 /** The same shapes for legend and tooltip swatches, as CSS shapes. */\n swatch?: typeof markerClip\n /**\n * Behind `view` and `zoom` in cartesian charts: the window of categories a\n * chart type draws, and what the `zoom()` plugin installs on a chart.\n */\n zoom?: { window: typeof viewWindow; install: ChartPlugin['install'] }\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/**\n * Inline style that gives the swatch of a legend or tooltip entry the point\n * shape of its color slot (the stylesheet applies it when points are drawn).\n */\nexport type SwatchShape = (slot: number) => Record<string, string | number> | undefined\n\n/** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */\nexport const swatchShape = (config: ChartConfig<object>): SwatchShape | undefined =>\n (config.shapes ?? config.patterns === true) ? features.swatch : undefined\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":";AAyEA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;;AASA,MAAa,eAAe,WACzB,OAAO,UAAU,OAAO,aAAa,OAAQ,SAAS,SAAS,KAAA;AAUlE,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 +1 @@
1
- {"version":3,"file":"features-DEDP5CEQ.cjs","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 { markerClip, 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 (installed by a chart whose type has `sweep`). */\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 /** The same shapes for legend and tooltip swatches, as CSS shapes. */\n swatch?: typeof markerClip\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/**\n * Inline style that gives the swatch of a legend or tooltip entry the point\n * shape of its color slot (the stylesheet applies it when points are drawn).\n */\nexport type SwatchShape = (slot: number) => Record<string, string | number> | undefined\n\n/** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */\nexport const swatchShape = (config: ChartConfig<object>): SwatchShape | undefined =>\n (config.shapes ?? config.patterns === true) ? features.swatch : undefined\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":";AA4DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;;AASA,MAAa,eAAe,WACzB,OAAO,UAAU,OAAO,aAAa,OAAQ,SAAS,SAAS,KAAA;AAUlE,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-DEDP5CEQ.cjs","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 { endLabels } from './charts/end-labels.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerClip, markerPath } from './charts/point-shapes.ts'\nimport type { sliceLabels } from './charts/slice-labels.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { viewWindow } from './charts/view.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { ChartPlugin } from './plugin.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`, `/end-labels`, `/slice-labels`, `/zoom`) 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 (installed by a chart whose type has `sweep`). */\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 /** Names and last values at the end of lines, behind `endLabels`. */\n 'end-labels'?: typeof endLabels\n /** Names beside the slices of a pie, behind its `labels`. */\n 'slice-labels'?: typeof sliceLabels\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 /** The same shapes for legend and tooltip swatches, as CSS shapes. */\n swatch?: typeof markerClip\n /**\n * Behind `view` and `zoom` in cartesian charts: the window of categories a\n * chart type draws, and what the `zoom()` plugin installs on a chart.\n */\n zoom?: { window: typeof viewWindow; install: ChartPlugin['install'] }\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/**\n * Inline style that gives the swatch of a legend or tooltip entry the point\n * shape of its color slot (the stylesheet applies it when points are drawn).\n */\nexport type SwatchShape = (slot: number) => Record<string, string | number> | undefined\n\n/** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */\nexport const swatchShape = (config: ChartConfig<object>): SwatchShape | undefined =>\n (config.shapes ?? config.patterns === true) ? features.swatch : undefined\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":";AAyEA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;;AASA,MAAa,eAAe,WACzB,OAAO,UAAU,OAAO,aAAa,OAAQ,SAAS,SAAS,KAAA;AAUlE,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,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CbPzP5Dp.cjs";
1
+ import { o as ChartType } from "./chart-Dz4geQZy.cjs";
2
2
  import { c as NumberFormat } from "./time-B4oxWHQI.cjs";
3
- import { a as InsetsInput } from "./annotations-CHafaGd4.cjs";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.cjs";
4
4
  import { a as ClassValue } from "./vnode-Du2cC8Fm.cjs";
5
5
  /** One stage of a funnel. */
6
6
  interface FunnelStage {
@@ -1,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CYrrUCi3.js";
1
+ import { o as ChartType } from "./chart-CE9EVbfV.js";
2
2
  import { c as NumberFormat } from "./time-DRIDgv2a.js";
3
- import { a as InsetsInput } from "./annotations-B02GR_KU.js";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.js";
4
4
  import { a as ClassValue } from "./vnode-Du2cC8Fm.js";
5
5
  /** One stage of a funnel. */
6
6
  interface FunnelStage {
package/dist/funnel.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { funnel } from '@tabler/charts/funnel'`. */
2
- import { n as FunnelStage, r as funnel, t as FunnelOptions } from "./funnel-CarOh8w_.cjs";
2
+ import { n as FunnelStage, r as funnel, t as FunnelOptions } from "./funnel-B9ridzNx.cjs";
3
3
  export { type FunnelOptions, type FunnelStage, funnel };
package/dist/funnel.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { funnel } from '@tabler/charts/funnel'`. */
2
- import { n as FunnelStage, r as funnel, t as FunnelOptions } from "./funnel-BdcfUkb5.js";
2
+ import { n as FunnelStage, r as funnel, t as FunnelOptions } from "./funnel-FogM8flk.js";
3
3
  export { type FunnelOptions, type FunnelStage, funnel };
@@ -1,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CbPzP5Dp.cjs";
1
+ import { o as ChartType } from "./chart-Dz4geQZy.cjs";
2
2
  import { c as NumberFormat } from "./time-B4oxWHQI.cjs";
3
- import { a as InsetsInput } from "./annotations-CHafaGd4.cjs";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.cjs";
4
4
  import { a as ClassValue } from "./vnode-Du2cC8Fm.cjs";
5
5
  /** One ring of a gauge. */
6
6
  interface GaugeRing {
@@ -1,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CYrrUCi3.js";
1
+ import { o as ChartType } from "./chart-CE9EVbfV.js";
2
2
  import { c as NumberFormat } from "./time-DRIDgv2a.js";
3
- import { a as InsetsInput } from "./annotations-B02GR_KU.js";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.js";
4
4
  import { a as ClassValue } from "./vnode-Du2cC8Fm.js";
5
5
  /** One ring of a gauge. */
6
6
  interface GaugeRing {
package/dist/gauge.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { gauge } from '@tabler/charts/gauge'`. */
2
- import { n as GaugeRing, r as gauge, t as GaugeOptions } from "./gauge-Ds9k1UV2.cjs";
2
+ import { n as GaugeRing, r as gauge, t as GaugeOptions } from "./gauge-BScJ7U6O.cjs";
3
3
  export { type GaugeOptions, type GaugeRing, gauge };
package/dist/gauge.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { gauge } from '@tabler/charts/gauge'`. */
2
- import { n as GaugeRing, r as gauge, t as GaugeOptions } from "./gauge-Zy25jfps.js";
2
+ import { n as GaugeRing, r as gauge, t as GaugeOptions } from "./gauge-D78oq1Lx.js";
3
3
  export { type GaugeOptions, type GaugeRing, gauge };
@@ -0,0 +1,38 @@
1
+ import { s as round } from "./layout-DqAte3H8.js";
2
+ // src/charts/heat.ts
3
+ /** The shade of a mark without a value, and the pale end of the single hue. */
4
+ const EMPTY = "var(--tc-heat-empty,var(--tc-grid-color))";
5
+ /**
6
+ * The scale from `lo` to `hi`: through the `stops` when there are any (with
7
+ * `mid` on the middle one), else one hue, `--tc-heat-color`, from `floor`
8
+ * (its share at `lo`) to the full color.
9
+ */
10
+ function heatScale(lo, hi, mid, stops, floor) {
11
+ return {
12
+ position(v) {
13
+ const t = stops && mid !== null && lo < mid && mid < hi ? v <= mid ? (v - lo) / (mid - lo) * .5 : .5 + (v - mid) / (hi - mid) * .5 : hi > lo ? (v - lo) / (hi - lo) : v > lo ? 1 : 0;
14
+ return Math.min(1, Math.max(0, t));
15
+ },
16
+ paint(t) {
17
+ if (stops) {
18
+ const at = t * (stops.length - 1);
19
+ const k = Math.min(stops.length - 2, Math.floor(at));
20
+ const u = round((at - k) * 100);
21
+ const from = stops[k];
22
+ const color = u <= 0 ? from : u >= 100 ? stops[k + 1] : `color-mix(in oklab,${stops[k + 1]} ${u}%,${from})`;
23
+ return {
24
+ style: { "--tc-cell-fill": color },
25
+ color
26
+ };
27
+ }
28
+ const pct = round((floor + (1 - floor) * t) * 100);
29
+ return {
30
+ style: `--tc-heat:${pct}%`,
31
+ color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`
32
+ };
33
+ }
34
+ };
35
+ }
36
+ export { heatScale as n, EMPTY as t };
37
+
38
+ //# sourceMappingURL=heat-Bsqq4zw9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heat-Bsqq4zw9.js","names":[],"sources":["../src/charts/heat.ts"],"sourcesContent":["import { round } from '../layout.ts'\nimport type { StyleValue } from '../vnode.ts'\n\n/** The shade of a mark without a value, and the pale end of the single hue. */\nexport const EMPTY = 'var(--tc-heat-empty,var(--tc-grid-color))'\n\n/** A scale that shades marks by value (map regions, treemap tiles). */\nexport interface HeatScale {\n /** Position of a value in the domain, 0…1 (through `mid` for a scale with a middle). */\n position(v: number): number\n /** How a mark at position `t` of the scale is painted: its style and the tooltip swatch. */\n paint(t: number): { style: StyleValue; color: string }\n}\n\n/**\n * The scale from `lo` to `hi`: through the `stops` when there are any (with\n * `mid` on the middle one), else one hue, `--tc-heat-color`, from `floor`\n * (its share at `lo`) to the full color.\n */\nexport function heatScale(\n lo: number,\n hi: number,\n mid: number | null,\n stops: readonly string[] | undefined,\n floor: number,\n): HeatScale {\n return {\n position(v) {\n const t =\n stops && mid !== null && lo < mid && mid < hi\n ? v <= mid\n ? ((v - lo) / (mid - lo)) * 0.5\n : 0.5 + ((v - mid) / (hi - mid)) * 0.5\n : hi > lo\n ? (v - lo) / (hi - lo)\n : v > lo\n ? 1\n : 0\n return Math.min(1, Math.max(0, t))\n },\n paint(t) {\n if (stops) {\n const at = t * (stops.length - 1)\n const k = Math.min(stops.length - 2, Math.floor(at))\n const u = round((at - k) * 100)\n const from = stops[k] as string\n const color =\n u <= 0\n ? from\n : u >= 100\n ? (stops[k + 1] as string)\n : `color-mix(in oklab,${stops[k + 1]} ${u}%,${from})`\n return { style: { '--tc-cell-fill': color }, color }\n }\n const pct = round((floor + (1 - floor) * t) * 100)\n return {\n style: `--tc-heat:${pct}%`,\n color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`,\n }\n },\n }\n}\n"],"mappings":";;;AAIA,MAAa,QAAQ;;;;;;AAerB,SAAgB,UACd,IACA,IACA,KACA,OACA,OACW;CACX,OAAO;EACL,SAAS,GAAG;GACV,MAAM,IACJ,SAAS,QAAQ,QAAQ,KAAK,OAAO,MAAM,KACvC,KAAK,OACD,IAAI,OAAO,MAAM,MAAO,KAC1B,MAAQ,IAAI,QAAQ,KAAK,OAAQ,KACnC,KAAK,MACF,IAAI,OAAO,KAAK,MACjB,IAAI,KACF,IACA;GACV,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;EACnC;EACA,MAAM,GAAG;GACP,IAAI,OAAO;IACT,MAAM,KAAK,KAAK,MAAM,SAAS;IAC/B,MAAM,IAAI,KAAK,IAAI,MAAM,SAAS,GAAG,KAAK,MAAM,EAAE,CAAC;IACnD,MAAM,IAAI,OAAO,KAAK,KAAK,GAAG;IAC9B,MAAM,OAAO,MAAM;IACnB,MAAM,QACJ,KAAK,IACD,OACA,KAAK,MACF,MAAM,IAAI,KACX,sBAAsB,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI,KAAK;IACzD,OAAO;KAAE,OAAO,EAAE,kBAAkB,MAAM;KAAG;IAAM;GACrD;GACA,MAAM,MAAM,OAAO,SAAS,IAAI,SAAS,KAAK,GAAG;GACjD,OAAO;IACL,OAAO,aAAa,IAAI;IACxB,OAAO,6DAA6D,IAAI,IAAI,MAAM;GACpF;EACF;CACF;AACF"}
@@ -0,0 +1,49 @@
1
+ const require_layout = require("./layout-Cfg9x1k2.cjs");
2
+ // src/charts/heat.ts
3
+ /** The shade of a mark without a value, and the pale end of the single hue. */
4
+ const EMPTY = "var(--tc-heat-empty,var(--tc-grid-color))";
5
+ /**
6
+ * The scale from `lo` to `hi`: through the `stops` when there are any (with
7
+ * `mid` on the middle one), else one hue, `--tc-heat-color`, from `floor`
8
+ * (its share at `lo`) to the full color.
9
+ */
10
+ function heatScale(lo, hi, mid, stops, floor) {
11
+ return {
12
+ position(v) {
13
+ const t = stops && mid !== null && lo < mid && mid < hi ? v <= mid ? (v - lo) / (mid - lo) * .5 : .5 + (v - mid) / (hi - mid) * .5 : hi > lo ? (v - lo) / (hi - lo) : v > lo ? 1 : 0;
14
+ return Math.min(1, Math.max(0, t));
15
+ },
16
+ paint(t) {
17
+ if (stops) {
18
+ const at = t * (stops.length - 1);
19
+ const k = Math.min(stops.length - 2, Math.floor(at));
20
+ const u = require_layout.round((at - k) * 100);
21
+ const from = stops[k];
22
+ const color = u <= 0 ? from : u >= 100 ? stops[k + 1] : `color-mix(in oklab,${stops[k + 1]} ${u}%,${from})`;
23
+ return {
24
+ style: { "--tc-cell-fill": color },
25
+ color
26
+ };
27
+ }
28
+ const pct = require_layout.round((floor + (1 - floor) * t) * 100);
29
+ return {
30
+ style: `--tc-heat:${pct}%`,
31
+ color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`
32
+ };
33
+ }
34
+ };
35
+ }
36
+ Object.defineProperty(exports, "EMPTY", {
37
+ enumerable: true,
38
+ get: function() {
39
+ return EMPTY;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "heatScale", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return heatScale;
46
+ }
47
+ });
48
+
49
+ //# sourceMappingURL=heat-DYsivvDq.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heat-DYsivvDq.cjs","names":["round"],"sources":["../src/charts/heat.ts"],"sourcesContent":["import { round } from '../layout.ts'\nimport type { StyleValue } from '../vnode.ts'\n\n/** The shade of a mark without a value, and the pale end of the single hue. */\nexport const EMPTY = 'var(--tc-heat-empty,var(--tc-grid-color))'\n\n/** A scale that shades marks by value (map regions, treemap tiles). */\nexport interface HeatScale {\n /** Position of a value in the domain, 0…1 (through `mid` for a scale with a middle). */\n position(v: number): number\n /** How a mark at position `t` of the scale is painted: its style and the tooltip swatch. */\n paint(t: number): { style: StyleValue; color: string }\n}\n\n/**\n * The scale from `lo` to `hi`: through the `stops` when there are any (with\n * `mid` on the middle one), else one hue, `--tc-heat-color`, from `floor`\n * (its share at `lo`) to the full color.\n */\nexport function heatScale(\n lo: number,\n hi: number,\n mid: number | null,\n stops: readonly string[] | undefined,\n floor: number,\n): HeatScale {\n return {\n position(v) {\n const t =\n stops && mid !== null && lo < mid && mid < hi\n ? v <= mid\n ? ((v - lo) / (mid - lo)) * 0.5\n : 0.5 + ((v - mid) / (hi - mid)) * 0.5\n : hi > lo\n ? (v - lo) / (hi - lo)\n : v > lo\n ? 1\n : 0\n return Math.min(1, Math.max(0, t))\n },\n paint(t) {\n if (stops) {\n const at = t * (stops.length - 1)\n const k = Math.min(stops.length - 2, Math.floor(at))\n const u = round((at - k) * 100)\n const from = stops[k] as string\n const color =\n u <= 0\n ? from\n : u >= 100\n ? (stops[k + 1] as string)\n : `color-mix(in oklab,${stops[k + 1]} ${u}%,${from})`\n return { style: { '--tc-cell-fill': color }, color }\n }\n const pct = round((floor + (1 - floor) * t) * 100)\n return {\n style: `--tc-heat:${pct}%`,\n color: `color-mix(in oklab,var(--tc-heat-color,var(--tc-color-1)) ${pct}%,${EMPTY})`,\n }\n },\n }\n}\n"],"mappings":";;;AAIA,MAAa,QAAQ;;;;;;AAerB,SAAgB,UACd,IACA,IACA,KACA,OACA,OACW;CACX,OAAO;EACL,SAAS,GAAG;GACV,MAAM,IACJ,SAAS,QAAQ,QAAQ,KAAK,OAAO,MAAM,KACvC,KAAK,OACD,IAAI,OAAO,MAAM,MAAO,KAC1B,MAAQ,IAAI,QAAQ,KAAK,OAAQ,KACnC,KAAK,MACF,IAAI,OAAO,KAAK,MACjB,IAAI,KACF,IACA;GACV,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;EACnC;EACA,MAAM,GAAG;GACP,IAAI,OAAO;IACT,MAAM,KAAK,KAAK,MAAM,SAAS;IAC/B,MAAM,IAAI,KAAK,IAAI,MAAM,SAAS,GAAG,KAAK,MAAM,EAAE,CAAC;IACnD,MAAM,IAAIA,eAAAA,OAAO,KAAK,KAAK,GAAG;IAC9B,MAAM,OAAO,MAAM;IACnB,MAAM,QACJ,KAAK,IACD,OACA,KAAK,MACF,MAAM,IAAI,KACX,sBAAsB,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI,KAAK;IACzD,OAAO;KAAE,OAAO,EAAE,kBAAkB,MAAM;KAAG;IAAM;GACrD;GACA,MAAM,MAAMA,eAAAA,OAAO,SAAS,IAAI,SAAS,KAAK,GAAG;GACjD,OAAO;IACL,OAAO,aAAa,IAAI;IACxB,OAAO,6DAA6D,IAAI,IAAI,MAAM;GACpF;EACF;CACF;AACF"}
@@ -1,7 +1,7 @@
1
- const require_axis = require("./axis-YfAerNBA.cjs");
1
+ const require_axis = require("./axis-BzBkkC5X.cjs");
2
2
  const require_format = require("./format-CAE5ruy6.cjs");
3
3
  const require_layout = require("./layout-Cfg9x1k2.cjs");
4
- const require_cartesian = require("./cartesian-DRSXHxWe.cjs");
4
+ const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
5
5
  const require_extent = require("./extent-DuYDcvM9.cjs");
6
6
  const require_rect = require("./rect-DPr9QRxl.cjs");
7
7
  const require_vnode = require("./vnode-ClAiw28x.cjs");
@@ -244,4 +244,4 @@ Object.defineProperty(exports, "heatmap", {
244
244
  }
245
245
  });
246
246
 
247
- //# sourceMappingURL=heatmap-Dcc_bsoQ.cjs.map
247
+ //# sourceMappingURL=heatmap-Dyzrd4Fd.cjs.map