@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range-bar-Dx6ce0J1.js","names":[],"sources":["../src/charts/range-bar.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext, RenderResult, TableContext } from '../chart.ts'\nimport {\n axisSize,\n axisTitleSize,\n bandTicks,\n linearTicks,\n type Tick,\n thinTicks,\n} from '../components/axis.ts'\nimport { feature } from '../features.ts'\nimport { formatDetail, type Locale, type NumberFormat } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { estimateTextWidth, type InsetsInput, plotFrame } from '../layout.ts'\nimport { band } from '../scales/band.ts'\nimport { extent } from '../scales/extent.ts'\nimport { linear } from '../scales/linear.ts'\nimport { rectPath } from '../shapes/rect.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport type { Annotation } from './annotations.ts'\nimport {\n type CartesianOptions,\n domainOf,\n EDGE,\n finishLayout,\n TICK_SPACING_X,\n tickCount,\n toMs,\n} from './cartesian.ts'\nimport { cleanData, finite, isRecord, label, list, named, records } from './clean.ts'\n\n/** Where a range starts or ends: a number, or a date (a `Date`, a timestamp, an ISO string) on a time axis. */\nexport type RangeValue = number | string | Date\n\n/** One range: a bar from `from` to `to`, in the row of its `name`. */\nexport interface RangeBarItem {\n /** The row of the range; ranges with the same name share a row. */\n name: string\n from: RangeValue\n to: RangeValue\n /** Stable identity for keyed updates. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the bar. */\n class?: ClassValue\n}\n\n/** Options for the axis the ranges run along (at the bottom). */\nexport interface RangeAxisOptions {\n /**\n * `'time'` reads `from` and `to` as dates or timestamps and draws\n * calendar-aware ticks. Needs `@tabler/charts/time` (included in\n * `@tabler/charts`). Defaults to `'linear'`: plain numbers.\n */\n type?: 'linear' | 'time'\n /** Align time ticks to UTC instead of local time (use it for SSR). */\n utc?: boolean\n /** Render the axis labels. Defaults to `true`. */\n show?: boolean\n /** Title of the axis, below its labels. */\n title?: string\n /** Render vertical grid lines. Defaults to `true`. */\n grid?: boolean\n /** Fixed lower bound; overrides the data. */\n min?: RangeValue\n /** Fixed upper bound. */\n max?: RangeValue\n /** Extend the domain to round tick values. Defaults to `true`. */\n nice?: boolean\n /** Approximate tick count. Defaults to one per ~80px of width. */\n ticks?: number\n /**\n * Format of the values (ticks, tooltip, table). On a time axis only a\n * function counts: it gets the timestamp in milliseconds.\n */\n format?: NumberFormat\n}\n\n/** Options for the axis of the rows (beside the plot). */\nexport interface RangeRowAxisOptions {\n /** Render the row names. Defaults to `true`. */\n show?: boolean\n /** Title of the axis, turned 90° beside the names. */\n title?: string\n /** Render a horizontal grid line through every row. Defaults to `false`. */\n grid?: boolean\n}\n\n/**\n * A reference line or band of a range bar chart: a moment or a value on the\n * range axis (`x: '2026-03-01'`), a period (`x: [from, to]`), a row\n * (`y: 'Design'`) or the rows from one to another (`y: ['Design', 'Testing']`).\n * With a single `x` and a single `y` it is a point in that row.\n */\nexport interface RangeBarAnnotation extends Omit<Annotation, 'x' | 'y'> {\n x?: RangeValue | readonly [RangeValue, RangeValue]\n y?: string | readonly [string, string]\n}\n\nexport interface RangeBarOptions {\n /** The ranges, top to bottom in the order their names first come. */\n data: readonly RangeBarItem[]\n /** The axis the ranges run along. */\n x?: RangeAxisOptions\n /** The axis of the rows. */\n y?: RangeRowAxisOptions\n /** Corner radius of the bars. Defaults to `4`. */\n radius?: number\n /** Maximum bar thickness in pixels; leftover row space stays empty. Defaults to `24`. */\n maxBarWidth?: number\n /** Share of each row left empty between bars, `0…1`. Defaults to `0.3`. */\n groupPadding?: number\n /** Reference lines and bands: today, a deadline, a freeze. Needs `@tabler/charts/annotations` on the core. */\n annotations?: readonly RangeBarAnnotation[]\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\n/** A range that can be drawn: its item, its row and its ends in axis units (lower first). */\ninterface Bar {\n item: RangeBarItem\n key: string\n row: number\n from: number\n to: number\n}\n\n/** The chart model: the options, with the ranges that can be drawn and their rows. */\ninterface RangeBarModel extends RangeBarOptions {\n timed: boolean\n rows: readonly string[]\n bars: readonly Bar[]\n}\n\n/** The shortest bar drawn, in pixels: a range with no length (a milestone) still shows. */\nconst MIN_LENGTH = 2\n\n/** Pixels around the plot area that still count as hovering it. */\nconst HOVER_SLOP = 8\n\nconst DAY = 24 * 60 * 60 * 1000\n\n/** A value in axis units (milliseconds on a time axis), or `null` when it has no place there. */\nconst position = (value: unknown, timed: boolean): number | null => {\n if (!timed) return finite(value)\n const ms = toMs(value as RangeValue)\n return Number.isFinite(ms) ? ms : null\n}\n\nfunction prepare(options: RangeBarOptions): RangeBarModel {\n const timed = options.x?.type === 'time'\n const rows: string[] = []\n const index = new Map<string, number>()\n const seen = new Map<string, number>()\n const bars: Bar[] = []\n for (const item of options.data) {\n const a = position(item.from, timed)\n const b = position(item.to, timed)\n if (a === null || b === null) continue\n let row = index.get(item.name)\n if (row === undefined) {\n row = rows.length\n index.set(item.name, row)\n rows.push(item.name)\n }\n // Ranges that share a name (and have no id) still need keys of their own.\n const base = item.id ?? item.name\n const nth = seen.get(base) ?? 0\n seen.set(base, nth + 1)\n bars.push({\n item,\n key: nth ? `${base}/${nth}` : base,\n row,\n from: Math.min(a, b),\n to: Math.max(a, b),\n })\n }\n return { ...options, timed, rows, bars }\n}\n\n/** How the ends of the ranges read in tooltips and the table. */\nfunction valueFormat(model: RangeBarModel, locale: Locale): (value: number) => string {\n const { format, utc } = model.x ?? {}\n if (!model.timed) return formatDetail(format, locale)\n if (typeof format === 'function') return format\n const [lo, hi] = extent(model.bars.flatMap((bar) => [bar.from, bar.to])) ?? [0, 0]\n const date = feature('dates')([lo, hi], utc, locale)\n return (value) => date(value)\n}\n\n/**\n * The annotations as the cartesian layers read them: there `y` is a value\n * on the value axis and `x` a category, here `x` runs along the ranges and\n * `y` names rows.\n */\nfunction annotationsOf(model: RangeBarModel): Annotation[] {\n const at = (v: unknown) => position(v, model.timed)\n return list(model.annotations)\n .filter(isRecord)\n .flatMap((a) => {\n const { x, y, ...rest } = a as RangeBarAnnotation\n const out: Annotation = { ...rest }\n if (x !== undefined) {\n const ends = Array.isArray(x) ? x.map(at) : at(x)\n if (ends === null || (Array.isArray(ends) && (ends.length !== 2 || ends.includes(null)))) {\n return []\n }\n out.y = ends as number | [number, number]\n }\n // A row is marked as a whole (a band), unless a single `x` makes it a point.\n if (y !== undefined) {\n out.x = typeof y === 'string' && (x === undefined || Array.isArray(x)) ? [y, y] : y\n }\n return [out]\n })\n}\n\n/** The range axis before the plot is placed: its domain and the ticks of a scale over it. */\nfunction rangeAxis(\n model: RangeBarModel,\n ctx: RenderContext,\n extra: readonly number[],\n): { domain: [number, number]; ticks(range: readonly [number, number]): Tick[] } {\n const options = model.x ?? {}\n const count = tickCount(options, Math.max(2, Math.round(ctx.width / TICK_SPACING_X)))\n const values = [...model.bars.flatMap((bar) => [bar.from, bar.to]), ...extra]\n const min = position(options.min, model.timed)\n const max = position(options.max, model.timed)\n if (!model.timed) {\n const { format } = options\n const bounds = { ...(min === null ? {} : { min }), ...(max === null ? {} : { max }) }\n const domain = domainOf(values, { ...bounds, nice: options.nice !== false }, false, count)\n return {\n domain,\n ticks: (range) => linearTicks(linear(domain, range), { count, format, locale: ctx.locale }),\n }\n }\n\n const time = feature('time').scale\n const utc = options.utc === true\n let [lo, hi] = extent(values) ?? [0, DAY]\n // A single moment still needs a visible range: the day around it.\n if (lo === hi) {\n lo -= DAY / 2\n hi += DAY / 2\n }\n if (min !== null) lo = min\n if (max !== null) hi = max\n if (options.nice !== false) {\n // Twice: the wider domain may call for a longer tick interval, whose\n // boundaries are then the ones the axis should end on.\n for (let pass = 0; pass < 2; pass++) {\n const [nlo, nhi] = time([lo, hi], [0, 1], { utc }).nice(count).domain\n if (min === null) lo = nlo\n if (max === null) hi = nhi\n }\n }\n const domain: [number, number] = [lo, hi]\n const { format } = options\n return {\n domain,\n ticks(range) {\n const scale = time(domain, range, { utc })\n const text =\n typeof format === 'function'\n ? (date: Date) => format(date.getTime())\n : scale.tickFormat(count, ctx.locale)\n return scale\n .ticks(count)\n .map((date) => ({ value: date.getTime(), position: scale(date), label: text(date) }))\n },\n }\n}\n\nfunction renderRangeBar(model: RangeBarModel, ctx: RenderContext): RenderResult {\n const { radius = 4, maxBarWidth = 24, groupPadding = 0.3, rows, bars } = model\n const { fontSize } = ctx\n const xOptions = model.x ?? {}\n const yOptions = model.y ?? {}\n const annotations = annotationsOf(model)\n // Annotations on the range axis stay in view, like targets on a value axis.\n const marked = annotations.flatMap((a) => (a.y === undefined ? [] : a.y))\n const axis = rangeAxis(model, ctx, marked)\n const showValues = xOptions.show !== false\n const showRows = yOptions.show !== false && rows.length > 0\n\n const probe = axis.ticks([0, 1])\n const names: Tick[] = rows.map((name) => ({ value: name, position: 0, label: name }))\n const edgeLabel = (tick: Tick | undefined) =>\n showValues && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0\n\n const { area, side, range } = plotFrame(ctx, model.padding, (pad) => ({\n top: pad.top + EDGE / 2,\n bottom:\n pad.bottom +\n Math.max(\n (showValues ? axisSize('bottom', probe, fontSize) : 0) +\n axisTitleSize(xOptions.title, fontSize),\n EDGE / 2,\n ),\n start:\n pad.start +\n Math.max(\n (showRows ? axisSize('left', names, fontSize) : 0) +\n axisTitleSize(yOptions.title, fontSize),\n edgeLabel(probe[0]),\n EDGE,\n ),\n end: pad.end + Math.max(edgeLabel(probe[probe.length - 1]), EDGE),\n }))\n\n const across = band(rows, [area.y, area.y + area.height], {\n paddingInner: groupPadding,\n paddingOuter: groupPadding / 2,\n })\n // The ranges run from the start side: from the right in a right-to-left chart.\n const along = linear(axis.domain, range())\n const valueTicks = thinTicks(axis.ticks(along.range), 'bottom', fontSize)\n const rowTicks = showRows ? thinTicks(bandTicks(across), 'left', fontSize) : []\n\n // The shared layers read categories as `x` and values as `y`, whichever way they run.\n const cartesian: CartesianOptions = {\n data: { series: [] },\n x: { show: yOptions.show !== false, grid: yOptions.grid === true, title: yOptions.title },\n y: { show: showValues, grid: xOptions.grid !== false, title: xOptions.title },\n annotations,\n }\n const layout = finishLayout(\n cartesian,\n ctx,\n side,\n 0,\n {\n area,\n labels: rows,\n x: across,\n y: along,\n horizontal: true,\n xTicks: rowTicks,\n yTicks: valueTicks,\n },\n rows,\n )\n\n const thickness = Math.max(1, Math.min(maxBarWidth, across.bandwidth))\n const top = (bar: Bar) => across.at(bar.row) + (across.bandwidth - thickness) / 2\n /** The bar's ends in pixels, left first. */\n const ends = (bar: Bar): [number, number] => {\n const a = along(bar.from)\n const b = along(bar.to)\n const lo = Math.min(a, b)\n const hi = Math.max(a, b)\n if (hi - lo >= MIN_LENGTH) return [lo, hi]\n const mid = (lo + hi) / 2\n return [mid - MIN_LENGTH / 2, mid + MIN_LENGTH / 2]\n }\n\n const text = valueFormat(model, ctx.locale)\n const hitFor = (i: number): Hit => {\n const bar = bars[i] as Bar\n const [lo, hi] = ends(bar)\n const y = top(bar)\n const item: HitItem = {\n name: bar.item.name,\n seriesIndex: 0,\n // The length of the range; value labels write the range itself.\n value: bar.to - bar.from,\n text: `${text(bar.from)} – ${text(bar.to)}`,\n // The end the bar runs to.\n x: ctx.rtl ? lo : hi,\n y: y + thickness / 2,\n box: { x: lo, y, width: hi - lo, height: thickness },\n }\n if (bar.item.color) item.color = bar.item.color\n return {\n index: i,\n label: bar.item.name,\n title: '',\n x: (lo + hi) / 2,\n y: across.at(bar.row) + across.bandwidth / 2,\n axis: 'y',\n area,\n items: [item],\n highlight: {\n kind: 'band',\n x: area.x,\n y: across.at(bar.row),\n width: area.width,\n height: across.bandwidth,\n },\n }\n }\n\n const interaction: Interaction = {\n count: bars.length,\n hitIndex: (i) => (i >= 0 && i < bars.length ? hitFor(i) : null),\n hitTest(px, py) {\n if (\n px < area.x - HOVER_SLOP ||\n px > area.x + area.width + HOVER_SLOP ||\n py < area.y - HOVER_SLOP ||\n py > area.y + area.height + HOVER_SLOP\n ) {\n return null\n }\n // The bar under the pointer in its row (the one drawn last), or the nearest one there.\n const row = across.indexAt(py)\n let found = -1\n let nearest = Number.POSITIVE_INFINITY\n bars.forEach((bar, i) => {\n if (bar.row !== row) return\n const [lo, hi] = ends(bar)\n const distance = Math.max(lo - px, px - hi, 0)\n if (distance <= nearest) {\n nearest = distance\n found = i\n }\n })\n if (found < 0) return null\n const hit = hitFor(found)\n if (nearest === 0) hit.seriesIndex = 0\n return hit\n },\n }\n\n const marks = bars.map((bar) => {\n const [lo, hi] = ends(bar)\n return h('path', {\n key: bar.key,\n class: ['tc-bar', 'tc-bar-horizontal', 'tc-range-bar', bar.item.class],\n 'data-series': bar.item.name,\n // A path, not a rect, so it morphs between updates (d), in Safari too.\n d: rectPath(lo, top(bar), hi - lo, thickness, Math.max(0, radius)),\n // A map, so values from data cannot inject CSS (see normalizeStyle).\n style: { '--tc-series-color': bar.item.color },\n })\n })\n\n const content = [\n h('defs', { key: 'defs' }, layout.clip.def),\n layout.background,\n h(\n 'g',\n { key: 'series', class: 'tc-series-list tc-range-bars', 'clip-path': layout.clip.url },\n // One color slot for every range: a bar's own `color` sets it apart.\n h('g', { class: 'tc-series tc-series-1' }, marks),\n ),\n layout.foreground,\n ]\n return { content, interaction }\n}\n\nfunction rangeBarTable(model: RangeBarModel, ctx: TableContext, limit: number): DataTable {\n const text = valueFormat(model, ctx.locale)\n const { bars } = model\n const shown = bars.length > limit ? bars.slice(0, limit) : bars\n return {\n columns: ['', 'From', 'To'],\n total: bars.length,\n rows: shown.map((bar) => [bar.item.name, text(bar.from), text(bar.to)]),\n }\n}\n\n/** Ranges with text for names; ends that are no number or date are left for `prepare` to drop. */\nconst cleanRanges = (data: unknown): unknown =>\n records(data, (r) => ({ ...named(r), from: label(r.from), to: label(r.to) }))\n\n/**\n * Range bar (timeline) chart: one row per name with a bar from `from` to\n * `to`, along a time axis (a roadmap, a schedule) or a number axis (floating\n * bars: salary bands, temperature ranges). Ranges with the same name share\n * a row.\n *\n * ```ts\n * new Chart('#el', {\n * type: rangeBar,\n * data: [\n * { name: 'Research', from: '2026-01-05', to: '2026-02-10' },\n * { name: 'Design', from: '2026-02-01', to: '2026-03-15' },\n * ],\n * x: { type: 'time' },\n * })\n * ```\n */\nexport const rangeBar: ChartType<RangeBarOptions, RangeBarModel> = {\n name: 'range-bar',\n clean: cleanData(cleanRanges),\n prepare,\n render: renderRangeBar,\n table: rangeBarTable,\n}\n"],"mappings":";;;;;;;;;;;AA2IA,MAAM,aAAa;;AAGnB,MAAM,aAAa;AAEnB,MAAM,MAAM;;AAGZ,MAAM,YAAY,OAAgB,UAAkC;CAClE,IAAI,CAAC,OAAO,OAAO,OAAO,KAAK;CAC/B,MAAM,KAAK,KAAK,KAAmB;CACnC,OAAO,OAAO,SAAS,EAAE,IAAI,KAAK;AACpC;AAEA,SAAS,QAAQ,SAAyC;CACxD,MAAM,QAAQ,QAAQ,GAAG,SAAS;CAClC,MAAM,OAAiB,CAAC;CACxB,MAAM,wBAAQ,IAAI,IAAoB;CACtC,MAAM,uBAAO,IAAI,IAAoB;CACrC,MAAM,OAAc,CAAC;CACrB,KAAK,MAAM,QAAQ,QAAQ,MAAM;EAC/B,MAAM,IAAI,SAAS,KAAK,MAAM,KAAK;EACnC,MAAM,IAAI,SAAS,KAAK,IAAI,KAAK;EACjC,IAAI,MAAM,QAAQ,MAAM,MAAM;EAC9B,IAAI,MAAM,MAAM,IAAI,KAAK,IAAI;EAC7B,IAAI,QAAQ,KAAA,GAAW;GACrB,MAAM,KAAK;GACX,MAAM,IAAI,KAAK,MAAM,GAAG;GACxB,KAAK,KAAK,KAAK,IAAI;EACrB;EAEA,MAAM,OAAO,KAAK,MAAM,KAAK;EAC7B,MAAM,MAAM,KAAK,IAAI,IAAI,KAAK;EAC9B,KAAK,IAAI,MAAM,MAAM,CAAC;EACtB,KAAK,KAAK;GACR;GACA,KAAK,MAAM,GAAG,KAAK,GAAG,QAAQ;GAC9B;GACA,MAAM,KAAK,IAAI,GAAG,CAAC;GACnB,IAAI,KAAK,IAAI,GAAG,CA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AAI;CAC3D,OAAO;EACL,SAAS;GAAC;GAAI;GAAQ;EAAI;EAC1B,OAAO,KAAK;EACZ,MAAM,MAAM,KAAK,QAAQ;GAAC,IAAI,KAAK;GAAM,KAAK,IAAI,IAAI;GAAG,KAAK,IAAI,EAAE;EAAC,CAAC;CACxE;AACF;;AAGA,MAAM,eAAe,SACnB,QAAQ,OAAO,OAAO;CAAE,GAAG,MAAM,CAAC;CAAG,MAAM,MAAM,EAAE,IAAI;CAAG,IAAI,MAAM,EAAE,EAAE;AAAE,EAAE;;;;;;;;;;;;;;;;;;AAmB9E,MAAa,WAAsD;CACjE,MAAM;CACN,OAAO,UAAU,WAAW;CAC5B;CACA,QAAQ;CACR,OAAO;AACT"}
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_range_bar = require("./range-bar-BnKjJP89.cjs");
3
+ exports.rangeBar = require_range_bar.rangeBar;
@@ -0,0 +1,3 @@
1
+ /** Standalone entry: `import { rangeBar } from '@tabler/charts/range-bar'`. */
2
+ import { a as RangeRowAxisOptions, i as RangeBarOptions, n as RangeBarAnnotation, o as RangeValue, r as RangeBarItem, s as rangeBar, t as RangeAxisOptions } from "./range-bar-D32dIQOY.cjs";
3
+ export { type RangeAxisOptions, type RangeBarAnnotation, type RangeBarItem, type RangeBarOptions, type RangeRowAxisOptions, type RangeValue, rangeBar };
@@ -0,0 +1,3 @@
1
+ /** Standalone entry: `import { rangeBar } from '@tabler/charts/range-bar'`. */
2
+ import { a as RangeRowAxisOptions, i as RangeBarOptions, n as RangeBarAnnotation, o as RangeValue, r as RangeBarItem, s as rangeBar, t as RangeAxisOptions } from "./range-bar-C4cRaaQE.js";
3
+ export { type RangeAxisOptions, type RangeBarAnnotation, type RangeBarItem, type RangeBarOptions, type RangeRowAxisOptions, type RangeValue, rangeBar };
@@ -0,0 +1 @@
1
+ export { t as rangeBar } from "./range-bar-Dx6ce0J1.js";
@@ -1,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CbPzP5Dp.cjs";
1
+ import { 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
  /** A node of the flow; nodes left out are made from the links. */
5
5
  interface SankeyNode {
6
6
  name: string;
@@ -1,6 +1,6 @@
1
- import { o as ChartType } from "./chart-CYrrUCi3.js";
1
+ import { o as ChartType } 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
  /** A node of the flow; nodes left out are made from the links. */
5
5
  interface SankeyNode {
6
6
  name: string;
package/dist/sankey.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { sankey } from '@tabler/charts/sankey'`. */
2
- import { a as sankey, i as SankeyOptions, n as SankeyLink, r as SankeyNode, t as SankeyData } from "./sankey-DqiuxUx7.cjs";
2
+ import { a as sankey, i as SankeyOptions, n as SankeyLink, r as SankeyNode, t as SankeyData } from "./sankey-D-8ATwBT.cjs";
3
3
  export { type SankeyData, type SankeyLink, type SankeyNode, type SankeyOptions, sankey };
package/dist/sankey.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Standalone entry: `import { sankey } from '@tabler/charts/sankey'`. */
2
- import { a as sankey, i as SankeyOptions, n as SankeyLink, r as SankeyNode, t as SankeyData } from "./sankey-7As41Fo4.js";
2
+ import { a as sankey, i as SankeyOptions, n as SankeyLink, r as SankeyNode, t as SankeyData } from "./sankey-DpYJsOI4.js";
3
3
  export { type SankeyData, type SankeyLink, type SankeyNode, type SankeyOptions, sankey };
@@ -1,5 +1,5 @@
1
- import { i as axisTitleSize, n as axisSize, r as axisTitle, s as thinTicks, t as axis } from "./axis-MMaVoSWB.js";
2
- import { E as grid, S as valueTicks, c as plotClip, l as plottable, r as domainOf, s as markerShape, v as tickCount, x as valueScale } from "./cartesian-BrPqb5Qn.js";
1
+ import { i as axisTitleSize, n as axisSize, r as axisTitle, s as thinTicks, t as axis } from "./axis-C5obgdJt.js";
2
+ import { D as grid, S as valueTicks, c as plotClip, l as plottable, r as domainOf, s as markerShape, v as tickCount, x as valueScale } from "./cartesian-COglz544.js";
3
3
  import { n as formatDetail, r as formatNumber } from "./format-it1kepFG.js";
4
4
  import { n as estimateTextWidth, o as plotFrame, s as round, t as LINE_HEIGHT } from "./layout-DqAte3H8.js";
5
5
  import { t as extent } from "./extent-DOV8rs-6.js";
@@ -11,8 +11,23 @@ import { n as keyOf, r as legendItems, t as groupAttrs } from "./named-BOiBah6I.
11
11
  /** Pointer distance (in pixels, beyond the radius) that still hits a point. */
12
12
  const HIT_RADIUS = 24;
13
13
  const EDGE = 8;
14
+ /**
15
+ * The categories of the x axis, or `null` when it is a value axis: `data.labels`,
16
+ * else every `x` in order of appearance once any of them is text.
17
+ */
18
+ function categories(data) {
19
+ if (data.labels) return data.labels.map(String);
20
+ if (!data.series.some((s) => s.points.some((p) => typeof p.x === "string"))) return null;
21
+ return [...new Set(data.series.flatMap((s) => s.points.map((p) => String(p.x))))];
22
+ }
14
23
  /** A point's bubble size, or `undefined` when it has none (or an invalid one). */
15
24
  const sizeOf = (p) => p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : void 0;
25
+ /** An `x` as text for the tooltip and the table: the category's name, or the formatted number. */
26
+ function xText(options, locale) {
27
+ const format = formatDetail(options.x?.format, locale);
28
+ const named = !!categories(options.data);
29
+ return (value) => named || typeof value === "string" ? String(value) : format(value);
30
+ }
16
31
  function renderScatter(options, ctx) {
17
32
  const { width, height, fontSize, locale } = ctx;
18
33
  const xOptions = options.x ?? {};
@@ -27,27 +42,56 @@ function renderScatter(options, ctx) {
27
42
  const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2;
28
43
  const countY = tickCount(yOptions, Math.max(2, Math.round(height / 60)));
29
44
  const countX = tickCount(xOptions, Math.max(2, Math.round(width / 80)));
30
- const usable = (p) => plottable(p.x, xOptions) && plottable(p.y, yOptions);
45
+ const labels = categories(options.data);
46
+ const index = new Map((labels ?? []).map((label, i) => [label, i]).reverse());
47
+ const usable = (p) => (labels ? index.has(String(p.x)) : typeof p.x === "number" && plottable(p.x, xOptions)) && plottable(p.y, yOptions);
31
48
  const shown = points.filter(usable);
32
- const xDomain = domainOf(shown.map((p) => p.x), xOptions, false, countX);
49
+ const xDomain = domainOf(labels ? [] : shown.map((p) => p.x), xOptions, false, countX);
33
50
  const yDomain = domainOf(shown.map((p) => p.y), yOptions, false, countY);
34
51
  const showX = xOptions.show !== false;
35
52
  const showY = yOptions.show !== false;
36
53
  const ticksOf = (scale, axis, count) => valueTicks(scale, axis, count, axis.format, locale);
37
54
  const probeY = ticksOf(valueScale(yDomain, [1, 0], yOptions), yOptions, countY);
38
- const probeX = ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX);
39
- const half = (tick) => showX && tick ? Math.ceil(estimateTextWidth(tick.label, fontSize) / 2) : 0;
55
+ const probeX = labels ? labels.map((label) => ({
56
+ value: label,
57
+ position: 0,
58
+ label
59
+ })) : ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX);
60
+ const half = (tick, halfBand = 0) => showX && tick ? Math.max(0, Math.ceil(estimateTextWidth(tick.label, fontSize) / 2 - halfBand)) : 0;
40
61
  const reverse = xOptions.reverse ?? ctx.rtl === true;
41
62
  const near = reverse === (ctx.rtl === true) ? 0 : probeX.length - 1;
42
- const { area, side, range } = plotFrame(ctx, options.padding, (pad) => ({
43
- top: pad.top + Math.max(showY ? Math.ceil(fontSize * LINE_HEIGHT / 2) : 0, overhang, EDGE / 2),
44
- bottom: pad.bottom + Math.max((showX ? axisSize("bottom", probeX, fontSize) : 0) + axisTitleSize(xOptions.title, fontSize), overhang, EDGE / 2),
45
- start: pad.start + Math.max((showY ? axisSize("left", probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize), half(probeX[near]), overhang),
46
- end: pad.end + Math.max(half(probeX[probeX.length - 1 - near]), overhang, EDGE)
47
- }));
48
- const x = valueScale(xDomain, range(reverse), xOptions);
63
+ const valueWidth = (showY ? axisSize("left", probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize);
64
+ const { area, side, range } = plotFrame(ctx, options.padding, (pad) => {
65
+ const sides = (halfBand) => ({
66
+ start: pad.start + Math.max(valueWidth, half(probeX[near], halfBand), overhang),
67
+ end: pad.end + Math.max(half(probeX[probeX.length - 1 - near], halfBand), overhang, EDGE)
68
+ });
69
+ let both = sides(0);
70
+ if (labels?.length) both = sides((width - both.start - both.end) / (labels.length * 2));
71
+ return {
72
+ top: pad.top + Math.max(showY ? Math.ceil(fontSize * LINE_HEIGHT / 2) : 0, overhang, EDGE / 2),
73
+ bottom: pad.bottom + Math.max((showX ? axisSize("bottom", probeX, fontSize) : 0) + axisTitleSize(xOptions.title, fontSize), overhang, EDGE / 2),
74
+ ...both
75
+ };
76
+ });
49
77
  const y = valueScale(yDomain, [area.y + area.height, area.y], yOptions);
50
- const xTicks = thinTicks(ticksOf(x, xOptions, countX), "bottom", fontSize);
78
+ let x;
79
+ let allX;
80
+ if (labels) {
81
+ const [from, to] = range(reverse);
82
+ const at = (i) => from + (to - from) * (i + .5) / labels.length;
83
+ x = (value) => at(index.get(String(value)));
84
+ allX = labels.map((label, i) => ({
85
+ value: label,
86
+ position: at(i),
87
+ label
88
+ }));
89
+ } else {
90
+ const scale = valueScale(xDomain, range(reverse), xOptions);
91
+ x = (value) => scale(value);
92
+ allX = ticksOf(scale, xOptions, countX);
93
+ }
94
+ const xTicks = thinTicks(allX, "bottom", fontSize);
51
95
  const yTicks = thinTicks(ticksOf(y, yOptions, countY), "left", fontSize, 4);
52
96
  const placed = [];
53
97
  options.data.series.forEach((series, seriesIndex) => {
@@ -65,7 +109,7 @@ function renderScatter(options, ctx) {
65
109
  });
66
110
  });
67
111
  placed.sort((a, b) => a.cx - b.cx);
68
- const fx = formatDetail(xOptions.format, locale);
112
+ const fx = xText(options, locale);
69
113
  const fy = formatDetail(yOptions.format, locale);
70
114
  const fs = formatNumber(void 0, locale);
71
115
  const hitFor = (p, index) => {
@@ -184,7 +228,7 @@ function renderScatter(options, ctx) {
184
228
  };
185
229
  }
186
230
  function scatterTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
187
- const fx = formatDetail(options.x?.format, ctx.locale);
231
+ const fx = xText(options, ctx.locale);
188
232
  const fy = formatDetail(options.y?.format, ctx.locale);
189
233
  const fs = formatNumber(void 0, ctx.locale);
190
234
  const series = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)));
@@ -216,7 +260,8 @@ function scatterTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
216
260
  }
217
261
  /**
218
262
  * Scatter chart: points on two value axes; give points a `size` for a
219
- * bubble chart (area-proportional radii).
263
+ * bubble chart (area-proportional radii). With `data.labels` (or a text `x`)
264
+ * the points stand over named categories instead.
220
265
  *
221
266
  * ```ts
222
267
  * new Chart('#el', {
@@ -229,11 +274,12 @@ const scatter = {
229
274
  name: "scatter",
230
275
  clean: cleanData((data) => ({
231
276
  ...isRecord(data) ? data : {},
277
+ labels: isRecord(data) && Array.isArray(data.labels) ? data.labels.map(text) : void 0,
232
278
  series: records(isRecord(data) && data.series, (s) => ({
233
279
  ...named(s),
234
280
  points: records(s.points, (p) => ({
235
281
  ...p,
236
- x: finite(p.x),
282
+ x: typeof p.x === "string" ? p.x : finite(p.x),
237
283
  y: finite(p.y),
238
284
  size: finite(p.size) ?? void 0,
239
285
  label: p.label == null ? void 0 : text(p.label)
@@ -247,4 +293,4 @@ const scatter = {
247
293
  };
248
294
  export { scatter as t };
249
295
 
250
- //# sourceMappingURL=scatter-DCMAtt5L.js.map
296
+ //# sourceMappingURL=scatter-0Z7K_YUz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scatter-0Z7K_YUz.js","names":[],"sources":["../src/charts/scatter.ts"],"sourcesContent":["import type { DataTable } from '../a11y.ts'\nimport type { ChartType, RenderContext } from '../chart.ts'\nimport {\n axis,\n axisSize,\n axisTitle,\n axisTitleSize,\n type Tick,\n thinTicks,\n} from '../components/axis.ts'\nimport { grid } from '../components/grid.ts'\nimport { formatDetail, formatNumber } from '../format.ts'\nimport type { Hit, HitItem, Interaction } from '../interaction.ts'\nimport { estimateTextWidth, type InsetsInput, LINE_HEIGHT, plotFrame, round } from '../layout.ts'\nimport { extent } from '../scales/extent.ts'\nimport type { LinearScale } from '../scales/linear.ts'\nimport { circlePath } from '../shapes/circle.ts'\nimport { type ClassValue, h } from '../vnode.ts'\nimport {\n domainOf,\n markerShape,\n plotClip,\n plottable,\n tickCount,\n type ValueAxisOptions,\n valueScale,\n valueTicks,\n} from './cartesian.ts'\nimport { cleanData, finite, isRecord, named, records, text } from './clean.ts'\nimport { groupAttrs, keyOf, legendItems } from './named.ts'\n\n/** A point of a scatter or bubble chart. */\nexport interface ScatterPoint {\n /** A number on a value axis; on a category axis, the label the point stands at. */\n x: number | string\n y: number\n /** Bubble size; the circle area is proportional to it. */\n size?: number\n /** Name shown in the tooltip and table (e.g. a country). */\n label?: string\n}\n\nexport interface ScatterSeries {\n name: string\n points: readonly ScatterPoint[]\n /** Stable identity for keyed updates and legend toggles. Defaults to `name`. */\n id?: string\n /**\n * Custom color; overrides the palette slot via `--tc-series-color`.\n * Values that could inject CSS (`;`, quotes, `url()` …) are ignored, so colors from user data are safe.\n */\n color?: string\n /** Extra classes on the series group. */\n class?: ClassValue\n /** Start hidden (toggle it back from the legend). */\n hidden?: boolean\n /**\n * Write values on this series' marks, whatever the chart's `valueLabels`\n * says: `true` labels it even when the chart option is off, `false` leaves\n * it out. Needs `@tabler/charts/value-labels` on the core.\n */\n valueLabels?: boolean\n}\n\nexport interface ScatterData {\n /**\n * Categories along x, in their order: the x axis then shows these names and\n * each point stands at the label its `x` names (points naming none are left\n * out). Without `labels`, points with a text `x` make the categories\n * themselves, in order of appearance.\n */\n labels?: readonly (string | number)[]\n series: readonly ScatterSeries[]\n}\n\nexport interface ScatterOptions {\n data: ScatterData\n /**\n * Horizontal value axis; `reverse` runs it from the right (the default with\n * `rtl`). Over categories only `show`, `title`, `grid` and `reverse` apply.\n */\n x?: ValueAxisOptions & { reverse?: boolean }\n /** Vertical value axis. */\n y?: ValueAxisOptions\n /** Radius of points without a size, in pixels. Defaults to `4`. */\n radius?: number\n /** Radius range for bubbles (points with `size`). Defaults to `{ min: 4, max: 24 }`. */\n size?: { min?: number; max?: number }\n /** Extra space around the plot area, in pixels. */\n padding?: InsetsInput\n}\n\n/** Pointer distance (in pixels, beyond the radius) that still hits a point. */\nconst HIT_RADIUS = 24\nconst EDGE = 8\n\ninterface Placed {\n seriesIndex: number\n pointIndex: number\n point: ScatterPoint\n cx: number\n cy: number\n r: number\n}\n\n/**\n * The categories of the x axis, or `null` when it is a value axis: `data.labels`,\n * else every `x` in order of appearance once any of them is text.\n */\nfunction categories(data: ScatterData): string[] | null {\n if (data.labels) return data.labels.map(String)\n if (!data.series.some((s) => s.points.some((p) => typeof p.x === 'string'))) return null\n return [...new Set(data.series.flatMap((s) => s.points.map((p) => String(p.x))))]\n}\n\n/** A point's bubble size, or `undefined` when it has none (or an invalid one). */\nconst sizeOf = (p: ScatterPoint): number | undefined =>\n p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : undefined\n\n/** An `x` as text for the tooltip and the table: the category's name, or the formatted number. */\nfunction xText(options: ScatterOptions, locale: RenderContext['locale']) {\n const format = formatDetail(options.x?.format, locale)\n const named = !!categories(options.data)\n return (value: number | string) =>\n named || typeof value === 'string' ? String(value) : format(value)\n}\n\nfunction renderScatter(options: ScatterOptions, ctx: RenderContext) {\n const { width, height, fontSize, locale } = ctx\n const xOptions = options.x ?? {}\n const yOptions = options.y ?? {}\n const radius = options.radius ?? 4\n const visible = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const points = visible.flatMap((s) => s.points)\n const sizes = points.map(sizeOf).filter((v): v is number => v !== undefined)\n const maxSize = extent(sizes)?.[1] ?? 0\n const rMin = options.size?.min ?? 4\n const rMax = options.size?.max ?? 24\n // Area-proportional bubbles: the radius grows with the square root of the size.\n const bubble = (size: number | undefined) =>\n size != null && size > 0 && maxSize > 0\n ? rMin + (rMax - rMin) * Math.sqrt(size / maxSize)\n : radius\n const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2\n\n const countY = tickCount(yOptions, Math.max(2, Math.round(height / 60)))\n const countX = tickCount(xOptions, Math.max(2, Math.round(width / 80)))\n const labels = categories(options.data)\n // Where each category stands (the first of two with one name).\n const index = new Map((labels ?? []).map((label, i) => [label, i] as const).reverse())\n // Only points that can be plotted on both axes take part.\n const usable = (p: ScatterPoint) =>\n (labels ? index.has(String(p.x)) : typeof p.x === 'number' && plottable(p.x, xOptions)) &&\n plottable(p.y, yOptions)\n const shown = points.filter(usable)\n const xDomain = domainOf(labels ? [] : shown.map((p) => p.x as number), xOptions, false, countX)\n const yDomain = domainOf(\n shown.map((p) => p.y),\n yOptions,\n false,\n countY,\n )\n\n const showX = xOptions.show !== false\n const showY = yOptions.show !== false\n // Linear or logarithmic, as each axis asks (see valueScale).\n const ticksOf = (scale: LinearScale, axis: ValueAxisOptions, count: number) =>\n valueTicks(scale, axis, count, axis.format, locale)\n const probeY = ticksOf(valueScale(yDomain, [1, 0], yOptions), yOptions, countY)\n const probeX: Tick[] = labels\n ? labels.map((label) => ({ value: label, position: 0, label }))\n : ticksOf(valueScale(xDomain, [0, 1], xOptions), xOptions, countX)\n // What an edge label needs beside the plot: half of it on a value axis, where\n // it is centered on the edge; over categories it has half a band of room first.\n const half = (tick: Tick | undefined, halfBand = 0) =>\n showX && tick\n ? Math.max(0, Math.ceil(estimateTextWidth(tick.label, fontSize) / 2 - halfBand))\n : 0\n const reverse = xOptions.reverse ?? ctx.rtl === true\n // The x tick on the start side of the plot, and the one on the end side.\n const near = reverse === (ctx.rtl === true) ? 0 : probeX.length - 1\n const valueWidth =\n (showY ? axisSize('left', probeY, fontSize) : 0) + axisTitleSize(yOptions.title, fontSize)\n const { area, side, range } = plotFrame(ctx, options.padding, (pad) => {\n const sides = (halfBand: number) => ({\n start: pad.start + Math.max(valueWidth, half(probeX[near], halfBand), overhang),\n end: pad.end + Math.max(half(probeX[probeX.length - 1 - near], halfBand), overhang, EDGE),\n })\n let both = sides(0)\n // The band depends on the margins, so they are worked out twice.\n if (labels?.length) both = sides((width - both.start - both.end) / (labels.length * 2))\n return {\n top:\n pad.top + Math.max(showY ? Math.ceil((fontSize * LINE_HEIGHT) / 2) : 0, overhang, EDGE / 2),\n bottom:\n pad.bottom +\n Math.max(\n (showX ? axisSize('bottom', probeX, fontSize) : 0) +\n axisTitleSize(xOptions.title, fontSize),\n overhang,\n EDGE / 2,\n ),\n ...both,\n }\n })\n const y = valueScale(yDomain, [area.y + area.height, area.y], yOptions)\n // Pixel of an `x`, and the ticks of its axis: a point stands in the middle of its category.\n let x: (value: number | string) => number\n let allX: Tick[]\n if (labels) {\n // Equal bands along the range (it runs backwards when reversed).\n const [from, to] = range(reverse)\n const at = (i: number) => from + ((to - from) * (i + 0.5)) / labels.length\n x = (value) => at(index.get(String(value)) as number)\n allX = labels.map((label, i) => ({ value: label, position: at(i), label }))\n } else {\n const scale = valueScale(xDomain, range(reverse), xOptions)\n x = (value) => scale(value as number)\n allX = ticksOf(scale, xOptions, countX)\n }\n // Thinned like the ticks of the other charts: on a log axis they crowd at the end of each decade.\n const xTicks = thinTicks(allX, 'bottom', fontSize)\n const yTicks = thinTicks(ticksOf(y, yOptions, countY), 'left', fontSize, 4)\n\n // Every visible point in pixels, sorted by x for fast nearest-point lookups.\n const placed: Placed[] = []\n options.data.series.forEach((series, seriesIndex) => {\n if (ctx.hidden.has(keyOf(series))) return\n series.points.forEach((point, pointIndex) => {\n if (!usable(point)) return\n placed.push({\n seriesIndex,\n pointIndex,\n point,\n cx: x(point.x),\n cy: y(point.y),\n r: bubble(sizeOf(point)),\n })\n })\n })\n placed.sort((a, b) => a.cx - b.cx)\n\n const fx = xText(options, locale)\n const fy = formatDetail(yOptions.format, locale)\n const fs = formatNumber(undefined, locale)\n const hitFor = (p: Placed, index: number): Hit => {\n const series = options.data.series[p.seriesIndex] as ScatterSeries\n const sz = sizeOf(p.point)\n const size = sz === undefined ? '' : ` · ${fs(sz)}`\n const item: HitItem = {\n name: series.name,\n seriesIndex: p.seriesIndex,\n value: p.point.y,\n text: `${fx(p.point.x)}, ${fy(p.point.y)}${size}`,\n x: p.cx,\n y: p.cy,\n }\n if (series.color) item.color = series.color\n return {\n index,\n label: p.point.label ?? series.name,\n title: p.point.label ?? '',\n x: p.cx,\n area,\n items: [item],\n seriesIndex: p.seriesIndex,\n highlight: { kind: 'halo', d: circlePath(round(p.r + 4)), x: p.cx, y: p.cy },\n }\n }\n\n const interaction: Interaction = {\n count: placed.length,\n hitIndex: (index) => {\n const p = placed[index]\n return p ? hitFor(p, index) : null\n },\n hitTest(px, py) {\n // Binary search the first point within reach on x, then scan the window.\n let lo = 0\n let hi = placed.length\n const reach = HIT_RADIUS + rMax\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n if ((placed[mid] as Placed).cx < px - reach) lo = mid + 1\n else hi = mid\n }\n let best = -1\n let bestDistance = Number.POSITIVE_INFINITY\n for (let i = lo; i < placed.length; i++) {\n const p = placed[i] as Placed\n if (p.cx > px + reach) break\n const distance = Math.hypot(p.cx - px, p.cy - py) - p.r\n if (distance < bestDistance && distance <= HIT_RADIUS) {\n best = i\n bestDistance = distance\n }\n }\n return best === -1 ? null : hitFor(placed[best] as Placed, best)\n },\n }\n\n /** One path drawing a dot of `radius` at every point (two arcs each, or the series' shape). */\n const shape = markerShape(options)\n const dotsPath = (dots: readonly ScatterPoint[], slot: number) => {\n if (!dots.length) return null\n const r = round(radius)\n let d = ''\n for (const p of dots) {\n d += shape\n ? shape(slot, x(p.x), y(p.y), r)\n : `M${round(x(p.x) - radius)},${round(y(p.y))}a${r},${r},0,1,0,${2 * r},0a${r},${r},0,1,0,${-2 * r},0`\n }\n return h('path', { key: 'dots', class: ['tc-point tc-dots', shape && 'tc-marker'], d })\n }\n\n const background = []\n if (yOptions.grid !== false) background.push(grid({ direction: 'y', ticks: yTicks, area }))\n if (xOptions.grid) background.push(grid({ direction: 'x', ticks: xTicks, area }))\n\n // Dots may reach a little past the plot edges; bubbles are cut at them (like\n // Chart.js), as a big one there would cover the axis labels.\n const clip = plotClip(ctx, area, sizes.length ? 0 : overhang)\n const groups = options.data.series.map(\n (series, seriesIndex) =>\n !ctx.hidden.has(keyOf(series)) &&\n h(\n 'g',\n groupAttrs(series, seriesIndex),\n // Plain points share one path per series: thousands of circles would\n // each cost the browser style and layout work. The path keeps its\n // commands while the point count does, so new data morphs. Bubbles\n // stay circles: each is see-through over the others.\n dotsPath(\n series.points.filter((p) => usable(p) && sizeOf(p) === undefined),\n seriesIndex,\n ),\n series.points.map(\n (point, i) =>\n usable(point) &&\n sizeOf(point) !== undefined &&\n h('circle', {\n key: i,\n class: 'tc-point tc-bubble',\n cx: round(x(point.x)),\n cy: round(y(point.y)),\n r: round(bubble(sizeOf(point))),\n }),\n ),\n ),\n )\n\n const content = [\n h('defs', null, clip.def),\n background,\n h('g', { key: 'series', class: 'tc-series-list', 'clip-path': clip.url }, groups),\n showY && axis({ position: side, ticks: yTicks, area }),\n showX && axis({ position: 'bottom', ticks: xTicks, area }),\n !!yOptions.title && axisTitle(side, showY ? yTicks : [], area, yOptions.title, fontSize),\n !!xOptions.title && axisTitle('bottom', showX ? xTicks : [], area, xOptions.title, fontSize),\n ]\n return { content, interaction }\n}\n\nfunction scatterTable(\n options: ScatterOptions,\n ctx: RenderContext,\n limit: number = Number.POSITIVE_INFINITY,\n): DataTable {\n const fx = xText(options, ctx.locale)\n const fy = formatDetail(options.y?.format, ctx.locale)\n const fs = formatNumber(undefined, ctx.locale)\n const series = options.data.series.filter((s) => !ctx.hidden.has(keyOf(s)))\n const withSize = series.some((s) => s.points.some((p) => p.size != null))\n const withLabel = series.some((s) => s.points.some((p) => p.label != null))\n const total = series.reduce((sum, s) => sum + s.points.length, 0)\n let left = limit\n return {\n columns: ['', ...(withLabel ? ['Label'] : []), 'x', 'y', ...(withSize ? ['Size'] : [])],\n total,\n rows: series.flatMap((s) => {\n const take = s.points.slice(0, Math.max(0, left))\n left -= take.length\n return take.map((p) => [\n s.name,\n ...(withLabel ? [p.label ?? ''] : []),\n fx(p.x),\n fy(p.y),\n ...(withSize ? [sizeOf(p) === undefined ? '–' : fs(sizeOf(p) as number)] : []),\n ])\n }),\n }\n}\n\n/**\n * Scatter chart: points on two value axes; give points a `size` for a\n * bubble chart (area-proportional radii). With `data.labels` (or a text `x`)\n * the points stand over named categories instead.\n *\n * ```ts\n * new Chart('#el', {\n * type: scatter,\n * data: { series: [{ name: 'Cities', points: [{ x: 12, y: 3.4 }, { x: 18, y: 5.1 }] }] },\n * })\n * ```\n */\nexport const scatter: ChartType<ScatterOptions> = {\n name: 'scatter',\n clean: cleanData((data) => ({\n ...(isRecord(data) ? data : {}),\n labels: isRecord(data) && Array.isArray(data.labels) ? data.labels.map(text) : undefined,\n series: records(isRecord(data) && data.series, (s) => ({\n ...named(s),\n points: records(s.points, (p) => ({\n ...p,\n x: typeof p.x === 'string' ? p.x : finite(p.x),\n y: finite(p.y),\n size: finite(p.size) ?? undefined,\n label: p.label == null ? undefined : text(p.label),\n })).filter((p) => p.x !== null && p.y !== null),\n })),\n })),\n render: renderScatter,\n legend: (options) => legendItems(options.data.series),\n table: scatterTable,\n valueLabels: { format: (options) => options.y?.format },\n}\n"],"mappings":";;;;;;;;;;;AA6FA,MAAM,aAAa;AACnB,MAAM,OAAO;;;;;AAeb,SAAS,WAAW,MAAoC;CACtD,IAAI,KAAK,QAAQ,OAAO,KAAK,OAAO,IAAI,MAAM;CAC9C,IAAI,CAAC,KAAK,OAAO,MAAM,MAAM,EAAE,OAAO,MAAM,MAAM,OAAO,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GAAG,EAAE,CAAC;IACN,GAAI,WAAW,CAAC,OAAO,CAAC,MAAM,KAAA,IAAY,MAAM,GAAG,OAAO,CAAC,CAAW,CAAC,IAAI,CAAC;GAC9E,CAAC;EACH,CAAC;CACH;AACF;;;;;;;;;;;;;AAcA,MAAa,UAAqC;CAChD,MAAM;CACN,OAAO,WAAW,UAAU;EAC1B,GAAI,SAAS,IAAI,IAAI,OAAO,CAAC;EAC7B,QAAQ,SAAS,IAAI,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,KAAK,OAAO,IAAI,IAAI,IAAI,KAAA;EAC/E,QAAQ,QAAQ,SAAS,IAAI,KAAK,KAAK,SAAS,OAAO;GACrD,GAAG,MAAM,CAAC;GACV,QAAQ,QAAQ,EAAE,SAAS,OAAO;IAChC,GAAG;IACH,GAAG,OAAO,EAAE,MAAM,WAAW,EAAE,IAAI,OAAO,EAAE,CAAC;IAC7C,GAAG,OAAO,EAAE,CAAC;IACb,MAAM,OAAO,EAAE,IAAI,KAAK,KAAA;IACxB,OAAO,EAAE,SAAS,OAAO,KAAA,IAAY,KAAK,EAAE,KAAK;GACnD,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE,MAAM,QAAQ,EAAE,MAAM,IAAI;EAChD,EAAE;CACJ,EAAE;CACF,QAAQ;CACR,SAAS,YAAY,YAAY,QAAQ,KAAK,MAAM;CACpD,OAAO;CACP,aAAa,EAAE,SAAS,YAAY,QAAQ,GAAG,OAAO;AACxD"}
@@ -1,9 +1,10 @@
1
- import { o as ChartType, ut as ValueAxisOptions } from "./chart-CYrrUCi3.js";
2
- import { a as InsetsInput } from "./annotations-B02GR_KU.js";
1
+ import { ht as ValueAxisOptions, o as ChartType } from "./chart-CE9EVbfV.js";
2
+ import { n as InsetsInput } from "./layout-CYerDebD.js";
3
3
  import { a as ClassValue } from "./vnode-Du2cC8Fm.js";
4
4
  /** A point of a scatter or bubble chart. */
5
5
  interface ScatterPoint {
6
- x: number;
6
+ /** A number on a value axis; on a category axis, the label the point stands at. */
7
+ x: number | string;
7
8
  y: number;
8
9
  /** Bubble size; the circle area is proportional to it. */
9
10
  size?: number;
@@ -31,11 +32,22 @@ interface ScatterSeries {
31
32
  */
32
33
  valueLabels?: boolean;
33
34
  }
35
+ interface ScatterData {
36
+ /**
37
+ * Categories along x, in their order: the x axis then shows these names and
38
+ * each point stands at the label its `x` names (points naming none are left
39
+ * out). Without `labels`, points with a text `x` make the categories
40
+ * themselves, in order of appearance.
41
+ */
42
+ labels?: readonly (string | number)[];
43
+ series: readonly ScatterSeries[];
44
+ }
34
45
  interface ScatterOptions {
35
- data: {
36
- series: readonly ScatterSeries[];
37
- };
38
- /** Horizontal value axis; `reverse` runs it from the right (the default with `rtl`). */
46
+ data: ScatterData;
47
+ /**
48
+ * Horizontal value axis; `reverse` runs it from the right (the default with
49
+ * `rtl`). Over categories only `show`, `title`, `grid` and `reverse` apply.
50
+ */
39
51
  x?: ValueAxisOptions & {
40
52
  reverse?: boolean;
41
53
  };
@@ -53,7 +65,8 @@ interface ScatterOptions {
53
65
  }
54
66
  /**
55
67
  * Scatter chart: points on two value axes; give points a `size` for a
56
- * bubble chart (area-proportional radii).
68
+ * bubble chart (area-proportional radii). With `data.labels` (or a text `x`)
69
+ * the points stand over named categories instead.
57
70
  *
58
71
  * ```ts
59
72
  * new Chart('#el', {
@@ -63,4 +76,4 @@ interface ScatterOptions {
63
76
  * ```
64
77
  */
65
78
  declare const scatter: ChartType<ScatterOptions>;
66
- export { scatter as i, ScatterPoint as n, ScatterSeries as r, ScatterOptions as t };
79
+ export { scatter as a, ScatterSeries as i, ScatterOptions as n, ScatterPoint as r, ScatterData as t };
@@ -1,9 +1,10 @@
1
- import { mt as ValueAxisOptions, o as ChartType } from "./chart-CbPzP5Dp.cjs";
2
- import { a as InsetsInput } from "./annotations-CHafaGd4.cjs";
1
+ import { o as ChartType, yt as ValueAxisOptions } from "./chart-Dz4geQZy.cjs";
2
+ import { n as InsetsInput } from "./layout-CYerDebD.cjs";
3
3
  import { a as ClassValue } from "./vnode-Du2cC8Fm.cjs";
4
4
  /** A point of a scatter or bubble chart. */
5
5
  interface ScatterPoint {
6
- x: number;
6
+ /** A number on a value axis; on a category axis, the label the point stands at. */
7
+ x: number | string;
7
8
  y: number;
8
9
  /** Bubble size; the circle area is proportional to it. */
9
10
  size?: number;
@@ -31,11 +32,22 @@ interface ScatterSeries {
31
32
  */
32
33
  valueLabels?: boolean;
33
34
  }
35
+ interface ScatterData {
36
+ /**
37
+ * Categories along x, in their order: the x axis then shows these names and
38
+ * each point stands at the label its `x` names (points naming none are left
39
+ * out). Without `labels`, points with a text `x` make the categories
40
+ * themselves, in order of appearance.
41
+ */
42
+ labels?: readonly (string | number)[];
43
+ series: readonly ScatterSeries[];
44
+ }
34
45
  interface ScatterOptions {
35
- data: {
36
- series: readonly ScatterSeries[];
37
- };
38
- /** Horizontal value axis; `reverse` runs it from the right (the default with `rtl`). */
46
+ data: ScatterData;
47
+ /**
48
+ * Horizontal value axis; `reverse` runs it from the right (the default with
49
+ * `rtl`). Over categories only `show`, `title`, `grid` and `reverse` apply.
50
+ */
39
51
  x?: ValueAxisOptions & {
40
52
  reverse?: boolean;
41
53
  };
@@ -53,7 +65,8 @@ interface ScatterOptions {
53
65
  }
54
66
  /**
55
67
  * Scatter chart: points on two value axes; give points a `size` for a
56
- * bubble chart (area-proportional radii).
68
+ * bubble chart (area-proportional radii). With `data.labels` (or a text `x`)
69
+ * the points stand over named categories instead.
57
70
  *
58
71
  * ```ts
59
72
  * new Chart('#el', {
@@ -63,4 +76,4 @@ interface ScatterOptions {
63
76
  * ```
64
77
  */
65
78
  declare const scatter: ChartType<ScatterOptions>;
66
- export { scatter as i, ScatterPoint as n, ScatterSeries as r, ScatterOptions as t };
79
+ export { scatter as a, ScatterSeries as i, ScatterOptions as n, ScatterPoint as r, ScatterData as t };
@@ -1,5 +1,5 @@
1
- const require_axis = require("./axis-YfAerNBA.cjs");
2
- const require_cartesian = require("./cartesian-DRSXHxWe.cjs");
1
+ const require_axis = require("./axis-BzBkkC5X.cjs");
2
+ const require_cartesian = require("./cartesian-B9CrasFJ.cjs");
3
3
  const require_format = require("./format-CAE5ruy6.cjs");
4
4
  const require_layout = require("./layout-Cfg9x1k2.cjs");
5
5
  const require_extent = require("./extent-DuYDcvM9.cjs");
@@ -11,8 +11,23 @@ const require_named = require("./named-BBASc8dW.cjs");
11
11
  /** Pointer distance (in pixels, beyond the radius) that still hits a point. */
12
12
  const HIT_RADIUS = 24;
13
13
  const EDGE = 8;
14
+ /**
15
+ * The categories of the x axis, or `null` when it is a value axis: `data.labels`,
16
+ * else every `x` in order of appearance once any of them is text.
17
+ */
18
+ function categories(data) {
19
+ if (data.labels) return data.labels.map(String);
20
+ if (!data.series.some((s) => s.points.some((p) => typeof p.x === "string"))) return null;
21
+ return [...new Set(data.series.flatMap((s) => s.points.map((p) => String(p.x))))];
22
+ }
14
23
  /** A point's bubble size, or `undefined` when it has none (or an invalid one). */
15
24
  const sizeOf = (p) => p.size != null && Number.isFinite(p.size) && p.size > 0 ? p.size : void 0;
25
+ /** An `x` as text for the tooltip and the table: the category's name, or the formatted number. */
26
+ function xText(options, locale) {
27
+ const format = require_format.formatDetail(options.x?.format, locale);
28
+ const named = !!categories(options.data);
29
+ return (value) => named || typeof value === "string" ? String(value) : format(value);
30
+ }
16
31
  function renderScatter(options, ctx) {
17
32
  const { width, height, fontSize, locale } = ctx;
18
33
  const xOptions = options.x ?? {};
@@ -27,27 +42,56 @@ function renderScatter(options, ctx) {
27
42
  const overhang = Math.max(radius, sizes.length ? rMax : 0) + 2;
28
43
  const countY = require_cartesian.tickCount(yOptions, Math.max(2, Math.round(height / 60)));
29
44
  const countX = require_cartesian.tickCount(xOptions, Math.max(2, Math.round(width / 80)));
30
- const usable = (p) => require_cartesian.plottable(p.x, xOptions) && require_cartesian.plottable(p.y, yOptions);
45
+ const labels = categories(options.data);
46
+ const index = new Map((labels ?? []).map((label, i) => [label, i]).reverse());
47
+ const usable = (p) => (labels ? index.has(String(p.x)) : typeof p.x === "number" && require_cartesian.plottable(p.x, xOptions)) && require_cartesian.plottable(p.y, yOptions);
31
48
  const shown = points.filter(usable);
32
- const xDomain = require_cartesian.domainOf(shown.map((p) => p.x), xOptions, false, countX);
49
+ const xDomain = require_cartesian.domainOf(labels ? [] : shown.map((p) => p.x), xOptions, false, countX);
33
50
  const yDomain = require_cartesian.domainOf(shown.map((p) => p.y), yOptions, false, countY);
34
51
  const showX = xOptions.show !== false;
35
52
  const showY = yOptions.show !== false;
36
53
  const ticksOf = (scale, axis, count) => require_cartesian.valueTicks(scale, axis, count, axis.format, locale);
37
54
  const probeY = ticksOf(require_cartesian.valueScale(yDomain, [1, 0], yOptions), yOptions, countY);
38
- const probeX = ticksOf(require_cartesian.valueScale(xDomain, [0, 1], xOptions), xOptions, countX);
39
- const half = (tick) => showX && tick ? Math.ceil(require_layout.estimateTextWidth(tick.label, fontSize) / 2) : 0;
55
+ const probeX = labels ? labels.map((label) => ({
56
+ value: label,
57
+ position: 0,
58
+ label
59
+ })) : ticksOf(require_cartesian.valueScale(xDomain, [0, 1], xOptions), xOptions, countX);
60
+ const half = (tick, halfBand = 0) => showX && tick ? Math.max(0, Math.ceil(require_layout.estimateTextWidth(tick.label, fontSize) / 2 - halfBand)) : 0;
40
61
  const reverse = xOptions.reverse ?? ctx.rtl === true;
41
62
  const near = reverse === (ctx.rtl === true) ? 0 : probeX.length - 1;
42
- const { area, side, range } = require_layout.plotFrame(ctx, options.padding, (pad) => ({
43
- top: pad.top + Math.max(showY ? Math.ceil(fontSize * require_layout.LINE_HEIGHT / 2) : 0, overhang, EDGE / 2),
44
- bottom: pad.bottom + Math.max((showX ? require_axis.axisSize("bottom", probeX, fontSize) : 0) + require_axis.axisTitleSize(xOptions.title, fontSize), overhang, EDGE / 2),
45
- start: pad.start + Math.max((showY ? require_axis.axisSize("left", probeY, fontSize) : 0) + require_axis.axisTitleSize(yOptions.title, fontSize), half(probeX[near]), overhang),
46
- end: pad.end + Math.max(half(probeX[probeX.length - 1 - near]), overhang, EDGE)
47
- }));
48
- const x = require_cartesian.valueScale(xDomain, range(reverse), xOptions);
63
+ const valueWidth = (showY ? require_axis.axisSize("left", probeY, fontSize) : 0) + require_axis.axisTitleSize(yOptions.title, fontSize);
64
+ const { area, side, range } = require_layout.plotFrame(ctx, options.padding, (pad) => {
65
+ const sides = (halfBand) => ({
66
+ start: pad.start + Math.max(valueWidth, half(probeX[near], halfBand), overhang),
67
+ end: pad.end + Math.max(half(probeX[probeX.length - 1 - near], halfBand), overhang, EDGE)
68
+ });
69
+ let both = sides(0);
70
+ if (labels?.length) both = sides((width - both.start - both.end) / (labels.length * 2));
71
+ return {
72
+ top: pad.top + Math.max(showY ? Math.ceil(fontSize * require_layout.LINE_HEIGHT / 2) : 0, overhang, EDGE / 2),
73
+ bottom: pad.bottom + Math.max((showX ? require_axis.axisSize("bottom", probeX, fontSize) : 0) + require_axis.axisTitleSize(xOptions.title, fontSize), overhang, EDGE / 2),
74
+ ...both
75
+ };
76
+ });
49
77
  const y = require_cartesian.valueScale(yDomain, [area.y + area.height, area.y], yOptions);
50
- const xTicks = require_axis.thinTicks(ticksOf(x, xOptions, countX), "bottom", fontSize);
78
+ let x;
79
+ let allX;
80
+ if (labels) {
81
+ const [from, to] = range(reverse);
82
+ const at = (i) => from + (to - from) * (i + .5) / labels.length;
83
+ x = (value) => at(index.get(String(value)));
84
+ allX = labels.map((label, i) => ({
85
+ value: label,
86
+ position: at(i),
87
+ label
88
+ }));
89
+ } else {
90
+ const scale = require_cartesian.valueScale(xDomain, range(reverse), xOptions);
91
+ x = (value) => scale(value);
92
+ allX = ticksOf(scale, xOptions, countX);
93
+ }
94
+ const xTicks = require_axis.thinTicks(allX, "bottom", fontSize);
51
95
  const yTicks = require_axis.thinTicks(ticksOf(y, yOptions, countY), "left", fontSize, 4);
52
96
  const placed = [];
53
97
  options.data.series.forEach((series, seriesIndex) => {
@@ -65,7 +109,7 @@ function renderScatter(options, ctx) {
65
109
  });
66
110
  });
67
111
  placed.sort((a, b) => a.cx - b.cx);
68
- const fx = require_format.formatDetail(xOptions.format, locale);
112
+ const fx = xText(options, locale);
69
113
  const fy = require_format.formatDetail(yOptions.format, locale);
70
114
  const fs = require_format.formatNumber(void 0, locale);
71
115
  const hitFor = (p, index) => {
@@ -184,7 +228,7 @@ function renderScatter(options, ctx) {
184
228
  };
185
229
  }
186
230
  function scatterTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
187
- const fx = require_format.formatDetail(options.x?.format, ctx.locale);
231
+ const fx = xText(options, ctx.locale);
188
232
  const fy = require_format.formatDetail(options.y?.format, ctx.locale);
189
233
  const fs = require_format.formatNumber(void 0, ctx.locale);
190
234
  const series = options.data.series.filter((s) => !ctx.hidden.has(require_named.keyOf(s)));
@@ -216,7 +260,8 @@ function scatterTable(options, ctx, limit = Number.POSITIVE_INFINITY) {
216
260
  }
217
261
  /**
218
262
  * Scatter chart: points on two value axes; give points a `size` for a
219
- * bubble chart (area-proportional radii).
263
+ * bubble chart (area-proportional radii). With `data.labels` (or a text `x`)
264
+ * the points stand over named categories instead.
220
265
  *
221
266
  * ```ts
222
267
  * new Chart('#el', {
@@ -229,11 +274,12 @@ const scatter = {
229
274
  name: "scatter",
230
275
  clean: require_clean.cleanData((data) => ({
231
276
  ...require_clean.isRecord(data) ? data : {},
277
+ labels: require_clean.isRecord(data) && Array.isArray(data.labels) ? data.labels.map(require_clean.text) : void 0,
232
278
  series: require_clean.records(require_clean.isRecord(data) && data.series, (s) => ({
233
279
  ...require_clean.named(s),
234
280
  points: require_clean.records(s.points, (p) => ({
235
281
  ...p,
236
- x: require_clean.finite(p.x),
282
+ x: typeof p.x === "string" ? p.x : require_clean.finite(p.x),
237
283
  y: require_clean.finite(p.y),
238
284
  size: require_clean.finite(p.size) ?? void 0,
239
285
  label: p.label == null ? void 0 : require_clean.text(p.label)
@@ -252,4 +298,4 @@ Object.defineProperty(exports, "scatter", {
252
298
  }
253
299
  });
254
300
 
255
- //# sourceMappingURL=scatter-Bwkblr4L.cjs.map
301
+ //# sourceMappingURL=scatter-CZ8do3Up.cjs.map