@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,709 @@
1
+ import { a as round, i as insets, n as estimateTextWidth, r as innerRect, t as LINE_HEIGHT } from "./layout-B3hiqVEw.js";
2
+ import { t as h } from "./vnode-tCWItoUH.js";
3
+ import { i as formatTicks, n as formatDetail } from "./format-lStwuc1L.js";
4
+ import { n as feature, r as features } from "./features-wASyHGic.js";
5
+ import { t as extent } from "./extent-BAMZo0Nq.js";
6
+ import { i as finite } from "./clean-o1vDEhFV.js";
7
+ import { n as keyOf, r as legendItems, t as groupAttrs } from "./named-DE15TOgh.js";
8
+ //#region src/scales/ticks.ts
9
+ const E10 = Math.sqrt(50);
10
+ const E5 = Math.sqrt(10);
11
+ const E2 = Math.sqrt(2);
12
+ /**
13
+ * Integer tick indices `[i1, i2]` and an increment `inc`. A negative `inc`
14
+ * means "divide by -inc", which keeps decimal ticks exact (0.3, not
15
+ * 0.30000000000000004).
16
+ */
17
+ function tickSpec(start, stop, count) {
18
+ const step = (stop - start) / Math.max(0, count);
19
+ const power = Math.floor(Math.log10(step));
20
+ const error = step / 10 ** power;
21
+ const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;
22
+ let i1;
23
+ let i2;
24
+ let inc;
25
+ if (power < 0) {
26
+ inc = 10 ** -power / factor;
27
+ i1 = Math.round(start * inc);
28
+ i2 = Math.round(stop * inc);
29
+ if (i1 / inc < start) ++i1;
30
+ if (i2 / inc > stop) --i2;
31
+ inc = -inc;
32
+ } else {
33
+ inc = 10 ** power * factor;
34
+ i1 = Math.round(start / inc);
35
+ i2 = Math.round(stop / inc);
36
+ if (i1 * inc < start) ++i1;
37
+ if (i2 * inc > stop) --i2;
38
+ }
39
+ if (i2 < i1 && count >= .5 && count < 2) return tickSpec(start, stop, count * 2);
40
+ return [
41
+ i1,
42
+ i2,
43
+ inc
44
+ ];
45
+ }
46
+ /**
47
+ * Roughly `count` evenly spaced, "nice" values (multiples of 1, 2 or 5 × 10ⁿ)
48
+ * between `start` and `stop`, inclusive. Order follows `start → stop`.
49
+ */
50
+ function ticks(start, stop, count = 5) {
51
+ if (!(count > 0) || !Number.isFinite(start) || !Number.isFinite(stop)) return [];
52
+ if (start === stop) return [start];
53
+ const reverse = stop < start;
54
+ const [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count);
55
+ if (!(i2 >= i1)) return [];
56
+ const n = i2 - i1 + 1;
57
+ const out = new Array(n);
58
+ for (let i = 0; i < n; i++) {
59
+ const index = reverse ? i2 - i : i1 + i;
60
+ out[i] = inc < 0 ? index / -inc : index * inc;
61
+ }
62
+ return out;
63
+ }
64
+ /**
65
+ * Signed tick increment: positive values are the step, negative values `-k`
66
+ * mean a step of `1 / k`.
67
+ */
68
+ function tickIncrement(start, stop, count) {
69
+ return tickSpec(start, stop, count)[2];
70
+ }
71
+ /** Distance between ticks produced by {@link ticks} for the same arguments. */
72
+ function tickStep(start, stop, count = 5) {
73
+ const reverse = stop < start;
74
+ const inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
75
+ return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
76
+ }
77
+ /**
78
+ * Extend `[start, stop]` to round tick values, e.g. `[0.2, 9.7] → [0, 10]`.
79
+ * Iterates because rounding can change the ideal step; if the step does not
80
+ * settle (e.g. very low `count` around zero keeps doubling the domain), the
81
+ * domain is returned unchanged, matching d3.
82
+ */
83
+ function niceDomain(start, stop, count = 5) {
84
+ if (!Number.isFinite(start) || !Number.isFinite(stop) || start === stop || !(count > 0)) return [start, stop];
85
+ const reverse = stop < start;
86
+ let lo = reverse ? stop : start;
87
+ let hi = reverse ? start : stop;
88
+ let prev;
89
+ for (let i = 0; i < 10; i++) {
90
+ const step = tickIncrement(lo, hi, count);
91
+ if (step === prev) return reverse ? [hi, lo] : [lo, hi];
92
+ if (step > 0) {
93
+ lo = Math.floor(lo / step) * step;
94
+ hi = Math.ceil(hi / step) * step;
95
+ } else if (step < 0) {
96
+ lo = Math.ceil(lo * step) / step;
97
+ hi = Math.floor(hi * step) / step;
98
+ } else break;
99
+ prev = step;
100
+ }
101
+ return [start, stop];
102
+ }
103
+ //#endregion
104
+ //#region src/components/axis.ts
105
+ /** Ticks for a linear scale, labelled with a shared precision. */
106
+ function linearTicks(scale, options = {}) {
107
+ const { count = 5, format, locale } = options;
108
+ const [d0, d1] = scale.domain;
109
+ const fmt = formatTicks(tickStep(d0, d1, count), format, locale);
110
+ return scale.ticks(count).map((value) => ({
111
+ value,
112
+ position: scale(value),
113
+ label: fmt(value)
114
+ }));
115
+ }
116
+ /** Ticks at the center of every band. */
117
+ function bandTicks(scale, format = String) {
118
+ return scale.domain.map((key, i) => ({
119
+ value: key,
120
+ position: scale.at(i) + scale.bandwidth / 2,
121
+ label: format(key, i)
122
+ }));
123
+ }
124
+ /** Whether labels are laid out along x (horizontal axes). */
125
+ const isHorizontal = (position) => position === "top" || position === "bottom";
126
+ /**
127
+ * Keep every n-th tick (smallest n) so labels do not overlap along the axis.
128
+ * The first and the last tick are always kept: when the last one does not
129
+ * land on the step, it replaces the last kept tick if they would collide.
130
+ */
131
+ function thinTicks(ticks, position, fontSize, gap = 8) {
132
+ if (ticks.length < 2) return ticks.slice();
133
+ const size = (tick) => isHorizontal(position) ? estimateTextWidth(tick.label, fontSize) : fontSize * LINE_HEIGHT;
134
+ const sizes = ticks.map(size);
135
+ const fitsBetween = (i, j) => Math.abs(ticks[j].position - ticks[i].position) >= (sizes[i] + sizes[j]) / 2 + gap;
136
+ const last = ticks.length - 1;
137
+ const span = Math.abs(ticks[last].position - ticks[0].position);
138
+ const total = sizes.reduce((sum, size) => sum + size + gap, 0);
139
+ const first = span > 0 ? Math.max(1, Math.floor(total / span)) : last;
140
+ for (let step = first; step <= last; step++) {
141
+ let fits = true;
142
+ for (let i = step; i <= last && fits; i += step) fits = fitsBetween(i - step, i);
143
+ if (!fits) continue;
144
+ const kept = [];
145
+ for (let i = 0; i <= last; i += step) kept.push(i);
146
+ const tail = kept[kept.length - 1];
147
+ if (tail !== last) {
148
+ if (fitsBetween(tail, last)) kept.push(last);
149
+ else if (kept.length > 1 && fitsBetween(kept[kept.length - 2], last)) kept[kept.length - 1] = last;
150
+ }
151
+ return kept.map((i) => ticks[i]);
152
+ }
153
+ return ticks.slice(0, 1);
154
+ }
155
+ /** Pixels an axis occupies perpendicular to the plot edge (for margins). */
156
+ function axisSize(position, ticks, fontSize, options = {}) {
157
+ const { tickSize = 0, tickPadding = 8 } = options;
158
+ if (ticks.length === 0) return 0;
159
+ const labels = isHorizontal(position) ? fontSize * LINE_HEIGHT : ticks.reduce((max, t) => Math.max(max, estimateTextWidth(t.label, fontSize)), 0) + 3;
160
+ return Math.ceil(labels + tickSize + tickPadding);
161
+ }
162
+ /**
163
+ * Render an axis as `<g class="tc-axis tc-axis-{x|y} tc-axis-{position}">`
164
+ * with one `<g class="tc-tick">` per tick, keyed by value so ticks can
165
+ * transition when the scale changes.
166
+ */
167
+ function axis(options) {
168
+ const { position, ticks, area, tickSize = 0, tickPadding = 8, line = false } = options;
169
+ const horizontal = isHorizontal(position);
170
+ const sign = position === "top" || position === "left" ? -1 : 1;
171
+ const offset = sign * (tickSize + tickPadding);
172
+ const edge = position === "top" ? area.y : position === "bottom" ? area.y + area.height : position === "left" ? area.x : area.x + area.width;
173
+ const label = horizontal ? {
174
+ y: offset,
175
+ dy: position === "top" ? "0em" : "0.71em",
176
+ "text-anchor": "middle"
177
+ } : {
178
+ x: offset,
179
+ dy: "0.32em",
180
+ "text-anchor": position === "left" ? "end" : "start"
181
+ };
182
+ const tickLine = horizontal ? { y2: sign * tickSize } : { x2: sign * tickSize };
183
+ return h("g", {
184
+ key: `axis-${position}`,
185
+ class: [
186
+ "tc-axis",
187
+ horizontal ? "tc-axis-x" : "tc-axis-y",
188
+ `tc-axis-${position}`
189
+ ],
190
+ "aria-hidden": "true"
191
+ }, line && h("line", horizontal ? {
192
+ class: "tc-axis-line",
193
+ x1: area.x,
194
+ x2: area.x + area.width,
195
+ y1: edge,
196
+ y2: edge
197
+ } : {
198
+ class: "tc-axis-line",
199
+ x1: edge,
200
+ x2: edge,
201
+ y1: area.y,
202
+ y2: area.y + area.height
203
+ }), ticks.map((tick) => h("g", {
204
+ key: tick.value,
205
+ class: "tc-tick",
206
+ style: horizontal ? `transform:translate(${round(tick.position)}px,${round(edge)}px)` : `transform:translate(${round(edge)}px,${round(tick.position)}px)`
207
+ }, tickSize > 0 && h("line", {
208
+ class: "tc-tick-line",
209
+ ...tickLine
210
+ }), h("text", {
211
+ class: "tc-tick-label",
212
+ ...label
213
+ }, tick.label))));
214
+ }
215
+ //#endregion
216
+ //#region src/components/grid.ts
217
+ /**
218
+ * Render grid lines as `<g class="tc-grid tc-grid-{x|y}">`. The line at
219
+ * value `0` also gets `tc-grid-line-zero`, so the baseline can be emphasized.
220
+ */
221
+ function grid(options) {
222
+ const { direction, ticks, area } = options;
223
+ return h("g", {
224
+ key: `grid-${direction}`,
225
+ class: ["tc-grid", `tc-grid-${direction}`],
226
+ "aria-hidden": "true"
227
+ }, ticks.map((tick) => {
228
+ const p = round(tick.position);
229
+ return h("line", {
230
+ key: tick.value,
231
+ class: ["tc-grid-line", tick.value === 0 && "tc-grid-line-zero"],
232
+ ...direction === "y" ? {
233
+ x1: area.x,
234
+ x2: area.x + area.width,
235
+ y1: 0,
236
+ y2: 0,
237
+ style: `transform:translateY(${p}px)`
238
+ } : {
239
+ x1: 0,
240
+ x2: 0,
241
+ y1: area.y,
242
+ y2: area.y + area.height,
243
+ style: `transform:translateX(${p}px)`
244
+ }
245
+ });
246
+ }));
247
+ }
248
+ //#endregion
249
+ //#region src/scales/band.ts
250
+ /**
251
+ * Create a band scale, e.g. for bar charts.
252
+ *
253
+ * ```ts
254
+ * const x = band(['Jan', 'Feb', 'Mar'], [0, 300], { paddingInner: 0.2 })
255
+ * x('Feb') // start of the "Feb" band
256
+ * x.bandwidth // bar width
257
+ * ```
258
+ */
259
+ function band(domain, range, options = {}) {
260
+ const { paddingInner = 0, paddingOuter = 0, align = .5 } = options;
261
+ const inner = Math.min(1, Math.max(0, paddingInner));
262
+ const n = domain.length;
263
+ const [r0, r1] = range;
264
+ const reverse = r1 < r0;
265
+ const lo = reverse ? r1 : r0;
266
+ const hi = reverse ? r0 : r1;
267
+ const step = (hi - lo) / Math.max(1, n - inner + paddingOuter * 2);
268
+ const start = lo + (hi - lo - step * (n - inner)) * align;
269
+ const bandwidth = step * (1 - inner);
270
+ const index = /* @__PURE__ */ new Map();
271
+ for (let i = 0; i < n; i++) {
272
+ const key = domain[i];
273
+ if (!index.has(key)) index.set(key, i);
274
+ }
275
+ const at = (i) => start + step * (reverse ? n - 1 - i : i);
276
+ const scale = (key) => {
277
+ const i = index.get(key);
278
+ return i === void 0 ? void 0 : at(i);
279
+ };
280
+ return Object.assign(scale, {
281
+ domain: domain.slice(),
282
+ range: [r0, r1],
283
+ bandwidth,
284
+ step,
285
+ at,
286
+ center(key) {
287
+ const px = scale(key);
288
+ return px === void 0 ? void 0 : px + bandwidth / 2;
289
+ },
290
+ indexAt(pixel) {
291
+ if (n === 0) return -1;
292
+ const raw = step === 0 ? 0 : Math.round((pixel - start - bandwidth / 2) / step);
293
+ const i = Math.min(n - 1, Math.max(0, raw));
294
+ return reverse ? n - 1 - i : i;
295
+ }
296
+ });
297
+ }
298
+ /**
299
+ * Create a point scale: a band scale with zero-width bands, placing each
300
+ * category on a single point (e.g. line charts over labels).
301
+ * `padding` is the space before the first and after the last point, in steps.
302
+ */
303
+ function point(domain, range, options = {}) {
304
+ const { padding = 0, align } = options;
305
+ return band(domain, range, {
306
+ paddingInner: 1,
307
+ paddingOuter: padding,
308
+ ...align === void 0 ? {} : { align }
309
+ });
310
+ }
311
+ //#endregion
312
+ //#region src/scales/linear.ts
313
+ /**
314
+ * Create a linear scale.
315
+ *
316
+ * ```ts
317
+ * const y = linear([0, 120], [300, 0]).nice()
318
+ * y(60) // 150
319
+ * ```
320
+ *
321
+ * A zero-width domain (e.g. a single data point) maps to the middle of the range.
322
+ */
323
+ function linear(domain, range, options = {}) {
324
+ const [d0, d1] = domain;
325
+ const [r0, r1] = range;
326
+ const span = d1 - d0;
327
+ const k = span === 0 ? 0 : (r1 - r0) / span;
328
+ const mid = (r0 + r1) / 2;
329
+ const { clamp = false } = options;
330
+ const rMin = Math.min(r0, r1);
331
+ const rMax = Math.max(r0, r1);
332
+ const dMin = Math.min(d0, d1);
333
+ const dMax = Math.max(d0, d1);
334
+ const scale = (value) => {
335
+ if (span === 0) return mid;
336
+ const px = r0 + (value - d0) * k;
337
+ return clamp ? Math.min(rMax, Math.max(rMin, px)) : px;
338
+ };
339
+ return Object.assign(scale, {
340
+ domain: [d0, d1],
341
+ range: [r0, r1],
342
+ invert(pixel) {
343
+ if (span === 0 || r1 === r0) return d0;
344
+ const value = d0 + (pixel - r0) / k;
345
+ return clamp ? Math.min(dMax, Math.max(dMin, value)) : value;
346
+ },
347
+ ticks(count) {
348
+ return ticks(d0, d1, count);
349
+ },
350
+ nice(count) {
351
+ return linear(niceDomain(d0, d1, count), range, options);
352
+ }
353
+ });
354
+ }
355
+ //#endregion
356
+ //#region src/charts/cartesian.ts
357
+ /** A label as a `key` for keyed rendering (dates by their timestamp). */
358
+ const labelKey = (label) => label instanceof Date ? label.getTime() : label;
359
+ /** Stable key of a series: its `id`, or its name. */
360
+ const seriesKey = keyOf;
361
+ /** Legend entries for series-based charts. */
362
+ const seriesLegend = (data) => legendItems(data.series);
363
+ /** Categories from `data.labels`, or `1…n` for the longest series. */
364
+ function resolveLabels(data) {
365
+ if (data.labels) return data.labels.slice();
366
+ const n = Math.max(0, ...data.series.map((s) => s.values.length));
367
+ return Array.from({ length: n }, (_, i) => i + 1);
368
+ }
369
+ /**
370
+ * Whether a value can be plotted on the axis: finite, and positive on a log
371
+ * scale (zero and negatives become gaps there).
372
+ */
373
+ function plottable(value, axis) {
374
+ if (value == null || !Number.isFinite(value)) return false;
375
+ return axis?.scale !== "log" || value > 0;
376
+ }
377
+ /**
378
+ * Whether the category axis carries time: `x.type === 'time'` and every label
379
+ * is a date, a timestamp or a parseable string. Otherwise the axis falls back
380
+ * to categories instead of producing NaN positions.
381
+ */
382
+ const isTimeAxis = (options) => options.x?.type === "time" && resolveLabels(options.data).every((l) => Number.isFinite(toMs(l)));
383
+ /** Formatter for category labels in tooltips and tables. */
384
+ function labelFormatter(options, ctx) {
385
+ if (options.x?.format) return options.x.format;
386
+ if (!isTimeAxis(options)) return (label) => String(label);
387
+ return feature("dates")(resolveLabels(options.data), options.x?.utc, ctx.locale);
388
+ }
389
+ /** A label as a timestamp: dates, numbers, or parseable strings (ISO); `NaN` otherwise. */
390
+ const toMs = (label) => new Date(label).getTime();
391
+ /** Value scale for a domain: linear, or logarithmic with positive-only ticks. */
392
+ function valueScale(domain, range, options) {
393
+ return options.scale === "log" ? feature("log").scale(domain, range) : linear(domain, range);
394
+ }
395
+ /** Ticks of a value scale with labels; log scales format each power as is. */
396
+ function valueTicks(scale, options, count, format, locale) {
397
+ return options.scale === "log" ? feature("log").ticks(scale, count, format, locale) : linearTicks(scale, {
398
+ count,
399
+ format,
400
+ locale
401
+ });
402
+ }
403
+ /** The point shapes of a chart (`shapes`, or with `patterns: true`), if it has them. */
404
+ const markerShape = (options) => {
405
+ const { shapes, patterns } = options;
406
+ return shapes ?? patterns === true ? features["point-shapes"] : void 0;
407
+ };
408
+ /** The tick count asked for on an axis (a number up to 100), or `auto`. */
409
+ const tickCount = (axis, auto) => Math.min(finite(axis?.ticks) ?? auto, 100);
410
+ /** Y domain from the data and axis options. */
411
+ function valueDomain(data, options, zeroDefault, count, hidden = /* @__PURE__ */ new Set(), override, extra = []) {
412
+ const values = override ?? data.series.filter((s) => !hidden.has(seriesKey(s))).flatMap((s) => s.values);
413
+ return domainOf(extra.length ? [...values, ...extra] : values, options, zeroDefault, count);
414
+ }
415
+ /** A niced numeric domain for `values`, honouring zero, min, max and nice. */
416
+ function domainOf(values, options, zeroDefault, count) {
417
+ if (options.scale === "log") return feature("log").domain(values, options);
418
+ const min = finite(options.min);
419
+ const max = finite(options.max);
420
+ let [lo, hi] = extent(values) ?? [0, 1];
421
+ if (options.zero ?? zeroDefault) {
422
+ lo = Math.min(lo, 0);
423
+ hi = Math.max(hi, 0);
424
+ }
425
+ if (lo === hi) {
426
+ if (lo === 0) hi = 1;
427
+ else {
428
+ const pad = Math.abs(lo) * .1;
429
+ lo -= pad;
430
+ hi += pad;
431
+ }
432
+ }
433
+ if (min !== null) lo = min;
434
+ if (max !== null) hi = max;
435
+ if (options.nice !== false) {
436
+ const [nlo, nhi] = niceDomain(lo, hi, count);
437
+ if (min === null) lo = nlo;
438
+ if (max === null) hi = nhi;
439
+ }
440
+ return [lo, hi];
441
+ }
442
+ /** The annotations feature, when the chart has annotations (it then must be registered). */
443
+ function notesFeature(options) {
444
+ return options.annotations?.length ? feature("annotations") : void 0;
445
+ }
446
+ /**
447
+ * The value axis of a cartesian layout, before the plot area is known: its
448
+ * scale over a pixel range, the ticks of that scale, and `probe`, ticks to
449
+ * measure the labels with (their positions mean nothing). `auto` is the
450
+ * tick count the plot has room for, unless the axis asks for its own.
451
+ */
452
+ function valueAxis(options, ctx, layout, auto) {
453
+ const axis = options.y ?? {};
454
+ const count = tickCount(axis, Math.max(2, auto));
455
+ const domain = valueDomain(options.data, axis, layout.zero, count, ctx.hidden, layout.values, notesFeature(options)?.values(options.annotations));
456
+ const format = layout.tickFormat ?? axis.format;
457
+ const scale = (range) => valueScale(domain, range, axis);
458
+ const ticks = (of) => valueTicks(of, axis, count, format, ctx.locale);
459
+ return {
460
+ scale,
461
+ ticks,
462
+ probe: ticks(scale([0, 1]))
463
+ };
464
+ }
465
+ /**
466
+ * Finish a layout that has its plot area, scales and ticks with what is
467
+ * drawn around the marks: grid lines and annotation bands below them,
468
+ * annotation lines and the axes above. Values run along y and categories
469
+ * along x, or the other way round when `horizontal`.
470
+ */
471
+ function finishLayout(options, ctx, overhang, plot, keys, time) {
472
+ const { area, x, y, xTicks, yTicks, horizontal: flip } = plot;
473
+ const xOptions = options.x ?? {};
474
+ const notes = notesFeature(options)?.layers(options.annotations, {
475
+ area,
476
+ horizontal: flip,
477
+ fontSize: ctx.fontSize,
478
+ value: y,
479
+ band: x,
480
+ keys,
481
+ time
482
+ });
483
+ const values = options.y?.show !== false && [axis({
484
+ position: flip ? "bottom" : "left",
485
+ ticks: yTicks,
486
+ area
487
+ })];
488
+ const categories = (xOptions.show !== false && plot.labels.length > 0 || xOptions.line) && [axis({
489
+ position: flip ? "left" : "bottom",
490
+ ticks: xTicks,
491
+ area,
492
+ line: xOptions.line === true
493
+ })];
494
+ const present = (parts) => parts.flatMap((part) => part || []);
495
+ return {
496
+ ...plot,
497
+ background: present([
498
+ options.y?.grid !== false && grid({
499
+ direction: flip ? "x" : "y",
500
+ ticks: yTicks,
501
+ area
502
+ }),
503
+ xOptions.grid && grid({
504
+ direction: flip ? "y" : "x",
505
+ ticks: xTicks,
506
+ area
507
+ }),
508
+ notes?.under
509
+ ]),
510
+ foreground: present([
511
+ notes?.over,
512
+ flip ? categories : values,
513
+ flip ? values : categories
514
+ ]),
515
+ clip: plotClip(ctx, area, overhang)
516
+ };
517
+ }
518
+ /** Compute scales, ticks, grid and axes shared by line, area and bar charts. */
519
+ function cartesianLayout(options, ctx, layout) {
520
+ const { data } = options;
521
+ const yOptions = options.y ?? {};
522
+ const xOptions = options.x ?? {};
523
+ const { fontSize, locale, width, height } = ctx;
524
+ const overhang = layout.overhang ?? 0;
525
+ const pad = insets(options.padding);
526
+ const labels = resolveLabels(data);
527
+ const format = labelFormatter(options, ctx);
528
+ const showY = yOptions.show !== false;
529
+ const showX = xOptions.show !== false && labels.length > 0;
530
+ const timed = isTimeAxis(options) && layout.scale === "point";
531
+ const value = valueAxis(options, ctx, layout, Math.round(height / 60));
532
+ const probeY = value.probe;
533
+ const countX = Math.max(2, Math.round(width / 80));
534
+ const keys = labels.map(labelKey);
535
+ const labelAt = (i) => format(labels[i], i);
536
+ const xAxis = timed ? feature("time").axis(labels, keys, xOptions, countX, locale) : {
537
+ edges: labels.length ? [labelAt(0), labelAt(labels.length - 1)] : [],
538
+ scale: (range) => layout.scale === "point" ? point(keys, range) : band(keys, range, {
539
+ paddingInner: layout.paddingInner ?? .3,
540
+ paddingOuter: layout.paddingOuter ?? .15
541
+ }),
542
+ ticks: (scale) => bandTicks(scale, (_, i) => labelAt(i))
543
+ };
544
+ const edgeLabels = xAxis.edges;
545
+ const halfLine = Math.ceil(fontSize * LINE_HEIGHT / 2);
546
+ const firstLabel = showX ? estimateTextWidth(edgeLabels[0] ?? "", fontSize) : 0;
547
+ const lastLabel = showX ? estimateTextWidth(edgeLabels[edgeLabels.length - 1] ?? "", fontSize) : 0;
548
+ const edgeX = layout.scale === "point";
549
+ const valueWidth = showY ? axisSize("left", probeY, fontSize) : 0;
550
+ const side = (halfStep) => {
551
+ const overflow = (label) => edgeX ? Math.ceil(label / 2) : Math.max(0, Math.ceil(label / 2 - halfStep));
552
+ return {
553
+ right: pad.right + Math.max(overflow(lastLabel), overhang, 8),
554
+ left: pad.left + Math.max(valueWidth, overflow(firstLabel), overhang, showY ? 0 : 8)
555
+ };
556
+ };
557
+ const steps = Math.max(1, labels.length) * 2;
558
+ let sides = side((width - pad.left - pad.right - valueWidth) / steps);
559
+ if (!edgeX) sides = side((width - sides.left - sides.right) / steps);
560
+ const margins = {
561
+ top: pad.top + Math.max(showY ? halfLine : 0, overhang, 4),
562
+ bottom: pad.bottom + Math.max(showX ? axisSize("bottom", [probeY[0]], fontSize) : showY ? halfLine : 0, overhang, 4),
563
+ ...sides
564
+ };
565
+ const area = innerRect(width, height, margins);
566
+ const x = xAxis.scale([area.x, area.x + area.width]);
567
+ const y = value.scale([area.y + area.height, area.y]);
568
+ const yTicks = thinTicks(value.ticks(y), "left", fontSize, 4);
569
+ return finishLayout(options, ctx, overhang, {
570
+ area,
571
+ labels,
572
+ x,
573
+ y,
574
+ horizontal: false,
575
+ xTicks: showX ? thinTicks(xAxis.ticks(x), "bottom", fontSize) : [],
576
+ yTicks
577
+ }, keys, xAxis.time);
578
+ }
579
+ /** Clip path around the plot area, a little larger so strokes and dots are not cut. */
580
+ function plotClip(ctx, area, overhang) {
581
+ const clipId = `${ctx.id}-clip`;
582
+ const bleed = overhang + 1;
583
+ return {
584
+ def: h("clipPath", { id: clipId }, h("rect", {
585
+ x: area.x - bleed,
586
+ y: area.y - bleed,
587
+ width: area.width + bleed * 2,
588
+ height: area.height + bleed * 2
589
+ })),
590
+ url: `url(#${clipId})`
591
+ };
592
+ }
593
+ /** Attributes shared by every series group. */
594
+ function seriesAttrs(series, index) {
595
+ const { dash, width } = series;
596
+ return {
597
+ ...groupAttrs(series, index),
598
+ style: {
599
+ "--tc-series-color": series.color,
600
+ "--tc-series-dash": Number.isFinite(dash) ? `${dash}px` : dash,
601
+ "--tc-series-width": Number.isFinite(width) ? `${width}px` : void 0
602
+ }
603
+ };
604
+ }
605
+ /** Pixels around the plot area that still count as hovering it. */
606
+ const HOVER_SLOP = 8;
607
+ /**
608
+ * Interaction by category: the nearest category to the pointer while it is
609
+ * over the plot area, with every visible series' value there. `anchor`
610
+ * places each value (line point, bar end, and the bar's box); `markAt` names the series of the
611
+ * mark directly under the pointer, if the chart has distinct marks (bars).
612
+ * Labels and values are formatted with `x.format` / `y.format` and the locale.
613
+ */
614
+ function categoryInteraction(layout, options, ctx, anchor, markAt) {
615
+ const { area, x, labels, horizontal } = layout;
616
+ const { data } = options;
617
+ const formatLabel = labelFormatter(options, ctx);
618
+ const formatValue = formatDetail(options.y?.format, ctx.locale);
619
+ const hitAt = (index) => {
620
+ const start = x.at(index);
621
+ const center = start + x.bandwidth / 2;
622
+ const label = labels[index];
623
+ const empty = horizontal ? {
624
+ x: area.x,
625
+ y: center
626
+ } : {
627
+ x: center,
628
+ y: null
629
+ };
630
+ const items = [];
631
+ data.series.forEach((series, seriesIndex) => {
632
+ if (ctx.hidden.has(seriesKey(series))) return;
633
+ const raw = series.values[index];
634
+ const value = plottable(raw, options.y) ? raw : null;
635
+ const point = value === null ? empty : anchor(seriesIndex, index, value);
636
+ const item = {
637
+ name: series.name,
638
+ seriesIndex,
639
+ value,
640
+ text: value === null ? "–" : formatValue(value),
641
+ ...point
642
+ };
643
+ if (series.color) item.color = series.color;
644
+ items.push(item);
645
+ });
646
+ const hit = {
647
+ index,
648
+ label: labelKey(label),
649
+ title: formatLabel(label, index),
650
+ x: horizontal ? area.x + area.width / 2 : center,
651
+ area,
652
+ items
653
+ };
654
+ if (horizontal) {
655
+ hit.y = center;
656
+ hit.axis = "y";
657
+ }
658
+ if (x.bandwidth > 0) hit.band = horizontal ? {
659
+ x: area.x,
660
+ y: start,
661
+ width: area.width,
662
+ height: x.bandwidth
663
+ } : {
664
+ x: start,
665
+ y: area.y,
666
+ width: x.bandwidth,
667
+ height: area.height
668
+ };
669
+ return hit;
670
+ };
671
+ return {
672
+ count: labels.length,
673
+ hitTest(px, py) {
674
+ if (labels.length === 0) return null;
675
+ if (px < area.x - HOVER_SLOP || px > area.x + area.width + HOVER_SLOP || py < area.y - HOVER_SLOP || py > area.y + area.height + HOVER_SLOP) return null;
676
+ const index = x.indexAt(horizontal ? py : px);
677
+ const hit = hitAt(index);
678
+ const mark = markAt?.(px, py, index);
679
+ if (mark !== void 0) hit.seriesIndex = mark;
680
+ return hit;
681
+ },
682
+ hitIndex(index, seriesIndex) {
683
+ if (index < 0 || index >= labels.length) return null;
684
+ const hit = hitAt(index);
685
+ if (seriesIndex !== void 0 && hit.items.some((item) => item.seriesIndex === seriesIndex)) hit.seriesIndex = seriesIndex;
686
+ return hit;
687
+ }
688
+ };
689
+ }
690
+ /** Accessible table of series values: one row per category, one column per visible series. */
691
+ function seriesTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
692
+ const all = resolveLabels(options.data);
693
+ const labels = all.length > limit ? all.slice(0, limit) : all;
694
+ const formatLabel = labelFormatter(options, ctx);
695
+ const formatValue = formatDetail(options.y?.format, ctx.locale);
696
+ const series = options.data.series.filter((s) => !ctx.hidden.has(seriesKey(s)));
697
+ return {
698
+ columns: ["", ...series.map((s) => s.name)],
699
+ total: all.length,
700
+ rows: labels.map((label, i) => [formatLabel(label, i), ...series.map((s) => {
701
+ const v = s.values[i];
702
+ return v == null || !Number.isFinite(v) ? "–" : formatValue(v);
703
+ })])
704
+ };
705
+ }
706
+ //#endregion
707
+ export { tickIncrement as A, grid as C, linearTicks as D, bandTicks as E, ticks as M, thinTicks as O, point as S, axisSize as T, valueAxis as _, labelFormatter as a, linear as b, plotClip as c, seriesAttrs as d, seriesKey as f, toMs as g, tickCount as h, finishLayout as i, tickStep as j, niceDomain as k, plottable as l, seriesTable as m, categoryInteraction as n, labelKey as o, seriesLegend as p, domainOf as r, markerShape as s, cartesianLayout as t, resolveLabels as u, valueScale as v, axis as w, band as x, valueTicks as y };
708
+
709
+ //# sourceMappingURL=cartesian-Cr0AF0nG.js.map