@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,285 @@
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 { n as formatDetail } from "./format-lStwuc1L.js";
4
+ import { D as linearTicks, b as linear, d as seriesAttrs, f as seriesKey, h as tickCount, m as seriesTable, o as labelKey, p as seriesLegend, r as domainOf, u as resolveLabels } from "./cartesian-Cr0AF0nG.js";
5
+ import { r as cleanSeries, t as cleanData } from "./clean-o1vDEhFV.js";
6
+ //#region src/charts/radar.ts
7
+ /** Space between the outer ring and the spoke labels. */
8
+ const LABEL_GAP = 8;
9
+ /** Pixels around the outer ring that still count as hovering it. */
10
+ const HOVER_SLOP = 8;
11
+ /** Smallest radius, as a share of the space, however long the labels. */
12
+ const MIN_RADIUS = .5;
13
+ /** Most lines a wrapped spoke label takes. */
14
+ const MAX_LINES = 3;
15
+ /** `text`, cut short with an ellipsis to fit `width` pixels. */
16
+ function truncate(text, width, fontSize) {
17
+ if (estimateTextWidth(text, fontSize) <= width) return text;
18
+ let end = text.length;
19
+ while (end > 0 && estimateTextWidth(`${text.slice(0, end)}…`, fontSize) > width) end--;
20
+ return end > 0 ? `${text.slice(0, end).trimEnd()}…` : "";
21
+ }
22
+ /**
23
+ * `text` split at its spaces into lines no wider than `width` pixels (a word
24
+ * wider than that gets a line of its own), at most `MAX_LINES` of them: what
25
+ * is left joins the last line.
26
+ */
27
+ function wrap(text, width, fontSize) {
28
+ const lines = [];
29
+ let line = "";
30
+ for (const word of text.split(" ")) {
31
+ const next = line ? `${line} ${word}` : word;
32
+ if (!line || estimateTextWidth(next, fontSize) <= width) line = next;
33
+ else {
34
+ lines.push(line);
35
+ line = word;
36
+ }
37
+ }
38
+ lines.push(line);
39
+ if (lines.length > MAX_LINES) lines.splice(2, lines.length, lines.slice(2).join(" "));
40
+ return lines;
41
+ }
42
+ /** Text anchor of a spoke label on the side its spoke points to. */
43
+ const side = (sin) => sin > .1 ? 1 : sin < -.1 ? -1 : 0;
44
+ /**
45
+ * The largest radius at which every spoke label still fits in `area`:
46
+ * labels sit beyond the outer ring, on the side their spoke points to.
47
+ */
48
+ function fitRadius(area, angles, labels, fontSize) {
49
+ let radius = Math.min(area.width, area.height) / 2;
50
+ angles.forEach((angle, i) => {
51
+ const sin = Math.sin(angle);
52
+ const cos = Math.cos(angle);
53
+ const lines = labels[i] ?? [];
54
+ const w = Math.max(0, ...lines.map((line) => estimateTextWidth(line, fontSize)));
55
+ const height = blockHeight(lines.length, fontSize);
56
+ const s = side(sin);
57
+ const across = s === 0 ? w / 2 : w + LABEL_GAP;
58
+ if (Math.abs(sin) > 1e-6) radius = Math.min(radius, (area.width / 2 - across) / Math.abs(sin));
59
+ if (Math.abs(cos) > 1e-6) {
60
+ const along = (s === 0 ? height + LABEL_GAP : height / 2) / Math.abs(cos);
61
+ radius = Math.min(radius, area.height / 2 / Math.abs(cos) - along);
62
+ }
63
+ });
64
+ return Math.max(0, radius);
65
+ }
66
+ /** Height of `lines` lines of text, in pixels. */
67
+ const blockHeight = (lines, fontSize) => fontSize * (1 + Math.max(0, lines - 1) * LINE_HEIGHT);
68
+ function renderRadar(options, ctx) {
69
+ const { width, height, fontSize, locale } = ctx;
70
+ const axis = options.r ?? {};
71
+ const { fill = true, points = false, pointRadius = 4 } = options;
72
+ const series = options.data.series;
73
+ const labels = resolveLabels(options.data);
74
+ const n = labels.length;
75
+ const visible = series.filter((s) => !ctx.hidden.has(seriesKey(s)));
76
+ const formatLabel = options.format ?? ((label) => String(label));
77
+ const formatValue = formatDetail(axis.format, locale);
78
+ const pad = insets(options.padding);
79
+ const area = innerRect(width, height, {
80
+ top: pad.top + LABEL_GAP,
81
+ right: pad.right + LABEL_GAP,
82
+ bottom: pad.bottom + LABEL_GAP,
83
+ left: pad.left + LABEL_GAP
84
+ });
85
+ const cx = area.x + area.width / 2;
86
+ const cy = area.y + area.height / 2;
87
+ const angles = labels.map((_, i) => i / Math.max(1, n) * Math.PI * 2);
88
+ const texts = labels.map((label, i) => formatLabel(label, i));
89
+ const labelWidth = options.labelWidth ?? area.width / 4;
90
+ const wrapped = texts.map((text) => wrap(text, labelWidth, fontSize));
91
+ const radius = Math.max(fitRadius(area, angles, wrapped, fontSize), Math.min(area.width, area.height) / 2 * MIN_RADIUS);
92
+ const shown = wrapped.map((lines, i) => {
93
+ const sin = Math.sin(angles[i]);
94
+ const room = side(sin) === 0 ? area.width : area.width / 2 - radius * Math.abs(sin) - LABEL_GAP;
95
+ return lines.map((line) => truncate(line, room, fontSize));
96
+ });
97
+ const count = tickCount(axis, Math.max(2, Math.round(radius / 40)));
98
+ const values = visible.flatMap((s) => s.values);
99
+ const domain = domainOf(values, axis, true, count);
100
+ const scale = linear(domain, [0, radius], { clamp: true });
101
+ const ticks = linearTicks(scale, {
102
+ count,
103
+ format: axis.format,
104
+ locale
105
+ });
106
+ /** Point at `r` pixels from the center along spoke `i`. */
107
+ const at = (i, r) => [cx + r * Math.sin(angles[i]), cy - r * Math.cos(angles[i])];
108
+ /** A closed path through one radius per spoke (the same commands for any values). */
109
+ const polygon = (radii) => `${radii.map((r, i) => `${i ? "L" : "M"}${at(i, r).map(round).join(",")}`).join("")}Z`;
110
+ const ring = (r) => options.grid === "circle" ? `M${round(cx)},${round(cy - r)}A${round(r)},${round(r)},0,1,1,${round(cx)},${round(cy + r)}A${round(r)},${round(r)},0,1,1,${round(cx)},${round(cy - r)}Z` : polygon(labels.map(() => r));
111
+ /** Pixel radius of a value; missing values sit at the center. */
112
+ const radiusOf = (v) => v != null && Number.isFinite(v) ? scale(v) : 0;
113
+ const hitAt = (index) => {
114
+ const items = [];
115
+ series.forEach((s, seriesIndex) => {
116
+ if (ctx.hidden.has(seriesKey(s))) return;
117
+ const raw = s.values[index];
118
+ const value = raw != null && Number.isFinite(raw) ? raw : null;
119
+ const [x, y] = at(index, radiusOf(value));
120
+ const item = {
121
+ name: s.name,
122
+ seriesIndex,
123
+ value,
124
+ text: value === null ? "–" : formatValue(value),
125
+ x,
126
+ y: value === null ? null : y
127
+ };
128
+ if (s.color) item.color = s.color;
129
+ items.push(item);
130
+ });
131
+ const [x2, y2] = at(index, radius);
132
+ return {
133
+ index,
134
+ label: labelKey(labels[index]),
135
+ title: texts[index],
136
+ x: x2,
137
+ area: {
138
+ x: cx - radius,
139
+ y: cy - radius,
140
+ width: radius * 2,
141
+ height: radius * 2
142
+ },
143
+ items,
144
+ guide: {
145
+ x1: cx,
146
+ y1: cy,
147
+ x2,
148
+ y2
149
+ }
150
+ };
151
+ };
152
+ const interaction = {
153
+ count: n,
154
+ hitTest(px, py) {
155
+ if (n === 0 || Math.hypot(px - cx, py - cy) > radius + HOVER_SLOP) return null;
156
+ const angle = Math.atan2(px - cx, cy - py);
157
+ const turn = (angle < 0 ? angle + Math.PI * 2 : angle) / (Math.PI * 2);
158
+ return hitAt(Math.round(turn * n) % n);
159
+ },
160
+ hitIndex(index, seriesIndex) {
161
+ if (index < 0 || index >= n) return null;
162
+ const hit = hitAt(index);
163
+ if (seriesIndex !== void 0 && hit.items.some((item) => item.seriesIndex === seriesIndex)) hit.seriesIndex = seriesIndex;
164
+ return hit;
165
+ }
166
+ };
167
+ ctx.onHitTest(interaction);
168
+ const grid = h("g", {
169
+ key: "grid",
170
+ class: "tc-radar-grid",
171
+ "aria-hidden": "true"
172
+ }, ticks.filter((tick) => tick.position > 0).map((tick) => h("path", {
173
+ key: tick.value,
174
+ class: "tc-radar-ring",
175
+ d: ring(tick.position)
176
+ })), labels.map((label, i) => {
177
+ const [x2, y2] = at(i, radius);
178
+ return h("line", {
179
+ key: labelKey(label),
180
+ class: "tc-radar-spoke",
181
+ x1: round(cx),
182
+ y1: round(cy),
183
+ x2: round(x2),
184
+ y2: round(y2)
185
+ });
186
+ }));
187
+ const groups = series.map((s, index) => {
188
+ if (ctx.hidden.has(seriesKey(s))) return null;
189
+ const d = polygon(labels.map((_, i) => radiusOf(s.values[i])));
190
+ return h("g", seriesAttrs(s, index), fill && h("path", {
191
+ class: "tc-area",
192
+ d
193
+ }), h("path", {
194
+ class: "tc-line",
195
+ d
196
+ }), points && h("g", { class: "tc-points" }, labels.map((label, i) => {
197
+ const v = s.values[i];
198
+ if (v == null || !Number.isFinite(v)) return null;
199
+ const [x, y] = at(i, scale(v));
200
+ return h("circle", {
201
+ key: labelKey(label),
202
+ class: "tc-point",
203
+ cx: round(x),
204
+ cy: round(y),
205
+ r: pointRadius
206
+ });
207
+ })));
208
+ });
209
+ const spokeLabels = h("g", {
210
+ key: "labels",
211
+ class: "tc-radar-labels",
212
+ "aria-hidden": "true"
213
+ }, labels.map((label, i) => {
214
+ const angle = angles[i];
215
+ const s = side(Math.sin(angle));
216
+ const cos = Math.cos(angle);
217
+ const [x, y] = at(i, radius + LABEL_GAP);
218
+ const [first = "", ...rest] = shown[i] ?? [];
219
+ const up = rest.length * LINE_HEIGHT;
220
+ const dy = s !== 0 ? `${round(.35 - up / 2)}em` : cos > 0 ? `${round(-up)}em` : "0.71em";
221
+ return h("text", {
222
+ key: labelKey(label),
223
+ class: "tc-tick-label tc-radar-label",
224
+ x: round(x),
225
+ y: round(y),
226
+ "text-anchor": s > 0 ? "start" : s < 0 ? "end" : "middle",
227
+ dy
228
+ }, first, rest.map((line, j) => h("tspan", {
229
+ key: j,
230
+ x: round(x),
231
+ dy: `${LINE_HEIGHT}em`
232
+ }, line)));
233
+ }));
234
+ const valueLabels = axis.show !== false && h("g", {
235
+ key: "values",
236
+ class: "tc-radar-values",
237
+ "aria-hidden": "true"
238
+ }, ticks.filter((tick) => tick.position > 0).map((tick) => h("text", {
239
+ key: tick.value,
240
+ class: "tc-tick-label tc-radar-value",
241
+ x: round(cx + 4),
242
+ y: round(cy - tick.position),
243
+ dy: "0.35em"
244
+ }, tick.label)));
245
+ return [
246
+ grid,
247
+ h("g", {
248
+ key: "series",
249
+ class: "tc-series-list tc-radar-series",
250
+ style: `transform-origin:${round(cx)}px ${round(cy)}px`
251
+ }, groups),
252
+ spokeLabels,
253
+ valueLabels
254
+ ];
255
+ }
256
+ /**
257
+ * Radar (spider) chart: one spoke per label, the values of each series
258
+ * joined into a polygon around the center. Good for comparing a few series
259
+ * over the same handful of measures.
260
+ *
261
+ * ```ts
262
+ * new Chart('#el', {
263
+ * type: radar,
264
+ * data: {
265
+ * labels: ['Speed', 'Range', 'Comfort', 'Price', 'Safety'],
266
+ * series: [{ name: 'Model A', values: [80, 60, 70, 40, 90] }],
267
+ * },
268
+ * })
269
+ * ```
270
+ */
271
+ const radar = {
272
+ name: "radar",
273
+ clean: cleanData(cleanSeries),
274
+ render: renderRadar,
275
+ legend: (options) => seriesLegend(options.data),
276
+ table: (options, ctx, limit) => seriesTable({
277
+ data: options.data,
278
+ ...options.r?.format ? { y: { format: options.r.format } } : {},
279
+ ...options.format ? { x: { format: options.format } } : {}
280
+ }, ctx, limit)
281
+ };
282
+ //#endregion
283
+ export { radar as t };
284
+
285
+ //# sourceMappingURL=radar-CYPab_I4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radar-CYPab_I4.js","names":[],"sources":["../src/charts/radar.ts"],"sourcesContent":["import type { ChartType, RenderContext } from '../chart.ts'\nimport { linearTicks } from '../components/axis.ts'\nimport { formatDetail, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport {\n estimateTextWidth,\n type InsetsInput,\n innerRect,\n insets,\n LINE_HEIGHT,\n round,\n} from '../layout.ts'\nimport { linear } from '../scales/linear.ts'\nimport { type ChildInput, h } from '../vnode.ts'\nimport {\n type CartesianData,\n domainOf,\n type Label,\n labelKey,\n resolveLabels,\n seriesAttrs,\n seriesKey,\n seriesLegend,\n seriesTable,\n tickCount,\n} from './cartesian.ts'\nimport { cleanData, cleanSeries } from './clean.ts'\n\n/** Options for the radial value axis. */\nexport interface RadialAxisOptions {\n /** Render the value labels along the first spoke. Defaults to `true`. */\n show?: boolean\n /** Value at the center. Defaults to `0` (or the data minimum when it is negative). */\n min?: number\n /** Value at the outer ring. Defaults to the niced data maximum. */\n max?: number\n /** Extend the domain to round values. Defaults to `true`. */\n nice?: boolean\n /** Approximate number of rings. Defaults to one per ~40px of radius. */\n ticks?: number\n format?: NumberFormat\n}\n\nexport interface RadarOptions {\n /** One spoke per label, one polygon per series. */\n data: CartesianData\n /** The radial value axis. */\n r?: RadialAxisOptions\n /** Format of the spoke labels (axis, tooltips and the table). */\n format?: (label: Label, index: number) => string\n /** Shape of the rings. Defaults to `'polygon'`. */\n grid?: 'polygon' | 'circle'\n /** Fill each polygon. Defaults to `true`. */\n fill?: boolean\n /** Draw a dot on every value. Defaults to `false`. */\n points?: boolean\n /** Dot radius in pixels. Defaults to `4`. */\n pointRadius?: number\n /**\n * Widest spoke label, in pixels: a longer one wraps at its spaces onto up\n * to three lines. Defaults to a quarter of the chart's width.\n */\n labelWidth?: number\n /** Extra space around the chart, in pixels. */\n padding?: InsetsInput\n}\n\n/** Space between the outer ring and the spoke labels. */\nconst LABEL_GAP = 8\n/** Pixels around the outer ring that still count as hovering it. */\nconst HOVER_SLOP = 8\n\n/** Smallest radius, as a share of the space, however long the labels. */\nconst MIN_RADIUS = 0.5\n/** Most lines a wrapped spoke label takes. */\nconst MAX_LINES = 3\n\n/** `text`, cut short with an ellipsis to fit `width` pixels. */\nfunction truncate(text: string, width: number, fontSize: number): string {\n if (estimateTextWidth(text, fontSize) <= width) return text\n let end = text.length\n while (end > 0 && estimateTextWidth(`${text.slice(0, end)}…`, fontSize) > width) end--\n return end > 0 ? `${text.slice(0, end).trimEnd()}…` : ''\n}\n\n/**\n * `text` split at its spaces into lines no wider than `width` pixels (a word\n * wider than that gets a line of its own), at most `MAX_LINES` of them: what\n * is left joins the last line.\n */\nfunction wrap(text: string, width: number, fontSize: number): string[] {\n const lines: string[] = []\n let line = ''\n for (const word of text.split(' ')) {\n const next = line ? `${line} ${word}` : word\n if (!line || estimateTextWidth(next, fontSize) <= width) line = next\n else {\n lines.push(line)\n line = word\n }\n }\n lines.push(line)\n if (lines.length > MAX_LINES)\n lines.splice(MAX_LINES - 1, lines.length, lines.slice(MAX_LINES - 1).join(' '))\n return lines\n}\n\n/** Text anchor of a spoke label on the side its spoke points to. */\nconst side = (sin: number): -1 | 0 | 1 => (sin > 0.1 ? 1 : sin < -0.1 ? -1 : 0)\n\n/**\n * The largest radius at which every spoke label still fits in `area`:\n * labels sit beyond the outer ring, on the side their spoke points to.\n */\nfunction fitRadius(\n area: { width: number; height: number },\n angles: readonly number[],\n labels: readonly (readonly string[])[],\n fontSize: number,\n): number {\n let radius = Math.min(area.width, area.height) / 2\n angles.forEach((angle, i) => {\n const sin = Math.sin(angle)\n const cos = Math.cos(angle)\n const lines = labels[i] ?? []\n const w = Math.max(0, ...lines.map((line) => estimateTextWidth(line, fontSize)))\n const height = blockHeight(lines.length, fontSize)\n const s = side(sin)\n // Horizontal: the label runs outwards from the spoke end (or is centered on it).\n const across = s === 0 ? w / 2 : w + LABEL_GAP\n if (Math.abs(sin) > 1e-6) radius = Math.min(radius, (area.width / 2 - across) / Math.abs(sin))\n // Vertical: the lines of text above the top spokes, below the bottom ones,\n // centered on the ones at the sides.\n if (Math.abs(cos) > 1e-6) {\n const along = (s === 0 ? height + LABEL_GAP : height / 2) / Math.abs(cos)\n radius = Math.min(radius, area.height / 2 / Math.abs(cos) - along)\n }\n })\n return Math.max(0, radius)\n}\n\n/** Height of `lines` lines of text, in pixels. */\nconst blockHeight = (lines: number, fontSize: number) =>\n fontSize * (1 + Math.max(0, lines - 1) * LINE_HEIGHT)\n\nfunction renderRadar(options: RadarOptions, ctx: RenderContext): ChildInput {\n const { width, height, fontSize, locale } = ctx\n const axis = options.r ?? {}\n const { fill = true, points = false, pointRadius = 4 } = options\n const series = options.data.series\n const labels = resolveLabels(options.data)\n const n = labels.length\n const visible = series.filter((s) => !ctx.hidden.has(seriesKey(s)))\n const formatLabel = options.format ?? ((label: Label) => String(label))\n const formatValue = formatDetail(axis.format, locale)\n\n const pad = insets(options.padding)\n const area = innerRect(width, height, {\n top: pad.top + LABEL_GAP,\n right: pad.right + LABEL_GAP,\n bottom: pad.bottom + LABEL_GAP,\n left: pad.left + LABEL_GAP,\n })\n const cx = area.x + area.width / 2\n const cy = area.y + area.height / 2\n const angles = labels.map((_, i) => (i / Math.max(1, n)) * Math.PI * 2)\n const texts = labels.map((label, i) => formatLabel(label, i))\n // Long labels wrap onto a few lines, then the radius fits them, but never\n // shrinks below a share of the space: lines that still do not fit are cut\n // short (the tooltip and the table keep the labels whole).\n const labelWidth = options.labelWidth ?? area.width / 4\n const wrapped = texts.map((text) => wrap(text, labelWidth, fontSize))\n const radius = Math.max(\n fitRadius(area, angles, wrapped, fontSize),\n (Math.min(area.width, area.height) / 2) * MIN_RADIUS,\n )\n const shown = wrapped.map((lines, i) => {\n const sin = Math.sin(angles[i] as number)\n const room = side(sin) === 0 ? area.width : area.width / 2 - radius * Math.abs(sin) - LABEL_GAP\n return lines.map((line) => truncate(line, room, fontSize))\n })\n\n const count = tickCount(axis, Math.max(2, Math.round(radius / 40)))\n const values = visible.flatMap((s) => s.values)\n const domain = domainOf(values, axis, true, count)\n const scale = linear(domain, [0, radius], { clamp: true })\n const ticks = linearTicks(scale, { count, format: axis.format, locale })\n\n /** Point at `r` pixels from the center along spoke `i`. */\n const at = (i: number, r: number): [number, number] => [\n cx + r * Math.sin(angles[i] as number),\n cy - r * Math.cos(angles[i] as number),\n ]\n /** A closed path through one radius per spoke (the same commands for any values). */\n const polygon = (radii: readonly number[]) =>\n `${radii.map((r, i) => `${i ? 'L' : 'M'}${at(i, r).map(round).join(',')}`).join('')}Z`\n const ring = (r: number) =>\n options.grid === 'circle'\n ? `M${round(cx)},${round(cy - r)}A${round(r)},${round(r)},0,1,1,${round(cx)},${round(cy + r)}A${round(r)},${round(r)},0,1,1,${round(cx)},${round(cy - r)}Z`\n : polygon(labels.map(() => r))\n /** Pixel radius of a value; missing values sit at the center. */\n const radiusOf = (v: number | null | undefined) =>\n v != null && Number.isFinite(v) ? scale(v) : 0\n\n const hitAt = (index: number): Hit => {\n const items: HitItem[] = []\n series.forEach((s, seriesIndex) => {\n if (ctx.hidden.has(seriesKey(s))) return\n const raw = s.values[index]\n const value = raw != null && Number.isFinite(raw) ? raw : null\n const [x, y] = at(index, radiusOf(value))\n const item: HitItem = {\n name: s.name,\n seriesIndex,\n value,\n text: value === null ? '–' : formatValue(value),\n x,\n y: value === null ? null : y,\n }\n if (s.color) item.color = s.color\n items.push(item)\n })\n const [x2, y2] = at(index, radius)\n return {\n index,\n label: labelKey(labels[index] as Label),\n title: texts[index] as string,\n x: x2,\n area: { x: cx - radius, y: cy - radius, width: radius * 2, height: radius * 2 },\n items,\n guide: { x1: cx, y1: cy, x2, y2 },\n }\n }\n\n const interaction: Interaction = {\n count: n,\n hitTest(px, py) {\n if (n === 0 || Math.hypot(px - cx, py - cy) > radius + HOVER_SLOP) return null\n // The nearest spoke by angle, clockwise from 12 o'clock.\n const angle = Math.atan2(px - cx, cy - py)\n const turn = (angle < 0 ? angle + Math.PI * 2 : angle) / (Math.PI * 2)\n return hitAt(Math.round(turn * n) % n)\n },\n hitIndex(index, seriesIndex) {\n if (index < 0 || index >= n) return null\n const hit = hitAt(index)\n if (seriesIndex !== undefined && hit.items.some((item) => item.seriesIndex === seriesIndex)) {\n hit.seriesIndex = seriesIndex\n }\n return hit\n },\n }\n ctx.onHitTest(interaction)\n\n const grid = h(\n 'g',\n { key: 'grid', class: 'tc-radar-grid', 'aria-hidden': 'true' },\n ticks\n .filter((tick) => tick.position > 0)\n .map((tick) =>\n h('path', { key: tick.value, class: 'tc-radar-ring', d: ring(tick.position) }),\n ),\n labels.map((label, i) => {\n const [x2, y2] = at(i, radius)\n return h('line', {\n key: labelKey(label),\n class: 'tc-radar-spoke',\n x1: round(cx),\n y1: round(cy),\n x2: round(x2),\n y2: round(y2),\n })\n }),\n )\n\n const groups = series.map((s, index) => {\n if (ctx.hidden.has(seriesKey(s))) return null\n const d = polygon(labels.map((_, i) => radiusOf(s.values[i])))\n return h(\n 'g',\n seriesAttrs(s, index),\n fill && h('path', { class: 'tc-area', d }),\n h('path', { class: 'tc-line', d }),\n points &&\n h(\n 'g',\n { class: 'tc-points' },\n labels.map((label, i) => {\n const v = s.values[i]\n if (v == null || !Number.isFinite(v)) return null\n const [x, y] = at(i, scale(v))\n return h('circle', {\n key: labelKey(label),\n class: 'tc-point',\n cx: round(x),\n cy: round(y),\n r: pointRadius,\n })\n }),\n ),\n )\n })\n\n const spokeLabels = h(\n 'g',\n { key: 'labels', class: 'tc-radar-labels', 'aria-hidden': 'true' },\n labels.map((label, i) => {\n const angle = angles[i] as number\n const s = side(Math.sin(angle))\n const cos = Math.cos(angle)\n const [x, y] = at(i, radius + LABEL_GAP)\n const [first = '', ...rest] = shown[i] ?? []\n // Above the top spokes, below the bottom ones, centered on the sides:\n // the first line moves up to leave room for the ones under it.\n const up = rest.length * LINE_HEIGHT\n const dy = s !== 0 ? `${round(0.35 - up / 2)}em` : cos > 0 ? `${round(-up)}em` : '0.71em'\n return h(\n 'text',\n {\n key: labelKey(label),\n class: 'tc-tick-label tc-radar-label',\n x: round(x),\n y: round(y),\n 'text-anchor': s > 0 ? 'start' : s < 0 ? 'end' : 'middle',\n dy,\n },\n first,\n rest.map((line, j) => h('tspan', { key: j, x: round(x), dy: `${LINE_HEIGHT}em` }, line)),\n )\n }),\n )\n\n const valueLabels =\n axis.show !== false &&\n h(\n 'g',\n { key: 'values', class: 'tc-radar-values', 'aria-hidden': 'true' },\n ticks\n .filter((tick) => tick.position > 0)\n .map((tick) =>\n h(\n 'text',\n {\n key: tick.value,\n class: 'tc-tick-label tc-radar-value',\n x: round(cx + 4),\n y: round(cy - tick.position),\n dy: '0.35em',\n },\n tick.label,\n ),\n ),\n )\n\n return [\n grid,\n // Series grow from the center: the transform origin is set here, in pixels.\n h(\n 'g',\n {\n key: 'series',\n class: 'tc-series-list tc-radar-series',\n style: `transform-origin:${round(cx)}px ${round(cy)}px`,\n },\n groups,\n ),\n spokeLabels,\n valueLabels,\n ]\n}\n\n/**\n * Radar (spider) chart: one spoke per label, the values of each series\n * joined into a polygon around the center. Good for comparing a few series\n * over the same handful of measures.\n *\n * ```ts\n * new Chart('#el', {\n * type: radar,\n * data: {\n * labels: ['Speed', 'Range', 'Comfort', 'Price', 'Safety'],\n * series: [{ name: 'Model A', values: [80, 60, 70, 40, 90] }],\n * },\n * })\n * ```\n */\nexport const radar: ChartType<RadarOptions> = {\n name: 'radar',\n clean: cleanData(cleanSeries),\n render: renderRadar,\n legend: (options) => seriesLegend(options.data),\n table: (options, ctx, limit) =>\n seriesTable(\n {\n data: options.data,\n ...(options.r?.format ? { y: { format: options.r.format } } : {}),\n ...(options.format ? { x: { format: options.format } } : {}),\n },\n ctx,\n limit,\n ),\n}\n"],"mappings":";;;;;;;AAoEA,MAAM,YAAY;;AAElB,MAAM,aAAa;;AAGnB,MAAM,aAAa;;AAEnB,MAAM,YAAY;;AAGlB,SAAS,SAAS,MAAc,OAAe,UAA0B;CACvE,IAAI,kBAAkB,MAAM,QAAQ,KAAK,OAAO,OAAO;CACvD,IAAI,MAAM,KAAK;CACf,OAAO,MAAM,KAAK,kBAAkB,GAAG,KAAK,MAAM,GAAG,GAAG,EAAE,IAAI,QAAQ,IAAI,OAAO;CACjF,OAAO,MAAM,IAAI,GAAG,KAAK,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK;AACxD;;;;;;AAOA,SAAS,KAAK,MAAc,OAAe,UAA4B;CACrE,MAAM,QAAkB,CAAC;CACzB,IAAI,OAAO;CACX,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;EAClC,MAAM,OAAO,OAAO,GAAG,KAAK,GAAG,SAAS;EACxC,IAAI,CAAC,QAAQ,kBAAkB,MAAM,QAAQ,KAAK,OAAO,OAAO;OAC3D;GACH,MAAM,KAAK,IAAI;GACf,OAAO;EACT;CACF;CACA,MAAM,KAAK,IAAI;CACf,IAAI,MAAM,SAAS,WACjB,MAAM,OAAO,GAAe,MAAM,QAAQ,MAAM,MAAM,CAAa,CAAC,CAAC,KAAK,GAAG,CAAC;CAChF,OAAO;AACT;;AAGA,MAAM,QAAQ,QAA6B,MAAM,KAAM,IAAI,MAAM,MAAO,KAAK;;;;;AAM7E,SAAS,UACP,MACA,QACA,QACA,UACQ;CACR,IAAI,SAAS,KAAK,IAAI,KAAK,OAAO,KAAK,MAAM,IAAI;CACjD,OAAO,SAAS,OAAO,MAAM;EAC3B,MAAM,MAAM,KAAK,IAAI,KAAK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"}
@@ -0,0 +1,290 @@
1
+ const require_layout = require("./layout-CtMBhNd9.cjs");
2
+ const require_vnode = require("./vnode-CkQ27Cxe.cjs");
3
+ const require_format = require("./format-B0yKXBTH.cjs");
4
+ const require_cartesian = require("./cartesian-BoDfgBCV.cjs");
5
+ const require_clean = require("./clean-Byl6kzf0.cjs");
6
+ //#region src/charts/radar.ts
7
+ /** Space between the outer ring and the spoke labels. */
8
+ const LABEL_GAP = 8;
9
+ /** Pixels around the outer ring that still count as hovering it. */
10
+ const HOVER_SLOP = 8;
11
+ /** Smallest radius, as a share of the space, however long the labels. */
12
+ const MIN_RADIUS = .5;
13
+ /** Most lines a wrapped spoke label takes. */
14
+ const MAX_LINES = 3;
15
+ /** `text`, cut short with an ellipsis to fit `width` pixels. */
16
+ function truncate(text, width, fontSize) {
17
+ if (require_layout.estimateTextWidth(text, fontSize) <= width) return text;
18
+ let end = text.length;
19
+ while (end > 0 && require_layout.estimateTextWidth(`${text.slice(0, end)}…`, fontSize) > width) end--;
20
+ return end > 0 ? `${text.slice(0, end).trimEnd()}…` : "";
21
+ }
22
+ /**
23
+ * `text` split at its spaces into lines no wider than `width` pixels (a word
24
+ * wider than that gets a line of its own), at most `MAX_LINES` of them: what
25
+ * is left joins the last line.
26
+ */
27
+ function wrap(text, width, fontSize) {
28
+ const lines = [];
29
+ let line = "";
30
+ for (const word of text.split(" ")) {
31
+ const next = line ? `${line} ${word}` : word;
32
+ if (!line || require_layout.estimateTextWidth(next, fontSize) <= width) line = next;
33
+ else {
34
+ lines.push(line);
35
+ line = word;
36
+ }
37
+ }
38
+ lines.push(line);
39
+ if (lines.length > MAX_LINES) lines.splice(2, lines.length, lines.slice(2).join(" "));
40
+ return lines;
41
+ }
42
+ /** Text anchor of a spoke label on the side its spoke points to. */
43
+ const side = (sin) => sin > .1 ? 1 : sin < -.1 ? -1 : 0;
44
+ /**
45
+ * The largest radius at which every spoke label still fits in `area`:
46
+ * labels sit beyond the outer ring, on the side their spoke points to.
47
+ */
48
+ function fitRadius(area, angles, labels, fontSize) {
49
+ let radius = Math.min(area.width, area.height) / 2;
50
+ angles.forEach((angle, i) => {
51
+ const sin = Math.sin(angle);
52
+ const cos = Math.cos(angle);
53
+ const lines = labels[i] ?? [];
54
+ const w = Math.max(0, ...lines.map((line) => require_layout.estimateTextWidth(line, fontSize)));
55
+ const height = blockHeight(lines.length, fontSize);
56
+ const s = side(sin);
57
+ const across = s === 0 ? w / 2 : w + LABEL_GAP;
58
+ if (Math.abs(sin) > 1e-6) radius = Math.min(radius, (area.width / 2 - across) / Math.abs(sin));
59
+ if (Math.abs(cos) > 1e-6) {
60
+ const along = (s === 0 ? height + LABEL_GAP : height / 2) / Math.abs(cos);
61
+ radius = Math.min(radius, area.height / 2 / Math.abs(cos) - along);
62
+ }
63
+ });
64
+ return Math.max(0, radius);
65
+ }
66
+ /** Height of `lines` lines of text, in pixels. */
67
+ const blockHeight = (lines, fontSize) => fontSize * (1 + Math.max(0, lines - 1) * require_layout.LINE_HEIGHT);
68
+ function renderRadar(options, ctx) {
69
+ const { width, height, fontSize, locale } = ctx;
70
+ const axis = options.r ?? {};
71
+ const { fill = true, points = false, pointRadius = 4 } = options;
72
+ const series = options.data.series;
73
+ const labels = require_cartesian.resolveLabels(options.data);
74
+ const n = labels.length;
75
+ const visible = series.filter((s) => !ctx.hidden.has(require_cartesian.seriesKey(s)));
76
+ const formatLabel = options.format ?? ((label) => String(label));
77
+ const formatValue = require_format.formatDetail(axis.format, locale);
78
+ const pad = require_layout.insets(options.padding);
79
+ const area = require_layout.innerRect(width, height, {
80
+ top: pad.top + LABEL_GAP,
81
+ right: pad.right + LABEL_GAP,
82
+ bottom: pad.bottom + LABEL_GAP,
83
+ left: pad.left + LABEL_GAP
84
+ });
85
+ const cx = area.x + area.width / 2;
86
+ const cy = area.y + area.height / 2;
87
+ const angles = labels.map((_, i) => i / Math.max(1, n) * Math.PI * 2);
88
+ const texts = labels.map((label, i) => formatLabel(label, i));
89
+ const labelWidth = options.labelWidth ?? area.width / 4;
90
+ const wrapped = texts.map((text) => wrap(text, labelWidth, fontSize));
91
+ const radius = Math.max(fitRadius(area, angles, wrapped, fontSize), Math.min(area.width, area.height) / 2 * MIN_RADIUS);
92
+ const shown = wrapped.map((lines, i) => {
93
+ const sin = Math.sin(angles[i]);
94
+ const room = side(sin) === 0 ? area.width : area.width / 2 - radius * Math.abs(sin) - LABEL_GAP;
95
+ return lines.map((line) => truncate(line, room, fontSize));
96
+ });
97
+ const count = require_cartesian.tickCount(axis, Math.max(2, Math.round(radius / 40)));
98
+ const values = visible.flatMap((s) => s.values);
99
+ const domain = require_cartesian.domainOf(values, axis, true, count);
100
+ const scale = require_cartesian.linear(domain, [0, radius], { clamp: true });
101
+ const ticks = require_cartesian.linearTicks(scale, {
102
+ count,
103
+ format: axis.format,
104
+ locale
105
+ });
106
+ /** Point at `r` pixels from the center along spoke `i`. */
107
+ const at = (i, r) => [cx + r * Math.sin(angles[i]), cy - r * Math.cos(angles[i])];
108
+ /** A closed path through one radius per spoke (the same commands for any values). */
109
+ const polygon = (radii) => `${radii.map((r, i) => `${i ? "L" : "M"}${at(i, r).map(require_layout.round).join(",")}`).join("")}Z`;
110
+ const ring = (r) => options.grid === "circle" ? `M${require_layout.round(cx)},${require_layout.round(cy - r)}A${require_layout.round(r)},${require_layout.round(r)},0,1,1,${require_layout.round(cx)},${require_layout.round(cy + r)}A${require_layout.round(r)},${require_layout.round(r)},0,1,1,${require_layout.round(cx)},${require_layout.round(cy - r)}Z` : polygon(labels.map(() => r));
111
+ /** Pixel radius of a value; missing values sit at the center. */
112
+ const radiusOf = (v) => v != null && Number.isFinite(v) ? scale(v) : 0;
113
+ const hitAt = (index) => {
114
+ const items = [];
115
+ series.forEach((s, seriesIndex) => {
116
+ if (ctx.hidden.has(require_cartesian.seriesKey(s))) return;
117
+ const raw = s.values[index];
118
+ const value = raw != null && Number.isFinite(raw) ? raw : null;
119
+ const [x, y] = at(index, radiusOf(value));
120
+ const item = {
121
+ name: s.name,
122
+ seriesIndex,
123
+ value,
124
+ text: value === null ? "–" : formatValue(value),
125
+ x,
126
+ y: value === null ? null : y
127
+ };
128
+ if (s.color) item.color = s.color;
129
+ items.push(item);
130
+ });
131
+ const [x2, y2] = at(index, radius);
132
+ return {
133
+ index,
134
+ label: require_cartesian.labelKey(labels[index]),
135
+ title: texts[index],
136
+ x: x2,
137
+ area: {
138
+ x: cx - radius,
139
+ y: cy - radius,
140
+ width: radius * 2,
141
+ height: radius * 2
142
+ },
143
+ items,
144
+ guide: {
145
+ x1: cx,
146
+ y1: cy,
147
+ x2,
148
+ y2
149
+ }
150
+ };
151
+ };
152
+ const interaction = {
153
+ count: n,
154
+ hitTest(px, py) {
155
+ if (n === 0 || Math.hypot(px - cx, py - cy) > radius + HOVER_SLOP) return null;
156
+ const angle = Math.atan2(px - cx, cy - py);
157
+ const turn = (angle < 0 ? angle + Math.PI * 2 : angle) / (Math.PI * 2);
158
+ return hitAt(Math.round(turn * n) % n);
159
+ },
160
+ hitIndex(index, seriesIndex) {
161
+ if (index < 0 || index >= n) return null;
162
+ const hit = hitAt(index);
163
+ if (seriesIndex !== void 0 && hit.items.some((item) => item.seriesIndex === seriesIndex)) hit.seriesIndex = seriesIndex;
164
+ return hit;
165
+ }
166
+ };
167
+ ctx.onHitTest(interaction);
168
+ const grid = require_vnode.h("g", {
169
+ key: "grid",
170
+ class: "tc-radar-grid",
171
+ "aria-hidden": "true"
172
+ }, ticks.filter((tick) => tick.position > 0).map((tick) => require_vnode.h("path", {
173
+ key: tick.value,
174
+ class: "tc-radar-ring",
175
+ d: ring(tick.position)
176
+ })), labels.map((label, i) => {
177
+ const [x2, y2] = at(i, radius);
178
+ return require_vnode.h("line", {
179
+ key: require_cartesian.labelKey(label),
180
+ class: "tc-radar-spoke",
181
+ x1: require_layout.round(cx),
182
+ y1: require_layout.round(cy),
183
+ x2: require_layout.round(x2),
184
+ y2: require_layout.round(y2)
185
+ });
186
+ }));
187
+ const groups = series.map((s, index) => {
188
+ if (ctx.hidden.has(require_cartesian.seriesKey(s))) return null;
189
+ const d = polygon(labels.map((_, i) => radiusOf(s.values[i])));
190
+ return require_vnode.h("g", require_cartesian.seriesAttrs(s, index), fill && require_vnode.h("path", {
191
+ class: "tc-area",
192
+ d
193
+ }), require_vnode.h("path", {
194
+ class: "tc-line",
195
+ d
196
+ }), points && require_vnode.h("g", { class: "tc-points" }, labels.map((label, i) => {
197
+ const v = s.values[i];
198
+ if (v == null || !Number.isFinite(v)) return null;
199
+ const [x, y] = at(i, scale(v));
200
+ return require_vnode.h("circle", {
201
+ key: require_cartesian.labelKey(label),
202
+ class: "tc-point",
203
+ cx: require_layout.round(x),
204
+ cy: require_layout.round(y),
205
+ r: pointRadius
206
+ });
207
+ })));
208
+ });
209
+ const spokeLabels = require_vnode.h("g", {
210
+ key: "labels",
211
+ class: "tc-radar-labels",
212
+ "aria-hidden": "true"
213
+ }, labels.map((label, i) => {
214
+ const angle = angles[i];
215
+ const s = side(Math.sin(angle));
216
+ const cos = Math.cos(angle);
217
+ const [x, y] = at(i, radius + LABEL_GAP);
218
+ const [first = "", ...rest] = shown[i] ?? [];
219
+ const up = rest.length * require_layout.LINE_HEIGHT;
220
+ const dy = s !== 0 ? `${require_layout.round(.35 - up / 2)}em` : cos > 0 ? `${require_layout.round(-up)}em` : "0.71em";
221
+ return require_vnode.h("text", {
222
+ key: require_cartesian.labelKey(label),
223
+ class: "tc-tick-label tc-radar-label",
224
+ x: require_layout.round(x),
225
+ y: require_layout.round(y),
226
+ "text-anchor": s > 0 ? "start" : s < 0 ? "end" : "middle",
227
+ dy
228
+ }, first, rest.map((line, j) => require_vnode.h("tspan", {
229
+ key: j,
230
+ x: require_layout.round(x),
231
+ dy: `${require_layout.LINE_HEIGHT}em`
232
+ }, line)));
233
+ }));
234
+ const valueLabels = axis.show !== false && require_vnode.h("g", {
235
+ key: "values",
236
+ class: "tc-radar-values",
237
+ "aria-hidden": "true"
238
+ }, ticks.filter((tick) => tick.position > 0).map((tick) => require_vnode.h("text", {
239
+ key: tick.value,
240
+ class: "tc-tick-label tc-radar-value",
241
+ x: require_layout.round(cx + 4),
242
+ y: require_layout.round(cy - tick.position),
243
+ dy: "0.35em"
244
+ }, tick.label)));
245
+ return [
246
+ grid,
247
+ require_vnode.h("g", {
248
+ key: "series",
249
+ class: "tc-series-list tc-radar-series",
250
+ style: `transform-origin:${require_layout.round(cx)}px ${require_layout.round(cy)}px`
251
+ }, groups),
252
+ spokeLabels,
253
+ valueLabels
254
+ ];
255
+ }
256
+ /**
257
+ * Radar (spider) chart: one spoke per label, the values of each series
258
+ * joined into a polygon around the center. Good for comparing a few series
259
+ * over the same handful of measures.
260
+ *
261
+ * ```ts
262
+ * new Chart('#el', {
263
+ * type: radar,
264
+ * data: {
265
+ * labels: ['Speed', 'Range', 'Comfort', 'Price', 'Safety'],
266
+ * series: [{ name: 'Model A', values: [80, 60, 70, 40, 90] }],
267
+ * },
268
+ * })
269
+ * ```
270
+ */
271
+ const radar = {
272
+ name: "radar",
273
+ clean: require_clean.cleanData(require_clean.cleanSeries),
274
+ render: renderRadar,
275
+ legend: (options) => require_cartesian.seriesLegend(options.data),
276
+ table: (options, ctx, limit) => require_cartesian.seriesTable({
277
+ data: options.data,
278
+ ...options.r?.format ? { y: { format: options.r.format } } : {},
279
+ ...options.format ? { x: { format: options.format } } : {}
280
+ }, ctx, limit)
281
+ };
282
+ //#endregion
283
+ Object.defineProperty(exports, "radar", {
284
+ enumerable: true,
285
+ get: function() {
286
+ return radar;
287
+ }
288
+ });
289
+
290
+ //# sourceMappingURL=radar-CoGUNNSb.cjs.map