@tabler/charts 0.3.0 → 0.4.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 (307) hide show
  1. package/README.md +94 -16
  2. package/dist/{annotations-CpCWA29b.cjs → annotations--m-HzMBM.cjs} +86 -10
  3. package/dist/annotations--m-HzMBM.cjs.map +1 -0
  4. package/dist/{annotations-B02GR_KU.d.ts → annotations-CCDUC1lW.d.ts} +16 -30
  5. package/dist/{annotations-CHafaGd4.d.cts → annotations-CqZM1z9R.d.cts} +16 -30
  6. package/dist/{annotations-BQ8l-qHs.js → annotations-DGITy6th.js} +86 -10
  7. package/dist/annotations-DGITy6th.js.map +1 -0
  8. package/dist/annotations.cjs +1 -1
  9. package/dist/annotations.d.cts +1 -1
  10. package/dist/annotations.d.ts +1 -1
  11. package/dist/annotations.js +1 -1
  12. package/dist/{area-WdtfqvhX.js → area-BN0uE9R0.js} +4 -3
  13. package/dist/area-BN0uE9R0.js.map +1 -0
  14. package/dist/{area-h_FvieFb.d.cts → area-D6LNLk3r.d.cts} +2 -2
  15. package/dist/{area-DEFQm_SQ.d.ts → area-DEFL-Yun.d.ts} +2 -2
  16. package/dist/{area-DYdQ_sMV.cjs → area-D_N8b4Ng.cjs} +4 -3
  17. package/dist/area-D_N8b4Ng.cjs.map +1 -0
  18. package/dist/area.cjs +1 -1
  19. package/dist/area.d.cts +1 -1
  20. package/dist/area.d.ts +1 -1
  21. package/dist/area.js +1 -1
  22. package/dist/{axis-YfAerNBA.cjs → axis-BzBkkC5X.cjs} +12 -7
  23. package/dist/axis-BzBkkC5X.cjs.map +1 -0
  24. package/dist/{axis-MMaVoSWB.js → axis-C5obgdJt.js} +12 -7
  25. package/dist/axis-C5obgdJt.js.map +1 -0
  26. package/dist/{bar-CVkOJ7WA.cjs → bar-BrmfXugT.cjs} +5 -4
  27. package/dist/bar-BrmfXugT.cjs.map +1 -0
  28. package/dist/{bar-D9B_arKf.d.ts → bar-Bs_rPqgR.d.ts} +1 -1
  29. package/dist/{bar-DZCQ-kyf.d.cts → bar-CEt8YRxf.d.cts} +2 -2
  30. package/dist/{bar-BOcRcArc.js → bar-D_KKd2fL.js} +5 -4
  31. package/dist/bar-D_KKd2fL.js.map +1 -0
  32. package/dist/bar.cjs +1 -1
  33. package/dist/bar.d.cts +1 -1
  34. package/dist/bar.d.ts +1 -1
  35. package/dist/bar.js +1 -1
  36. package/dist/{calendar-BSvO8nRb.d.cts → calendar-B7843sQu.d.cts} +2 -2
  37. package/dist/{calendar-DAFXjV99.cjs → calendar-BG_q_NC_.cjs} +2 -2
  38. package/dist/{calendar-DAFXjV99.cjs.map → calendar-BG_q_NC_.cjs.map} +1 -1
  39. package/dist/{calendar-BXgIX5H1.js → calendar-CF3gfDQk.js} +2 -2
  40. package/dist/{calendar-BXgIX5H1.js.map → calendar-CF3gfDQk.js.map} +1 -1
  41. package/dist/{calendar-Bq3vFzPl.d.ts → calendar-D10_ki1S.d.ts} +2 -2
  42. package/dist/calendar.cjs +1 -1
  43. package/dist/calendar.d.cts +1 -1
  44. package/dist/calendar.d.ts +1 -1
  45. package/dist/calendar.js +1 -1
  46. package/dist/{candlestick-BtT9glp9.js → candlestick-B1onjo1o.js} +3 -2
  47. package/dist/candlestick-B1onjo1o.js.map +1 -0
  48. package/dist/{candlestick-BcomxeVG.d.cts → candlestick-B7YXUVVh.d.cts} +4 -3
  49. package/dist/{candlestick-CSmRuZ4v.cjs → candlestick-BwrFKak_.cjs} +3 -2
  50. package/dist/candlestick-BwrFKak_.cjs.map +1 -0
  51. package/dist/{candlestick-B3WcLzph.d.ts → candlestick-XpqJvarq.d.ts} +4 -3
  52. package/dist/candlestick.cjs +2 -2
  53. package/dist/candlestick.d.cts +1 -1
  54. package/dist/candlestick.d.ts +1 -1
  55. package/dist/candlestick.js +2 -2
  56. package/dist/{cartesian-DRSXHxWe.cjs → cartesian-B9CrasFJ.cjs} +49 -7
  57. package/dist/cartesian-B9CrasFJ.cjs.map +1 -0
  58. package/dist/{cartesian-BrPqb5Qn.js → cartesian-COglz544.js} +45 -9
  59. package/dist/cartesian-COglz544.js.map +1 -0
  60. package/dist/{chart-B6TTY4Kr.js → chart-B97FBRCd.js} +22 -12
  61. package/dist/chart-B97FBRCd.js.map +1 -0
  62. package/dist/{chart-CYrrUCi3.d.ts → chart-CE9EVbfV.d.ts} +240 -62
  63. package/dist/{chart-CbPzP5Dp.d.cts → chart-Dz4geQZy.d.cts} +240 -62
  64. package/dist/{chart-D_lyOy-M.cjs → chart-GUmmjJ7S.cjs} +27 -11
  65. package/dist/chart-GUmmjJ7S.cjs.map +1 -0
  66. package/dist/{core-CQ0FaJ4G.js → core-7fgM3su0.js} +84 -16
  67. package/dist/core-7fgM3su0.js.map +1 -0
  68. package/dist/{core-C3qEppSm.d.ts → core-BUQzLsRJ.d.ts} +21 -6
  69. package/dist/{core-D2PSked3.cjs → core-BZTrsPxc.cjs} +93 -13
  70. package/dist/core-BZTrsPxc.cjs.map +1 -0
  71. package/dist/{core-9BnLEW4K.d.cts → core-Ck5uHcW8.d.cts} +40 -23
  72. package/dist/core.cjs +20 -16
  73. package/dist/core.d.cts +23 -21
  74. package/dist/core.d.ts +23 -21
  75. package/dist/core.js +18 -17
  76. package/dist/{dates-DerXTb1J.cjs → dates-0YNY49KQ.cjs} +2 -2
  77. package/dist/{dates-DerXTb1J.cjs.map → dates-0YNY49KQ.cjs.map} +1 -1
  78. package/dist/{dates-DLe2Ww64.js → dates-CKDRgpin.js} +2 -2
  79. package/dist/{dates-DLe2Ww64.js.map → dates-CKDRgpin.js.map} +1 -1
  80. package/dist/end-labels-B3oRvjxw.js +114 -0
  81. package/dist/end-labels-B3oRvjxw.js.map +1 -0
  82. package/dist/end-labels-CS-fnpp-.cjs +119 -0
  83. package/dist/end-labels-CS-fnpp-.cjs.map +1 -0
  84. package/dist/end-labels.cjs +11 -0
  85. package/dist/end-labels.cjs.map +1 -0
  86. package/dist/end-labels.d.cts +6 -0
  87. package/dist/end-labels.d.ts +6 -0
  88. package/dist/end-labels.js +11 -0
  89. package/dist/end-labels.js.map +1 -0
  90. package/dist/{export-chart-DoeiAyR2.js → export-chart-BOH_nfcH.js} +76 -4
  91. package/dist/export-chart-BOH_nfcH.js.map +1 -0
  92. package/dist/{export-chart-CPtXmZvi.cjs → export-chart-Be4T9J3m.cjs} +81 -3
  93. package/dist/export-chart-Be4T9J3m.cjs.map +1 -0
  94. package/dist/export.cjs +4 -2
  95. package/dist/export.cjs.map +1 -1
  96. package/dist/export.d.cts +4 -3
  97. package/dist/export.d.ts +4 -3
  98. package/dist/export.js +4 -3
  99. package/dist/export.js.map +1 -1
  100. package/dist/features-B55rwpQC.js.map +1 -1
  101. package/dist/features-DEDP5CEQ.cjs.map +1 -1
  102. package/dist/{funnel-CarOh8w_.d.cts → funnel-B9ridzNx.d.cts} +2 -2
  103. package/dist/{funnel-BdcfUkb5.d.ts → funnel-FogM8flk.d.ts} +2 -2
  104. package/dist/funnel.d.cts +1 -1
  105. package/dist/funnel.d.ts +1 -1
  106. package/dist/{gauge-Ds9k1UV2.d.cts → gauge-BScJ7U6O.d.cts} +2 -2
  107. package/dist/{gauge-Zy25jfps.d.ts → gauge-D78oq1Lx.d.ts} +2 -2
  108. package/dist/gauge.d.cts +1 -1
  109. package/dist/gauge.d.ts +1 -1
  110. package/dist/heat-Bsqq4zw9.js +38 -0
  111. package/dist/heat-Bsqq4zw9.js.map +1 -0
  112. package/dist/heat-DYsivvDq.cjs +49 -0
  113. package/dist/heat-DYsivvDq.cjs.map +1 -0
  114. package/dist/{heatmap-Dcc_bsoQ.cjs → heatmap-Dyzrd4Fd.cjs} +3 -3
  115. package/dist/{heatmap-Dcc_bsoQ.cjs.map → heatmap-Dyzrd4Fd.cjs.map} +1 -1
  116. package/dist/{heatmap-C1v8bwpq.js → heatmap-J7fxG7MM.js} +3 -3
  117. package/dist/{heatmap-C1v8bwpq.js.map → heatmap-J7fxG7MM.js.map} +1 -1
  118. package/dist/{heatmap-CJ-0dfhJ.d.cts → heatmap-Jvwo7iFW.d.cts} +2 -2
  119. package/dist/{heatmap-Jp5sHRTo.d.ts → heatmap-mFCnP6aB.d.ts} +2 -2
  120. package/dist/heatmap.cjs +1 -1
  121. package/dist/heatmap.d.cts +1 -1
  122. package/dist/heatmap.d.ts +1 -1
  123. package/dist/heatmap.js +1 -1
  124. package/dist/index.cjs +37 -26
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.d.cts +23 -21
  127. package/dist/index.d.ts +23 -21
  128. package/dist/index.js +34 -27
  129. package/dist/index.js.map +1 -1
  130. package/dist/interaction-DXYSjgnP.cjs.map +1 -1
  131. package/dist/interaction-En1KlwFO.js.map +1 -1
  132. package/dist/layout-CYerDebD.d.cts +29 -0
  133. package/dist/layout-CYerDebD.d.ts +29 -0
  134. package/dist/{line-CxR4tg1Q.js → line-CXH0L10d.js} +43 -8
  135. package/dist/line-CXH0L10d.js.map +1 -0
  136. package/dist/{line-vyWO030v.d.cts → line-Cu9ctpbv.d.cts} +9 -2
  137. package/dist/{line-YiCuhVMI.cjs → line-DHbYCQy4.cjs} +43 -8
  138. package/dist/line-DHbYCQy4.cjs.map +1 -0
  139. package/dist/{line-Bpr5uVLQ.d.ts → line-TkzA7wMK.d.ts} +8 -1
  140. package/dist/line.cjs +1 -1
  141. package/dist/line.d.cts +1 -1
  142. package/dist/line.d.ts +1 -1
  143. package/dist/line.js +1 -1
  144. package/dist/{map-49FcfdmJ.d.cts → map-BirylCmT.d.cts} +2 -2
  145. package/dist/{map-C15NC7kW.js → map-CYp6x-uS.js} +3 -26
  146. package/dist/map-CYp6x-uS.js.map +1 -0
  147. package/dist/{map-BqrZ80vT.cjs → map-ChwSgooH.cjs} +4 -27
  148. package/dist/map-ChwSgooH.cjs.map +1 -0
  149. package/dist/{map-BMC61J-P.d.ts → map-DNqog2Xs.d.ts} +2 -2
  150. package/dist/map.cjs +1 -1
  151. package/dist/map.d.cts +1 -1
  152. package/dist/map.d.ts +1 -1
  153. package/dist/map.js +1 -1
  154. package/dist/maps/world.d.cts +1 -1
  155. package/dist/maps/world.d.ts +1 -1
  156. package/dist/{others-ls5eKtZ4.d.cts → others-CuNdpvjd.d.cts} +1 -1
  157. package/dist/{parliament-Cz9n_DoK.d.ts → parliament-CHdf13XU.d.ts} +2 -2
  158. package/dist/{parliament-C7V8UJj1.d.cts → parliament-CsYgh4N2.d.cts} +2 -2
  159. package/dist/parliament.d.cts +1 -1
  160. package/dist/parliament.d.ts +1 -1
  161. package/dist/{patterns-Dw7OMD_2.cjs → patterns-BPN1c9qe.cjs} +2 -2
  162. package/dist/{patterns-Dw7OMD_2.cjs.map → patterns-BPN1c9qe.cjs.map} +1 -1
  163. package/dist/{patterns-BMUINoka.js → patterns-CVrLrJXg.js} +2 -2
  164. package/dist/{patterns-BMUINoka.js.map → patterns-CVrLrJXg.js.map} +1 -1
  165. package/dist/patterns.cjs +1 -1
  166. package/dist/patterns.d.cts +1 -1
  167. package/dist/patterns.d.ts +1 -1
  168. package/dist/patterns.js +1 -1
  169. package/dist/{percentage-bar-cSeiLdwU.d.ts → percentage-bar-CSAbzDOn.d.ts} +2 -2
  170. package/dist/{percentage-bar-R1--2grK.d.cts → percentage-bar-UZHCRvlK.d.cts} +3 -3
  171. package/dist/percentage-bar.d.cts +1 -1
  172. package/dist/percentage-bar.d.ts +1 -1
  173. package/dist/{pie-vD5-g8je.d.cts → pie-AFedsDcF.d.cts} +12 -3
  174. package/dist/{pie-Bd8wyrtY.js → pie-Ch6Bx0ih.js} +54 -39
  175. package/dist/pie-Ch6Bx0ih.js.map +1 -0
  176. package/dist/{pie-BseZlCgP.cjs → pie-Cll1OrVZ.cjs} +54 -39
  177. package/dist/pie-Cll1OrVZ.cjs.map +1 -0
  178. package/dist/{pie-BQQkvy1N.d.ts → pie-Cn2H3pz8.d.ts} +11 -2
  179. package/dist/pie.cjs +1 -1
  180. package/dist/pie.d.cts +1 -1
  181. package/dist/pie.d.ts +1 -1
  182. package/dist/pie.js +1 -1
  183. package/dist/point-shapes.d.cts +1 -1
  184. package/dist/point-shapes.d.ts +1 -1
  185. package/dist/{radar-D6XqkFWQ.js → radar-Bg-IiIWB.js} +3 -3
  186. package/dist/{radar-D6XqkFWQ.js.map → radar-Bg-IiIWB.js.map} +1 -1
  187. package/dist/{radar-vLxilcr4.d.ts → radar-DEer2jjd.d.ts} +2 -2
  188. package/dist/{radar-7I6hsY_h.d.cts → radar-DxmjXhMc.d.cts} +2 -2
  189. package/dist/{radar-DjISDnSf.cjs → radar-wDyX17S3.cjs} +3 -3
  190. package/dist/{radar-DjISDnSf.cjs.map → radar-wDyX17S3.cjs.map} +1 -1
  191. package/dist/radar.cjs +1 -1
  192. package/dist/radar.d.cts +1 -1
  193. package/dist/radar.d.ts +1 -1
  194. package/dist/radar.js +1 -1
  195. package/dist/range-bar-BnKjJP89.cjs +348 -0
  196. package/dist/range-bar-BnKjJP89.cjs.map +1 -0
  197. package/dist/range-bar-C4cRaaQE.d.ts +123 -0
  198. package/dist/range-bar-D32dIQOY.d.cts +123 -0
  199. package/dist/range-bar-Dx6ce0J1.js +343 -0
  200. package/dist/range-bar-Dx6ce0J1.js.map +1 -0
  201. package/dist/range-bar.cjs +3 -0
  202. package/dist/range-bar.d.cts +3 -0
  203. package/dist/range-bar.d.ts +3 -0
  204. package/dist/range-bar.js +1 -0
  205. package/dist/{sankey-DqiuxUx7.d.cts → sankey-D-8ATwBT.d.cts} +2 -2
  206. package/dist/{sankey-7As41Fo4.d.ts → sankey-DpYJsOI4.d.ts} +2 -2
  207. package/dist/sankey.d.cts +1 -1
  208. package/dist/sankey.d.ts +1 -1
  209. package/dist/{scatter-DCMAtt5L.js → scatter-0Z7K_YUz.js} +65 -19
  210. package/dist/scatter-0Z7K_YUz.js.map +1 -0
  211. package/dist/{scatter-BXkXGgM_.d.ts → scatter-BAL5K9_4.d.ts} +22 -9
  212. package/dist/{scatter-DL0zAV09.d.cts → scatter-BUGbnRzM.d.cts} +22 -9
  213. package/dist/{scatter-Bwkblr4L.cjs → scatter-CZ8do3Up.cjs} +65 -19
  214. package/dist/scatter-CZ8do3Up.cjs.map +1 -0
  215. package/dist/scatter.cjs +1 -1
  216. package/dist/scatter.d.cts +2 -2
  217. package/dist/scatter.d.ts +2 -2
  218. package/dist/scatter.js +1 -1
  219. package/dist/slice-labels-1TBq7p3q.d.cts +28 -0
  220. package/dist/slice-labels-C9ucsBVW.js +88 -0
  221. package/dist/slice-labels-C9ucsBVW.js.map +1 -0
  222. package/dist/slice-labels-CbFiy46l.cjs +93 -0
  223. package/dist/slice-labels-CbFiy46l.cjs.map +1 -0
  224. package/dist/slice-labels-Cm5CyV7B.d.ts +28 -0
  225. package/dist/slice-labels.cjs +11 -0
  226. package/dist/slice-labels.cjs.map +1 -0
  227. package/dist/slice-labels.d.cts +6 -0
  228. package/dist/slice-labels.d.ts +6 -0
  229. package/dist/slice-labels.js +11 -0
  230. package/dist/slice-labels.js.map +1 -0
  231. package/dist/{sparkline-BElUSd0r.d.ts → sparkline-CtoBJe-a.d.ts} +2 -2
  232. package/dist/{sparkline-BMSuEPHP.cjs → sparkline-DjR-V6BI.cjs} +2 -2
  233. package/dist/{sparkline-BMSuEPHP.cjs.map → sparkline-DjR-V6BI.cjs.map} +1 -1
  234. package/dist/{sparkline-RYly7bR0.d.cts → sparkline-DwHJfeZz.d.cts} +2 -2
  235. package/dist/{sparkline-NDmq90kP.js → sparkline-_dxwtdli.js} +2 -2
  236. package/dist/{sparkline-NDmq90kP.js.map → sparkline-_dxwtdli.js.map} +1 -1
  237. package/dist/sparkline.cjs +1 -1
  238. package/dist/sparkline.d.cts +1 -1
  239. package/dist/sparkline.d.ts +1 -1
  240. package/dist/sparkline.js +1 -1
  241. package/dist/{stack-BTWYIwLO.d.cts → stack-CcmyALx0.d.cts} +1 -1
  242. package/dist/{stack-jVKvg2x_.js → stack-CyVlS7Fr.js} +2 -2
  243. package/dist/{stack-jVKvg2x_.js.map → stack-CyVlS7Fr.js.map} +1 -1
  244. package/dist/{stack-BO4624CY.cjs → stack-DBhmYNat.cjs} +2 -2
  245. package/dist/{stack-BO4624CY.cjs.map → stack-DBhmYNat.cjs.map} +1 -1
  246. package/dist/style.css +1 -1
  247. package/dist/{time-axis-B3VekUfX.cjs → time-axis-CVKjQKSS.cjs} +3 -3
  248. package/dist/{time-axis-B3VekUfX.cjs.map → time-axis-CVKjQKSS.cjs.map} +1 -1
  249. package/dist/{time-axis-CLjqOakA.js → time-axis-CkmbAw4Z.js} +3 -3
  250. package/dist/{time-axis-CLjqOakA.js.map → time-axis-CkmbAw4Z.js.map} +1 -1
  251. package/dist/time.cjs +2 -2
  252. package/dist/time.js +2 -2
  253. package/dist/{treemap-25vHO_UK.d.cts → treemap-C2maqerU.d.cts} +26 -4
  254. package/dist/{treemap-BCXUbixd.d.ts → treemap-D_zbubo3.d.ts} +26 -4
  255. package/dist/{treemap-CZk8kKFD.cjs → treemap-PulGXZv0.cjs} +38 -8
  256. package/dist/treemap-PulGXZv0.cjs.map +1 -0
  257. package/dist/{treemap-C4glsx-g.js → treemap-lbYxb-7h.js} +38 -8
  258. package/dist/treemap-lbYxb-7h.js.map +1 -0
  259. package/dist/treemap.cjs +1 -1
  260. package/dist/treemap.d.cts +1 -1
  261. package/dist/treemap.d.ts +1 -1
  262. package/dist/treemap.js +1 -1
  263. package/dist/{value-labels-C7GrhOXJ.js → value-labels-B0VeheyE.js} +5 -4
  264. package/dist/value-labels-B0VeheyE.js.map +1 -0
  265. package/dist/{value-labels-DzaKIWKp.cjs → value-labels-Dcyk3GIY.cjs} +5 -4
  266. package/dist/value-labels-Dcyk3GIY.cjs.map +1 -0
  267. package/dist/value-labels.cjs +1 -1
  268. package/dist/value-labels.d.cts +1 -1
  269. package/dist/value-labels.d.ts +1 -1
  270. package/dist/value-labels.js +1 -1
  271. package/dist/zoom.cjs +810 -0
  272. package/dist/zoom.cjs.map +1 -0
  273. package/dist/zoom.d.cts +34 -0
  274. package/dist/zoom.d.ts +34 -0
  275. package/dist/zoom.js +806 -0
  276. package/dist/zoom.js.map +1 -0
  277. package/package.json +27 -2
  278. package/dist/annotations-BQ8l-qHs.js.map +0 -1
  279. package/dist/annotations-CpCWA29b.cjs.map +0 -1
  280. package/dist/area-DYdQ_sMV.cjs.map +0 -1
  281. package/dist/area-WdtfqvhX.js.map +0 -1
  282. package/dist/axis-MMaVoSWB.js.map +0 -1
  283. package/dist/axis-YfAerNBA.cjs.map +0 -1
  284. package/dist/bar-BOcRcArc.js.map +0 -1
  285. package/dist/bar-CVkOJ7WA.cjs.map +0 -1
  286. package/dist/candlestick-BtT9glp9.js.map +0 -1
  287. package/dist/candlestick-CSmRuZ4v.cjs.map +0 -1
  288. package/dist/cartesian-BrPqb5Qn.js.map +0 -1
  289. package/dist/cartesian-DRSXHxWe.cjs.map +0 -1
  290. package/dist/chart-B6TTY4Kr.js.map +0 -1
  291. package/dist/chart-D_lyOy-M.cjs.map +0 -1
  292. package/dist/core-CQ0FaJ4G.js.map +0 -1
  293. package/dist/core-D2PSked3.cjs.map +0 -1
  294. package/dist/export-chart-CPtXmZvi.cjs.map +0 -1
  295. package/dist/export-chart-DoeiAyR2.js.map +0 -1
  296. package/dist/line-CxR4tg1Q.js.map +0 -1
  297. package/dist/line-YiCuhVMI.cjs.map +0 -1
  298. package/dist/map-BqrZ80vT.cjs.map +0 -1
  299. package/dist/map-C15NC7kW.js.map +0 -1
  300. package/dist/pie-Bd8wyrtY.js.map +0 -1
  301. package/dist/pie-BseZlCgP.cjs.map +0 -1
  302. package/dist/scatter-Bwkblr4L.cjs.map +0 -1
  303. package/dist/scatter-DCMAtt5L.js.map +0 -1
  304. package/dist/treemap-C4glsx-g.js.map +0 -1
  305. package/dist/treemap-CZk8kKFD.cjs.map +0 -1
  306. package/dist/value-labels-C7GrhOXJ.js.map +0 -1
  307. package/dist/value-labels-DzaKIWKp.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"radar-D6XqkFWQ.js","names":[],"sources":["../src/charts/radar.ts"],"sourcesContent":["import type { ChartType, RenderContext, RenderResult } 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 { h } from '../vnode.ts'\nimport {\n type CartesianData,\n domainOf,\n type Label,\n labelKey,\n markerShape,\n pointMark,\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): RenderResult {\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 highlight: { kind: 'spoke', 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\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 shape = markerShape(options)\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 pointMark(\n shape,\n index,\n labelKey(label),\n 'tc-point',\n round(x),\n round(y),\n 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 const content = [\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 return { content, interaction }\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":";;;;;;;;AAsEA,MAAM,YAAY;;AAElB,MAAM,aAAa;;AAGnB,MAAM,aAAa;;AAEnB,MAAM,YAAY;;AAGlB,SAAS,SAAS,MAAc,OAAe,UAA0B;CACvE,IAAI,kBAAkB,MAAM,QAAQ,KAAK,O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AI,GAAG,IAAI,CAAC,CACzF;CACF,CAAC,CACH;CAEA,MAAM,cACJ,KAAK,SAAS,SACd,EACE,KACA;EAAE,KAAK;EAAU,OAAO;EAAmB,eAAe;CAAO,GACjE,MACG,QAAQ,SAAS,KAAK,WAAW,CAAC,CAAC,CACnC,KAAK,SACJ,EACE,QACA;EACE,KAAK,KAAK;EACV,OAAO;EACP,GAAG,MAAM,KAAK,CAAC;EACf,GAAG,MAAM,KAAK,KAAK,QAAQ;EAC3B,IAAI;CACN,GACA,KAAK,KACP,CACF,CACJ;CAiBF,OAAO;EAAE,SAAA;GAdP;GAEA,EACE,KACA;IACE,KAAK;IACL,OAAO;IACP,OAAO,oBAAoB,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,EAAE;GACtD,GACA,MACF;GACA;GACA;EAEa;EAAG;CAAY;AAChC;;;;;;;;;;;;;;;;AAiBA,MAAa,QAAiC;CAC5C,MAAM;CACN,OAAO,UAAU,WAAW;CAC5B,QAAQ;CACR,SAAS,YAAY,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UACpB,YACE;EACE,MAAM,QAAQ;EACd,GAAI,QAAQ,GAAG,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,OAAO,EAAE,IAAI,CAAC;CAC5D,GACA,KACA,KACF;AACJ"}
1
+ {"version":3,"file":"radar-Bg-IiIWB.js","names":[],"sources":["../src/charts/radar.ts"],"sourcesContent":["import type { ChartType, RenderContext, RenderResult } 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 { h } from '../vnode.ts'\nimport {\n type CartesianData,\n domainOf,\n type Label,\n labelKey,\n markerShape,\n pointMark,\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): RenderResult {\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 highlight: { kind: 'spoke', 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\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 shape = markerShape(options)\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 pointMark(\n shape,\n index,\n labelKey(label),\n 'tc-point',\n round(x),\n round(y),\n 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 const content = [\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 return { content, interaction }\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":";;;;;;;;AAsEA,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,UAA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AAC;EACf,GAAG,MAAM,KAAK,KAAK,QAAQ;EAC3B,IAAI;CACN,GACA,KAAK,KACP,CACF,CACJ;CAiBF,OAAO;EAAE,SAAA;GAdP;GAEA,EACE,KACA;IACE,KAAK;IACL,OAAO;IACP,OAAO,oBAAoB,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,EAAE;GACtD,GACA,MACF;GACA;GACA;EAEa;EAAG;CAAY;AAChC;;;;;;;;;;;;;;;;AAiBA,MAAa,QAAiC;CAC5C,MAAM;CACN,OAAO,UAAU,WAAW;CAC5B,QAAQ;CACR,SAAS,YAAY,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UACpB,YACE;EACE,MAAM,QAAQ;EACd,GAAI,QAAQ,GAAG,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,OAAO,EAAE,IAAI,CAAC;CAC5D,GACA,KACA,KACF;AACJ"}
@@ -1,6 +1,6 @@
1
- import { at as CartesianData, ct as Label, o as ChartType } from "./chart-CYrrUCi3.js";
1
+ import { o as ChartType, pt as Label, ut as CartesianData } from "./chart-CE9EVbfV.js";
2
2
  import { c as NumberFormat } from "./time-DRIDgv2a.js";
3
- import { a as InsetsInput } from "./annotations-B02GR_KU.js";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.js";
4
4
  /** Options for the radial value axis. */
5
5
  interface RadialAxisOptions {
6
6
  /** Render the value labels along the first spoke. Defaults to `true`. */
@@ -1,6 +1,6 @@
1
- import { ft as Label, lt as CartesianData, o as ChartType } from "./chart-CbPzP5Dp.cjs";
1
+ import { _t as Label, mt as CartesianData, o as ChartType } from "./chart-Dz4geQZy.cjs";
2
2
  import { c as NumberFormat } from "./time-B4oxWHQI.cjs";
3
- import { a as InsetsInput } from "./annotations-CHafaGd4.cjs";
3
+ import { n as InsetsInput } from "./layout-CYerDebD.cjs";
4
4
  /** Options for the radial value axis. */
5
5
  interface RadialAxisOptions {
6
6
  /** Render the value labels along the first spoke. Defaults to `true`. */
@@ -1,7 +1,7 @@
1
- const require_axis = require("./axis-YfAerNBA.cjs");
1
+ const require_axis = require("./axis-BzBkkC5X.cjs");
2
2
  const require_format = require("./format-CAE5ruy6.cjs");
3
3
  const require_layout = require("./layout-Cfg9x1k2.cjs");
4
- const require_cartesian = require("./cartesian-DRSXHxWe.cjs");
4
+ const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
5
5
  const require_vnode = require("./vnode-ClAiw28x.cjs");
6
6
  const require_clean = require("./clean-Die2iCNc.cjs");
7
7
  // src/charts/radar.ts
@@ -285,4 +285,4 @@ Object.defineProperty(exports, "radar", {
285
285
  }
286
286
  });
287
287
 
288
- //# sourceMappingURL=radar-DjISDnSf.cjs.map
288
+ //# sourceMappingURL=radar-wDyX17S3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"radar-DjISDnSf.cjs","names":["estimateTextWidth","LINE_HEIGHT","resolveLabels","seriesKey","formatDetail","insets","innerRect","tickCount","domainOf","linear","linearTicks","round","labelKey","h","markerShape","seriesAttrs","pointMark","cleanData","cleanSeries","seriesLegend","seriesTable"],"sources":["../src/charts/radar.ts"],"sourcesContent":["import type { ChartType, RenderContext, RenderResult } 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 { h } from '../vnode.ts'\nimport {\n type CartesianData,\n domainOf,\n type Label,\n labelKey,\n markerShape,\n pointMark,\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): RenderResult {\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 highlight: { kind: 'spoke', 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\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 shape = markerShape(options)\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 pointMark(\n shape,\n index,\n labelKey(label),\n 'tc-point',\n round(x),\n round(y),\n 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 const content = [\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 return { content, interaction }\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":";;;;;;;;AAsEA,MAAM,YAAY;;AAElB,MAAM,aAAa;;AAGnB,MAAM,aAAa;;AAEnB,MAAM,YAAY;;AAGlB,SAAS,SAAS,MAAc,OAAe,UAA0B;CACvE,IAAIA,eAAAA,kBAAkB,MAAM,QAAQ,KAAK,OAAO,OAAO;CACvD,IAAI,MAAM,KAAK;CACf,OAAO,MAAM,KAAKA,eAAAA,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,QAAQA,eAAAA,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,IAAI,GAAGV,eAAAA,YAAY;EAAI,GAAG,IAAI,CAAC,CACzF;CACF,CAAC,CACH;CAEA,MAAM,cACJ,KAAK,SAAS,SACdY,cAAAA,EACE,KACA;EAAE,KAAK;EAAU,OAAO;EAAmB,eAAe;CAAO,GACjE,MACG,QAAQ,SAAS,KAAK,WAAW,CAAC,CAAC,CACnC,KAAK,SACJA,cAAAA,EACE,QACA;EACE,KAAK,KAAK;EACV,OAAO;EACP,GAAGF,eAAAA,MAAM,KAAK,CAAC;EACf,GAAGA,eAAAA,MAAM,KAAK,KAAK,QAAQ;EAC3B,IAAI;CACN,GACA,KAAK,KACP,CACF,CACJ;CAiBF,OAAO;EAAE,SAAA;GAdP;GAEAE,cAAAA,EACE,KACA;IACE,KAAK;IACL,OAAO;IACP,OAAO,oBAAoBF,eAAAA,MAAM,EAAE,EAAE,KAAKA,eAAAA,MAAM,EAAE,EAAE;GACtD,GACA,MACF;GACA;GACA;EAEa;EAAG;CAAY;AAChC;;;;;;;;;;;;;;;;AAiBA,MAAa,QAAiC;CAC5C,MAAM;CACN,OAAOM,cAAAA,UAAUC,cAAAA,WAAW;CAC5B,QAAQ;CACR,SAAS,YAAYC,kBAAAA,aAAa,QAAQ,IAAI;CAC9C,QAAQ,SAAS,KAAK,UACpBC,kBAAAA,YACE;EACE,MAAM,QAAQ;EACd,GAAI,QAAQ,GAAG,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,OAAO,EAAE,IAAI,CAAC;CAC5D,GACA,KACA,KACF;AACJ"}
1
+ {"version":3,"file":"radar-wDyX17S3.cjs","names":["estimateTextWidth","LINE_HEIGHT","resolveLabels","seriesKey","formatDetail","insets","innerRect","tickCount","domainOf","linear","linearTicks","round","labelKey","h","markerShape","seriesAttrs","pointMark","cleanData","cleanSeries","seriesLegend","seriesTable"],"sources":["../src/charts/radar.ts"],"sourcesContent":["import type { ChartType, RenderContext, RenderResult } 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 { h } from '../vnode.ts'\nimport {\n type CartesianData,\n domainOf,\n type Label,\n labelKey,\n markerShape,\n pointMark,\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): RenderResult {\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 highlight: { kind: 'spoke', 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\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 shape = markerShape(options)\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 pointMark(\n shape,\n index,\n labelKey(label),\n 'tc-point',\n round(x),\n round(y),\n 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 const content = [\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 return { content, interaction }\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":";;;;;;;;AAsEA,MAAM,YAAY;;AAElB,MAAM,aAAa;;AAGnB,MAAM,aAAa;;AAEnB,MAAM,YAAY;;AAGlB,SAAS,SAAS,MAAc,OAAe,UAA0B;CACvE,IAAIA,eAAAA,kBAAkB,MAAM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Q,SAAS,KAAK,UACpBC,kBAAAA,YACE;EACE,MAAM,QAAQ;EACd,GAAI,QAAQ,GAAG,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,GAAG,EAAE,QAAQ,QAAQ,OAAO,EAAE,IAAI,CAAC;CAC5D,GACA,KACA,KACF;AACJ"}
package/dist/radar.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_radar = require("./radar-DjISDnSf.cjs");
2
+ const require_radar = require("./radar-wDyX17S3.cjs");
3
3
  exports.radar = require_radar.radar;
package/dist/radar.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { radar } from '@tabler/charts/radar'`. */
2
- import { n as RadialAxisOptions, r as radar, t as RadarOptions } from "./radar-7I6hsY_h.cjs";
2
+ import { n as RadialAxisOptions, r as radar, t as RadarOptions } from "./radar-DxmjXhMc.cjs";
3
3
  export { type RadarOptions, type RadialAxisOptions, radar };
package/dist/radar.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { radar } from '@tabler/charts/radar'`. */
2
- import { n as RadialAxisOptions, r as radar, t as RadarOptions } from "./radar-vLxilcr4.js";
2
+ import { n as RadialAxisOptions, r as radar, t as RadarOptions } from "./radar-DEer2jjd.js";
3
3
  export { type RadarOptions, type RadialAxisOptions, radar };
package/dist/radar.js CHANGED
@@ -1 +1 @@
1
- export { t as radar } from "./radar-D6XqkFWQ.js";
1
+ export { t as radar } from "./radar-Bg-IiIWB.js";
@@ -0,0 +1,348 @@
1
+ const require_axis = require("./axis-BzBkkC5X.cjs");
2
+ const require_features = require("./features-DEDP5CEQ.cjs");
3
+ const require_format = require("./format-CAE5ruy6.cjs");
4
+ const require_layout = require("./layout-Cfg9x1k2.cjs");
5
+ const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
6
+ const require_extent = require("./extent-DuYDcvM9.cjs");
7
+ const require_rect = require("./rect-DPr9QRxl.cjs");
8
+ const require_vnode = require("./vnode-ClAiw28x.cjs");
9
+ const require_clean = require("./clean-Die2iCNc.cjs");
10
+ // src/charts/range-bar.ts
11
+ /** The shortest bar drawn, in pixels: a range with no length (a milestone) still shows. */
12
+ const MIN_LENGTH = 2;
13
+ /** Pixels around the plot area that still count as hovering it. */
14
+ const HOVER_SLOP = 8;
15
+ const DAY = 864e5;
16
+ /** A value in axis units (milliseconds on a time axis), or `null` when it has no place there. */
17
+ const position = (value, timed) => {
18
+ if (!timed) return require_clean.finite(value);
19
+ const ms = require_cartesian.toMs(value);
20
+ return Number.isFinite(ms) ? ms : null;
21
+ };
22
+ function prepare(options) {
23
+ const timed = options.x?.type === "time";
24
+ const rows = [];
25
+ const index = /* @__PURE__ */ new Map();
26
+ const seen = /* @__PURE__ */ new Map();
27
+ const bars = [];
28
+ for (const item of options.data) {
29
+ const a = position(item.from, timed);
30
+ const b = position(item.to, timed);
31
+ if (a === null || b === null) continue;
32
+ let row = index.get(item.name);
33
+ if (row === void 0) {
34
+ row = rows.length;
35
+ index.set(item.name, row);
36
+ rows.push(item.name);
37
+ }
38
+ const base = item.id ?? item.name;
39
+ const nth = seen.get(base) ?? 0;
40
+ seen.set(base, nth + 1);
41
+ bars.push({
42
+ item,
43
+ key: nth ? `${base}/${nth}` : base,
44
+ row,
45
+ from: Math.min(a, b),
46
+ to: Math.max(a, b)
47
+ });
48
+ }
49
+ return {
50
+ ...options,
51
+ timed,
52
+ rows,
53
+ bars
54
+ };
55
+ }
56
+ /** How the ends of the ranges read in tooltips and the table. */
57
+ function valueFormat(model, locale) {
58
+ const { format, utc } = model.x ?? {};
59
+ if (!model.timed) return require_format.formatDetail(format, locale);
60
+ if (typeof format === "function") return format;
61
+ const [lo, hi] = require_extent.extent(model.bars.flatMap((bar) => [bar.from, bar.to])) ?? [0, 0];
62
+ const date = require_features.feature("dates")([lo, hi], utc, locale);
63
+ return (value) => date(value);
64
+ }
65
+ /**
66
+ * The annotations as the cartesian layers read them: there `y` is a value
67
+ * on the value axis and `x` a category, here `x` runs along the ranges and
68
+ * `y` names rows.
69
+ */
70
+ function annotationsOf(model) {
71
+ const at = (v) => position(v, model.timed);
72
+ return require_clean.list(model.annotations).filter(require_clean.isRecord).flatMap((a) => {
73
+ const { x, y, ...rest } = a;
74
+ const out = { ...rest };
75
+ if (x !== void 0) {
76
+ const ends = Array.isArray(x) ? x.map(at) : at(x);
77
+ if (ends === null || Array.isArray(ends) && (ends.length !== 2 || ends.includes(null))) return [];
78
+ out.y = ends;
79
+ }
80
+ if (y !== void 0) out.x = typeof y === "string" && (x === void 0 || Array.isArray(x)) ? [y, y] : y;
81
+ return [out];
82
+ });
83
+ }
84
+ /** The range axis before the plot is placed: its domain and the ticks of a scale over it. */
85
+ function rangeAxis(model, ctx, extra) {
86
+ const options = model.x ?? {};
87
+ const count = require_cartesian.tickCount(options, Math.max(2, Math.round(ctx.width / 80)));
88
+ const values = [...model.bars.flatMap((bar) => [bar.from, bar.to]), ...extra];
89
+ const min = position(options.min, model.timed);
90
+ const max = position(options.max, model.timed);
91
+ if (!model.timed) {
92
+ const { format } = options;
93
+ const bounds = {
94
+ ...min === null ? {} : { min },
95
+ ...max === null ? {} : { max }
96
+ };
97
+ const domain = require_cartesian.domainOf(values, {
98
+ ...bounds,
99
+ nice: options.nice !== false
100
+ }, false, count);
101
+ return {
102
+ domain,
103
+ ticks: (range) => require_axis.linearTicks(require_cartesian.linear(domain, range), {
104
+ count,
105
+ format,
106
+ locale: ctx.locale
107
+ })
108
+ };
109
+ }
110
+ const time = require_features.feature("time").scale;
111
+ const utc = options.utc === true;
112
+ let [lo, hi] = require_extent.extent(values) ?? [0, DAY];
113
+ if (lo === hi) {
114
+ lo -= DAY / 2;
115
+ hi += DAY / 2;
116
+ }
117
+ if (min !== null) lo = min;
118
+ if (max !== null) hi = max;
119
+ if (options.nice !== false) for (let pass = 0; pass < 2; pass++) {
120
+ const [nlo, nhi] = time([lo, hi], [0, 1], { utc }).nice(count).domain;
121
+ if (min === null) lo = nlo;
122
+ if (max === null) hi = nhi;
123
+ }
124
+ const domain = [lo, hi];
125
+ const { format } = options;
126
+ return {
127
+ domain,
128
+ ticks(range) {
129
+ const scale = time(domain, range, { utc });
130
+ const text = typeof format === "function" ? (date) => format(date.getTime()) : scale.tickFormat(count, ctx.locale);
131
+ return scale.ticks(count).map((date) => ({
132
+ value: date.getTime(),
133
+ position: scale(date),
134
+ label: text(date)
135
+ }));
136
+ }
137
+ };
138
+ }
139
+ function renderRangeBar(model, ctx) {
140
+ const { radius = 4, maxBarWidth = 24, groupPadding = .3, rows, bars } = model;
141
+ const { fontSize } = ctx;
142
+ const xOptions = model.x ?? {};
143
+ const yOptions = model.y ?? {};
144
+ const annotations = annotationsOf(model);
145
+ const axis = rangeAxis(model, ctx, annotations.flatMap((a) => a.y === void 0 ? [] : a.y));
146
+ const showValues = xOptions.show !== false;
147
+ const showRows = yOptions.show !== false && rows.length > 0;
148
+ const probe = axis.ticks([0, 1]);
149
+ const names = rows.map((name) => ({
150
+ value: name,
151
+ position: 0,
152
+ label: name
153
+ }));
154
+ const edgeLabel = (tick) => showValues && tick ? Math.ceil(require_layout.estimateTextWidth(tick.label, fontSize) / 2) : 0;
155
+ const { area, side, range } = require_layout.plotFrame(ctx, model.padding, (pad) => ({
156
+ top: pad.top + 4,
157
+ bottom: pad.bottom + Math.max((showValues ? require_axis.axisSize("bottom", probe, fontSize) : 0) + require_axis.axisTitleSize(xOptions.title, fontSize), 4),
158
+ start: pad.start + Math.max((showRows ? require_axis.axisSize("left", names, fontSize) : 0) + require_axis.axisTitleSize(yOptions.title, fontSize), edgeLabel(probe[0]), 8),
159
+ end: pad.end + Math.max(edgeLabel(probe[probe.length - 1]), 8)
160
+ }));
161
+ const across = require_cartesian.band(rows, [area.y, area.y + area.height], {
162
+ paddingInner: groupPadding,
163
+ paddingOuter: groupPadding / 2
164
+ });
165
+ const along = require_cartesian.linear(axis.domain, range());
166
+ const valueTicks = require_axis.thinTicks(axis.ticks(along.range), "bottom", fontSize);
167
+ const rowTicks = showRows ? require_axis.thinTicks(require_axis.bandTicks(across), "left", fontSize) : [];
168
+ const cartesian = {
169
+ data: { series: [] },
170
+ x: {
171
+ show: yOptions.show !== false,
172
+ grid: yOptions.grid === true,
173
+ title: yOptions.title
174
+ },
175
+ y: {
176
+ show: showValues,
177
+ grid: xOptions.grid !== false,
178
+ title: xOptions.title
179
+ },
180
+ annotations
181
+ };
182
+ const layout = require_cartesian.finishLayout(cartesian, ctx, side, 0, {
183
+ area,
184
+ labels: rows,
185
+ x: across,
186
+ y: along,
187
+ horizontal: true,
188
+ xTicks: rowTicks,
189
+ yTicks: valueTicks
190
+ }, rows);
191
+ const thickness = Math.max(1, Math.min(maxBarWidth, across.bandwidth));
192
+ const top = (bar) => across.at(bar.row) + (across.bandwidth - thickness) / 2;
193
+ /** The bar's ends in pixels, left first. */
194
+ const ends = (bar) => {
195
+ const a = along(bar.from);
196
+ const b = along(bar.to);
197
+ const lo = Math.min(a, b);
198
+ const hi = Math.max(a, b);
199
+ if (hi - lo >= MIN_LENGTH) return [lo, hi];
200
+ const mid = (lo + hi) / 2;
201
+ return [mid - MIN_LENGTH / 2, mid + MIN_LENGTH / 2];
202
+ };
203
+ const text = valueFormat(model, ctx.locale);
204
+ const hitFor = (i) => {
205
+ const bar = bars[i];
206
+ const [lo, hi] = ends(bar);
207
+ const y = top(bar);
208
+ const item = {
209
+ name: bar.item.name,
210
+ seriesIndex: 0,
211
+ value: bar.to - bar.from,
212
+ text: `${text(bar.from)} – ${text(bar.to)}`,
213
+ x: ctx.rtl ? lo : hi,
214
+ y: y + thickness / 2,
215
+ box: {
216
+ x: lo,
217
+ y,
218
+ width: hi - lo,
219
+ height: thickness
220
+ }
221
+ };
222
+ if (bar.item.color) item.color = bar.item.color;
223
+ return {
224
+ index: i,
225
+ label: bar.item.name,
226
+ title: "",
227
+ x: (lo + hi) / 2,
228
+ y: across.at(bar.row) + across.bandwidth / 2,
229
+ axis: "y",
230
+ area,
231
+ items: [item],
232
+ highlight: {
233
+ kind: "band",
234
+ x: area.x,
235
+ y: across.at(bar.row),
236
+ width: area.width,
237
+ height: across.bandwidth
238
+ }
239
+ };
240
+ };
241
+ const interaction = {
242
+ count: bars.length,
243
+ hitIndex: (i) => i >= 0 && i < bars.length ? hitFor(i) : null,
244
+ hitTest(px, py) {
245
+ 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;
246
+ const row = across.indexAt(py);
247
+ let found = -1;
248
+ let nearest = Number.POSITIVE_INFINITY;
249
+ bars.forEach((bar, i) => {
250
+ if (bar.row !== row) return;
251
+ const [lo, hi] = ends(bar);
252
+ const distance = Math.max(lo - px, px - hi, 0);
253
+ if (distance <= nearest) {
254
+ nearest = distance;
255
+ found = i;
256
+ }
257
+ });
258
+ if (found < 0) return null;
259
+ const hit = hitFor(found);
260
+ if (nearest === 0) hit.seriesIndex = 0;
261
+ return hit;
262
+ }
263
+ };
264
+ const marks = bars.map((bar) => {
265
+ const [lo, hi] = ends(bar);
266
+ return require_vnode.h("path", {
267
+ key: bar.key,
268
+ class: [
269
+ "tc-bar",
270
+ "tc-bar-horizontal",
271
+ "tc-range-bar",
272
+ bar.item.class
273
+ ],
274
+ "data-series": bar.item.name,
275
+ d: require_rect.rectPath(lo, top(bar), hi - lo, thickness, Math.max(0, radius)),
276
+ style: { "--tc-series-color": bar.item.color }
277
+ });
278
+ });
279
+ return {
280
+ content: [
281
+ require_vnode.h("defs", { key: "defs" }, layout.clip.def),
282
+ layout.background,
283
+ require_vnode.h("g", {
284
+ key: "series",
285
+ class: "tc-series-list tc-range-bars",
286
+ "clip-path": layout.clip.url
287
+ }, require_vnode.h("g", { class: "tc-series tc-series-1" }, marks)),
288
+ layout.foreground
289
+ ],
290
+ interaction
291
+ };
292
+ }
293
+ function rangeBarTable(model, ctx, limit) {
294
+ const text = valueFormat(model, ctx.locale);
295
+ const { bars } = model;
296
+ const shown = bars.length > limit ? bars.slice(0, limit) : bars;
297
+ return {
298
+ columns: [
299
+ "",
300
+ "From",
301
+ "To"
302
+ ],
303
+ total: bars.length,
304
+ rows: shown.map((bar) => [
305
+ bar.item.name,
306
+ text(bar.from),
307
+ text(bar.to)
308
+ ])
309
+ };
310
+ }
311
+ /** Ranges with text for names; ends that are no number or date are left for `prepare` to drop. */
312
+ const cleanRanges = (data) => require_clean.records(data, (r) => ({
313
+ ...require_clean.named(r),
314
+ from: require_clean.label(r.from),
315
+ to: require_clean.label(r.to)
316
+ }));
317
+ /**
318
+ * Range bar (timeline) chart: one row per name with a bar from `from` to
319
+ * `to`, along a time axis (a roadmap, a schedule) or a number axis (floating
320
+ * bars: salary bands, temperature ranges). Ranges with the same name share
321
+ * a row.
322
+ *
323
+ * ```ts
324
+ * new Chart('#el', {
325
+ * type: rangeBar,
326
+ * data: [
327
+ * { name: 'Research', from: '2026-01-05', to: '2026-02-10' },
328
+ * { name: 'Design', from: '2026-02-01', to: '2026-03-15' },
329
+ * ],
330
+ * x: { type: 'time' },
331
+ * })
332
+ * ```
333
+ */
334
+ const rangeBar = {
335
+ name: "range-bar",
336
+ clean: require_clean.cleanData(cleanRanges),
337
+ prepare,
338
+ render: renderRangeBar,
339
+ table: rangeBarTable
340
+ };
341
+ Object.defineProperty(exports, "rangeBar", {
342
+ enumerable: true,
343
+ get: function() {
344
+ return rangeBar;
345
+ }
346
+ });
347
+
348
+ //# sourceMappingURL=range-bar-BnKjJP89.cjs.map