@tabler/charts 0.0.0-stage → 0.1.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 (338) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +258 -2
  3. package/dist/annotations-Bp7HwtF5.d.ts +86 -0
  4. package/dist/annotations-BszTTjf9.js +202 -0
  5. package/dist/annotations-BszTTjf9.js.map +1 -0
  6. package/dist/annotations-DpETO8dE.cjs +213 -0
  7. package/dist/annotations-DpETO8dE.cjs.map +1 -0
  8. package/dist/annotations-lyt0I3HU.d.cts +86 -0
  9. package/dist/annotations.cjs +14 -0
  10. package/dist/annotations.cjs.map +1 -0
  11. package/dist/annotations.d.cts +2 -0
  12. package/dist/annotations.d.ts +2 -0
  13. package/dist/annotations.js +12 -0
  14. package/dist/annotations.js.map +1 -0
  15. package/dist/arc-BXpLrt9b.cjs +301 -0
  16. package/dist/arc-BXpLrt9b.cjs.map +1 -0
  17. package/dist/arc-a1tRTEw7.js +278 -0
  18. package/dist/arc-a1tRTEw7.js.map +1 -0
  19. package/dist/area-CF__HOwL.d.ts +20 -0
  20. package/dist/area-DIxaAbYZ.d.cts +20 -0
  21. package/dist/area-DQsLERhx.js +26 -0
  22. package/dist/area-DQsLERhx.js.map +1 -0
  23. package/dist/area-sHCE3pg5.cjs +31 -0
  24. package/dist/area-sHCE3pg5.cjs.map +1 -0
  25. package/dist/area.cjs +3 -0
  26. package/dist/area.d.cts +2 -0
  27. package/dist/area.d.ts +2 -0
  28. package/dist/area.js +2 -0
  29. package/dist/band-DTcNDAFO.d.cts +50 -0
  30. package/dist/band-DTcNDAFO.d.ts +50 -0
  31. package/dist/bar-BBM8RhoL.d.ts +43 -0
  32. package/dist/bar-C-7zR2qp.cjs +243 -0
  33. package/dist/bar-C-7zR2qp.cjs.map +1 -0
  34. package/dist/bar-CRKLDg98.d.cts +43 -0
  35. package/dist/bar-DGuUN3nc.cjs +67 -0
  36. package/dist/bar-DGuUN3nc.cjs.map +1 -0
  37. package/dist/bar-DM16NUvV.js +56 -0
  38. package/dist/bar-DM16NUvV.js.map +1 -0
  39. package/dist/bar-jZEoao74.js +238 -0
  40. package/dist/bar-jZEoao74.js.map +1 -0
  41. package/dist/bar.cjs +3 -0
  42. package/dist/bar.d.cts +2 -0
  43. package/dist/bar.d.ts +2 -0
  44. package/dist/bar.js +2 -0
  45. package/dist/candlestick-B5r1w3kc.cjs +150 -0
  46. package/dist/candlestick-B5r1w3kc.cjs.map +1 -0
  47. package/dist/candlestick-D_vV0_XZ.d.ts +44 -0
  48. package/dist/candlestick-DuXwAFID.js +145 -0
  49. package/dist/candlestick-DuXwAFID.js.map +1 -0
  50. package/dist/candlestick-__pXl_pV.d.cts +44 -0
  51. package/dist/candlestick.cjs +11 -0
  52. package/dist/candlestick.cjs.map +1 -0
  53. package/dist/candlestick.d.cts +2 -0
  54. package/dist/candlestick.d.ts +2 -0
  55. package/dist/candlestick.js +10 -0
  56. package/dist/candlestick.js.map +1 -0
  57. package/dist/cartesian-BoDfgBCV.cjs +900 -0
  58. package/dist/cartesian-BoDfgBCV.cjs.map +1 -0
  59. package/dist/cartesian-Cr0AF0nG.js +709 -0
  60. package/dist/cartesian-Cr0AF0nG.js.map +1 -0
  61. package/dist/chart-BF2CK9I_.js +790 -0
  62. package/dist/chart-BF2CK9I_.js.map +1 -0
  63. package/dist/chart-CowF_lWY.cjs +903 -0
  64. package/dist/chart-CowF_lWY.cjs.map +1 -0
  65. package/dist/chart-D7ooEFnk.d.cts +933 -0
  66. package/dist/chart-DyN7bcx8.d.ts +933 -0
  67. package/dist/circle-BQMuAfls.cjs +12 -0
  68. package/dist/circle-BQMuAfls.cjs.map +1 -0
  69. package/dist/circle-Z7YfCoCM.js +7 -0
  70. package/dist/circle-Z7YfCoCM.js.map +1 -0
  71. package/dist/clean-Byl6kzf0.cjs +115 -0
  72. package/dist/clean-Byl6kzf0.cjs.map +1 -0
  73. package/dist/clean-o1vDEhFV.js +56 -0
  74. package/dist/clean-o1vDEhFV.js.map +1 -0
  75. package/dist/core-CegR_j55.js +884 -0
  76. package/dist/core-CegR_j55.js.map +1 -0
  77. package/dist/core-D1vO1LrC.d.cts +220 -0
  78. package/dist/core-DcbemzGf.d.ts +220 -0
  79. package/dist/core-RzS9IQO5.cjs +985 -0
  80. package/dist/core-RzS9IQO5.cjs.map +1 -0
  81. package/dist/core.cjs +115 -0
  82. package/dist/core.d.cts +21 -0
  83. package/dist/core.d.ts +21 -0
  84. package/dist/core.js +25 -0
  85. package/dist/dates-Btm7Zm6W.cjs +32 -0
  86. package/dist/dates-Btm7Zm6W.cjs.map +1 -0
  87. package/dist/dates-CG-FvioW.js +27 -0
  88. package/dist/dates-CG-FvioW.js.map +1 -0
  89. package/dist/decimate-BGg9XgF0.d.ts +17 -0
  90. package/dist/decimate-C87cl_Sp.js +84 -0
  91. package/dist/decimate-C87cl_Sp.js.map +1 -0
  92. package/dist/decimate-CNSpgGa5.d.cts +17 -0
  93. package/dist/decimate-tLhDk1ys.cjs +95 -0
  94. package/dist/decimate-tLhDk1ys.cjs.map +1 -0
  95. package/dist/decimate.cjs +14 -0
  96. package/dist/decimate.cjs.map +1 -0
  97. package/dist/decimate.d.cts +2 -0
  98. package/dist/decimate.d.ts +2 -0
  99. package/dist/decimate.js +12 -0
  100. package/dist/decimate.js.map +1 -0
  101. package/dist/dom-CLF868Qs.cjs +222 -0
  102. package/dist/dom-CLF868Qs.cjs.map +1 -0
  103. package/dist/dom-vP3IcMak.js +175 -0
  104. package/dist/dom-vP3IcMak.js.map +1 -0
  105. package/dist/export-chart-9w8t3rjZ.js +232 -0
  106. package/dist/export-chart-9w8t3rjZ.js.map +1 -0
  107. package/dist/export-chart-BhhYgksr.cjs +249 -0
  108. package/dist/export-chart-BhhYgksr.cjs.map +1 -0
  109. package/dist/export.cjs +18 -0
  110. package/dist/export.cjs.map +1 -0
  111. package/dist/export.d.cts +2 -0
  112. package/dist/export.d.ts +2 -0
  113. package/dist/export.js +15 -0
  114. package/dist/export.js.map +1 -0
  115. package/dist/extent-BAMZo0Nq.js +19 -0
  116. package/dist/extent-BAMZo0Nq.js.map +1 -0
  117. package/dist/extent-DsFWvAHJ.cjs +24 -0
  118. package/dist/extent-DsFWvAHJ.cjs.map +1 -0
  119. package/dist/fade-Cs74puQS.cjs +217 -0
  120. package/dist/fade-Cs74puQS.cjs.map +1 -0
  121. package/dist/fade-D3NxH5Qg.js +200 -0
  122. package/dist/fade-D3NxH5Qg.js.map +1 -0
  123. package/dist/features-BclHgg2W.cjs +48 -0
  124. package/dist/features-BclHgg2W.cjs.map +1 -0
  125. package/dist/features-wASyHGic.js +25 -0
  126. package/dist/features-wASyHGic.js.map +1 -0
  127. package/dist/format-B0yKXBTH.cjs +183 -0
  128. package/dist/format-B0yKXBTH.cjs.map +1 -0
  129. package/dist/format-lStwuc1L.js +142 -0
  130. package/dist/format-lStwuc1L.js.map +1 -0
  131. package/dist/gauge-D-FYhuds.cjs +236 -0
  132. package/dist/gauge-D-FYhuds.cjs.map +1 -0
  133. package/dist/gauge-DP_EB2z3.d.cts +65 -0
  134. package/dist/gauge-Dh423FHh.js +231 -0
  135. package/dist/gauge-Dh423FHh.js.map +1 -0
  136. package/dist/gauge-zpia05t2.d.ts +65 -0
  137. package/dist/gauge.cjs +3 -0
  138. package/dist/gauge.d.cts +2 -0
  139. package/dist/gauge.d.ts +2 -0
  140. package/dist/gauge.js +2 -0
  141. package/dist/heatmap-BK18EBgJ.cjs +247 -0
  142. package/dist/heatmap-BK18EBgJ.cjs.map +1 -0
  143. package/dist/heatmap-BectCEeE.d.ts +81 -0
  144. package/dist/heatmap-CCso6m61.d.cts +81 -0
  145. package/dist/heatmap-DSZ2bVIa.js +242 -0
  146. package/dist/heatmap-DSZ2bVIa.js.map +1 -0
  147. package/dist/heatmap.cjs +3 -0
  148. package/dist/heatmap.d.cts +2 -0
  149. package/dist/heatmap.d.ts +2 -0
  150. package/dist/heatmap.js +2 -0
  151. package/dist/hydrate-CTTmQy0x.d.cts +10 -0
  152. package/dist/hydrate-CxwTXDqO.cjs +60 -0
  153. package/dist/hydrate-CxwTXDqO.cjs.map +1 -0
  154. package/dist/hydrate-CzfxLfTv.d.ts +10 -0
  155. package/dist/hydrate-DDNIHYv_.js +55 -0
  156. package/dist/hydrate-DDNIHYv_.js.map +1 -0
  157. package/dist/hydrate.cjs +13 -0
  158. package/dist/hydrate.cjs.map +1 -0
  159. package/dist/hydrate.d.cts +2 -0
  160. package/dist/hydrate.d.ts +2 -0
  161. package/dist/hydrate.js +12 -0
  162. package/dist/hydrate.js.map +1 -0
  163. package/dist/index.cjs +214 -0
  164. package/dist/index.cjs.map +1 -0
  165. package/dist/index.d.cts +46 -0
  166. package/dist/index.d.ts +46 -0
  167. package/dist/index.js +115 -0
  168. package/dist/index.js.map +1 -0
  169. package/dist/layout-B3hiqVEw.js +69 -0
  170. package/dist/layout-B3hiqVEw.js.map +1 -0
  171. package/dist/layout-CtMBhNd9.cjs +98 -0
  172. package/dist/layout-CtMBhNd9.cjs.map +1 -0
  173. package/dist/line-B3Ed6u7j.js +120 -0
  174. package/dist/line-B3Ed6u7j.js.map +1 -0
  175. package/dist/line-CN4uZ9ZX.d.ts +47 -0
  176. package/dist/line-W7VD_qs1.d.cts +47 -0
  177. package/dist/line-fQbtP_jL.cjs +131 -0
  178. package/dist/line-fQbtP_jL.cjs.map +1 -0
  179. package/dist/line.cjs +14 -0
  180. package/dist/line.cjs.map +1 -0
  181. package/dist/line.d.cts +2 -0
  182. package/dist/line.d.ts +2 -0
  183. package/dist/line.js +13 -0
  184. package/dist/line.js.map +1 -0
  185. package/dist/log-CaofN3-n.d.cts +48 -0
  186. package/dist/log-CaofN3-n.d.ts +48 -0
  187. package/dist/log-axis-83rSpvL5.cjs +130 -0
  188. package/dist/log-axis-83rSpvL5.cjs.map +1 -0
  189. package/dist/log-axis-B_uvvOFc.js +113 -0
  190. package/dist/log-axis-B_uvvOFc.js.map +1 -0
  191. package/dist/log.cjs +17 -0
  192. package/dist/log.cjs.map +1 -0
  193. package/dist/log.d.cts +2 -0
  194. package/dist/log.d.ts +2 -0
  195. package/dist/log.js +16 -0
  196. package/dist/log.js.map +1 -0
  197. package/dist/morph-BMxz3X2b.d.cts +10 -0
  198. package/dist/morph-BMxz3X2b.d.ts +10 -0
  199. package/dist/morph-Bgg-24l8.js +36 -0
  200. package/dist/morph-Bgg-24l8.js.map +1 -0
  201. package/dist/morph-CqYDu1bY.cjs +41 -0
  202. package/dist/morph-CqYDu1bY.cjs.map +1 -0
  203. package/dist/morph.cjs +14 -0
  204. package/dist/morph.cjs.map +1 -0
  205. package/dist/morph.d.cts +2 -0
  206. package/dist/morph.d.ts +2 -0
  207. package/dist/morph.js +13 -0
  208. package/dist/morph.js.map +1 -0
  209. package/dist/named-BWWb5LQJ.cjs +50 -0
  210. package/dist/named-BWWb5LQJ.cjs.map +1 -0
  211. package/dist/named-DE15TOgh.js +33 -0
  212. package/dist/named-DE15TOgh.js.map +1 -0
  213. package/dist/parliament-1Zv2Xh0D.d.ts +69 -0
  214. package/dist/parliament-CpWnoEvG.cjs +308 -0
  215. package/dist/parliament-CpWnoEvG.cjs.map +1 -0
  216. package/dist/parliament-DdrLVZwt.d.cts +69 -0
  217. package/dist/parliament-Dw0sOERi.js +303 -0
  218. package/dist/parliament-Dw0sOERi.js.map +1 -0
  219. package/dist/parliament.cjs +3 -0
  220. package/dist/parliament.d.cts +2 -0
  221. package/dist/parliament.d.ts +2 -0
  222. package/dist/parliament.js +2 -0
  223. package/dist/path-CwB28da0.d.cts +29 -0
  224. package/dist/path-CwB28da0.d.ts +29 -0
  225. package/dist/patterns-DtgcnA8o.js +85 -0
  226. package/dist/patterns-DtgcnA8o.js.map +1 -0
  227. package/dist/patterns-LfcQAWCy.cjs +102 -0
  228. package/dist/patterns-LfcQAWCy.cjs.map +1 -0
  229. package/dist/patterns.cjs +15 -0
  230. package/dist/patterns.cjs.map +1 -0
  231. package/dist/patterns.d.cts +2 -0
  232. package/dist/patterns.d.ts +2 -0
  233. package/dist/patterns.js +12 -0
  234. package/dist/patterns.js.map +1 -0
  235. package/dist/pie-5z1fDdKO.d.ts +58 -0
  236. package/dist/pie-BF9yI5mE.d.cts +58 -0
  237. package/dist/pie-BxTZt6Go.cjs +212 -0
  238. package/dist/pie-BxTZt6Go.cjs.map +1 -0
  239. package/dist/pie-DzUXDTcn.js +201 -0
  240. package/dist/pie-DzUXDTcn.js.map +1 -0
  241. package/dist/pie.cjs +4 -0
  242. package/dist/pie.d.cts +2 -0
  243. package/dist/pie.d.ts +2 -0
  244. package/dist/pie.js +2 -0
  245. package/dist/point-shapes-CGl4dugc.cjs +166 -0
  246. package/dist/point-shapes-CGl4dugc.cjs.map +1 -0
  247. package/dist/point-shapes-DI84NNpI.js +155 -0
  248. package/dist/point-shapes-DI84NNpI.js.map +1 -0
  249. package/dist/point-shapes.cjs +15 -0
  250. package/dist/point-shapes.cjs.map +1 -0
  251. package/dist/point-shapes.d.cts +2 -0
  252. package/dist/point-shapes.d.ts +2 -0
  253. package/dist/point-shapes.js +13 -0
  254. package/dist/point-shapes.js.map +1 -0
  255. package/dist/radar-1-EryihA.d.ts +60 -0
  256. package/dist/radar-CYPab_I4.js +285 -0
  257. package/dist/radar-CYPab_I4.js.map +1 -0
  258. package/dist/radar-CoGUNNSb.cjs +290 -0
  259. package/dist/radar-CoGUNNSb.cjs.map +1 -0
  260. package/dist/radar-DBW4O0Vt.d.cts +60 -0
  261. package/dist/radar.cjs +3 -0
  262. package/dist/radar.d.cts +2 -0
  263. package/dist/radar.d.ts +2 -0
  264. package/dist/radar.js +2 -0
  265. package/dist/sankey-B4PNKusJ.js +420 -0
  266. package/dist/sankey-B4PNKusJ.js.map +1 -0
  267. package/dist/sankey-Bacx4fVe.cjs +425 -0
  268. package/dist/sankey-Bacx4fVe.cjs.map +1 -0
  269. package/dist/sankey-DuGI3Qc5.d.cts +67 -0
  270. package/dist/sankey-OV_WoPrl.d.ts +67 -0
  271. package/dist/sankey.cjs +3 -0
  272. package/dist/sankey.d.cts +2 -0
  273. package/dist/sankey.d.ts +2 -0
  274. package/dist/sankey.js +2 -0
  275. package/dist/scatter-BqzgJqdX.d.ts +61 -0
  276. package/dist/scatter-DbxLyZX0.d.cts +61 -0
  277. package/dist/scatter-DgMN9zRy.cjs +250 -0
  278. package/dist/scatter-DgMN9zRy.cjs.map +1 -0
  279. package/dist/scatter-kgtgR318.js +245 -0
  280. package/dist/scatter-kgtgR318.js.map +1 -0
  281. package/dist/scatter.cjs +3 -0
  282. package/dist/scatter.d.cts +2 -0
  283. package/dist/scatter.d.ts +2 -0
  284. package/dist/scatter.js +2 -0
  285. package/dist/sparkline-BQzt27Fr.js +171 -0
  286. package/dist/sparkline-BQzt27Fr.js.map +1 -0
  287. package/dist/sparkline-BS9-hltA.cjs +176 -0
  288. package/dist/sparkline-BS9-hltA.cjs.map +1 -0
  289. package/dist/sparkline-BfyO_oNM.d.ts +43 -0
  290. package/dist/sparkline-CWlJDKyh.d.cts +43 -0
  291. package/dist/sparkline.cjs +3 -0
  292. package/dist/sparkline.d.cts +2 -0
  293. package/dist/sparkline.d.ts +2 -0
  294. package/dist/sparkline.js +2 -0
  295. package/dist/stack-CpR6RGKd.d.cts +6 -0
  296. package/dist/stack-CpR6RGKd.d.ts +6 -0
  297. package/dist/stack-DRbwTeF3.js +66 -0
  298. package/dist/stack-DRbwTeF3.js.map +1 -0
  299. package/dist/stack-DVhJWaki.cjs +77 -0
  300. package/dist/stack-DVhJWaki.cjs.map +1 -0
  301. package/dist/style.css +2 -0
  302. package/dist/sweep-CbfR7--d.js +60 -0
  303. package/dist/sweep-CbfR7--d.js.map +1 -0
  304. package/dist/sweep-DaTEDDuC.cjs +71 -0
  305. package/dist/sweep-DaTEDDuC.cjs.map +1 -0
  306. package/dist/time-CHjiY9Q4.d.ts +112 -0
  307. package/dist/time-CNVnt-B2.d.cts +112 -0
  308. package/dist/time-axis-Bc9eHX1r.js +365 -0
  309. package/dist/time-axis-Bc9eHX1r.js.map +1 -0
  310. package/dist/time-axis-VSX34_Tb.cjs +382 -0
  311. package/dist/time-axis-VSX34_Tb.cjs.map +1 -0
  312. package/dist/time.cjs +22 -0
  313. package/dist/time.cjs.map +1 -0
  314. package/dist/time.d.cts +2 -0
  315. package/dist/time.d.ts +2 -0
  316. package/dist/time.js +20 -0
  317. package/dist/time.js.map +1 -0
  318. package/dist/tween-BCYd0RTY.js +40 -0
  319. package/dist/tween-BCYd0RTY.js.map +1 -0
  320. package/dist/tween-CIGBlryn.cjs +51 -0
  321. package/dist/tween-CIGBlryn.cjs.map +1 -0
  322. package/dist/value-labels-B0WJoJ7x.cjs +134 -0
  323. package/dist/value-labels-B0WJoJ7x.cjs.map +1 -0
  324. package/dist/value-labels-IZIQPhfk.js +123 -0
  325. package/dist/value-labels-IZIQPhfk.js.map +1 -0
  326. package/dist/value-labels.cjs +14 -0
  327. package/dist/value-labels.cjs.map +1 -0
  328. package/dist/value-labels.d.cts +2 -0
  329. package/dist/value-labels.d.ts +2 -0
  330. package/dist/value-labels.js +12 -0
  331. package/dist/value-labels.js.map +1 -0
  332. package/dist/vnode-BUflsBsa.d.cts +66 -0
  333. package/dist/vnode-BUflsBsa.d.ts +66 -0
  334. package/dist/vnode-CkQ27Cxe.cjs +110 -0
  335. package/dist/vnode-CkQ27Cxe.cjs.map +1 -0
  336. package/dist/vnode-tCWItoUH.js +93 -0
  337. package/dist/vnode-tCWItoUH.js.map +1 -0
  338. package/package.json +320 -3
@@ -0,0 +1,24 @@
1
+ //#region src/scales/extent.ts
2
+ /**
3
+ * Minimum and maximum of `values`, skipping `null`, `undefined` and
4
+ * non-finite numbers. Returns `undefined` when nothing is left.
5
+ */
6
+ function extent(values) {
7
+ let min = Number.POSITIVE_INFINITY;
8
+ let max = Number.NEGATIVE_INFINITY;
9
+ for (const value of values) {
10
+ if (value == null || !Number.isFinite(value)) continue;
11
+ if (value < min) min = value;
12
+ if (value > max) max = value;
13
+ }
14
+ return min <= max ? [min, max] : void 0;
15
+ }
16
+ //#endregion
17
+ Object.defineProperty(exports, "extent", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return extent;
21
+ }
22
+ });
23
+
24
+ //# sourceMappingURL=extent-DsFWvAHJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extent-DsFWvAHJ.cjs","names":[],"sources":["../src/scales/extent.ts"],"sourcesContent":["/**\n * Minimum and maximum of `values`, skipping `null`, `undefined` and\n * non-finite numbers. Returns `undefined` when nothing is left.\n */\nexport function extent(values: Iterable<number | null | undefined>): [number, number] | undefined {\n let min = Number.POSITIVE_INFINITY\n let max = Number.NEGATIVE_INFINITY\n for (const value of values) {\n if (value == null || !Number.isFinite(value)) continue\n if (value < min) min = value\n if (value > max) max = value\n }\n return min <= max ? [min, max] : undefined\n}\n"],"mappings":";;;;;AAIA,SAAgB,OAAO,QAA2E;CAChG,IAAI,MAAM,OAAO;CACjB,IAAI,MAAM,OAAO;CACjB,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,SAAS,QAAQ,CAAC,OAAO,SAAS,KAAK,GAAG;EAC9C,IAAI,QAAQ,KAAK,MAAM;EACvB,IAAI,QAAQ,KAAK,MAAM;CACzB;CACA,OAAO,OAAO,MAAM,CAAC,KAAK,GAAG,IAAI,KAAA;AACnC"}
@@ -0,0 +1,217 @@
1
+ const require_vnode = require("./vnode-CkQ27Cxe.cjs");
2
+ //#region 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
+ };
30
+ /**
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.
34
+ */
35
+ function emit(path, input, curve, move) {
36
+ const points = curve === "monotone" ? dedupe(input) : input;
37
+ 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
+ }
58
+ }
59
+ return points.length;
60
+ }
61
+ function dedupe(points) {
62
+ return points.filter((p, i) => {
63
+ const prev = points[i - 1];
64
+ return !prev || p[0] !== prev[0] || p[1] !== prev[1];
65
+ });
66
+ }
67
+ function step(path, points, t) {
68
+ for (let i = 1; i < points.length; i++) {
69
+ const [x0, y0] = points[i - 1];
70
+ 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 {
78
+ 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);
82
+ }
83
+ }
84
+ }
85
+ const sign = (x) => x < 0 ? -1 : 1;
86
+ /**
87
+ * Monotone cubic interpolation in x (Steffen, 1990), as in d3's
88
+ * `curveMonotoneX`: smooth, but never overshoots the data.
89
+ */
90
+ function monotone(path, points) {
91
+ const n = points.length;
92
+ if (n < 2) return;
93
+ if (n === 2) {
94
+ const p = points[1];
95
+ path.lineTo(p[0], p[1]);
96
+ return;
97
+ }
98
+ const tangents = new Array(n);
99
+ for (let i = 1; i < n - 1; i++) {
100
+ const [x0, y0] = points[i - 1];
101
+ const [x1, y1] = points[i];
102
+ const [x2, y2] = points[i + 1];
103
+ const h0 = x1 - x0;
104
+ const h1 = x2 - x1;
105
+ const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0));
106
+ const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0));
107
+ const p = (s0 * h1 + s1 * h0) / (h0 + h1);
108
+ tangents[i] = (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), .5 * Math.abs(p)) || 0;
109
+ }
110
+ tangents[0] = endTangent(points[0], points[1], tangents[1]);
111
+ tangents[n - 1] = endTangent(points[n - 2], points[n - 1], tangents[n - 2]);
112
+ for (let i = 1; i < n; i++) {
113
+ const [x0, y0] = points[i - 1];
114
+ const [x1, y1] = points[i];
115
+ const dx = (x1 - x0) / 3;
116
+ path.curveTo(x0 + dx, y0 + dx * tangents[i - 1], x1 - dx, y1 - dx * tangents[i], x1, y1);
117
+ }
118
+ }
119
+ /** One-sided tangent for the first/last point from the neighbour's tangent. */
120
+ function endTangent(a, b, t) {
121
+ const h = b[0] - a[0];
122
+ return h ? 3 * (b[1] - a[1]) / h / 2 - t / 2 : t;
123
+ }
124
+ const isValid = (p) => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1]);
125
+ /** Split points into runs of consecutive valid points, keeping their indices. */
126
+ function runs(points, valid = () => true) {
127
+ const out = [];
128
+ let current;
129
+ for (let i = 0; i < points.length; i++) if (isValid(points[i]) && valid(i)) {
130
+ if (!current) {
131
+ current = [];
132
+ out.push(current);
133
+ }
134
+ current.push(i);
135
+ } else current = void 0;
136
+ return out;
137
+ }
138
+ /**
139
+ * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)
140
+ * start a new subpath; a lone point renders as `M x,y Z`.
141
+ *
142
+ * ```ts
143
+ * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })
144
+ * ```
145
+ */
146
+ function linePath(points, options = {}) {
147
+ 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;
151
+ }
152
+ /**
153
+ * Build the `d` attribute of an area between `points` and a `baseline`:
154
+ * a constant y (e.g. the zero line) or one y per point (stacked areas).
155
+ * Each run of valid points becomes a closed subpath.
156
+ */
157
+ function areaPath(points, baseline, options = {}) {
158
+ const { curve = "linear", precision = 2 } = options;
159
+ const path = new PathBuilder(precision);
160
+ const baseAt = (i) => typeof baseline === "number" ? baseline : baseline[i] ?? NaN;
161
+ 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();
165
+ }
166
+ return path.d;
167
+ }
168
+ //#endregion
169
+ //#region src/components/fade.ts
170
+ /**
171
+ * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their
172
+ * series color from CSS; the mask only fades them, with stop opacities read
173
+ * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.
174
+ */
175
+ function fadeMask(id) {
176
+ return require_vnode.h("mask", {
177
+ id,
178
+ maskContentUnits: "objectBoundingBox"
179
+ }, require_vnode.h("linearGradient", {
180
+ id: `${id}-gradient`,
181
+ x1: 0,
182
+ y1: 0,
183
+ x2: 0,
184
+ y2: 1
185
+ }, require_vnode.h("stop", {
186
+ class: "tc-fade-start",
187
+ offset: 0
188
+ }), require_vnode.h("stop", {
189
+ class: "tc-fade-end",
190
+ offset: 1
191
+ })), require_vnode.h("rect", {
192
+ width: 1,
193
+ height: 1,
194
+ fill: `url(#${id}-gradient)`
195
+ }));
196
+ }
197
+ //#endregion
198
+ Object.defineProperty(exports, "areaPath", {
199
+ enumerable: true,
200
+ get: function() {
201
+ return areaPath;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "fadeMask", {
205
+ enumerable: true,
206
+ get: function() {
207
+ return fadeMask;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "linePath", {
211
+ enumerable: true,
212
+ get: function() {
213
+ return linePath;
214
+ }
215
+ });
216
+
217
+ //# sourceMappingURL=fade-Cs74puQS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade-Cs74puQS.cjs","names":["h"],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill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;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"}
@@ -0,0 +1,200 @@
1
+ import { t as h } from "./vnode-tCWItoUH.js";
2
+ //#region 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
+ };
30
+ /**
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.
34
+ */
35
+ function emit(path, input, curve, move) {
36
+ const points = curve === "monotone" ? dedupe(input) : input;
37
+ 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
+ }
58
+ }
59
+ return points.length;
60
+ }
61
+ function dedupe(points) {
62
+ return points.filter((p, i) => {
63
+ const prev = points[i - 1];
64
+ return !prev || p[0] !== prev[0] || p[1] !== prev[1];
65
+ });
66
+ }
67
+ function step(path, points, t) {
68
+ for (let i = 1; i < points.length; i++) {
69
+ const [x0, y0] = points[i - 1];
70
+ 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 {
78
+ 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);
82
+ }
83
+ }
84
+ }
85
+ const sign = (x) => x < 0 ? -1 : 1;
86
+ /**
87
+ * Monotone cubic interpolation in x (Steffen, 1990), as in d3's
88
+ * `curveMonotoneX`: smooth, but never overshoots the data.
89
+ */
90
+ function monotone(path, points) {
91
+ const n = points.length;
92
+ if (n < 2) return;
93
+ if (n === 2) {
94
+ const p = points[1];
95
+ path.lineTo(p[0], p[1]);
96
+ return;
97
+ }
98
+ const tangents = new Array(n);
99
+ for (let i = 1; i < n - 1; i++) {
100
+ const [x0, y0] = points[i - 1];
101
+ const [x1, y1] = points[i];
102
+ const [x2, y2] = points[i + 1];
103
+ const h0 = x1 - x0;
104
+ const h1 = x2 - x1;
105
+ const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0));
106
+ const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0));
107
+ const p = (s0 * h1 + s1 * h0) / (h0 + h1);
108
+ tangents[i] = (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), .5 * Math.abs(p)) || 0;
109
+ }
110
+ tangents[0] = endTangent(points[0], points[1], tangents[1]);
111
+ tangents[n - 1] = endTangent(points[n - 2], points[n - 1], tangents[n - 2]);
112
+ for (let i = 1; i < n; i++) {
113
+ const [x0, y0] = points[i - 1];
114
+ const [x1, y1] = points[i];
115
+ const dx = (x1 - x0) / 3;
116
+ path.curveTo(x0 + dx, y0 + dx * tangents[i - 1], x1 - dx, y1 - dx * tangents[i], x1, y1);
117
+ }
118
+ }
119
+ /** One-sided tangent for the first/last point from the neighbour's tangent. */
120
+ function endTangent(a, b, t) {
121
+ const h = b[0] - a[0];
122
+ return h ? 3 * (b[1] - a[1]) / h / 2 - t / 2 : t;
123
+ }
124
+ const isValid = (p) => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1]);
125
+ /** Split points into runs of consecutive valid points, keeping their indices. */
126
+ function runs(points, valid = () => true) {
127
+ const out = [];
128
+ let current;
129
+ for (let i = 0; i < points.length; i++) if (isValid(points[i]) && valid(i)) {
130
+ if (!current) {
131
+ current = [];
132
+ out.push(current);
133
+ }
134
+ current.push(i);
135
+ } else current = void 0;
136
+ return out;
137
+ }
138
+ /**
139
+ * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)
140
+ * start a new subpath; a lone point renders as `M x,y Z`.
141
+ *
142
+ * ```ts
143
+ * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })
144
+ * ```
145
+ */
146
+ function linePath(points, options = {}) {
147
+ 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;
151
+ }
152
+ /**
153
+ * Build the `d` attribute of an area between `points` and a `baseline`:
154
+ * a constant y (e.g. the zero line) or one y per point (stacked areas).
155
+ * Each run of valid points becomes a closed subpath.
156
+ */
157
+ function areaPath(points, baseline, options = {}) {
158
+ const { curve = "linear", precision = 2 } = options;
159
+ const path = new PathBuilder(precision);
160
+ const baseAt = (i) => typeof baseline === "number" ? baseline : baseline[i] ?? NaN;
161
+ 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();
165
+ }
166
+ return path.d;
167
+ }
168
+ //#endregion
169
+ //#region src/components/fade.ts
170
+ /**
171
+ * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their
172
+ * series color from CSS; the mask only fades them, with stop opacities read
173
+ * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.
174
+ */
175
+ function fadeMask(id) {
176
+ return h("mask", {
177
+ id,
178
+ maskContentUnits: "objectBoundingBox"
179
+ }, h("linearGradient", {
180
+ id: `${id}-gradient`,
181
+ x1: 0,
182
+ y1: 0,
183
+ x2: 0,
184
+ y2: 1
185
+ }, h("stop", {
186
+ class: "tc-fade-start",
187
+ offset: 0
188
+ }), h("stop", {
189
+ class: "tc-fade-end",
190
+ offset: 1
191
+ })), h("rect", {
192
+ width: 1,
193
+ height: 1,
194
+ fill: `url(#${id}-gradient)`
195
+ }));
196
+ }
197
+ //#endregion
198
+ export { areaPath as n, linePath as r, fadeMask as t };
199
+
200
+ //# sourceMappingURL=fade-D3NxH5Qg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade-D3NxH5Qg.js","names":[],"sources":["../src/shapes/path.ts","../src/components/fade.ts"],"sourcesContent":["/** A point in pixels; `null` (or a non-finite coordinate) marks a gap. */\nexport type Point = readonly [x: number, y: number] | null | undefined\n\n/** Curve used to connect consecutive points. */\nexport type Curve = 'linear' | 'monotone' | 'step' | 'step-before' | 'step-after'\n\nexport interface PathOptions {\n /** Interpolation between points. Defaults to `'linear'`. */\n curve?: Curve\n /** Decimal places kept in the path data. Defaults to `2`. */\n precision?: number\n}\n\ntype Pt = readonly [number, number]\n\n/** Accumulates SVG path commands with rounded coordinates. */\nclass PathBuilder {\n d = ''\n readonly #k: number\n\n constructor(precision: number) {\n this.#k = 10 ** Math.max(0, Math.min(12, Math.floor(precision)))\n }\n\n #n(value: number): string {\n const rounded = Math.round(value * this.#k) / this.#k\n return String(rounded === 0 ? 0 : rounded)\n }\n\n #xy(x: number, y: number): string {\n return `${this.#n(x)},${this.#n(y)}`\n }\n\n moveTo(x: number, y: number): void {\n this.d += `M${this.#xy(x, y)}`\n }\n\n lineTo(x: number, y: number): void {\n this.d += `L${this.#xy(x, y)}`\n }\n\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void {\n this.d += `C${this.#xy(x1, y1)},${this.#xy(x2, y2)},${this.#xy(x, y)}`\n }\n\n close(): void {\n this.d += 'Z'\n }\n}\n\n/**\n * Emit `points` with a curve. The first point is a `moveTo` when `move` is\n * true, otherwise a `lineTo` (continuing an existing subpath). Returns the\n * number of points drawn.\n */\nfunction emit(path: PathBuilder, input: readonly Pt[], curve: Curve, move: boolean): number {\n // Monotone tangents break on zero-length segments, so drop coincident points.\n const points = curve === 'monotone' ? dedupe(input) : input\n const first = points[0]\n if (!first) return 0\n if (move) path.moveTo(first[0], first[1])\n else path.lineTo(first[0], first[1])\n\n switch (curve) {\n case 'monotone':\n monotone(path, points)\n break\n case 'step':\n step(path, points, 0.5)\n break\n case 'step-before':\n step(path, points, 0)\n break\n case 'step-after':\n step(path, points, 1)\n break\n default:\n for (let i = 1; i < points.length; i++) {\n const p = points[i] as Pt\n path.lineTo(p[0], p[1])\n }\n }\n return points.length\n}\n\nfunction dedupe(points: readonly Pt[]): readonly Pt[] {\n return points.filter((p, i) => {\n const prev = points[i - 1]\n return !prev || p[0] !== prev[0] || p[1] !== prev[1]\n })\n}\n\nfunction step(path: PathBuilder, points: readonly Pt[], t: number): void {\n for (let i = 1; i < points.length; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n if (t <= 0) {\n path.lineTo(x0, y1)\n path.lineTo(x1, y1)\n } else if (t >= 1) {\n path.lineTo(x1, y0)\n path.lineTo(x1, y1)\n } else {\n const xm = x0 * (1 - t) + x1 * t\n path.lineTo(xm, y0)\n path.lineTo(xm, y1)\n // The next horizontal run continues from here, so only the last point is needed.\n if (i === points.length - 1) path.lineTo(x1, y1)\n }\n }\n}\n\nconst sign = (x: number): number => (x < 0 ? -1 : 1)\n\n/**\n * Monotone cubic interpolation in x (Steffen, 1990), as in d3's\n * `curveMonotoneX`: smooth, but never overshoots the data.\n */\nfunction monotone(path: PathBuilder, points: readonly Pt[]): void {\n const n = points.length\n if (n < 2) return\n if (n === 2) {\n const p = points[1] as Pt\n path.lineTo(p[0], p[1])\n return\n }\n\n const tangents = new Array<number>(n)\n for (let i = 1; i < n - 1; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const [x2, y2] = points[i + 1] as Pt\n const h0 = x1 - x0\n const h1 = x2 - x1\n const s0 = (y1 - y0) / (h0 || (h1 < 0 ? -0 : 0))\n const s1 = (y2 - y1) / (h1 || (h0 < 0 ? -0 : 0))\n const p = (s0 * h1 + s1 * h0) / (h0 + h1)\n tangents[i] =\n (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0\n }\n tangents[0] = endTangent(points[0] as Pt, points[1] as Pt, tangents[1] as number)\n tangents[n - 1] = endTangent(points[n - 2] as Pt, points[n - 1] as Pt, tangents[n - 2] as number)\n\n for (let i = 1; i < n; i++) {\n const [x0, y0] = points[i - 1] as Pt\n const [x1, y1] = points[i] as Pt\n const dx = (x1 - x0) / 3\n path.curveTo(\n x0 + dx,\n y0 + dx * (tangents[i - 1] as number),\n x1 - dx,\n y1 - dx * (tangents[i] as number),\n x1,\n y1,\n )\n }\n}\n\n/** One-sided tangent for the first/last point from the neighbour's tangent. */\nfunction endTangent(a: Pt, b: Pt, t: number): number {\n const h = b[0] - a[0]\n return h ? (3 * (b[1] - a[1])) / h / 2 - t / 2 : t\n}\n\nconst isValid = (p: Point): p is Pt => p != null && Number.isFinite(p[0]) && Number.isFinite(p[1])\n\n/** Split points into runs of consecutive valid points, keeping their indices. */\nfunction runs(points: readonly Point[], valid: (i: number) => boolean = () => true): number[][] {\n const out: number[][] = []\n let current: number[] | undefined\n for (let i = 0; i < points.length; i++) {\n if (isValid(points[i]) && valid(i)) {\n if (!current) {\n current = []\n out.push(current)\n }\n current.push(i)\n } else {\n current = undefined\n }\n }\n return out\n}\n\n/**\n * Build the `d` attribute of a line through `points`. Gaps (`null`/`NaN`)\n * start a new subpath; a lone point renders as `M x,y Z`.\n *\n * ```ts\n * linePath([[0, 10], [50, 40], null, [100, 20]], { curve: 'monotone' })\n * ```\n */\nexport function linePath(points: readonly Point[], options: PathOptions = {}): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n for (const run of runs(points)) {\n const drawn = emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n if (drawn === 1) path.close()\n }\n return path.d\n}\n\n/**\n * Build the `d` attribute of an area between `points` and a `baseline`:\n * a constant y (e.g. the zero line) or one y per point (stacked areas).\n * Each run of valid points becomes a closed subpath.\n */\nexport function areaPath(\n points: readonly Point[],\n baseline: number | readonly (number | null | undefined)[],\n options: PathOptions = {},\n): string {\n const { curve = 'linear', precision = 2 } = options\n const path = new PathBuilder(precision)\n const baseAt = (i: number): number =>\n typeof baseline === 'number' ? baseline : (baseline[i] ?? Number.NaN)\n\n for (const run of runs(points, (i) => Number.isFinite(baseAt(i)))) {\n emit(\n path,\n run.map((i) => points[i] as Pt),\n curve,\n true,\n )\n\n const bottom = run.map((i) => [(points[i] as Pt)[0], baseAt(i)] as const).reverse()\n // Walking backwards mirrors step curves, so stacked steps line up. A flat\n // baseline takes the same curve (it stays straight) so that the path keeps\n // its commands between flat and stacked, and CSS can morph one into the other.\n const back =\n curve === 'step-before' ? 'step-after' : curve === 'step-after' ? 'step-before' : curve\n emit(path, bottom, back, false)\n path.close()\n }\n return path.d\n}\n","import { h, type VNode } from '../vnode.ts'\n\n/**\n * A vertical luminance mask shared by all gradient areas of a chart (line, area, sparkline). Areas keep their\n * series color from CSS; the mask only fades them, with stop opacities read\n * from `--tc-area-gradient-start` / `--tc-area-gradient-end`.\n */\nexport function fadeMask(id: string): VNode {\n return h(\n 'mask',\n { id, maskContentUnits: 'objectBoundingBox' },\n h(\n 'linearGradient',\n { id: `${id}-gradient`, x1: 0, y1: 0, x2: 0, y2: 1 },\n h('stop', { class: 'tc-fade-start', offset: 0 }),\n h('stop', { class: 'tc-fade-end', offset: 1 }),\n ),\n h('rect', { width: 1, height: 1, fill: `url(#${id}-gradient)` }),\n )\n}\n"],"mappings":";;;AAgBA,IAAM,cAAN,MAAkB;CAChB,IAAI;CACJ;CAEA,YAAY,WAAmB;EAC7B,KAAK,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS,CAAC,CAAC;CACjE;CAEA,GAAG,OAAuB;EACxB,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,EAAE,IAAI,KAAK;EACnD,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO;CAC3C;CAEA,IAAI,GAAW,GAAmB;EAChC,OAAO,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,OAAO,GAAW,GAAiB;EACjC,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC7B;CAEA,QAAQ,IAAY,IAAY,IAAY,IAAY,GAAW,GAAiB;EAClF,KAAK,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE,EAAE,GAAG,KAAK,IAAI,IAAI,EAAE,EAAE,GAAG,KAAK,IAAI,GAAG,CAAC;CACrE;CAEA,QAAc;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CAAC,CAAC,GAAG;EACjE,KACE,MACA,IAAI,KAAK,MAAM,OAAO,EAAQ,GAC9B,OACA,IACF;EAQA,KAAK,MANU,IAAI,KAAK,MAAM,CAAE,OAAO,EAAE,CAAQ,IAAI,OAAO,CAAC,CAAC,CAAU,CAAC,CAAC,QAM1D,GADd,UAAU,gBAAgB,eAAe,UAAU,eAAe,gBAAgB,OAC3D,KAAK;EAC9B,KAAK,MAAM;CACb;CACA,OAAO,KAAK;AACd;;;;;;;;ACzOA,SAAgB,SAAS,IAAmB;CAC1C,OAAO,EACL,QACA;EAAE;EAAI,kBAAkB;CAAoB,GAC5C,EACE,kBACA;EAAE,IAAI,GAAG,GAAG;EAAY,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAE,GACnD,EAAE,QAAQ;EAAE,OAAO;EAAiB,QAAQ;CAAE,CAAC,GAC/C,EAAE,QAAQ;EAAE,OAAO;EAAe,QAAQ;CAAE,CAAC,CAC/C,GACA,EAAE,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,MAAM,QAAQ,GAAG;CAAY,CAAC,CACjE;AACF"}
@@ -0,0 +1,48 @@
1
+ //#region src/features.ts
2
+ const features = {};
3
+ /** Register optional features (idempotent). */
4
+ function register(added) {
5
+ Object.assign(features, added);
6
+ }
7
+ const steps = /* @__PURE__ */ new Set();
8
+ /** Add a step that finishes rendered content, once, in the order added. */
9
+ function addPost(step) {
10
+ steps.add(step);
11
+ features.post = (config, content, interaction, ctx) => {
12
+ for (const each of steps) content = each(config, content, interaction, ctx);
13
+ return content;
14
+ };
15
+ }
16
+ /** The registered feature, or a helpful error naming the import that provides it. */
17
+ function feature(name) {
18
+ const found = features[name];
19
+ if (!found) throw new Error(`@tabler/charts: Import "@tabler/charts/${name === "dates" ? "time" : name}" for ${name}.`);
20
+ return found;
21
+ }
22
+ //#endregion
23
+ Object.defineProperty(exports, "addPost", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return addPost;
27
+ }
28
+ });
29
+ Object.defineProperty(exports, "feature", {
30
+ enumerable: true,
31
+ get: function() {
32
+ return feature;
33
+ }
34
+ });
35
+ Object.defineProperty(exports, "features", {
36
+ enumerable: true,
37
+ get: function() {
38
+ return features;
39
+ }
40
+ });
41
+ Object.defineProperty(exports, "register", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return register;
45
+ }
46
+ });
47
+
48
+ //# sourceMappingURL=features-BclHgg2W.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features-BclHgg2W.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 { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}
@@ -0,0 +1,25 @@
1
+ //#region src/features.ts
2
+ const features = {};
3
+ /** Register optional features (idempotent). */
4
+ function register(added) {
5
+ Object.assign(features, added);
6
+ }
7
+ const steps = /* @__PURE__ */ new Set();
8
+ /** Add a step that finishes rendered content, once, in the order added. */
9
+ function addPost(step) {
10
+ steps.add(step);
11
+ features.post = (config, content, interaction, ctx) => {
12
+ for (const each of steps) content = each(config, content, interaction, ctx);
13
+ return content;
14
+ };
15
+ }
16
+ /** The registered feature, or a helpful error naming the import that provides it. */
17
+ function feature(name) {
18
+ const found = features[name];
19
+ if (!found) throw new Error(`@tabler/charts: Import "@tabler/charts/${name === "dates" ? "time" : name}" for ${name}.`);
20
+ return found;
21
+ }
22
+ //#endregion
23
+ export { register as i, feature as n, features as r, addPost as t };
24
+
25
+ //# sourceMappingURL=features-wASyHGic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features-wASyHGic.js","names":[],"sources":["../src/features.ts"],"sourcesContent":["import type { ChartConfig, RenderContext } from './chart.ts'\nimport type { annotationLayers, annotationValues } from './charts/annotations.ts'\nimport type { dateLabels } from './charts/dates.ts'\nimport type { logDomain, logTicks } from './charts/log-axis.ts'\nimport type { patternFills } from './charts/patterns.ts'\nimport type { markerPath } from './charts/point-shapes.ts'\nimport type { timeAxis } from './charts/time-axis.ts'\nimport type { downloadChart } from './export-chart.ts'\nimport type { Interaction } from './interaction.ts'\nimport type { hydrate } from './render/hydrate.ts'\nimport type { morph } from './render/morph.ts'\nimport type { sweep } from './render/sweep.ts'\nimport type { log } from './scales/log.ts'\nimport type { time, timePointScale } from './scales/time.ts'\nimport type { areaPath, linePath, Point } from './shapes/path.ts'\nimport type { ChildInput } from './vnode.ts'\n\n/**\n * Optional features that chart types look up at render time. Each lives in\n * its own module (`@tabler/charts/time`, `/log`, `/decimate`, `/line`, `/annotations`) and registers\n * itself when imported; `@tabler/charts` registers all of them, while\n * `@tabler/charts/core` starts empty so unused code never ships.\n */\nexport interface Features {\n /** Time scale (and the point scale over it) behind `x: { type: 'time' }`. */\n time?: { scale: typeof time; points: typeof timePointScale; axis: typeof timeAxis }\n /** Date labels behind `x: { type: 'time' }` (also registered by `@tabler/charts/candlestick`). */\n dates?: typeof dateLabels\n /** Log scale and axis behind `scale: 'log'`. */\n log?: { scale: typeof log; domain: typeof logDomain; ticks: typeof logTicks }\n /** Downsampling behind `decimate: N`: indices of the points to keep. */\n decimate?: (points: readonly Point[], threshold: number) => number[]\n /**\n * Taking over server-rendered markup node by node (without it, the server\n * svg is replaced on the first render).\n */\n hydrate?: typeof hydrate\n /** Path morphing on data updates where CSS cannot transition `d` (Safari). */\n morph?: typeof morph\n /** Arcs turning to their new angles on data updates (set by pie, donut and gauge). */\n sweep?: typeof sweep\n /** Line and area paths behind `series.type: 'line' | 'area'` in bar charts. */\n line?: { linePath: typeof linePath; areaPath: typeof areaPath }\n /** Reference lines and bands behind `annotations` in cartesian charts. */\n annotations?: { layers: typeof annotationLayers; values: typeof annotationValues }\n /** Pattern fills behind `patterns` (and forced colors, with `'auto'`). */\n patterns?: typeof patternFills\n /**\n * Steps that finish a chart's rendered content (see `addPost`): point\n * shapes, value labels.\n */\n post?: PostStep\n /** Point shapes by color slot, behind `shapes`. */\n 'point-shapes'?: typeof markerPath\n /** Saving a chart as a file, behind the `download` menu. */\n export?: typeof downloadChart\n}\n\nexport const features: Features = {}\n\n/** Register optional features (idempotent). */\nexport function register(added: Features): void {\n Object.assign(features, added)\n}\n\n/** A step that finishes rendered chart content, e.g. by adding value labels. */\nexport type PostStep = (\n config: ChartConfig<object>,\n content: ChildInput,\n interaction: Interaction | undefined,\n ctx: RenderContext,\n) => ChildInput\n\nconst steps = /* @__PURE__ */ new Set<PostStep>()\n\n/** Add a step that finishes rendered content, once, in the order added. */\nexport function addPost(step: PostStep): void {\n steps.add(step)\n features.post = (config, content, interaction, ctx) => {\n for (const each of steps) content = each(config, content, interaction, ctx)\n return content\n }\n}\n\n/** The registered feature, or a helpful error naming the import that provides it. */\nexport function feature<K extends keyof Features>(name: K): NonNullable<Features[K]> {\n const found = features[name]\n if (!found) {\n throw new Error(\n `@tabler/charts: Import \"@tabler/charts/${name === 'dates' ? 'time' : name}\" for ${name}.`,\n )\n }\n return found\n}\n"],"mappings":";AA0DA,MAAa,WAAqB,CAAC;;AAGnC,SAAgB,SAAS,OAAuB;CAC9C,OAAO,OAAO,UAAU,KAAK;AAC/B;AAUA,MAAM,wBAAwB,IAAI,IAAc;;AAGhD,SAAgB,QAAQ,MAAsB;CAC5C,MAAM,IAAI,IAAI;CACd,SAAS,QAAQ,QAAQ,SAAS,aAAa,QAAQ;EACrD,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,QAAQ,SAAS,aAAa,GAAG;EAC1E,OAAO;CACT;AACF;;AAGA,SAAgB,QAAkC,MAAmC;CACnF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,0CAA0C,SAAS,UAAU,SAAS,KAAK,QAAQ,KAAK,EAC1F;CAEF,OAAO;AACT"}