@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,48 @@
1
+ //#region src/scales/linear.d.ts
2
+ interface LinearScaleOptions {
3
+ /** Clamp output to the range (and `invert()` output to the domain). */
4
+ clamp?: boolean;
5
+ }
6
+ /** Continuous scale mapping a numeric domain to a pixel range. */
7
+ interface LinearScale {
8
+ (value: number): number;
9
+ readonly domain: readonly [number, number];
10
+ readonly range: readonly [number, number];
11
+ /** Map a pixel back to a domain value. */
12
+ invert(pixel: number): number;
13
+ /** Nice tick values inside the domain. */
14
+ ticks(count?: number): number[];
15
+ /** A copy of the scale with its domain extended to round values. */
16
+ nice(count?: number): LinearScale;
17
+ }
18
+ /**
19
+ * Create a linear scale.
20
+ *
21
+ * ```ts
22
+ * const y = linear([0, 120], [300, 0]).nice()
23
+ * y(60) // 150
24
+ * ```
25
+ *
26
+ * A zero-width domain (e.g. a single data point) maps to the middle of the range.
27
+ */
28
+ declare function linear(domain: readonly [number, number], range: readonly [number, number], options?: LinearScaleOptions): LinearScale;
29
+ //#endregion
30
+ //#region src/scales/log.d.ts
31
+ interface LogScaleOptions extends LinearScaleOptions {
32
+ /** Logarithm base. Defaults to `10`. */
33
+ base?: number;
34
+ }
35
+ /**
36
+ * Create a logarithmic scale. The domain must not cross zero: both ends
37
+ * positive (or both negative, mirrored). Same interface as {@link linear},
38
+ * so layouts can use either.
39
+ *
40
+ * ```ts
41
+ * const y = log([1, 10000], [300, 0])
42
+ * y.ticks() // 1, 10, 100, 1000, 10000
43
+ * ```
44
+ */
45
+ declare function log(domain: readonly [number, number], range: readonly [number, number], options?: LogScaleOptions): LinearScale;
46
+ //#endregion
47
+ export { linear as a, LinearScaleOptions as i, log as n, LinearScale as r, LogScaleOptions as t };
48
+ //# sourceMappingURL=log-CaofN3-n.d.cts.map
@@ -0,0 +1,48 @@
1
+ //#region src/scales/linear.d.ts
2
+ interface LinearScaleOptions {
3
+ /** Clamp output to the range (and `invert()` output to the domain). */
4
+ clamp?: boolean;
5
+ }
6
+ /** Continuous scale mapping a numeric domain to a pixel range. */
7
+ interface LinearScale {
8
+ (value: number): number;
9
+ readonly domain: readonly [number, number];
10
+ readonly range: readonly [number, number];
11
+ /** Map a pixel back to a domain value. */
12
+ invert(pixel: number): number;
13
+ /** Nice tick values inside the domain. */
14
+ ticks(count?: number): number[];
15
+ /** A copy of the scale with its domain extended to round values. */
16
+ nice(count?: number): LinearScale;
17
+ }
18
+ /**
19
+ * Create a linear scale.
20
+ *
21
+ * ```ts
22
+ * const y = linear([0, 120], [300, 0]).nice()
23
+ * y(60) // 150
24
+ * ```
25
+ *
26
+ * A zero-width domain (e.g. a single data point) maps to the middle of the range.
27
+ */
28
+ declare function linear(domain: readonly [number, number], range: readonly [number, number], options?: LinearScaleOptions): LinearScale;
29
+ //#endregion
30
+ //#region src/scales/log.d.ts
31
+ interface LogScaleOptions extends LinearScaleOptions {
32
+ /** Logarithm base. Defaults to `10`. */
33
+ base?: number;
34
+ }
35
+ /**
36
+ * Create a logarithmic scale. The domain must not cross zero: both ends
37
+ * positive (or both negative, mirrored). Same interface as {@link linear},
38
+ * so layouts can use either.
39
+ *
40
+ * ```ts
41
+ * const y = log([1, 10000], [300, 0])
42
+ * y.ticks() // 1, 10, 100, 1000, 10000
43
+ * ```
44
+ */
45
+ declare function log(domain: readonly [number, number], range: readonly [number, number], options?: LogScaleOptions): LinearScale;
46
+ //#endregion
47
+ export { linear as a, LinearScaleOptions as i, log as n, LinearScale as r, LogScaleOptions as t };
48
+ //# sourceMappingURL=log-CaofN3-n.d.ts.map
@@ -0,0 +1,130 @@
1
+ const require_format = require("./format-B0yKXBTH.cjs");
2
+ const require_extent = require("./extent-DsFWvAHJ.cjs");
3
+ const require_clean = require("./clean-Byl6kzf0.cjs");
4
+ //#region src/scales/log.ts
5
+ /**
6
+ * Create a logarithmic scale. The domain must not cross zero: both ends
7
+ * positive (or both negative, mirrored). Same interface as {@link linear},
8
+ * so layouts can use either.
9
+ *
10
+ * ```ts
11
+ * const y = log([1, 10000], [300, 0])
12
+ * y.ticks() // 1, 10, 100, 1000, 10000
13
+ * ```
14
+ */
15
+ function log(domain, range, options = {}) {
16
+ const base = options.base && options.base > 1 ? options.base : 10;
17
+ const clamp = options.clamp === true;
18
+ const sign = domain[0] < 0 || domain[1] < 0 ? -1 : 1;
19
+ const safe = (v) => Math.max(Number.MIN_VALUE, v * sign);
20
+ const ln = Math.log(base);
21
+ const logBase = base === 10 ? Math.log10 : base === 2 ? Math.log2 : (v) => Math.log(v) / ln;
22
+ const transform = (v) => logBase(safe(v));
23
+ const untransform = (t) => sign * base ** t;
24
+ const t0 = transform(domain[0]);
25
+ const t1 = transform(domain[1]);
26
+ const [r0, r1] = range;
27
+ const span = t1 - t0;
28
+ const k = span === 0 ? 0 : (r1 - r0) / span;
29
+ const rMin = Math.min(r0, r1);
30
+ const rMax = Math.max(r0, r1);
31
+ const scale = (value) => {
32
+ if (span === 0) return (r0 + r1) / 2;
33
+ const px = r0 + (transform(value) - t0) * k;
34
+ return clamp ? Math.min(rMax, Math.max(rMin, px)) : px;
35
+ };
36
+ return Object.assign(scale, {
37
+ domain: [domain[0], domain[1]],
38
+ range: [r0, r1],
39
+ invert(pixel) {
40
+ if (span === 0 || r1 === r0) return domain[0];
41
+ return untransform(t0 + (pixel - r0) / k);
42
+ },
43
+ ticks(count = 5) {
44
+ const lo = Math.min(t0, t1);
45
+ const hi = Math.max(t0, t1);
46
+ if (!Number.isFinite(lo) || !Number.isFinite(hi)) return [];
47
+ const first = Math.floor(lo);
48
+ const last = Math.ceil(hi);
49
+ const decades = last - first;
50
+ const inside = (v) => {
51
+ const t = transform(v);
52
+ return t >= lo - 1e-9 && t <= hi + 1e-9;
53
+ };
54
+ let out = [];
55
+ if (decades <= count && Number.isInteger(base)) {
56
+ const at = (keep) => {
57
+ const ticks = [];
58
+ for (let p = first; p <= last; p++) for (let m = 1; m < base; m++) {
59
+ const v = sign * m * base ** p;
60
+ if (keep(m) && inside(v)) ticks.push(v);
61
+ }
62
+ return ticks;
63
+ };
64
+ out = at(() => true);
65
+ if (out.length > count * 2) out = at((m) => m === 1 || m === 2 || m === 5);
66
+ if (out.length > count * 2) out = at((m) => m === 1);
67
+ } else {
68
+ const step = Math.max(1, Math.ceil(decades / Math.max(1, count)));
69
+ for (let p = Math.ceil(lo / step) * step; p <= hi + 1e-9; p += step) {
70
+ const v = sign * base ** p;
71
+ if (inside(v)) out.push(v);
72
+ }
73
+ }
74
+ return t1 < t0 ? out.reverse() : out;
75
+ },
76
+ nice() {
77
+ const lo = untransform(Math.floor(Math.min(t0, t1)));
78
+ const hi = untransform(Math.ceil(Math.max(t0, t1)));
79
+ return log(t1 < t0 ? [hi, lo] : [lo, hi], range, options);
80
+ }
81
+ });
82
+ }
83
+ //#endregion
84
+ //#region src/charts/log-axis.ts
85
+ /** Domain of a log axis: positive values only, niced to whole powers of ten. */
86
+ function logDomain(values, options) {
87
+ const positive = values.filter((v) => v != null && v > 0 && Number.isFinite(v));
88
+ let [lo, hi] = require_extent.extent(positive) ?? [1, 10];
89
+ const min = require_clean.finite(options.min);
90
+ const max = require_clean.finite(options.max);
91
+ if (min !== null && min > 0) lo = min;
92
+ if (max !== null && max > 0) hi = max;
93
+ if (lo === hi) hi = lo * 10;
94
+ if (options.nice !== false) {
95
+ const niced = log([lo, hi], [0, 1]).nice().domain;
96
+ if (min === null) lo = niced[0];
97
+ if (max === null) hi = niced[1];
98
+ }
99
+ return [lo, hi];
100
+ }
101
+ /** Ticks of a log axis, each power formatted as is. */
102
+ function logTicks(scale, count, format, locale) {
103
+ const fmt = require_format.formatNumber(format, locale);
104
+ return scale.ticks(count).map((value) => ({
105
+ value,
106
+ position: scale(value),
107
+ label: fmt(value)
108
+ }));
109
+ }
110
+ //#endregion
111
+ Object.defineProperty(exports, "log", {
112
+ enumerable: true,
113
+ get: function() {
114
+ return log;
115
+ }
116
+ });
117
+ Object.defineProperty(exports, "logDomain", {
118
+ enumerable: true,
119
+ get: function() {
120
+ return logDomain;
121
+ }
122
+ });
123
+ Object.defineProperty(exports, "logTicks", {
124
+ enumerable: true,
125
+ get: function() {
126
+ return logTicks;
127
+ }
128
+ });
129
+
130
+ //# sourceMappingURL=log-axis-83rSpvL5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-axis-83rSpvL5.cjs","names":["extent","finite","formatNumber"],"sources":["../src/scales/log.ts","../src/charts/log-axis.ts"],"sourcesContent":["import type { LinearScale, LinearScaleOptions } from './linear.ts'\n\nexport interface LogScaleOptions extends LinearScaleOptions {\n /** Logarithm base. Defaults to `10`. */\n base?: number\n}\n\n/**\n * Create a logarithmic scale. The domain must not cross zero: both ends\n * positive (or both negative, mirrored). Same interface as {@link linear},\n * so layouts can use either.\n *\n * ```ts\n * const y = log([1, 10000], [300, 0])\n * y.ticks() // 1, 10, 100, 1000, 10000\n * ```\n */\nexport function log(\n domain: readonly [number, number],\n range: readonly [number, number],\n options: LogScaleOptions = {},\n): LinearScale {\n const base = options.base && options.base > 1 ? options.base : 10\n const clamp = options.clamp === true\n const negative = domain[0] < 0 || domain[1] < 0\n const sign = negative ? -1 : 1\n // Values at or below zero cannot be shown; treat them as the smallest positive step.\n const safe = (v: number): number => Math.max(Number.MIN_VALUE, v * sign)\n const ln = Math.log(base)\n // Exact for the common bases, so powers map to whole numbers.\n const logBase =\n base === 10 ? Math.log10 : base === 2 ? Math.log2 : (v: number) => Math.log(v) / ln\n const transform = (v: number): number => logBase(safe(v))\n const untransform = (t: number): number => sign * base ** t\n const t0 = transform(domain[0])\n const t1 = transform(domain[1])\n const [r0, r1] = range\n const span = t1 - t0\n const k = span === 0 ? 0 : (r1 - r0) / span\n const rMin = Math.min(r0, r1)\n const rMax = Math.max(r0, r1)\n\n const scale = (value: number): number => {\n if (span === 0) return (r0 + r1) / 2\n const px = r0 + (transform(value) - t0) * k\n return clamp ? Math.min(rMax, Math.max(rMin, px)) : px\n }\n\n return Object.assign(scale, {\n domain: [domain[0], domain[1]] as const,\n range: [r0, r1] as const,\n invert(pixel: number): number {\n if (span === 0 || r1 === r0) return domain[0]\n return untransform(t0 + (pixel - r0) / k)\n },\n ticks(count = 5): number[] {\n const lo = Math.min(t0, t1)\n const hi = Math.max(t0, t1)\n if (!Number.isFinite(lo) || !Number.isFinite(hi)) return []\n const first = Math.floor(lo)\n const last = Math.ceil(hi)\n const decades = last - first\n const inside = (v: number) => {\n const t = transform(v)\n return t >= lo - 1e-9 && t <= hi + 1e-9\n }\n let out: number[] = []\n if (decades <= count && Number.isInteger(base)) {\n // Few decades: integer multiples inside each (1, 2, 3 … 9 × 10ⁿ), thinned when crowded.\n const at = (keep: (m: number) => boolean) => {\n const ticks: number[] = []\n for (let p = first; p <= last; p++) {\n for (let m = 1; m < base; m++) {\n const v = sign * m * base ** p\n if (keep(m) && inside(v)) ticks.push(v)\n }\n }\n return ticks\n }\n out = at(() => true)\n if (out.length > count * 2) out = at((m) => m === 1 || m === 2 || m === 5)\n if (out.length > count * 2) out = at((m) => m === 1)\n } else {\n // Many decades: one tick per power (or per few powers).\n const step = Math.max(1, Math.ceil(decades / Math.max(1, count)))\n for (let p = Math.ceil(lo / step) * step; p <= hi + 1e-9; p += step) {\n const v = sign * base ** p\n if (inside(v)) out.push(v)\n }\n }\n return t1 < t0 ? out.reverse() : out\n },\n nice(): LinearScale {\n const lo = untransform(Math.floor(Math.min(t0, t1)))\n const hi = untransform(Math.ceil(Math.max(t0, t1)))\n return log(t1 < t0 ? [hi, lo] : [lo, hi], range, options)\n },\n })\n}\n","import type { Tick } from '../components/axis.ts'\nimport { formatNumber, type Locale, type NumberFormat } from '../format.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { log } from '../scales/log.ts'\nimport type { ValueAxisOptions } from './cartesian.ts'\nimport { finite } from './clean.ts'\n\n/** Domain of a log axis: positive values only, niced to whole powers of ten. */\nexport function logDomain(\n values: readonly (number | null | undefined)[],\n options: ValueAxisOptions,\n): [number, number] {\n const positive = values.filter((v): v is number => v != null && v > 0 && Number.isFinite(v))\n let [lo, hi] = extent(positive) ?? [1, 10]\n // Bounds may come from outside: only positive numbers count.\n const min = finite(options.min)\n const max = finite(options.max)\n if (min !== null && min > 0) lo = min\n if (max !== null && max > 0) hi = max\n if (lo === hi) hi = lo * 10\n if (options.nice !== false) {\n const niced = log([lo, hi], [0, 1]).nice().domain\n if (min === null) lo = niced[0]\n if (max === null) hi = niced[1]\n }\n return [lo, hi]\n}\n\n/** Ticks of a log axis, each power formatted as is. */\nexport function logTicks(\n scale: LinearScale,\n count: number,\n format: NumberFormat | undefined,\n locale: Locale,\n): Tick[] {\n const fmt = formatNumber(format, locale)\n return scale.ticks(count).map((value) => ({ value, position: scale(value), label: fmt(value) }))\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,IACd,QACA,OACA,UAA2B,CAAC,GACf;CACb,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,IAAI,QAAQ,OAAO;CAC/D,MAAM,QAAQ,QAAQ,UAAU;CAEhC,MAAM,OADW,OAAO,KAAK,KAAK,OAAO,KAAK,IACtB,KAAK;CAE7B,MAAM,QAAQ,MAAsB,KAAK,IAAI,OAAO,WAAW,IAAI,IAAI;CACvE,MAAM,KAAK,KAAK,IAAI,IAAI;CAExB,MAAM,UACJ,SAAS,KAAK,KAAK,QAAQ,SAAS,IAAI,KAAK,QAAQ,MAAc,KAAK,IAAI,CAAC,IAAI;CACnF,MAAM,aAAa,MAAsB,QAAQ,KAAK,CAAC,CAAC;CACxD,MAAM,eAAe,MAAsB,OAAO,QAAQ;CAC1D,MAAM,KAAK,UAAU,OAAO,EAAE;CAC9B,MAAM,KAAK,UAAU,OAAO,EAAE;CAC9B,MAAM,CAAC,IAAI,MAAM;CACjB,MAAM,OAAO,KAAK;CAClB,MAAM,IAAI,SAAS,IAAI,KAAK,KAAK,MAAM;CACvC,MAAM,OAAO,KAAK,IAAI,IAAI,EAAE;CAC5B,MAAM,OAAO,KAAK,IAAI,IAAI,EAAE;CAE5B,MAAM,SAAS,UAA0B;EACvC,IAAI,SAAS,GAAG,QAAQ,KAAK,MAAM;EACnC,MAAM,KAAK,MAAM,UAAU,KAAK,IAAI,MAAM;EAC1C,OAAO,QAAQ,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC,IAAI;CACtD;CAEA,OAAO,OAAO,OAAO,OAAO;EAC1B,QAAQ,CAAC,OAAO,IAAI,OAAO,EAAE;EAC7B,OAAO,CAAC,IAAI,EAAE;EACd,OAAO,OAAuB;GAC5B,IAAI,SAAS,KAA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I,KAAK;CAAE,EAAE;AACjG"}
@@ -0,0 +1,113 @@
1
+ import { r as formatNumber } from "./format-lStwuc1L.js";
2
+ import { t as extent } from "./extent-BAMZo0Nq.js";
3
+ import { i as finite } from "./clean-o1vDEhFV.js";
4
+ //#region src/scales/log.ts
5
+ /**
6
+ * Create a logarithmic scale. The domain must not cross zero: both ends
7
+ * positive (or both negative, mirrored). Same interface as {@link linear},
8
+ * so layouts can use either.
9
+ *
10
+ * ```ts
11
+ * const y = log([1, 10000], [300, 0])
12
+ * y.ticks() // 1, 10, 100, 1000, 10000
13
+ * ```
14
+ */
15
+ function log(domain, range, options = {}) {
16
+ const base = options.base && options.base > 1 ? options.base : 10;
17
+ const clamp = options.clamp === true;
18
+ const sign = domain[0] < 0 || domain[1] < 0 ? -1 : 1;
19
+ const safe = (v) => Math.max(Number.MIN_VALUE, v * sign);
20
+ const ln = Math.log(base);
21
+ const logBase = base === 10 ? Math.log10 : base === 2 ? Math.log2 : (v) => Math.log(v) / ln;
22
+ const transform = (v) => logBase(safe(v));
23
+ const untransform = (t) => sign * base ** t;
24
+ const t0 = transform(domain[0]);
25
+ const t1 = transform(domain[1]);
26
+ const [r0, r1] = range;
27
+ const span = t1 - t0;
28
+ const k = span === 0 ? 0 : (r1 - r0) / span;
29
+ const rMin = Math.min(r0, r1);
30
+ const rMax = Math.max(r0, r1);
31
+ const scale = (value) => {
32
+ if (span === 0) return (r0 + r1) / 2;
33
+ const px = r0 + (transform(value) - t0) * k;
34
+ return clamp ? Math.min(rMax, Math.max(rMin, px)) : px;
35
+ };
36
+ return Object.assign(scale, {
37
+ domain: [domain[0], domain[1]],
38
+ range: [r0, r1],
39
+ invert(pixel) {
40
+ if (span === 0 || r1 === r0) return domain[0];
41
+ return untransform(t0 + (pixel - r0) / k);
42
+ },
43
+ ticks(count = 5) {
44
+ const lo = Math.min(t0, t1);
45
+ const hi = Math.max(t0, t1);
46
+ if (!Number.isFinite(lo) || !Number.isFinite(hi)) return [];
47
+ const first = Math.floor(lo);
48
+ const last = Math.ceil(hi);
49
+ const decades = last - first;
50
+ const inside = (v) => {
51
+ const t = transform(v);
52
+ return t >= lo - 1e-9 && t <= hi + 1e-9;
53
+ };
54
+ let out = [];
55
+ if (decades <= count && Number.isInteger(base)) {
56
+ const at = (keep) => {
57
+ const ticks = [];
58
+ for (let p = first; p <= last; p++) for (let m = 1; m < base; m++) {
59
+ const v = sign * m * base ** p;
60
+ if (keep(m) && inside(v)) ticks.push(v);
61
+ }
62
+ return ticks;
63
+ };
64
+ out = at(() => true);
65
+ if (out.length > count * 2) out = at((m) => m === 1 || m === 2 || m === 5);
66
+ if (out.length > count * 2) out = at((m) => m === 1);
67
+ } else {
68
+ const step = Math.max(1, Math.ceil(decades / Math.max(1, count)));
69
+ for (let p = Math.ceil(lo / step) * step; p <= hi + 1e-9; p += step) {
70
+ const v = sign * base ** p;
71
+ if (inside(v)) out.push(v);
72
+ }
73
+ }
74
+ return t1 < t0 ? out.reverse() : out;
75
+ },
76
+ nice() {
77
+ const lo = untransform(Math.floor(Math.min(t0, t1)));
78
+ const hi = untransform(Math.ceil(Math.max(t0, t1)));
79
+ return log(t1 < t0 ? [hi, lo] : [lo, hi], range, options);
80
+ }
81
+ });
82
+ }
83
+ //#endregion
84
+ //#region src/charts/log-axis.ts
85
+ /** Domain of a log axis: positive values only, niced to whole powers of ten. */
86
+ function logDomain(values, options) {
87
+ const positive = values.filter((v) => v != null && v > 0 && Number.isFinite(v));
88
+ let [lo, hi] = extent(positive) ?? [1, 10];
89
+ const min = finite(options.min);
90
+ const max = finite(options.max);
91
+ if (min !== null && min > 0) lo = min;
92
+ if (max !== null && max > 0) hi = max;
93
+ if (lo === hi) hi = lo * 10;
94
+ if (options.nice !== false) {
95
+ const niced = log([lo, hi], [0, 1]).nice().domain;
96
+ if (min === null) lo = niced[0];
97
+ if (max === null) hi = niced[1];
98
+ }
99
+ return [lo, hi];
100
+ }
101
+ /** Ticks of a log axis, each power formatted as is. */
102
+ function logTicks(scale, count, format, locale) {
103
+ const fmt = formatNumber(format, locale);
104
+ return scale.ticks(count).map((value) => ({
105
+ value,
106
+ position: scale(value),
107
+ label: fmt(value)
108
+ }));
109
+ }
110
+ //#endregion
111
+ export { logTicks as n, log as r, logDomain as t };
112
+
113
+ //# sourceMappingURL=log-axis-B_uvvOFc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-axis-B_uvvOFc.js","names":[],"sources":["../src/scales/log.ts","../src/charts/log-axis.ts"],"sourcesContent":["import type { LinearScale, LinearScaleOptions } from './linear.ts'\n\nexport interface LogScaleOptions extends LinearScaleOptions {\n /** Logarithm base. Defaults to `10`. */\n base?: number\n}\n\n/**\n * Create a logarithmic scale. The domain must not cross zero: both ends\n * positive (or both negative, mirrored). Same interface as {@link linear},\n * so layouts can use either.\n *\n * ```ts\n * const y = log([1, 10000], [300, 0])\n * y.ticks() // 1, 10, 100, 1000, 10000\n * ```\n */\nexport function log(\n domain: readonly [number, number],\n range: readonly [number, number],\n options: LogScaleOptions = {},\n): LinearScale {\n const base = options.base && options.base > 1 ? options.base : 10\n const clamp = options.clamp === true\n const negative = domain[0] < 0 || domain[1] < 0\n const sign = negative ? -1 : 1\n // Values at or below zero cannot be shown; treat them as the smallest positive step.\n const safe = (v: number): number => Math.max(Number.MIN_VALUE, v * sign)\n const ln = Math.log(base)\n // Exact for the common bases, so powers map to whole numbers.\n const logBase =\n base === 10 ? Math.log10 : base === 2 ? Math.log2 : (v: number) => Math.log(v) / ln\n const transform = (v: number): number => logBase(safe(v))\n const untransform = (t: number): number => sign * base ** t\n const t0 = transform(domain[0])\n const t1 = transform(domain[1])\n const [r0, r1] = range\n const span = t1 - t0\n const k = span === 0 ? 0 : (r1 - r0) / span\n const rMin = Math.min(r0, r1)\n const rMax = Math.max(r0, r1)\n\n const scale = (value: number): number => {\n if (span === 0) return (r0 + r1) / 2\n const px = r0 + (transform(value) - t0) * k\n return clamp ? Math.min(rMax, Math.max(rMin, px)) : px\n }\n\n return Object.assign(scale, {\n domain: [domain[0], domain[1]] as const,\n range: [r0, r1] as const,\n invert(pixel: number): number {\n if (span === 0 || r1 === r0) return domain[0]\n return untransform(t0 + (pixel - r0) / k)\n },\n ticks(count = 5): number[] {\n const lo = Math.min(t0, t1)\n const hi = Math.max(t0, t1)\n if (!Number.isFinite(lo) || !Number.isFinite(hi)) return []\n const first = Math.floor(lo)\n const last = Math.ceil(hi)\n const decades = last - first\n const inside = (v: number) => {\n const t = transform(v)\n return t >= lo - 1e-9 && t <= hi + 1e-9\n }\n let out: number[] = []\n if (decades <= count && Number.isInteger(base)) {\n // Few decades: integer multiples inside each (1, 2, 3 … 9 × 10ⁿ), thinned when crowded.\n const at = (keep: (m: number) => boolean) => {\n const ticks: number[] = []\n for (let p = first; p <= last; p++) {\n for (let m = 1; m < base; m++) {\n const v = sign * m * base ** p\n if (keep(m) && inside(v)) ticks.push(v)\n }\n }\n return ticks\n }\n out = at(() => true)\n if (out.length > count * 2) out = at((m) => m === 1 || m === 2 || m === 5)\n if (out.length > count * 2) out = at((m) => m === 1)\n } else {\n // Many decades: one tick per power (or per few powers).\n const step = Math.max(1, Math.ceil(decades / Math.max(1, count)))\n for (let p = Math.ceil(lo / step) * step; p <= hi + 1e-9; p += step) {\n const v = sign * base ** p\n if (inside(v)) out.push(v)\n }\n }\n return t1 < t0 ? out.reverse() : out\n },\n nice(): LinearScale {\n const lo = untransform(Math.floor(Math.min(t0, t1)))\n const hi = untransform(Math.ceil(Math.max(t0, t1)))\n return log(t1 < t0 ? [hi, lo] : [lo, hi], range, options)\n },\n })\n}\n","import type { Tick } from '../components/axis.ts'\nimport { formatNumber, type Locale, type NumberFormat } from '../format.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { log } from '../scales/log.ts'\nimport type { ValueAxisOptions } from './cartesian.ts'\nimport { finite } from './clean.ts'\n\n/** Domain of a log axis: positive values only, niced to whole powers of ten. */\nexport function logDomain(\n values: readonly (number | null | undefined)[],\n options: ValueAxisOptions,\n): [number, number] {\n const positive = values.filter((v): v is number => v != null && v > 0 && Number.isFinite(v))\n let [lo, hi] = extent(positive) ?? [1, 10]\n // Bounds may come from outside: only positive numbers count.\n const min = finite(options.min)\n const max = finite(options.max)\n if (min !== null && min > 0) lo = min\n if (max !== null && max > 0) hi = max\n if (lo === hi) hi = lo * 10\n if (options.nice !== false) {\n const niced = log([lo, hi], [0, 1]).nice().domain\n if (min === null) lo = niced[0]\n if (max === null) hi = niced[1]\n }\n return [lo, hi]\n}\n\n/** Ticks of a log axis, each power formatted as is. */\nexport function logTicks(\n scale: LinearScale,\n count: number,\n format: NumberFormat | undefined,\n locale: Locale,\n): Tick[] {\n const fmt = formatNumber(format, locale)\n return scale.ticks(count).map((value) => ({ value, position: scale(value), label: fmt(value) }))\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,IACd,QACA,OACA,UAA2B,CAAC,GACf;CACb,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,IAAI,QAAQ,OAAO;CAC/D,MAAM,QAAQ,QAAQ,UAAU;CAEhC,MAAM,OADW,OAAO,KAAK,KAAK,OAAO,KAAK,IACtB,KAAK;CAE7B,MAAM,QAAQ,MAAsB,KAAK,IAAI,OAAO,WAAW,IAAI,IAAI;CACvE,MAAM,KAAK,KAAK,IAAI,IAAI;CAExB,MAAM,UACJ,SAAS,KAAK,KAAK,QAAQ,SAAS,IAAI,KAAK,QAAQ,MAAc,KAAK,IAAI,CAAC,IAAI;CACnF,MAAM,aAAa,MAAsB,QAAQ,KAAK,CAAC,CAAC;CACxD,MAAM,eAAe,MAAsB,OAAO,QAAQ;CAC1D,MAAM,KAAK,UAAU,OAAO,EAAE;CAC9B,MAAM,KAAK,UAAU,OAAO,EAAE;CAC9B,MAAM,CAAC,IAAI,MAAM;CACjB,MAAM,OAAO,KAAK;CAClB,MAAM,IAAI,SAAS,IAAI,KAAK,KAAK,MAAM;CACvC,MAAM,OAAO,KAAK,IAAI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,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;EAC3C,IAAI,QAAQ,MAAM,KAAK,MAAM;EAC7B,IAAI,QAAQ,MAAM,KAAK,MAAM;CAC/B;CACA,OAAO,CAAC,IAAI,EAAE;AAChB;;AAGA,SAAgB,SACd,OACA,OACA,QACA,QACQ;CACR,MAAM,MAAM,aAAa,QAAQ,MAAM;CACvC,OAAO,MAAM,MAAM,KAAK,CAAC,CAAC,KAAK,WAAW;EAAE;EAAO,UAAU,MAAM,KAAK;EAAG,OAAO,IAAI,KAAK;CAAE,EAAE;AACjG"}
package/dist/log.cjs ADDED
@@ -0,0 +1,17 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_features = require("./features-BclHgg2W.cjs");
3
+ const require_log_axis = require("./log-axis-83rSpvL5.cjs");
4
+ //#region src/log.ts
5
+ /**
6
+ * Registers logarithmic value axes (`scale: 'log'`):
7
+ * `import '@tabler/charts/log'`. Also exports the scale itself.
8
+ */
9
+ require_features.register({ log: {
10
+ scale: require_log_axis.log,
11
+ domain: require_log_axis.logDomain,
12
+ ticks: require_log_axis.logTicks
13
+ } });
14
+ //#endregion
15
+ exports.log = require_log_axis.log;
16
+
17
+ //# sourceMappingURL=log.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.cjs","names":["register","log","logDomain","logTicks"],"sources":["../src/log.ts"],"sourcesContent":["/**\n * Registers logarithmic value axes (`scale: 'log'`):\n * `import '@tabler/charts/log'`. Also exports the scale itself.\n */\nimport { logDomain, logTicks } from './charts/log-axis.ts'\nimport { register } from './features.ts'\nimport { log } from './scales/log.ts'\n\nregister({ log: { scale: log, domain: logDomain, ticks: logTicks } })\n\nexport type { LogScaleOptions } from './scales/log.ts'\nexport { log }\n"],"mappings":";;;;;;;;AAQAA,iBAAAA,SAAS,EAAE,KAAK;CAAE,OAAOC,iBAAAA;CAAK,QAAQC,iBAAAA;CAAW,OAAOC,iBAAAA;AAAS,EAAE,CAAC"}
package/dist/log.d.cts ADDED
@@ -0,0 +1,2 @@
1
+ import { n as log, t as LogScaleOptions } from "./log-CaofN3-n.cjs";
2
+ export { type LogScaleOptions, log };
package/dist/log.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { n as log, t as LogScaleOptions } from "./log-CaofN3-n.js";
2
+ export { type LogScaleOptions, log };
package/dist/log.js ADDED
@@ -0,0 +1,16 @@
1
+ import { i as register } from "./features-wASyHGic.js";
2
+ import { n as logTicks, r as log, t as logDomain } from "./log-axis-B_uvvOFc.js";
3
+ //#region src/log.ts
4
+ /**
5
+ * Registers logarithmic value axes (`scale: 'log'`):
6
+ * `import '@tabler/charts/log'`. Also exports the scale itself.
7
+ */
8
+ register({ log: {
9
+ scale: log,
10
+ domain: logDomain,
11
+ ticks: logTicks
12
+ } });
13
+ //#endregion
14
+ export { log };
15
+
16
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","names":[],"sources":["../src/log.ts"],"sourcesContent":["/**\n * Registers logarithmic value axes (`scale: 'log'`):\n * `import '@tabler/charts/log'`. Also exports the scale itself.\n */\nimport { logDomain, logTicks } from './charts/log-axis.ts'\nimport { register } from './features.ts'\nimport { log } from './scales/log.ts'\n\nregister({ log: { scale: log, domain: logDomain, ticks: logTicks } })\n\nexport type { LogScaleOptions } from './scales/log.ts'\nexport { log }\n"],"mappings":";;;;;;;AAQA,SAAS,EAAE,KAAK;CAAE,OAAO;CAAK,QAAQ;CAAW,OAAO;AAAS,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ //#region src/render/morph.d.ts
2
+ /**
3
+ * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by
4
+ * frame. Returns `false` when the browser transitions `d` itself, or the
5
+ * path is not meant to move (the caller then just sets the attribute).
6
+ */
7
+ declare function morph(el: Element, from: string, to: string): boolean;
8
+ //#endregion
9
+ export { morph as t };
10
+ //# sourceMappingURL=morph-BMxz3X2b.d.cts.map
@@ -0,0 +1,10 @@
1
+ //#region src/render/morph.d.ts
2
+ /**
3
+ * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by
4
+ * frame. Returns `false` when the browser transitions `d` itself, or the
5
+ * path is not meant to move (the caller then just sets the attribute).
6
+ */
7
+ declare function morph(el: Element, from: string, to: string): boolean;
8
+ //#endregion
9
+ export { morph as t };
10
+ //# sourceMappingURL=morph-BMxz3X2b.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { a as round } from "./layout-B3hiqVEw.js";
2
+ import { n as tween, t as stop } from "./tween-BCYd0RTY.js";
3
+ //#region src/render/morph.ts
4
+ /**
5
+ * Path morphing for browsers that cannot transition `d` in CSS (Safari):
6
+ * when a patch changes the `d` of a path whose style asks for a `d`
7
+ * transition, the numbers in the path are interpolated frame by frame
8
+ * instead, over the transition's duration with an ease-out curve. Chart
9
+ * paths keep their commands between renders, so only the numbers move; a
10
+ * path whose commands changed jumps, as it would in CSS too.
11
+ */
12
+ const NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi;
13
+ let native;
14
+ /**
15
+ * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by
16
+ * frame. Returns `false` when the browser transitions `d` itself, or the
17
+ * path is not meant to move (the caller then just sets the attribute).
18
+ */
19
+ function morph(el, from, to) {
20
+ native ??= typeof CSS === "undefined" || CSS.supports("d", "path(\"M0 0\")");
21
+ const current = stop(el);
22
+ if (native || el.closest(".tc-static,[data-resizing]")) return false;
23
+ const style = getComputedStyle(el);
24
+ const index = style.transitionProperty.split(", ").findIndex((p) => p === "d" || p === "all");
25
+ const duration = index < 0 ? 0 : Number.parseFloat(style.transitionDuration.split(", ")[index] ?? "") * 1e3;
26
+ const text = to.split(NUMBER);
27
+ const end = to.match(NUMBER)?.map(Number) ?? [];
28
+ const start = from.match(NUMBER)?.map(Number) ?? [];
29
+ if (!(duration > 0) || start.length !== end.length || from.split(NUMBER).join() !== text.join()) return false;
30
+ tween(el, current?.length === end.length ? current : start, end, duration, (now) => now.reduce((d, value, i) => d + round(value) + text[i + 1], text[0]), to);
31
+ return true;
32
+ }
33
+ //#endregion
34
+ export { morph as t };
35
+
36
+ //# sourceMappingURL=morph-Bgg-24l8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph-Bgg-24l8.js","names":[],"sources":["../src/render/morph.ts"],"sourcesContent":["/**\n * Path morphing for browsers that cannot transition `d` in CSS (Safari):\n * when a patch changes the `d` of a path whose style asks for a `d`\n * transition, the numbers in the path are interpolated frame by frame\n * instead, over the transition's duration with an ease-out curve. Chart\n * paths keep their commands between renders, so only the numbers move; a\n * path whose commands changed jumps, as it would in CSS too.\n */\n\nimport { round } from '../layout.ts'\nimport { stop, tween } from './tween.ts'\n\nconst NUMBER = /-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi\n\nlet native: boolean | undefined\n\n/**\n * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by\n * frame. Returns `false` when the browser transitions `d` itself, or the\n * path is not meant to move (the caller then just sets the attribute).\n */\nexport function morph(el: Element, from: string, to: string): boolean {\n native ??= typeof CSS === 'undefined' || CSS.supports('d', 'path(\"M0 0\")')\n const current = stop(el)\n // A chart without transitions (too big to animate, or resizing) has nothing to\n // morph: said here, before asking for the style of each of its paths.\n if (native || el.closest('.tc-static,[data-resizing]')) return false\n\n const style = getComputedStyle(el)\n const index = style.transitionProperty.split(', ').findIndex((p) => p === 'd' || p === 'all')\n const duration =\n index < 0 ? 0 : Number.parseFloat(style.transitionDuration.split(', ')[index] ?? '') * 1000\n const text = to.split(NUMBER)\n const end = to.match(NUMBER)?.map(Number) ?? []\n const start = from.match(NUMBER)?.map(Number) ?? []\n if (!(duration > 0) || start.length !== end.length || from.split(NUMBER).join() !== text.join()) {\n return false\n }\n\n // An interrupted morph continues from where the path is now.\n tween(\n el,\n current?.length === end.length ? current : start,\n end,\n duration,\n (now) =>\n now.reduce((d, value, i) => d + round(value) + (text[i + 1] as string), text[0] as string),\n to,\n )\n return true\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,SAAS;AAEf,IAAI;;;;;;AAOJ,SAAgB,MAAM,IAAa,MAAc,IAAqB;CACpE,WAAW,OAAO,QAAQ,eAAe,IAAI,SAAS,KAAK,gBAAc;CACzE,MAAM,UAAU,KAAK,EAAE;CAGvB,IAAI,UAAU,GAAG,QAAQ,4BAA4B,GAAG,OAAO;CAE/D,MAAM,QAAQ,iBAAiB,EAAE;CACjC,MAAM,QAAQ,MAAM,mBAAmB,MAAM,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM,OAAO,MAAM,KAAK;CAC5F,MAAM,WACJ,QAAQ,IAAI,IAAI,OAAO,WAAW,MAAM,mBAAmB,MAAM,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI;CACzF,MAAM,OAAO,GAAG,MAAM,MAAM;CAC5B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,IAAI,MAAM,KAAK,CAAC;CAC9C,MAAM,QAAQ,KAAK,MAAM,MAAM,CAAC,EAAE,IAAI,MAAM,KAAK,CAAC;CAClD,IAAI,EAAE,WAAW,MAAM,MAAM,WAAW,IAAI,UAAU,KAAK,MAAM,MAAM,CAAC,CAAC,KAAK,MAAM,KAAK,KAAK,GAC5F,OAAO;CAIT,MACE,IACA,SAAS,WAAW,IAAI,SAAS,UAAU,OAC3C,KACA,WACC,QACC,IAAI,QAAQ,GAAG,OAAO,MAAM,IAAI,MAAM,KAAK,IAAK,KAAK,IAAI,IAAe,KAAK,EAAY,GAC3F,EACF;CACA,OAAO;AACT"}
@@ -0,0 +1,41 @@
1
+ const require_layout = require("./layout-CtMBhNd9.cjs");
2
+ const require_tween = require("./tween-CIGBlryn.cjs");
3
+ //#region src/render/morph.ts
4
+ /**
5
+ * Path morphing for browsers that cannot transition `d` in CSS (Safari):
6
+ * when a patch changes the `d` of a path whose style asks for a `d`
7
+ * transition, the numbers in the path are interpolated frame by frame
8
+ * instead, over the transition's duration with an ease-out curve. Chart
9
+ * paths keep their commands between renders, so only the numbers move; a
10
+ * path whose commands changed jumps, as it would in CSS too.
11
+ */
12
+ const NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi;
13
+ let native;
14
+ /**
15
+ * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by
16
+ * frame. Returns `false` when the browser transitions `d` itself, or the
17
+ * path is not meant to move (the caller then just sets the attribute).
18
+ */
19
+ function morph(el, from, to) {
20
+ native ??= typeof CSS === "undefined" || CSS.supports("d", "path(\"M0 0\")");
21
+ const current = require_tween.stop(el);
22
+ if (native || el.closest(".tc-static,[data-resizing]")) return false;
23
+ const style = getComputedStyle(el);
24
+ const index = style.transitionProperty.split(", ").findIndex((p) => p === "d" || p === "all");
25
+ const duration = index < 0 ? 0 : Number.parseFloat(style.transitionDuration.split(", ")[index] ?? "") * 1e3;
26
+ const text = to.split(NUMBER);
27
+ const end = to.match(NUMBER)?.map(Number) ?? [];
28
+ const start = from.match(NUMBER)?.map(Number) ?? [];
29
+ if (!(duration > 0) || start.length !== end.length || from.split(NUMBER).join() !== text.join()) return false;
30
+ require_tween.tween(el, current?.length === end.length ? current : start, end, duration, (now) => now.reduce((d, value, i) => d + require_layout.round(value) + text[i + 1], text[0]), to);
31
+ return true;
32
+ }
33
+ //#endregion
34
+ Object.defineProperty(exports, "morph", {
35
+ enumerable: true,
36
+ get: function() {
37
+ return morph;
38
+ }
39
+ });
40
+
41
+ //# sourceMappingURL=morph-CqYDu1bY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph-CqYDu1bY.cjs","names":["stop","round"],"sources":["../src/render/morph.ts"],"sourcesContent":["/**\n * Path morphing for browsers that cannot transition `d` in CSS (Safari):\n * when a patch changes the `d` of a path whose style asks for a `d`\n * transition, the numbers in the path are interpolated frame by frame\n * instead, over the transition's duration with an ease-out curve. Chart\n * paths keep their commands between renders, so only the numbers move; a\n * path whose commands changed jumps, as it would in CSS too.\n */\n\nimport { round } from '../layout.ts'\nimport { stop, tween } from './tween.ts'\n\nconst NUMBER = /-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi\n\nlet native: boolean | undefined\n\n/**\n * Change `el`'s `d` from `from` to `to` over its CSS transition, frame by\n * frame. Returns `false` when the browser transitions `d` itself, or the\n * path is not meant to move (the caller then just sets the attribute).\n */\nexport function morph(el: Element, from: string, to: string): boolean {\n native ??= typeof CSS === 'undefined' || CSS.supports('d', 'path(\"M0 0\")')\n const current = stop(el)\n // A chart without transitions (too big to animate, or resizing) has nothing to\n // morph: said here, before asking for the style of each of its paths.\n if (native || el.closest('.tc-static,[data-resizing]')) return false\n\n const style = getComputedStyle(el)\n const index = style.transitionProperty.split(', ').findIndex((p) => p === 'd' || p === 'all')\n const duration =\n index < 0 ? 0 : Number.parseFloat(style.transitionDuration.split(', ')[index] ?? '') * 1000\n const text = to.split(NUMBER)\n const end = to.match(NUMBER)?.map(Number) ?? []\n const start = from.match(NUMBER)?.map(Number) ?? []\n if (!(duration > 0) || start.length !== end.length || from.split(NUMBER).join() !== text.join()) {\n return false\n }\n\n // An interrupted morph continues from where the path is now.\n tween(\n el,\n current?.length === end.length ? current : start,\n end,\n duration,\n (now) =>\n now.reduce((d, value, i) => d + round(value) + (text[i + 1] as string), text[0] as string),\n to,\n )\n return true\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,SAAS;AAEf,IAAI;;;;;;AAOJ,SAAgB,MAAM,IAAa,MAAc,IAAqB;CACpE,WAAW,OAAO,QAAQ,eAAe,IAAI,SAAS,KAAK,gBAAc;CACzE,MAAM,UAAUA,cAAAA,KAAK,EAAE;CAGvB,IAAI,UAAU,GAAG,QAAQ,4BAA4B,GAAG,OAAO;CAE/D,MAAM,QAAQ,iBAAiB,EAAE;CACjC,MAAM,QAAQ,MAAM,mBAAmB,MAAM,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM,OAAO,MAAM,KAAK;CAC5F,MAAM,WACJ,QAAQ,IAAI,IAAI,OAAO,WAAW,MAAM,mBAAmB,MAAM,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI;CACzF,MAAM,OAAO,GAAG,MAAM,MAAM;CAC5B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,IAAI,MAAM,KAAK,CAAC;CAC9C,MAAM,QAAQ,KAAK,MAAM,MAAM,CAAC,EAAE,IAAI,MAAM,KAAK,CAAC;CAClD,IAAI,EAAE,WAAW,MAAM,MAAM,WAAW,IAAI,UAAU,KAAK,MAAM,MAAM,CAAC,CAAC,KAAK,MAAM,KAAK,KAAK,GAC5F,OAAO;CAIT,cAAA,MACE,IACA,SAAS,WAAW,IAAI,SAAS,UAAU,OAC3C,KACA,WACC,QACC,IAAI,QAAQ,GAAG,OAAO,MAAM,IAAIC,eAAAA,MAAM,KAAK,IAAK,KAAK,IAAI,IAAe,KAAK,EAAY,GAC3F,EACF;CACA,OAAO;AACT"}
package/dist/morph.cjs ADDED
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_features = require("./features-BclHgg2W.cjs");
3
+ const require_morph = require("./morph-CqYDu1bY.cjs");
4
+ //#region src/morph.ts
5
+ /**
6
+ * Standalone entry: `import '@tabler/charts/morph'` animates path changes
7
+ * (new data) in browsers that cannot transition `d` in CSS, such as Safari.
8
+ * Elsewhere it does nothing; `@tabler/charts` includes it.
9
+ */
10
+ require_features.register({ morph: require_morph.morph });
11
+ //#endregion
12
+ exports.morph = require_morph.morph;
13
+
14
+ //# sourceMappingURL=morph.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.cjs","names":["register"],"sources":["../src/morph.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/morph'` animates path changes\n * (new data) in browsers that cannot transition `d` in CSS, such as Safari.\n * Elsewhere it does nothing; `@tabler/charts` includes it.\n */\nimport { register } from './features.ts'\nimport { morph } from './render/morph.ts'\n\nregister({ morph })\n\nexport { morph }\n"],"mappings":";;;;;;;;;AAQAA,iBAAAA,SAAS,EAAE,OAAA,cAAA,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { t as morph } from "./morph-BMxz3X2b.cjs";
2
+ export { morph };
@@ -0,0 +1,2 @@
1
+ import { t as morph } from "./morph-BMxz3X2b.js";
2
+ export { morph };
package/dist/morph.js ADDED
@@ -0,0 +1,13 @@
1
+ import { i as register } from "./features-wASyHGic.js";
2
+ import { t as morph } from "./morph-Bgg-24l8.js";
3
+ //#region src/morph.ts
4
+ /**
5
+ * Standalone entry: `import '@tabler/charts/morph'` animates path changes
6
+ * (new data) in browsers that cannot transition `d` in CSS, such as Safari.
7
+ * Elsewhere it does nothing; `@tabler/charts` includes it.
8
+ */
9
+ register({ morph });
10
+ //#endregion
11
+ export { morph };
12
+
13
+ //# sourceMappingURL=morph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.js","names":[],"sources":["../src/morph.ts"],"sourcesContent":["/**\n * Standalone entry: `import '@tabler/charts/morph'` animates path changes\n * (new data) in browsers that cannot transition `d` in CSS, such as Safari.\n * Elsewhere it does nothing; `@tabler/charts` includes it.\n */\nimport { register } from './features.ts'\nimport { morph } from './render/morph.ts'\n\nregister({ morph })\n\nexport { morph }\n"],"mappings":";;;;;;;;AAQA,SAAS,EAAE,MAAM,CAAC"}
@@ -0,0 +1,50 @@
1
+ //#region src/charts/named.ts
2
+ /** Stable key of a series, slice or ring: its `id`, or its name. */
3
+ const keyOf = (item) => item.id ?? item.name;
4
+ /** Legend entries for series, slices or rings, in their order (which is their color slot). */
5
+ function legendItems(list) {
6
+ return list.map((entry, index) => {
7
+ const item = {
8
+ key: keyOf(entry),
9
+ name: entry.name,
10
+ index
11
+ };
12
+ if (entry.color) item.color = entry.color;
13
+ if (entry.hidden) item.hidden = true;
14
+ return item;
15
+ });
16
+ }
17
+ /** Attributes of the group of a series, slice or ring in color slot `index`. */
18
+ function groupAttrs(item, index) {
19
+ return {
20
+ key: keyOf(item),
21
+ class: [
22
+ "tc-series",
23
+ `tc-series-${index + 1}`,
24
+ item.class
25
+ ],
26
+ "data-series": item.name,
27
+ style: { "--tc-series-color": item.color }
28
+ };
29
+ }
30
+ //#endregion
31
+ Object.defineProperty(exports, "groupAttrs", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return groupAttrs;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "keyOf", {
38
+ enumerable: true,
39
+ get: function() {
40
+ return keyOf;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "legendItems", {
44
+ enumerable: true,
45
+ get: function() {
46
+ return legendItems;
47
+ }
48
+ });
49
+
50
+ //# sourceMappingURL=named-BWWb5LQJ.cjs.map