@tabler/charts 0.2.0 → 0.3.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 (364) hide show
  1. package/README.md +74 -4
  2. package/dist/{annotations-D0YQ0IoA.js → annotations-BQ8l-qHs.js} +3 -3
  3. package/dist/{annotations-D0YQ0IoA.js.map → annotations-BQ8l-qHs.js.map} +1 -1
  4. package/dist/{annotations-DdRdeBUB.cjs → annotations-CpCWA29b.cjs} +3 -3
  5. package/dist/{annotations-DdRdeBUB.cjs.map → annotations-CpCWA29b.cjs.map} +1 -1
  6. package/dist/annotations.cjs +2 -2
  7. package/dist/annotations.js +2 -2
  8. package/dist/{area-d11XePuw.d.ts → area-DEFQm_SQ.d.ts} +2 -2
  9. package/dist/{area-4eRs3c0K.cjs → area-DYdQ_sMV.cjs} +3 -3
  10. package/dist/{area-4eRs3c0K.cjs.map → area-DYdQ_sMV.cjs.map} +1 -1
  11. package/dist/{area-0-L1bG9B.js → area-WdtfqvhX.js} +3 -3
  12. package/dist/{area-0-L1bG9B.js.map → area-WdtfqvhX.js.map} +1 -1
  13. package/dist/{area-CJX9219z.d.cts → area-h_FvieFb.d.cts} +2 -2
  14. package/dist/area.cjs +1 -1
  15. package/dist/area.d.cts +1 -1
  16. package/dist/area.d.ts +1 -1
  17. package/dist/area.js +1 -1
  18. package/dist/axis-MMaVoSWB.js +235 -0
  19. package/dist/axis-MMaVoSWB.js.map +1 -0
  20. package/dist/axis-YfAerNBA.cjs +300 -0
  21. package/dist/axis-YfAerNBA.cjs.map +1 -0
  22. package/dist/{bar-BNZ3GhIw.js → bar-BOcRcArc.js} +74 -56
  23. package/dist/bar-BOcRcArc.js.map +1 -0
  24. package/dist/{bar-Da6dE_nI.cjs → bar-CVkOJ7WA.cjs} +76 -58
  25. package/dist/bar-CVkOJ7WA.cjs.map +1 -0
  26. package/dist/{bar-B5n2oq9-.js → bar-CgpC2EpX.js} +2 -2
  27. package/dist/{bar-B5n2oq9-.js.map → bar-CgpC2EpX.js.map} +1 -1
  28. package/dist/{bar-XwzM6Pb0.d.ts → bar-D9B_arKf.d.ts} +1 -1
  29. package/dist/{bar-BDLR4p9c.d.cts → bar-DZCQ-kyf.d.cts} +2 -2
  30. package/dist/{bar-LYIF8MEz.cjs → bar-wVykm1us.cjs} +2 -2
  31. package/dist/{bar-LYIF8MEz.cjs.map → bar-wVykm1us.cjs.map} +1 -1
  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 +106 -0
  37. package/dist/calendar-BXgIX5H1.js +502 -0
  38. package/dist/calendar-BXgIX5H1.js.map +1 -0
  39. package/dist/calendar-Bq3vFzPl.d.ts +106 -0
  40. package/dist/calendar-DAFXjV99.cjs +507 -0
  41. package/dist/calendar-DAFXjV99.cjs.map +1 -0
  42. package/dist/calendar.cjs +3 -0
  43. package/dist/calendar.d.cts +3 -0
  44. package/dist/calendar.d.ts +3 -0
  45. package/dist/calendar.js +1 -0
  46. package/dist/{candlestick-D0xKkdqd.d.ts → candlestick-B3WcLzph.d.ts} +1 -1
  47. package/dist/{candlestick-Dq7qp-F0.d.cts → candlestick-BcomxeVG.d.cts} +1 -1
  48. package/dist/{candlestick-BHQkQfxH.js → candlestick-BtT9glp9.js} +16 -14
  49. package/dist/{candlestick-BHQkQfxH.js.map → candlestick-BtT9glp9.js.map} +1 -1
  50. package/dist/{candlestick-CYCQXgky.cjs → candlestick-CSmRuZ4v.cjs} +16 -14
  51. package/dist/{candlestick-CYCQXgky.cjs.map → candlestick-CSmRuZ4v.cjs.map} +1 -1
  52. package/dist/candlestick.cjs +3 -3
  53. package/dist/candlestick.d.cts +1 -1
  54. package/dist/candlestick.d.ts +1 -1
  55. package/dist/candlestick.js +3 -3
  56. package/dist/{cartesian-CI2x6N7N.js → cartesian-BrPqb5Qn.js} +122 -248
  57. package/dist/cartesian-BrPqb5Qn.js.map +1 -0
  58. package/dist/{cartesian-DV02PsBe.cjs → cartesian-DRSXHxWe.cjs} +146 -308
  59. package/dist/cartesian-DRSXHxWe.cjs.map +1 -0
  60. package/dist/{chart-DWn9v6qw.js → chart-B6TTY4Kr.js} +94 -62
  61. package/dist/chart-B6TTY4Kr.js.map +1 -0
  62. package/dist/{chart-QilhWP8Z.d.ts → chart-CYrrUCi3.d.ts} +193 -56
  63. package/dist/{chart-kqFMEwDo.d.cts → chart-CbPzP5Dp.d.cts} +193 -56
  64. package/dist/{chart-e2VqomCI.cjs → chart-D_lyOy-M.cjs} +106 -68
  65. package/dist/chart-D_lyOy-M.cjs.map +1 -0
  66. package/dist/{core-PAX5ogLk.d.cts → core-9BnLEW4K.d.cts} +24 -20
  67. package/dist/{core-DRUCk67j.d.ts → core-C3qEppSm.d.ts} +7 -6
  68. package/dist/{core-BKRQvPAT.js → core-CQ0FaJ4G.js} +112 -65
  69. package/dist/core-CQ0FaJ4G.js.map +1 -0
  70. package/dist/{core-DIOC61up.cjs → core-D2PSked3.cjs} +113 -66
  71. package/dist/core-D2PSked3.cjs.map +1 -0
  72. package/dist/core.cjs +41 -31
  73. package/dist/core.d.cts +20 -17
  74. package/dist/core.d.ts +20 -17
  75. package/dist/core.js +27 -23
  76. package/dist/{dates-C2RzY3rE.js → dates-DLe2Ww64.js} +2 -2
  77. package/dist/{dates-C2RzY3rE.js.map → dates-DLe2Ww64.js.map} +1 -1
  78. package/dist/{dates-DurEr9WT.cjs → dates-DerXTb1J.cjs} +2 -2
  79. package/dist/{dates-DurEr9WT.cjs.map → dates-DerXTb1J.cjs.map} +1 -1
  80. package/dist/decimate.cjs +1 -1
  81. package/dist/decimate.js +1 -1
  82. package/dist/{dom-D_g13XWY.cjs → dom-C33zvtPo.cjs} +3 -7
  83. package/dist/dom-C33zvtPo.cjs.map +1 -0
  84. package/dist/{dom-CuceR8gt.js → dom-CTse6Rvd.js} +3 -7
  85. package/dist/dom-CTse6Rvd.js.map +1 -0
  86. package/dist/{export-chart-mYgEfK-L.cjs → export-chart-CPtXmZvi.cjs} +17 -12
  87. package/dist/export-chart-CPtXmZvi.cjs.map +1 -0
  88. package/dist/{export-chart-83UYH48t.js → export-chart-DoeiAyR2.js} +17 -12
  89. package/dist/export-chart-DoeiAyR2.js.map +1 -0
  90. package/dist/export.cjs +2 -2
  91. package/dist/export.d.cts +1 -1
  92. package/dist/export.d.ts +1 -1
  93. package/dist/export.js +2 -2
  94. package/dist/{fade-GGxcBdss.js → fade-CDrQjnDz.js} +56 -78
  95. package/dist/fade-CDrQjnDz.js.map +1 -0
  96. package/dist/{fade-DVTkhrFU.cjs → fade-CRqcKMWY.cjs} +56 -78
  97. package/dist/fade-CRqcKMWY.cjs.map +1 -0
  98. package/dist/{features-BMxkqCyS.js → features-B55rwpQC.js} +4 -2
  99. package/dist/features-B55rwpQC.js.map +1 -0
  100. package/dist/{features-DCXEvoya.cjs → features-DEDP5CEQ.cjs} +9 -1
  101. package/dist/features-DEDP5CEQ.cjs.map +1 -0
  102. package/dist/fit-BPyPRnsK.js +16 -0
  103. package/dist/fit-BPyPRnsK.js.map +1 -0
  104. package/dist/fit-D4MIIQQz.cjs +21 -0
  105. package/dist/fit-D4MIIQQz.cjs.map +1 -0
  106. package/dist/funnel-BdcfUkb5.d.ts +50 -0
  107. package/dist/funnel-CFEEulw_.cjs +244 -0
  108. package/dist/funnel-CFEEulw_.cjs.map +1 -0
  109. package/dist/funnel-CYCv8cq2.js +239 -0
  110. package/dist/funnel-CYCv8cq2.js.map +1 -0
  111. package/dist/funnel-CarOh8w_.d.cts +50 -0
  112. package/dist/funnel.cjs +3 -0
  113. package/dist/funnel.d.cts +3 -0
  114. package/dist/funnel.d.ts +3 -0
  115. package/dist/funnel.js +1 -0
  116. package/dist/{gauge-DXkjXNCD.cjs → gauge-6HfDcLMJ.cjs} +28 -28
  117. package/dist/gauge-6HfDcLMJ.cjs.map +1 -0
  118. package/dist/{gauge-ts0kqN1-.js → gauge-DiTk5aWO.js} +28 -28
  119. package/dist/gauge-DiTk5aWO.js.map +1 -0
  120. package/dist/{gauge-BSist7My.d.cts → gauge-Ds9k1UV2.d.cts} +1 -1
  121. package/dist/{gauge-0VJuAHWF.d.ts → gauge-Zy25jfps.d.ts} +1 -1
  122. package/dist/gauge.cjs +1 -1
  123. package/dist/gauge.d.cts +1 -1
  124. package/dist/gauge.d.ts +1 -1
  125. package/dist/gauge.js +1 -1
  126. package/dist/{heatmap-19BGJTKF.js → heatmap-C1v8bwpq.js} +35 -33
  127. package/dist/heatmap-C1v8bwpq.js.map +1 -0
  128. package/dist/{heatmap-Dp_oyEe0.d.cts → heatmap-CJ-0dfhJ.d.cts} +1 -1
  129. package/dist/{heatmap-CXhlrLTl.cjs → heatmap-Dcc_bsoQ.cjs} +39 -37
  130. package/dist/heatmap-Dcc_bsoQ.cjs.map +1 -0
  131. package/dist/{heatmap-59lmClj9.d.ts → heatmap-Jp5sHRTo.d.ts} +1 -1
  132. package/dist/heatmap.cjs +1 -1
  133. package/dist/heatmap.d.cts +1 -1
  134. package/dist/heatmap.d.ts +1 -1
  135. package/dist/heatmap.js +1 -1
  136. package/dist/{hydrate-OA6R2_Pn.js → hydrate-BB3MlR36.js} +2 -2
  137. package/dist/{hydrate-OA6R2_Pn.js.map → hydrate-BB3MlR36.js.map} +1 -1
  138. package/dist/{hydrate-CmN1k8Mo.cjs → hydrate-m0I5m6ue.cjs} +2 -2
  139. package/dist/{hydrate-CmN1k8Mo.cjs.map → hydrate-m0I5m6ue.cjs.map} +1 -1
  140. package/dist/hydrate.cjs +2 -2
  141. package/dist/hydrate.js +2 -2
  142. package/dist/index.cjs +55 -42
  143. package/dist/index.cjs.map +1 -1
  144. package/dist/index.d.cts +21 -18
  145. package/dist/index.d.ts +21 -18
  146. package/dist/index.js +41 -34
  147. package/dist/index.js.map +1 -1
  148. package/dist/interaction-DXYSjgnP.cjs +32 -0
  149. package/dist/interaction-DXYSjgnP.cjs.map +1 -0
  150. package/dist/interaction-En1KlwFO.js +21 -0
  151. package/dist/interaction-En1KlwFO.js.map +1 -0
  152. package/dist/{layout-JY2aR-yE.cjs → layout-Cfg9x1k2.cjs} +32 -1
  153. package/dist/layout-Cfg9x1k2.cjs.map +1 -0
  154. package/dist/{layout-DmrrLjwN.js → layout-DqAte3H8.js} +27 -2
  155. package/dist/layout-DqAte3H8.js.map +1 -0
  156. package/dist/{line-DtSh7HQU.d.ts → line-Bpr5uVLQ.d.ts} +1 -1
  157. package/dist/{line-DO66LtwH.js → line-CxR4tg1Q.js} +46 -34
  158. package/dist/line-CxR4tg1Q.js.map +1 -0
  159. package/dist/{line-Dbt6KFRK.cjs → line-YiCuhVMI.cjs} +46 -34
  160. package/dist/line-YiCuhVMI.cjs.map +1 -0
  161. package/dist/{line-_rNdeKmS.d.cts → line-vyWO030v.d.cts} +2 -3
  162. package/dist/line.cjs +3 -3
  163. package/dist/line.d.cts +1 -1
  164. package/dist/line.d.ts +1 -1
  165. package/dist/line.js +3 -3
  166. package/dist/log.cjs +1 -1
  167. package/dist/log.js +1 -1
  168. package/dist/map-49FcfdmJ.d.cts +156 -0
  169. package/dist/map-BMC61J-P.d.ts +156 -0
  170. package/dist/map-BqrZ80vT.cjs +818 -0
  171. package/dist/map-BqrZ80vT.cjs.map +1 -0
  172. package/dist/map-C15NC7kW.js +807 -0
  173. package/dist/map-C15NC7kW.js.map +1 -0
  174. package/dist/map.cjs +4 -0
  175. package/dist/map.d.cts +3 -0
  176. package/dist/map.d.ts +3 -0
  177. package/dist/map.js +1 -0
  178. package/dist/maps/world.cjs +875 -0
  179. package/dist/maps/world.cjs.map +1 -0
  180. package/dist/maps/world.d.cts +2 -0
  181. package/dist/maps/world.d.ts +2 -0
  182. package/dist/maps/world.js +874 -0
  183. package/dist/maps/world.js.map +1 -0
  184. package/dist/{morph-9_LJL0ra.cjs → morph-3I1Nf_tR.cjs} +2 -2
  185. package/dist/{morph-9_LJL0ra.cjs.map → morph-3I1Nf_tR.cjs.map} +1 -1
  186. package/dist/{morph-DnRxuwR-.js → morph-GfBab-b3.js} +2 -2
  187. package/dist/{morph-DnRxuwR-.js.map → morph-GfBab-b3.js.map} +1 -1
  188. package/dist/morph.cjs +2 -2
  189. package/dist/morph.js +2 -2
  190. package/dist/{others-J7NCAMA0.js → others-DBIGE6jr.js} +11 -3
  191. package/dist/others-DBIGE6jr.js.map +1 -0
  192. package/dist/others-DBO4Kjwl.d.ts +29 -0
  193. package/dist/{others-DWdK7vKp.cjs → others-WfjCsjqT.cjs} +14 -6
  194. package/dist/others-WfjCsjqT.cjs.map +1 -0
  195. package/dist/others-ls5eKtZ4.d.cts +31 -0
  196. package/dist/{parliament-Cru4IcuM.js → parliament-BKN6ikBJ.js} +30 -29
  197. package/dist/parliament-BKN6ikBJ.js.map +1 -0
  198. package/dist/{parliament-CgsVnWEe.d.cts → parliament-C7V8UJj1.d.cts} +1 -1
  199. package/dist/{parliament-CLCI7tUO.d.ts → parliament-Cz9n_DoK.d.ts} +1 -1
  200. package/dist/{parliament-x5hcFaQ3.cjs → parliament-DhxAaIZ3.cjs} +30 -29
  201. package/dist/parliament-DhxAaIZ3.cjs.map +1 -0
  202. package/dist/parliament.cjs +1 -1
  203. package/dist/parliament.d.cts +1 -1
  204. package/dist/parliament.d.ts +1 -1
  205. package/dist/parliament.js +1 -1
  206. package/dist/{patterns-CufKZYhm.js → patterns-BMUINoka.js} +2 -2
  207. package/dist/{patterns-CufKZYhm.js.map → patterns-BMUINoka.js.map} +1 -1
  208. package/dist/{patterns-D3-wQagb.cjs → patterns-Dw7OMD_2.cjs} +2 -2
  209. package/dist/{patterns-D3-wQagb.cjs.map → patterns-Dw7OMD_2.cjs.map} +1 -1
  210. package/dist/patterns.cjs +2 -2
  211. package/dist/patterns.d.cts +1 -1
  212. package/dist/patterns.d.ts +1 -1
  213. package/dist/patterns.js +2 -2
  214. package/dist/{percentage-bar-ybNS3goo.cjs → percentage-bar-BChkTRoz.cjs} +37 -35
  215. package/dist/percentage-bar-BChkTRoz.cjs.map +1 -0
  216. package/dist/{percentage-bar-B6tNOqNn.js → percentage-bar-CaInxrL8.js} +37 -35
  217. package/dist/percentage-bar-CaInxrL8.js.map +1 -0
  218. package/dist/{percentage-bar-tepMr7Hd.d.cts → percentage-bar-R1--2grK.d.cts} +10 -14
  219. package/dist/{percentage-bar-nhTeakD_.d.ts → percentage-bar-cSeiLdwU.d.ts} +10 -14
  220. package/dist/percentage-bar.cjs +1 -1
  221. package/dist/percentage-bar.d.cts +1 -1
  222. package/dist/percentage-bar.d.ts +1 -1
  223. package/dist/percentage-bar.js +1 -1
  224. package/dist/{pie-CFptILSm.d.ts → pie-BQQkvy1N.d.ts} +7 -13
  225. package/dist/{pie-CVsc-6qD.js → pie-Bd8wyrtY.js} +45 -44
  226. package/dist/pie-Bd8wyrtY.js.map +1 -0
  227. package/dist/{pie-BpjvSPnz.cjs → pie-BseZlCgP.cjs} +45 -44
  228. package/dist/pie-BseZlCgP.cjs.map +1 -0
  229. package/dist/{pie-BXg2gNpb.d.cts → pie-vD5-g8je.d.cts} +7 -13
  230. package/dist/pie.cjs +1 -1
  231. package/dist/pie.d.cts +1 -1
  232. package/dist/pie.d.ts +1 -1
  233. package/dist/pie.js +1 -1
  234. package/dist/{point-shapes--_gmdTyK.cjs → point-shapes-BRawRM78.cjs} +23 -22
  235. package/dist/point-shapes-BRawRM78.cjs.map +1 -0
  236. package/dist/{point-shapes-DD2Ektzm.js → point-shapes-DI6GhcI7.js} +18 -23
  237. package/dist/point-shapes-DI6GhcI7.js.map +1 -0
  238. package/dist/point-shapes.cjs +6 -4
  239. package/dist/point-shapes.cjs.map +1 -1
  240. package/dist/point-shapes.d.cts +2 -2
  241. package/dist/point-shapes.d.ts +2 -2
  242. package/dist/point-shapes.js +7 -5
  243. package/dist/point-shapes.js.map +1 -1
  244. package/dist/{radar-D1-lItDy.d.cts → radar-7I6hsY_h.d.cts} +1 -1
  245. package/dist/{radar-BR-mumDd.js → radar-D6XqkFWQ.js} +21 -22
  246. package/dist/radar-D6XqkFWQ.js.map +1 -0
  247. package/dist/{radar-HPDrIdzc.cjs → radar-DjISDnSf.cjs} +22 -23
  248. package/dist/radar-DjISDnSf.cjs.map +1 -0
  249. package/dist/{radar-BC9Skgpj.d.ts → radar-vLxilcr4.d.ts} +1 -1
  250. package/dist/radar.cjs +1 -1
  251. package/dist/radar.d.cts +1 -1
  252. package/dist/radar.d.ts +1 -1
  253. package/dist/radar.js +1 -1
  254. package/dist/{rect-DSVmUZrD.js → rect-CZTNvMlf.js} +2 -2
  255. package/dist/{rect-DSVmUZrD.js.map → rect-CZTNvMlf.js.map} +1 -1
  256. package/dist/{rect-D6VhynBM.cjs → rect-DPr9QRxl.cjs} +2 -2
  257. package/dist/{rect-D6VhynBM.cjs.map → rect-DPr9QRxl.cjs.map} +1 -1
  258. package/dist/{sankey-fCoo1cpz.cjs → sankey-0CSp_Er9.cjs} +72 -71
  259. package/dist/sankey-0CSp_Er9.cjs.map +1 -0
  260. package/dist/{sankey-D_v7KxnJ.d.ts → sankey-7As41Fo4.d.ts} +1 -1
  261. package/dist/{sankey-D6JeZfK5.js → sankey-Dp4CuLVe.js} +72 -71
  262. package/dist/sankey-Dp4CuLVe.js.map +1 -0
  263. package/dist/{sankey-Dk7jUt8x.d.cts → sankey-DqiuxUx7.d.cts} +1 -1
  264. package/dist/sankey.cjs +1 -1
  265. package/dist/sankey.d.cts +1 -1
  266. package/dist/sankey.d.ts +1 -1
  267. package/dist/sankey.js +1 -1
  268. package/dist/{scatter-CXEsioOJ.d.ts → scatter-BXkXGgM_.d.ts} +7 -1
  269. package/dist/{scatter-DVqB_fP9.cjs → scatter-Bwkblr4L.cjs} +40 -38
  270. package/dist/scatter-Bwkblr4L.cjs.map +1 -0
  271. package/dist/{scatter-C0TWjFpW.js → scatter-DCMAtt5L.js} +38 -36
  272. package/dist/scatter-DCMAtt5L.js.map +1 -0
  273. package/dist/{scatter-DZeEIfyo.d.cts → scatter-DL0zAV09.d.cts} +7 -1
  274. package/dist/scatter.cjs +1 -1
  275. package/dist/scatter.d.cts +1 -1
  276. package/dist/scatter.d.ts +1 -1
  277. package/dist/scatter.js +1 -1
  278. package/dist/{sparkline-cbvRkWqS.d.ts → sparkline-BElUSd0r.d.ts} +1 -1
  279. package/dist/{sparkline-B39NA0Mi.cjs → sparkline-BMSuEPHP.cjs} +13 -15
  280. package/dist/sparkline-BMSuEPHP.cjs.map +1 -0
  281. package/dist/{sparkline-XO_TqCNP.js → sparkline-NDmq90kP.js} +13 -15
  282. package/dist/sparkline-NDmq90kP.js.map +1 -0
  283. package/dist/{sparkline-DAP6jtzw.d.cts → sparkline-RYly7bR0.d.cts} +1 -1
  284. package/dist/sparkline.cjs +1 -1
  285. package/dist/sparkline.d.cts +1 -1
  286. package/dist/sparkline.d.ts +1 -1
  287. package/dist/sparkline.js +1 -1
  288. package/dist/{stack-BgPzoQmv.cjs → stack-BO4624CY.cjs} +2 -2
  289. package/dist/{stack-BgPzoQmv.cjs.map → stack-BO4624CY.cjs.map} +1 -1
  290. package/dist/{stack-Dagxq7l2.d.cts → stack-BTWYIwLO.d.cts} +1 -1
  291. package/dist/{stack-2H2Gfs1Q.js → stack-jVKvg2x_.js} +2 -2
  292. package/dist/{stack-2H2Gfs1Q.js.map → stack-jVKvg2x_.js.map} +1 -1
  293. package/dist/style.css +1 -1
  294. package/dist/{time-axis-BjZ1bYTK.cjs → time-axis-B3VekUfX.cjs} +4 -3
  295. package/dist/{time-axis-BjZ1bYTK.cjs.map → time-axis-B3VekUfX.cjs.map} +1 -1
  296. package/dist/{time-axis-FLONo54E.js → time-axis-CLjqOakA.js} +3 -2
  297. package/dist/{time-axis-FLONo54E.js.map → time-axis-CLjqOakA.js.map} +1 -1
  298. package/dist/time.cjs +3 -3
  299. package/dist/time.js +3 -3
  300. package/dist/{treemap-BAkhmVQc.d.cts → treemap-25vHO_UK.d.cts} +12 -2
  301. package/dist/{treemap-BNpxFBao.d.ts → treemap-BCXUbixd.d.ts} +12 -2
  302. package/dist/{treemap-CQdavQ9u.js → treemap-C4glsx-g.js} +20 -25
  303. package/dist/treemap-C4glsx-g.js.map +1 -0
  304. package/dist/{treemap-BWpEUlDh.cjs → treemap-CZk8kKFD.cjs} +21 -26
  305. package/dist/treemap-CZk8kKFD.cjs.map +1 -0
  306. package/dist/treemap.cjs +1 -1
  307. package/dist/treemap.d.cts +1 -1
  308. package/dist/treemap.d.ts +1 -1
  309. package/dist/treemap.js +1 -1
  310. package/dist/{value-labels-BBuSi4i0.js → value-labels-C7GrhOXJ.js} +25 -5
  311. package/dist/value-labels-C7GrhOXJ.js.map +1 -0
  312. package/dist/{value-labels-BV9keAuL.cjs → value-labels-DzaKIWKp.cjs} +25 -5
  313. package/dist/value-labels-DzaKIWKp.cjs.map +1 -0
  314. package/dist/value-labels.cjs +2 -2
  315. package/dist/value-labels.d.cts +1 -1
  316. package/dist/value-labels.d.ts +1 -1
  317. package/dist/value-labels.js +2 -2
  318. package/package.json +93 -233
  319. package/dist/bar-BNZ3GhIw.js.map +0 -1
  320. package/dist/bar-Da6dE_nI.cjs.map +0 -1
  321. package/dist/cartesian-CI2x6N7N.js.map +0 -1
  322. package/dist/cartesian-DV02PsBe.cjs.map +0 -1
  323. package/dist/chart-DWn9v6qw.js.map +0 -1
  324. package/dist/chart-e2VqomCI.cjs.map +0 -1
  325. package/dist/core-BKRQvPAT.js.map +0 -1
  326. package/dist/core-DIOC61up.cjs.map +0 -1
  327. package/dist/dom-CuceR8gt.js.map +0 -1
  328. package/dist/dom-D_g13XWY.cjs.map +0 -1
  329. package/dist/export-chart-83UYH48t.js.map +0 -1
  330. package/dist/export-chart-mYgEfK-L.cjs.map +0 -1
  331. package/dist/fade-DVTkhrFU.cjs.map +0 -1
  332. package/dist/fade-GGxcBdss.js.map +0 -1
  333. package/dist/features-BMxkqCyS.js.map +0 -1
  334. package/dist/features-DCXEvoya.cjs.map +0 -1
  335. package/dist/gauge-DXkjXNCD.cjs.map +0 -1
  336. package/dist/gauge-ts0kqN1-.js.map +0 -1
  337. package/dist/heatmap-19BGJTKF.js.map +0 -1
  338. package/dist/heatmap-CXhlrLTl.cjs.map +0 -1
  339. package/dist/layout-DmrrLjwN.js.map +0 -1
  340. package/dist/layout-JY2aR-yE.cjs.map +0 -1
  341. package/dist/line-DO66LtwH.js.map +0 -1
  342. package/dist/line-Dbt6KFRK.cjs.map +0 -1
  343. package/dist/others-DWdK7vKp.cjs.map +0 -1
  344. package/dist/others-J7NCAMA0.js.map +0 -1
  345. package/dist/parliament-Cru4IcuM.js.map +0 -1
  346. package/dist/parliament-x5hcFaQ3.cjs.map +0 -1
  347. package/dist/percentage-bar-B6tNOqNn.js.map +0 -1
  348. package/dist/percentage-bar-ybNS3goo.cjs.map +0 -1
  349. package/dist/pie-BpjvSPnz.cjs.map +0 -1
  350. package/dist/pie-CVsc-6qD.js.map +0 -1
  351. package/dist/point-shapes--_gmdTyK.cjs.map +0 -1
  352. package/dist/point-shapes-DD2Ektzm.js.map +0 -1
  353. package/dist/radar-BR-mumDd.js.map +0 -1
  354. package/dist/radar-HPDrIdzc.cjs.map +0 -1
  355. package/dist/sankey-D6JeZfK5.js.map +0 -1
  356. package/dist/sankey-fCoo1cpz.cjs.map +0 -1
  357. package/dist/scatter-C0TWjFpW.js.map +0 -1
  358. package/dist/scatter-DVqB_fP9.cjs.map +0 -1
  359. package/dist/sparkline-B39NA0Mi.cjs.map +0 -1
  360. package/dist/sparkline-XO_TqCNP.js.map +0 -1
  361. package/dist/treemap-BWpEUlDh.cjs.map +0 -1
  362. package/dist/treemap-CQdavQ9u.js.map +0 -1
  363. package/dist/value-labels-BBuSi4i0.js.map +0 -1
  364. package/dist/value-labels-BV9keAuL.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-chart-DoeiAyR2.js","names":[],"sources":["../src/export-chart.ts"],"sourcesContent":["/**\n * Export a rendered chart as a standalone SVG or an image\n * (`exportSVG()`, `exportImage()`, `downloadChart()` of `@tabler/charts/export`).\n *\n * Charts are styled by CSS, so the export copies the computed styles of\n * every mark into the SVG: the file looks the same anywhere, without the\n * stylesheet or the page's custom properties. Browser only.\n *\n * Kept free of side effects, so `@tabler/charts` can re-export the functions\n * without carrying them into every bundle: the `/export` entry registers the\n * `download` menu's saver on top.\n */\nimport type { Chart } from './chart.ts'\nimport { round } from './layout.ts'\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\n\nexport interface ExportOptions {\n /**\n * Background color, `'auto'` for the chart's surface (`--tc-surface`), or\n * `false` for none (transparent). Defaults to `'auto'`.\n */\n background?: string | false\n /** Draw the legend into the image, as the page shows it. Defaults to `true`. */\n legend?: boolean\n}\n\nexport interface ImageOptions extends ExportOptions {\n /** Image type. Defaults to `'image/png'`. */\n type?: 'image/png' | 'image/jpeg' | 'image/webp'\n /** Pixels per chart pixel. Defaults to `2`. */\n scale?: number\n /** Quality of lossy types, `0…1`. */\n quality?: number\n}\n\nexport interface DownloadOptions extends ImageOptions {\n /** File name without the extension. Defaults to the chart's title, or `chart`. */\n filename?: string\n /** File format. Defaults to `'png'`. */\n format?: 'svg' | 'png' | 'jpeg' | 'webp'\n}\n\n/** A chart, its container, or its root `<svg>`. */\nexport type ExportTarget = Chart<object> | Element\n\n/** Properties copied from the computed style, with the values they can be left out at. */\nconst SHAPE: Record<string, string> = {\n fill: 'rgb(0, 0, 0)',\n 'fill-opacity': '1',\n stroke: 'none',\n 'stroke-width': '1px',\n 'stroke-opacity': '1',\n 'stroke-dasharray': 'none',\n 'stroke-dashoffset': '0px',\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n 'paint-order': 'normal',\n 'shape-rendering': 'auto',\n 'vector-effect': 'none',\n opacity: '1',\n visibility: 'visible',\n}\nconst TEXT: Record<string, string> = {\n ...SHAPE,\n 'font-family': '',\n 'font-size': '',\n 'font-weight': '400',\n 'font-style': 'normal',\n 'font-variant-numeric': 'normal',\n 'letter-spacing': 'normal',\n}\nconst STOP: Record<string, string> = { 'stop-color': '', 'stop-opacity': '1' }\nconst GROUP: Record<string, string> = { opacity: '1' }\nconst SHAPES = new Set(['path', 'line', 'rect', 'circle', 'ellipse', 'polygon', 'polyline'])\n\nfunction rootOf(target: ExportTarget): SVGSVGElement {\n const el = 'element' in target && !(target instanceof Element) ? target.element : target\n const svg = el.localName === 'svg' ? el : el.querySelector(':scope > svg.tc-chart')\n if (!svg) throw new Error('@tabler/charts: no rendered chart to export.')\n return svg as SVGSVGElement\n}\n\n/** A computed transform as an SVG `transform` attribute, around its origin. */\nfunction transformOf(style: CSSStyleDeclaration): string | undefined {\n const value = style.transform\n if (!value || value === 'none') return undefined\n // Browsers report a matrix; SVG takes the same functions without units.\n const svg = value.replace(/px/g, '')\n if (svg.startsWith('translate')) return svg\n const [ox = 0, oy = 0] = (style.transformOrigin || '0 0').split(' ').map(Number.parseFloat)\n return ox || oy ? `translate(${ox} ${oy}) ${svg} translate(${-ox} ${-oy})` : svg\n}\n\n/** Copy the computed look of `live` onto its clone, recursively. */\nfunction inline(live: Element, copy: Element): boolean {\n const style = getComputedStyle(live)\n if (style.display === 'none') return false\n const tag = live.localName\n const props = tag === 'text' ? TEXT : tag === 'stop' ? STOP : SHAPES.has(tag) ? SHAPE : GROUP\n const declarations: string[] = []\n for (const name in props) {\n const value = style.getPropertyValue(name)\n if (value && value !== props[name]) declarations.push(`${name}:${value}`)\n }\n copy.removeAttribute('style')\n if (declarations.length) copy.setAttribute('style', declarations.join(';'))\n const transform = transformOf(style)\n if (transform) copy.setAttribute('transform', transform)\n\n const liveChildren = Array.from(live.children)\n const copies = Array.from(copy.children)\n liveChildren.forEach((child, i) => {\n const twin = copies[i] as Element\n if (child.classList.contains('tc-hover-layer') || !inline(child, twin)) twin.remove()\n })\n return true\n}\n\n/**\n * The legend as the page lays it out: every entry at its place relative to\n * the legend box, with a swatch (hollow when hidden) and its name.\n */\nfunction legendLayer(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/**\n * Save the chart as a file: PNG by default, or SVG, JPEG or WebP.\n *\n * ```ts\n * button.onclick = () => downloadChart(chart, { format: 'svg', filename: 'sales' })\n * ```\n */\nexport async function downloadChart(\n target: ExportTarget,\n options: DownloadOptions = {},\n): Promise<void> {\n const { format = 'png' } = options\n const svg = rootOf(target)\n const blob =\n format === 'svg'\n ? new Blob([exportSVG(target, options)], { type: 'image/svg+xml' })\n : await exportImage(target, { ...options, type: `image/${format}` })\n const name = (options.filename ?? svg.getAttribute('aria-label') ?? 'chart')\n .replace(/[\\\\/:*?\"<>|]+/g, '')\n .trim()\n const link = svg.ownerDocument.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.download = `${name || 'chart'}.${format === 'jpeg' ? 'jpg' : format}`\n link.click()\n // Give the browser a moment to start the download before the URL goes.\n setTimeout(() => UR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module" });
2
- const require_export_chart = require("./export-chart-mYgEfK-L.cjs");
2
+ const require_export_chart = require("./export-chart-CPtXmZvi.cjs");
3
3
  // src/export.ts
4
4
  /**
5
5
  * Standalone entry: `import { exportSVG, exportImage, downloadChart } from '@tabler/charts/export'`
@@ -8,7 +8,7 @@ const require_export_chart = require("./export-chart-mYgEfK-L.cjs");
8
8
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
9
9
  * plugin installed on the core.
10
10
  */
11
- require("./features-DCXEvoya.cjs").register({ export: require_export_chart.downloadChart });
11
+ require("./features-DEDP5CEQ.cjs").register({ export: require_export_chart.downloadChart });
12
12
  exports.downloadChart = require_export_chart.downloadChart;
13
13
  exports.exportImage = require_export_chart.exportImage;
14
14
  exports.exportSVG = require_export_chart.exportSVG;
package/dist/export.d.cts CHANGED
@@ -5,5 +5,5 @@
5
5
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
6
6
  * plugin installed on the core.
7
7
  */
8
- import { B as DownloadOptions, G as exportImage, H as ExportTarget, K as exportSVG, U as ImageOptions, V as ExportOptions, W as downloadChart } from "./chart-kqFMEwDo.cjs";
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
9
  export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
package/dist/export.d.ts CHANGED
@@ -5,5 +5,5 @@
5
5
  * `Chart` of `@tabler/charts`, which has the `download()` plugin, or with the
6
6
  * plugin installed on the core.
7
7
  */
8
- import { B as downloadChart, H as exportSVG, I as DownloadOptions, L as ExportOptions, R as ExportTarget, V as exportImage, z as ImageOptions } from "./chart-QilhWP8Z.js";
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
9
  export { type DownloadOptions, type ExportOptions, type ExportTarget, type ImageOptions, downloadChart, exportImage, exportSVG };
package/dist/export.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-chart-83UYH48t.js";
2
- import { i as register } from "./features-BMxkqCyS.js";
1
+ import { n as exportImage, r as exportSVG, t as downloadChart } from "./export-chart-DoeiAyR2.js";
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'`
@@ -1,99 +1,68 @@
1
1
  import { t as h } from "./vnode-_EMUqysL.js";
2
2
  // src/shapes/path.ts
3
- /** Accumulates SVG path commands with rounded coordinates. */
4
- var PathBuilder = class {
5
- d = "";
6
- #k;
7
- constructor(precision) {
8
- this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)));
9
- }
10
- #n(value) {
11
- const rounded = Math.round(value * this.#k) / this.#k;
12
- return String(rounded === 0 ? 0 : rounded);
13
- }
14
- #xy(x, y) {
15
- return `${this.#n(x)},${this.#n(y)}`;
16
- }
17
- moveTo(x, y) {
18
- this.d += `M${this.#xy(x, y)}`;
19
- }
20
- lineTo(x, y) {
21
- this.d += `L${this.#xy(x, y)}`;
22
- }
23
- curveTo(x1, y1, x2, y2, x, y) {
24
- this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`;
25
- }
26
- close() {
27
- this.d += "Z";
28
- }
29
- };
3
+ function pair(precision) {
4
+ const k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)));
5
+ const n = (value) => Math.round(value * k) / k || 0;
6
+ return (x, y) => `${n(x)},${n(y)}`;
7
+ }
8
+ /** Monotone tangents break on zero-length segments, so coincident points are dropped. */
9
+ const prepare = (input, curve) => curve === "monotone" ? dedupe(input) : input;
30
10
  /**
31
- * Emit `points` with a curve. The first point is a `moveTo` when `move` is
32
- * true, otherwise a `lineTo` (continuing an existing subpath). Returns the
33
- * number of points drawn.
11
+ * Path commands through `points` with a curve. The first point is a move
12
+ * when `move` is true, otherwise a line (continuing an existing subpath).
34
13
  */
35
- function emit(path, input, curve, move) {
36
- const points = curve === "monotone" ? dedupe(input) : input;
14
+ function emit(xy, points, curve, move) {
37
15
  const first = points[0];
38
- if (!first) return 0;
39
- if (move) path.moveTo(first[0], first[1]);
40
- else path.lineTo(first[0], first[1]);
41
- switch (curve) {
42
- case "monotone":
43
- monotone(path, points);
44
- break;
45
- case "step":
46
- step(path, points, .5);
47
- break;
48
- case "step-before":
49
- step(path, points, 0);
50
- break;
51
- case "step-after":
52
- step(path, points, 1);
53
- break;
54
- default: for (let i = 1; i < points.length; i++) {
55
- const p = points[i];
56
- path.lineTo(p[0], p[1]);
57
- }
16
+ if (!first) return "";
17
+ const start = (move ? "M" : "L") + xy(first[0], first[1]);
18
+ if (curve === "monotone") return start + monotone(xy, points);
19
+ const t = STEPS[curve];
20
+ if (t !== void 0) return start + step(xy, points, t);
21
+ let d = start;
22
+ for (let i = 1; i < points.length; i++) {
23
+ const p = points[i];
24
+ d += `L${xy(p[0], p[1])}`;
58
25
  }
59
- return points.length;
26
+ return d;
60
27
  }
28
+ /** Where a step curve turns between two points, as a share of the way. */
29
+ const STEPS = {
30
+ step: .5,
31
+ "step-before": 0,
32
+ "step-after": 1
33
+ };
61
34
  function dedupe(points) {
62
35
  return points.filter((p, i) => {
63
36
  const prev = points[i - 1];
64
37
  return !prev || p[0] !== prev[0] || p[1] !== prev[1];
65
38
  });
66
39
  }
67
- function step(path, points, t) {
40
+ function step(xy, points, t) {
41
+ let d = "";
68
42
  for (let i = 1; i < points.length; i++) {
69
43
  const [x0, y0] = points[i - 1];
70
44
  const [x1, y1] = points[i];
71
- if (t <= 0) {
72
- path.lineTo(x0, y1);
73
- path.lineTo(x1, y1);
74
- } else if (t >= 1) {
75
- path.lineTo(x1, y0);
76
- path.lineTo(x1, y1);
77
- } else {
45
+ if (t <= 0) d += `L${xy(x0, y1)}L${xy(x1, y1)}`;
46
+ else if (t >= 1) d += `L${xy(x1, y0)}L${xy(x1, y1)}`;
47
+ else {
78
48
  const xm = x0 * (1 - t) + x1 * t;
79
- path.lineTo(xm, y0);
80
- path.lineTo(xm, y1);
81
- if (i === points.length - 1) path.lineTo(x1, y1);
49
+ d += `L${xy(xm, y0)}L${xy(xm, y1)}`;
50
+ if (i === points.length - 1) d += `L${xy(x1, y1)}`;
82
51
  }
83
52
  }
53
+ return d;
84
54
  }
85
55
  const sign = (x) => x < 0 ? -1 : 1;
86
56
  /**
87
57
  * Monotone cubic interpolation in x (Steffen, 1990), as in d3's
88
58
  * `curveMonotoneX`: smooth, but never overshoots the data.
89
59
  */
90
- function monotone(path, points) {
60
+ function monotone(xy, points) {
91
61
  const n = points.length;
92
- if (n < 2) return;
62
+ if (n < 2) return "";
93
63
  if (n === 2) {
94
64
  const p = points[1];
95
- path.lineTo(p[0], p[1]);
96
- return;
65
+ return `L${xy(p[0], p[1])}`;
97
66
  }
98
67
  const tangents = new Array(n);
99
68
  for (let i = 1; i < n - 1; i++) {
@@ -109,12 +78,14 @@ function monotone(path, points) {
109
78
  }
110
79
  tangents[0] = endTangent(points[0], points[1], tangents[1]);
111
80
  tangents[n - 1] = endTangent(points[n - 2], points[n - 1], tangents[n - 2]);
81
+ let d = "";
112
82
  for (let i = 1; i < n; i++) {
113
83
  const [x0, y0] = points[i - 1];
114
84
  const [x1, y1] = points[i];
115
85
  const dx = (x1 - x0) / 3;
116
- path.curveTo(x0 + dx, y0 + dx * tangents[i - 1], x1 - dx, y1 - dx * tangents[i], x1, y1);
86
+ d += `C${xy(x0 + dx, y0 + dx * tangents[i - 1])},${xy(x1 - dx, y1 - dx * tangents[i])},${xy(x1, y1)}`;
117
87
  }
88
+ return d;
118
89
  }
119
90
  /** One-sided tangent for the first/last point from the neighbour's tangent. */
120
91
  function endTangent(a, b, t) {
@@ -145,9 +116,14 @@ function runs(points, valid = () => true) {
145
116
  */
146
117
  function linePath(points, options = {}) {
147
118
  const { curve = "linear", precision = 2 } = options;
148
- const path = new PathBuilder(precision);
149
- for (const run of runs(points)) if (emit(path, run.map((i) => points[i]), curve, true) === 1) path.close();
150
- return path.d;
119
+ const xy = pair(precision);
120
+ let d = "";
121
+ for (const run of runs(points)) {
122
+ const drawn = prepare(run.map((i) => points[i]), curve);
123
+ d += emit(xy, drawn, curve, true);
124
+ if (drawn.length === 1) d += "Z";
125
+ }
126
+ return d;
151
127
  }
152
128
  /**
153
129
  * Build the `d` attribute of an area between `points` and a `baseline`:
@@ -156,14 +132,16 @@ function linePath(points, options = {}) {
156
132
  */
157
133
  function areaPath(points, baseline, options = {}) {
158
134
  const { curve = "linear", precision = 2 } = options;
159
- const path = new PathBuilder(precision);
135
+ const xy = pair(precision);
136
+ let d = "";
160
137
  const baseAt = (i) => typeof baseline === "number" ? baseline : baseline[i] ?? NaN;
161
138
  for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {
162
- emit(path, run.map((i) => points[i]), curve, true);
163
- emit(path, run.map((i) => [points[i][0], baseAt(i)]).reverse(), curve === "step-before" ? "step-after" : curve === "step-after" ? "step-before" : curve, false);
164
- path.close();
139
+ d += emit(xy, prepare(run.map((i) => points[i]), curve), curve, true);
140
+ const bottom = run.map((i) => [points[i][0], baseAt(i)]).reverse();
141
+ const back = curve === "step-before" ? "step-after" : curve === "step-after" ? "step-before" : curve;
142
+ d += `${emit(xy, prepare(bottom, back), back, false)}Z`;
165
143
  }
166
- return path.d;
144
+ return d;
167
145
  }
168
146
  // src/components/fade.ts
169
147
  /**
@@ -195,4 +173,4 @@ function fadeMask(id) {
195
173
  }
196
174
  export { areaPath as n, linePath as r, fadeMask as t };
197
175
 
198
- //# sourceMappingURL=fade-GGxcBdss.js.map
176
+ //# sourceMappingURL=fade-CDrQjnDz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade-CDrQjnDz.js","names":[],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Writes a coordinate pair, rounded to `precision` decimals. */\ntype XY = (x: number, y: number) => string\n\nfunction pair(precision: number): XY {\n const k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n const n = (value: number): number => Math.round(value * k) / k || 0\n return (x, y) => `${n(x)},${n(y)}`\n}\n\n/** Monotone tangents break on zero-length segments, so coincident points are dropped. */\nconst prepare = (input: readonly Pt[], curve: Curve): readonly Pt[] =>\n curve === 'monotone' ? dedupe(input) : input\n\n/**\n * Path commands through `points` with a curve. The first point is a move\n * when `move` is true, otherwise a line (continuing an existing subpath).\n */\nfunction emit(xy: XY, points: readonly Pt[], curve: Curve, move: boolean): string {\n const first = points[0]\n if (!first) return ''\n const start = (move ? 'M' : 'L') + xy(first[0], first[1])\n if (curve === 'monotone') return start + monotone(xy, points)\n const t = STEPS[curve]\n if (t !== undefined) return start + step(xy, points, t)\n let d = start\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n d += `L${xy(p[0], p[1])}`\n }\n return d\n}\n\n/** Where a step curve turns between two points, as a share of the way. */\nconst STEPS: Partial<Record<Curve, number>> = { step: 0.5, 'step-before': 0, 'step-after': 1 }\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(xy: XY, points: readonly Pt[], t: number): string {\n let d = ''\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) d += `L${xy(x0, y1)}L${xy(x1, y1)}`\n else if (t >= 1) d += `L${xy(x1, y0)}L${xy(x1, y1)}`\n else {\n const xm = x0 * (1 - t) + x1 * t\n d += `L${xy(xm, y0)}L${xy(xm, y1)}`\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) d += `L${xy(x1, y1)}`\n }\n }\n return d\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(xy: XY, points: readonly Pt[]): string {\n const n = points.length\n if (n < 2) return ''\n if (n === 2) {\n const p = points[1] as Pt\n return `L${xy(p[0], p[1])}`\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n let d = ''\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n d += `C${xy(x0 + dx, y0 + dx * (tangents[i - 1] as number))},${xy(\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n )},${xy(x1, y1)}`\n }\n return d\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const xy = pair(precision)\n let d = ''\n for (const run of runs(points)) {\n const drawn = prepare(\n run.map((i) => points[i] as Pt),\n curve,\n )\n d += emit(xy, drawn, curve, true)\n if (drawn.length === 1) d += 'Z'\n }\n return d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const xy = pair(precision)\n let d = ''\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n d += emit(\n xy,\n prepare(\n run.map((i) => points[i] as Pt),\n curve,\n ),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n d += `${emit(xy, prepare(bottom, back), back, false)}Z`\n }\n return d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;AAkBA,SAAS,KAAK,WAAuB;CACnC,MAAM,IAAI,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CAC/D,MAAM,KAAK,UAA0B,KAAK,MAAM,QAAQ,CAAC,IAAI,KAAK;CAClE,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AACjC;;AAGA,MAAM,WAAW,OAAsB,UACrC,UAAU,aAAa,OAAO,KAAK,IAAI;;;;;AAMzC,SAAS,KAAK,IAAQ,QAAuB,OAAc,MAAuB;CAChF,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,SAAS,OAAO,MAAM,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE;CACxD,IAAI,UAAU,YAAY,OAAO,QAAQ,SAAS,IAAI,MAAM;CAC5D,MAAM,IAAI,MAAM;CAChB,IAAI,MAAM,KAAA,GAAW,OAAO,QAAQ,KAAK,IAAI,QAAQ,CAAC;CACtD,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,IA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QAAQ,QAAQ,IAAI,GAAG,MAAM,KAAK,EAAE;CACvD;CACA,OAAO;AACT;;;;;;;ACnMA,SAAgB,SAAS,IAAmB;CAC1C,OAAO,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5C,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnD,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/C,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
@@ -1,99 +1,68 @@
1
1
  const require_vnode = require("./vnode-ClAiw28x.cjs");
2
2
  // src/shapes/path.ts
3
- /** Accumulates SVG path commands with rounded coordinates. */
4
- var PathBuilder = class {
5
- d = "";
6
- #k;
7
- constructor(precision) {
8
- this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)));
9
- }
10
- #n(value) {
11
- const rounded = Math.round(value * this.#k) / this.#k;
12
- return String(rounded === 0 ? 0 : rounded);
13
- }
14
- #xy(x, y) {
15
- return `${this.#n(x)},${this.#n(y)}`;
16
- }
17
- moveTo(x, y) {
18
- this.d += `M${this.#xy(x, y)}`;
19
- }
20
- lineTo(x, y) {
21
- this.d += `L${this.#xy(x, y)}`;
22
- }
23
- curveTo(x1, y1, x2, y2, x, y) {
24
- this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`;
25
- }
26
- close() {
27
- this.d += "Z";
28
- }
29
- };
3
+ function pair(precision) {
4
+ const k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)));
5
+ const n = (value) => Math.round(value * k) / k || 0;
6
+ return (x, y) => `${n(x)},${n(y)}`;
7
+ }
8
+ /** Monotone tangents break on zero-length segments, so coincident points are dropped. */
9
+ const prepare = (input, curve) => curve === "monotone" ? dedupe(input) : input;
30
10
  /**
31
- * Emit `points` with a curve. The first point is a `moveTo` when `move` is
32
- * true, otherwise a `lineTo` (continuing an existing subpath). Returns the
33
- * number of points drawn.
11
+ * Path commands through `points` with a curve. The first point is a move
12
+ * when `move` is true, otherwise a line (continuing an existing subpath).
34
13
  */
35
- function emit(path, input, curve, move) {
36
- const points = curve === "monotone" ? dedupe(input) : input;
14
+ function emit(xy, points, curve, move) {
37
15
  const first = points[0];
38
- if (!first) return 0;
39
- if (move) path.moveTo(first[0], first[1]);
40
- else path.lineTo(first[0], first[1]);
41
- switch (curve) {
42
- case "monotone":
43
- monotone(path, points);
44
- break;
45
- case "step":
46
- step(path, points, .5);
47
- break;
48
- case "step-before":
49
- step(path, points, 0);
50
- break;
51
- case "step-after":
52
- step(path, points, 1);
53
- break;
54
- default: for (let i = 1; i < points.length; i++) {
55
- const p = points[i];
56
- path.lineTo(p[0], p[1]);
57
- }
16
+ if (!first) return "";
17
+ const start = (move ? "M" : "L") + xy(first[0], first[1]);
18
+ if (curve === "monotone") return start + monotone(xy, points);
19
+ const t = STEPS[curve];
20
+ if (t !== void 0) return start + step(xy, points, t);
21
+ let d = start;
22
+ for (let i = 1; i < points.length; i++) {
23
+ const p = points[i];
24
+ d += `L${xy(p[0], p[1])}`;
58
25
  }
59
- return points.length;
26
+ return d;
60
27
  }
28
+ /** Where a step curve turns between two points, as a share of the way. */
29
+ const STEPS = {
30
+ step: .5,
31
+ "step-before": 0,
32
+ "step-after": 1
33
+ };
61
34
  function dedupe(points) {
62
35
  return points.filter((p, i) => {
63
36
  const prev = points[i - 1];
64
37
  return !prev || p[0] !== prev[0] || p[1] !== prev[1];
65
38
  });
66
39
  }
67
- function step(path, points, t) {
40
+ function step(xy, points, t) {
41
+ let d = "";
68
42
  for (let i = 1; i < points.length; i++) {
69
43
  const [x0, y0] = points[i - 1];
70
44
  const [x1, y1] = points[i];
71
- if (t <= 0) {
72
- path.lineTo(x0, y1);
73
- path.lineTo(x1, y1);
74
- } else if (t >= 1) {
75
- path.lineTo(x1, y0);
76
- path.lineTo(x1, y1);
77
- } else {
45
+ if (t <= 0) d += `L${xy(x0, y1)}L${xy(x1, y1)}`;
46
+ else if (t >= 1) d += `L${xy(x1, y0)}L${xy(x1, y1)}`;
47
+ else {
78
48
  const xm = x0 * (1 - t) + x1 * t;
79
- path.lineTo(xm, y0);
80
- path.lineTo(xm, y1);
81
- if (i === points.length - 1) path.lineTo(x1, y1);
49
+ d += `L${xy(xm, y0)}L${xy(xm, y1)}`;
50
+ if (i === points.length - 1) d += `L${xy(x1, y1)}`;
82
51
  }
83
52
  }
53
+ return d;
84
54
  }
85
55
  const sign = (x) => x < 0 ? -1 : 1;
86
56
  /**
87
57
  * Monotone cubic interpolation in x (Steffen, 1990), as in d3's
88
58
  * `curveMonotoneX`: smooth, but never overshoots the data.
89
59
  */
90
- function monotone(path, points) {
60
+ function monotone(xy, points) {
91
61
  const n = points.length;
92
- if (n < 2) return;
62
+ if (n < 2) return "";
93
63
  if (n === 2) {
94
64
  const p = points[1];
95
- path.lineTo(p[0], p[1]);
96
- return;
65
+ return `L${xy(p[0], p[1])}`;
97
66
  }
98
67
  const tangents = new Array(n);
99
68
  for (let i = 1; i < n - 1; i++) {
@@ -109,12 +78,14 @@ function monotone(path, points) {
109
78
  }
110
79
  tangents[0] = endTangent(points[0], points[1], tangents[1]);
111
80
  tangents[n - 1] = endTangent(points[n - 2], points[n - 1], tangents[n - 2]);
81
+ let d = "";
112
82
  for (let i = 1; i < n; i++) {
113
83
  const [x0, y0] = points[i - 1];
114
84
  const [x1, y1] = points[i];
115
85
  const dx = (x1 - x0) / 3;
116
- path.curveTo(x0 + dx, y0 + dx * tangents[i - 1], x1 - dx, y1 - dx * tangents[i], x1, y1);
86
+ d += `C${xy(x0 + dx, y0 + dx * tangents[i - 1])},${xy(x1 - dx, y1 - dx * tangents[i])},${xy(x1, y1)}`;
117
87
  }
88
+ return d;
118
89
  }
119
90
  /** One-sided tangent for the first/last point from the neighbour's tangent. */
120
91
  function endTangent(a, b, t) {
@@ -145,9 +116,14 @@ function runs(points, valid = () => true) {
145
116
  */
146
117
  function linePath(points, options = {}) {
147
118
  const { curve = "linear", precision = 2 } = options;
148
- const path = new PathBuilder(precision);
149
- for (const run of runs(points)) if (emit(path, run.map((i) => points[i]), curve, true) === 1) path.close();
150
- return path.d;
119
+ const xy = pair(precision);
120
+ let d = "";
121
+ for (const run of runs(points)) {
122
+ const drawn = prepare(run.map((i) => points[i]), curve);
123
+ d += emit(xy, drawn, curve, true);
124
+ if (drawn.length === 1) d += "Z";
125
+ }
126
+ return d;
151
127
  }
152
128
  /**
153
129
  * Build the `d` attribute of an area between `points` and a `baseline`:
@@ -156,14 +132,16 @@ function linePath(points, options = {}) {
156
132
  */
157
133
  function areaPath(points, baseline, options = {}) {
158
134
  const { curve = "linear", precision = 2 } = options;
159
- const path = new PathBuilder(precision);
135
+ const xy = pair(precision);
136
+ let d = "";
160
137
  const baseAt = (i) => typeof baseline === "number" ? baseline : baseline[i] ?? NaN;
161
138
  for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {
162
- emit(path, run.map((i) => points[i]), curve, true);
163
- emit(path, run.map((i) => [points[i][0], baseAt(i)]).reverse(), curve === "step-before" ? "step-after" : curve === "step-after" ? "step-before" : curve, false);
164
- path.close();
139
+ d += emit(xy, prepare(run.map((i) => points[i]), curve), curve, true);
140
+ const bottom = run.map((i) => [points[i][0], baseAt(i)]).reverse();
141
+ const back = curve === "step-before" ? "step-after" : curve === "step-after" ? "step-before" : curve;
142
+ d += `${emit(xy, prepare(bottom, back), back, false)}Z`;
165
143
  }
166
- return path.d;
144
+ return d;
167
145
  }
168
146
  // src/components/fade.ts
169
147
  /**
@@ -212,4 +190,4 @@ Object.defineProperty(exports, "linePath", {
212
190
  }
213
191
  });
214
192
 
215
- //# sourceMappingURL=fade-DVTkhrFU.cjs.map
193
+ //# sourceMappingURL=fade-CRqcKMWY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade-CRqcKMWY.cjs","names":["h"],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Writes a coordinate pair, rounded to `precision` decimals. */\ntype XY = (x: number, y: number) => string\n\nfunction pair(precision: number): XY {\n const k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n const n = (value: number): number => Math.round(value * k) / k || 0\n return (x, y) => `${n(x)},${n(y)}`\n}\n\n/** Monotone tangents break on zero-length segments, so coincident points are dropped. */\nconst prepare = (input: readonly Pt[], curve: Curve): readonly Pt[] =>\n curve === 'monotone' ? dedupe(input) : input\n\n/**\n * Path commands through `points` with a curve. The first point is a move\n * when `move` is true, otherwise a line (continuing an existing subpath).\n */\nfunction emit(xy: XY, points: readonly Pt[], curve: Curve, move: boolean): string {\n const first = points[0]\n if (!first) return ''\n const start = (move ? 'M' : 'L') + xy(first[0], first[1])\n if (curve === 'monotone') return start + monotone(xy, points)\n const t = STEPS[curve]\n if (t !== undefined) return start + step(xy, points, t)\n let d = start\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n d += `L${xy(p[0], p[1])}`\n }\n return d\n}\n\n/** Where a step curve turns between two points, as a share of the way. */\nconst STEPS: Partial<Record<Curve, number>> = { step: 0.5, 'step-before': 0, 'step-after': 1 }\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(xy: XY, points: readonly Pt[], t: number): string {\n let d = ''\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) d += `L${xy(x0, y1)}L${xy(x1, y1)}`\n else if (t >= 1) d += `L${xy(x1, y0)}L${xy(x1, y1)}`\n else {\n const xm = x0 * (1 - t) + x1 * t\n d += `L${xy(xm, y0)}L${xy(xm, y1)}`\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) d += `L${xy(x1, y1)}`\n }\n }\n return d\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(xy: XY, points: readonly Pt[]): string {\n const n = points.length\n if (n < 2) return ''\n if (n === 2) {\n const p = points[1] as Pt\n return `L${xy(p[0], p[1])}`\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n let d = ''\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n d += `C${xy(x0 + dx, y0 + dx * (tangents[i - 1] as number))},${xy(\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n )},${xy(x1, y1)}`\n }\n return d\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const xy = pair(precision)\n let d = ''\n for (const run of runs(points)) {\n const drawn = prepare(\n run.map((i) => points[i] as Pt),\n curve,\n )\n d += emit(xy, drawn, curve, true)\n if (drawn.length === 1) d += 'Z'\n }\n return d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const xy = pair(precision)\n let d = ''\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n d += emit(\n xy,\n prepare(\n run.map((i) => points[i] as Pt),\n curve,\n ),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n d += `${emit(xy, prepare(bottom, back), back, false)}Z`\n }\n return d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;AAkBA,SAAS,KAAK,WAAuB;CACnC,MAAM,IAAI,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CAC/D,MAAM,KAAK,UAA0B,KAAK,MAAM,QAAQ,CAAC,IAAI,KAAK;CAClE,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AACjC;;AAGA,MAAM,WAAW,OAAsB,UACrC,UAAU,aAAa,OAAO,KAAK,IAAI;;;;;AAMzC,SAAS,KAAK,IAAQ,QAAuB,OAAc,MAAuB;CAChF,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,SAAS,OAAO,MAAM,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE;CACxD,IAAI,UAAU,YAAY,OAAO,QAAQ,SAAS,IAAI,MAAM;CAC5D,MAAM,IAAI,MAAM;CAChB,IAAI,MAAM,KAA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OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAAQ;EAIlF,MAAM,OACJ,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB;EACpF,KAAK,GAAG,KAAK,IAAI,QAAQ,QAAQ,IAAI,GAAG,MAAM,KAAK,EAAE;CACvD;CACA,OAAO;AACT;;;;;;;ACnMA,SAAgB,SAAS,IAAmB;CAC1C,OAAOA,cAAAA,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5CA,cAAAA,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnDA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/CA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACAA,cAAAA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
@@ -4,6 +4,8 @@ const features = {};
4
4
  function register(added) {
5
5
  Object.assign(features, added);
6
6
  }
7
+ /** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */
8
+ const swatchShape = (config) => config.shapes ?? config.patterns === true ? features.swatch : void 0;
7
9
  const steps = /* @__PURE__ */ new Set();
8
10
  /** Add a step that finishes rendered content, once, in the order added. */
9
11
  function addPost(step) {
@@ -19,6 +21,6 @@ function feature(name) {
19
21
  if (!found) throw new Error(`@tabler/charts: Import "@tabler/charts/${name === "dates" ? "time" : name}" for ${name}.`);
20
22
  return found;
21
23
  }
22
- export { register as i, feature as n, features as r, addPost as t };
24
+ export { swatchShape as a, register as i, feature as n, features as r, addPost as t };
23
25
 
24
- //# sourceMappingURL=features-BMxkqCyS.js.map
26
+ //# sourceMappingURL=features-B55rwpQC.js.map
@@ -0,0 +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"}
@@ -4,6 +4,8 @@ const features = {};
4
4
  function register(added) {
5
5
  Object.assign(features, added);
6
6
  }
7
+ /** The swatch shapes of a chart, if it has point shapes (`shapes`, or `patterns: true`). */
8
+ const swatchShape = (config) => config.shapes ?? config.patterns === true ? features.swatch : void 0;
7
9
  const steps = /* @__PURE__ */ new Set();
8
10
  /** Add a step that finishes rendered content, once, in the order added. */
9
11
  function addPost(step) {
@@ -43,5 +45,11 @@ Object.defineProperty(exports, "register", {
43
45
  return register;
44
46
  }
45
47
  });
48
+ Object.defineProperty(exports, "swatchShape", {
49
+ enumerable: true,
50
+ get: function() {
51
+ return swatchShape;
52
+ }
53
+ });
46
54
 
47
- //# sourceMappingURL=features-DCXEvoya.cjs.map
55
+ //# sourceMappingURL=features-DEDP5CEQ.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ import { n as estimateTextWidth } from "./layout-DqAte3H8.js";
2
+ // src/charts/fit.ts
3
+ /** `text` cut to `width` pixels with an ellipsis, or `''` when not even a few letters fit. */
4
+ function fit(text, width, fontSize) {
5
+ if (estimateTextWidth(text, fontSize) <= width) return text;
6
+ const chars = [...text];
7
+ while (chars.length > 2) {
8
+ chars.pop();
9
+ const cut = `${chars.join("").trimEnd()}…`;
10
+ if (estimateTextWidth(cut, fontSize) <= width) return cut;
11
+ }
12
+ return "";
13
+ }
14
+ export { fit as t };
15
+
16
+ //# sourceMappingURL=fit-BPyPRnsK.js.map