boardplot 0.0.0-stage → 0.53.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 (818) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE.md +180 -0
  4. package/README.md +208 -2
  5. package/THIRD_PARTY_NOTICES.md +1110 -0
  6. package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
  7. package/dist/ReaderBox-VOJSJ66R.js +137 -0
  8. package/dist/annotateEngine-DLMFJZ67.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24BHMKDD.js +83 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QADBDV.js +211 -0
  13. package/dist/chunk-2CVH5E57.js +128 -0
  14. package/dist/chunk-2DOR5SS6.js +446 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2FNNAPCI.js +24 -0
  17. package/dist/chunk-2L2Q53EP.js +251 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2ND7ZITT.js +3069 -0
  20. package/dist/chunk-2QT5ZUHO.js +2937 -0
  21. package/dist/chunk-2RSG7JYI.js +24 -0
  22. package/dist/chunk-2V6CLH33.js +1392 -0
  23. package/dist/chunk-2VWJ5BGO.js +566 -0
  24. package/dist/chunk-2WNYRWHG.js +51 -0
  25. package/dist/chunk-323YZWYJ.js +548 -0
  26. package/dist/chunk-33PB4V6K.js +382 -0
  27. package/dist/chunk-33PLBIMA.js +176 -0
  28. package/dist/chunk-3A2IEBCN.js +195 -0
  29. package/dist/chunk-3D3D3D23.js +25 -0
  30. package/dist/chunk-3EZRM4YM.js +92 -0
  31. package/dist/chunk-3H2W76TB.js +2353 -0
  32. package/dist/chunk-3JEQGGVD.js +19 -0
  33. package/dist/chunk-3QWZAEW5.js +26 -0
  34. package/dist/chunk-3SIRPKMP.js +12 -0
  35. package/dist/chunk-3SQCCESO.js +1592 -0
  36. package/dist/chunk-3XHJHQWU.js +42 -0
  37. package/dist/chunk-4G2O2ZPJ.js +83 -0
  38. package/dist/chunk-4JLBVIGW.js +24 -0
  39. package/dist/chunk-4RRNJLCM.js +746 -0
  40. package/dist/chunk-4UVW5WU6.js +76 -0
  41. package/dist/chunk-4X66BTP5.js +344 -0
  42. package/dist/chunk-53OYF4ZT.js +687 -0
  43. package/dist/chunk-57ZGVAU3.js +179 -0
  44. package/dist/chunk-5HECRVXJ.js +62 -0
  45. package/dist/chunk-5LGSRWFC.js +63 -0
  46. package/dist/chunk-5LYXD6ME.js +1112 -0
  47. package/dist/chunk-66RFKRGO.js +28 -0
  48. package/dist/chunk-6KWIQ5KF.js +18 -0
  49. package/dist/chunk-6OCR6ITN.js +72 -0
  50. package/dist/chunk-6RBTTCQD.js +802 -0
  51. package/dist/chunk-6Y7EXYLR.js +563 -0
  52. package/dist/chunk-7CTKTIPF.js +613 -0
  53. package/dist/chunk-7EVIIADO.js +185 -0
  54. package/dist/chunk-7X2ZYVAX.js +89 -0
  55. package/dist/chunk-7X65ZQN4.js +38 -0
  56. package/dist/chunk-A4QZXLXF.js +7 -0
  57. package/dist/chunk-A6CQPJWR.js +49 -0
  58. package/dist/chunk-A7IEVBYI.js +35 -0
  59. package/dist/chunk-ACXX2JNL.js +6 -0
  60. package/dist/chunk-ADKCLH3Z.js +98 -0
  61. package/dist/chunk-ADWSGPH5.js +23 -0
  62. package/dist/chunk-AG2CJ4JY.js +203 -0
  63. package/dist/chunk-AHQ4L3BE.js +30 -0
  64. package/dist/chunk-AOQ6VF5H.js +6 -0
  65. package/dist/chunk-AQROQDLR.js +3303 -0
  66. package/dist/chunk-AWTG3RFF.js +85 -0
  67. package/dist/chunk-B54RN2FD.js +692 -0
  68. package/dist/chunk-B67K6OWJ.js +48 -0
  69. package/dist/chunk-B6GFKYBZ.js +40 -0
  70. package/dist/chunk-BBL3R5YZ.js +186 -0
  71. package/dist/chunk-BBRBCMNR.js +28 -0
  72. package/dist/chunk-BIDIGDGH.js +6 -0
  73. package/dist/chunk-BLFWUMTD.js +12 -0
  74. package/dist/chunk-BM6SFFWF.js +6 -0
  75. package/dist/chunk-BMRD6MAH.js +24 -0
  76. package/dist/chunk-BPKXEMRE.js +197 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BW5VLBSZ.js +15 -0
  79. package/dist/chunk-BWGRWGVA.js +295 -0
  80. package/dist/chunk-BWLOXQDV.js +131 -0
  81. package/dist/chunk-BWTX7LUG.js +203 -0
  82. package/dist/chunk-C54QLNE4.js +69 -0
  83. package/dist/chunk-CAQ5P4VN.js +296 -0
  84. package/dist/chunk-CCCEBIUZ.js +296 -0
  85. package/dist/chunk-CDZHNLO6.js +42 -0
  86. package/dist/chunk-CJGSJKPO.js +25 -0
  87. package/dist/chunk-CN7JRHST.js +25 -0
  88. package/dist/chunk-CNX7EGSU.js +266 -0
  89. package/dist/chunk-COYOTQC2.js +75 -0
  90. package/dist/chunk-CRNMNZJD.js +1161 -0
  91. package/dist/chunk-CUVUDK4O.js +68 -0
  92. package/dist/chunk-CWDHCSL2.js +2919 -0
  93. package/dist/chunk-CYOJZ3GQ.js +631 -0
  94. package/dist/chunk-D4SOADBD.js +19 -0
  95. package/dist/chunk-D7SHZDA3.js +1808 -0
  96. package/dist/chunk-DAVHGK27.js +657 -0
  97. package/dist/chunk-DCCJRLAJ.js +422 -0
  98. package/dist/chunk-DCTCUZ5L.js +51 -0
  99. package/dist/chunk-DDCB7ZA5.js +2511 -0
  100. package/dist/chunk-DDI2W4TR.js +149 -0
  101. package/dist/chunk-DIHUGBZO.js +61 -0
  102. package/dist/chunk-DJHIQWSG.js +25 -0
  103. package/dist/chunk-DO5OZJAO.js +302 -0
  104. package/dist/chunk-DOFYKPTC.js +18 -0
  105. package/dist/chunk-DRTA6JG5.js +160 -0
  106. package/dist/chunk-DRW6KGBK.js +1062 -0
  107. package/dist/chunk-DU4A5AOY.js +1156 -0
  108. package/dist/chunk-DYS7EIXY.js +294 -0
  109. package/dist/chunk-E4IQ6M4S.js +24 -0
  110. package/dist/chunk-EFUWFB64.js +24 -0
  111. package/dist/chunk-EHBB2Z4D.js +290 -0
  112. package/dist/chunk-EHVESNLV.js +30 -0
  113. package/dist/chunk-EJPVVGD7.js +67 -0
  114. package/dist/chunk-EKQK5D6G.js +14 -0
  115. package/dist/chunk-EUADDXAV.js +30 -0
  116. package/dist/chunk-F6CNPC4L.js +47 -0
  117. package/dist/chunk-FBAYZSFC.js +2806 -0
  118. package/dist/chunk-FBB4BWKN.js +30 -0
  119. package/dist/chunk-FF23FYQD.js +1269 -0
  120. package/dist/chunk-FG6EDGMI.js +53 -0
  121. package/dist/chunk-FHA3KMFC.js +43 -0
  122. package/dist/chunk-FIANWJXX.js +19 -0
  123. package/dist/chunk-FIWNDOMO.js +6 -0
  124. package/dist/chunk-FV3VF36K.js +2721 -0
  125. package/dist/chunk-G5FMTRG5.js +37 -0
  126. package/dist/chunk-GCBOHVDZ.js +229 -0
  127. package/dist/chunk-GDOW2KNP.js +19 -0
  128. package/dist/chunk-GTG3IGLF.js +2674 -0
  129. package/dist/chunk-GZTNTHSW.js +21 -0
  130. package/dist/chunk-H4H4O62O.js +46 -0
  131. package/dist/chunk-H5G7T35P.js +24 -0
  132. package/dist/chunk-H63XQ3OO.js +942 -0
  133. package/dist/chunk-H67RTX46.js +43 -0
  134. package/dist/chunk-HA4IPWMM.js +841 -0
  135. package/dist/chunk-HKYTOJLV.js +33 -0
  136. package/dist/chunk-HOAH5XBR.js +542 -0
  137. package/dist/chunk-HTYFQHRC.js +24 -0
  138. package/dist/chunk-HYY5V2KL.js +19 -0
  139. package/dist/chunk-HZI56ASJ.js +79 -0
  140. package/dist/chunk-I6VAWNNU.js +24 -0
  141. package/dist/chunk-IBXXZVG7.js +80 -0
  142. package/dist/chunk-IDDA5INB.js +60 -0
  143. package/dist/chunk-IK4BHOPZ.js +33 -0
  144. package/dist/chunk-IL5T7I2A.js +27 -0
  145. package/dist/chunk-ILSXT6KT.js +24 -0
  146. package/dist/chunk-IV2UXZXX.js +16 -0
  147. package/dist/chunk-IYEFEBRN.js +41 -0
  148. package/dist/chunk-IYMI7YI4.js +829 -0
  149. package/dist/chunk-J6I2YFJH.js +58 -0
  150. package/dist/chunk-JFBEAUJ6.js +24 -0
  151. package/dist/chunk-JR7Y5ONB.js +27 -0
  152. package/dist/chunk-JSEYUJUQ.js +836 -0
  153. package/dist/chunk-JYBT2JNY.js +61 -0
  154. package/dist/chunk-K3HSQPSM.js +24 -0
  155. package/dist/chunk-KAXJFL7N.js +43 -0
  156. package/dist/chunk-KDMKHR5A.js +32 -0
  157. package/dist/chunk-KKWZWP67.js +24 -0
  158. package/dist/chunk-KOJ5QETJ.js +8 -0
  159. package/dist/chunk-KPKXJYQH.js +19 -0
  160. package/dist/chunk-KSJVENRU.js +113 -0
  161. package/dist/chunk-KZJOV4QW.js +33 -0
  162. package/dist/chunk-KZS46KDY.js +58 -0
  163. package/dist/chunk-L3JWM7FR.js +50 -0
  164. package/dist/chunk-L4S6UFTL.js +26 -0
  165. package/dist/chunk-L6DJ4ZY5.js +2008 -0
  166. package/dist/chunk-L7RHB734.js +23 -0
  167. package/dist/chunk-LCWJS34U.js +38 -0
  168. package/dist/chunk-LFTAMH7I.js +24 -0
  169. package/dist/chunk-LFX7W4B7.js +113 -0
  170. package/dist/chunk-LINZPU5D.js +8 -0
  171. package/dist/chunk-LIWLBLCT.js +83 -0
  172. package/dist/chunk-LNKY5Z2X.js +23 -0
  173. package/dist/chunk-LS7HVBI7.js +24 -0
  174. package/dist/chunk-M4EUXOLU.js +170 -0
  175. package/dist/chunk-M4SPKUZE.js +7 -0
  176. package/dist/chunk-M4YLED7M.js +17 -0
  177. package/dist/chunk-MBKZYJRC.js +1424 -0
  178. package/dist/chunk-MCYM3RNF.js +227 -0
  179. package/dist/chunk-MF6IVSBJ.js +48 -0
  180. package/dist/chunk-MIAPBQCA.js +24 -0
  181. package/dist/chunk-MJZHFH5R.js +1075 -0
  182. package/dist/chunk-MQFCG4KS.js +1467 -0
  183. package/dist/chunk-MVV6RQMG.js +128 -0
  184. package/dist/chunk-MYMT5KJL.js +1182 -0
  185. package/dist/chunk-MZL6LGKO.js +587 -0
  186. package/dist/chunk-N23YFPPI.js +47 -0
  187. package/dist/chunk-N3G2FYDL.js +300 -0
  188. package/dist/chunk-N3TPMXS3.js +161 -0
  189. package/dist/chunk-N73IBH55.js +58 -0
  190. package/dist/chunk-N7J7CZS6.js +43 -0
  191. package/dist/chunk-NCB3YLHF.js +28 -0
  192. package/dist/chunk-NHQGRKEA.js +63 -0
  193. package/dist/chunk-NKIYLFXZ.js +2774 -0
  194. package/dist/chunk-NOSDEJ3K.js +25934 -0
  195. package/dist/chunk-NQDVMUHX.js +433 -0
  196. package/dist/chunk-NSSNYY6Y.js +58 -0
  197. package/dist/chunk-NY5NUFDZ.js +117 -0
  198. package/dist/chunk-O3S2KNIW.js +25 -0
  199. package/dist/chunk-O3VN6BTL.js +24 -0
  200. package/dist/chunk-ONZLC47B.js +88 -0
  201. package/dist/chunk-OQEBOVUO.js +30 -0
  202. package/dist/chunk-OUEGGWH7.js +24 -0
  203. package/dist/chunk-OURX73UJ.js +728 -0
  204. package/dist/chunk-P25VEGGX.js +24 -0
  205. package/dist/chunk-P26Z62UV.js +24 -0
  206. package/dist/chunk-P5RNWMZC.js +2984 -0
  207. package/dist/chunk-P6KZIZDV.js +987 -0
  208. package/dist/chunk-PEUSKIFV.js +168 -0
  209. package/dist/chunk-PFVTYFSL.js +24 -0
  210. package/dist/chunk-PWROWDZS.js +137 -0
  211. package/dist/chunk-Q3CV2JJ2.js +3650 -0
  212. package/dist/chunk-QBR6IKIX.js +50 -0
  213. package/dist/chunk-QGCEHR6S.js +13 -0
  214. package/dist/chunk-QHRE2M6V.js +26 -0
  215. package/dist/chunk-QKL7IY42.js +38 -0
  216. package/dist/chunk-QO6HEXIZ.js +272 -0
  217. package/dist/chunk-QOIVXZUF.js +24 -0
  218. package/dist/chunk-QPWRHDLZ.js +17 -0
  219. package/dist/chunk-QSXK6PJL.js +19 -0
  220. package/dist/chunk-QTZVVZ2A.js +54 -0
  221. package/dist/chunk-QWXWVPNE.js +18 -0
  222. package/dist/chunk-QY5ZKUWY.js +383 -0
  223. package/dist/chunk-QZAT46PP.js +95 -0
  224. package/dist/chunk-RA66JA3D.js +24 -0
  225. package/dist/chunk-REOPXBUR.js +600 -0
  226. package/dist/chunk-RGZGLKFB.js +648 -0
  227. package/dist/chunk-RL3NUWMY.js +3378 -0
  228. package/dist/chunk-RNOJSEES.js +16 -0
  229. package/dist/chunk-ROXO4R3J.js +16 -0
  230. package/dist/chunk-RPIW5T55.js +40 -0
  231. package/dist/chunk-RQ5DNYLG.js +10 -0
  232. package/dist/chunk-RZNYW7UP.js +133 -0
  233. package/dist/chunk-S32YYDIB.js +420 -0
  234. package/dist/chunk-S4QSJAGY.js +44 -0
  235. package/dist/chunk-S6UX7KB6.js +335 -0
  236. package/dist/chunk-SDSONLMZ.js +2546 -0
  237. package/dist/chunk-SGD3ZHID.js +250 -0
  238. package/dist/chunk-SKRSCTT5.js +28 -0
  239. package/dist/chunk-SMCDXUIO.js +24 -0
  240. package/dist/chunk-SPTPFY4S.js +528 -0
  241. package/dist/chunk-SREWFAAJ.js +90 -0
  242. package/dist/chunk-SS42FJVN.js +3875 -0
  243. package/dist/chunk-SVZDXFPX.js +891 -0
  244. package/dist/chunk-SZPTTNW7.js +16 -0
  245. package/dist/chunk-T3IGJARD.js +22 -0
  246. package/dist/chunk-TA3TFKYZ.js +86 -0
  247. package/dist/chunk-TBGUEF3M.js +939 -0
  248. package/dist/chunk-TGK6KUGN.js +331 -0
  249. package/dist/chunk-TJSND556.js +1783 -0
  250. package/dist/chunk-TKOJZQAJ.js +24 -0
  251. package/dist/chunk-TM4OC53S.js +97 -0
  252. package/dist/chunk-TNEHPP3H.js +18 -0
  253. package/dist/chunk-TWOREVKJ.js +1760 -0
  254. package/dist/chunk-TXS3U77A.js +60 -0
  255. package/dist/chunk-UB6ODJHO.js +134 -0
  256. package/dist/chunk-UBZXQIDR.js +24 -0
  257. package/dist/chunk-ULTSSIOU.js +38 -0
  258. package/dist/chunk-UMDEWWXT.js +33 -0
  259. package/dist/chunk-V6O6KVOA.js +347 -0
  260. package/dist/chunk-VABRPZVC.js +43 -0
  261. package/dist/chunk-VDAKTZQP.js +18 -0
  262. package/dist/chunk-VDAZPGR2.js +79 -0
  263. package/dist/chunk-VERLFNWR.js +25 -0
  264. package/dist/chunk-VH2UUU7K.js +24 -0
  265. package/dist/chunk-VJ3FCGQF.js +12 -0
  266. package/dist/chunk-VK5ZDV67.js +47 -0
  267. package/dist/chunk-VKQNDOAI.js +40 -0
  268. package/dist/chunk-VTEV3WVF.js +690 -0
  269. package/dist/chunk-VXZFQKBJ.js +21 -0
  270. package/dist/chunk-WI5ITCOH.js +22 -0
  271. package/dist/chunk-WLZ54FWG.js +120 -0
  272. package/dist/chunk-WYJEOMNY.js +31 -0
  273. package/dist/chunk-WZGJSQKN.js +29 -0
  274. package/dist/chunk-WZL4EEBS.js +11 -0
  275. package/dist/chunk-X4YNDLVA.js +54 -0
  276. package/dist/chunk-X6SUFTD7.js +17 -0
  277. package/dist/chunk-XB4KZ6WO.js +81 -0
  278. package/dist/chunk-XJI6SWFS.js +569 -0
  279. package/dist/chunk-XJP5DKIL.js +29 -0
  280. package/dist/chunk-XN4ARQ2W.js +47 -0
  281. package/dist/chunk-XN7MQO45.js +359 -0
  282. package/dist/chunk-XQCQZBGX.js +100 -0
  283. package/dist/chunk-XXOHXA3A.js +69 -0
  284. package/dist/chunk-XZOHR765.js +127 -0
  285. package/dist/chunk-YCNLQYTC.js +133 -0
  286. package/dist/chunk-YCRGWQBS.js +526 -0
  287. package/dist/chunk-YF2PYLC4.js +210 -0
  288. package/dist/chunk-YG5GUELW.js +935 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YWP7XFKD.js +12 -0
  291. package/dist/chunk-Z2MGTKDR.js +20 -0
  292. package/dist/chunk-Z6CL7AR6.js +24 -0
  293. package/dist/chunk-Z7X3RGGA.js +22 -0
  294. package/dist/chunk-ZF43WRG3.js +29 -0
  295. package/dist/chunk-ZMF7WEGG.js +60 -0
  296. package/dist/chunk-ZNHFLJSY.js +375 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZQF34VPS.js +72 -0
  299. package/dist/chunk-ZU425HNM.js +24 -0
  300. package/dist/chunk-ZZU5R5UU.js +24 -0
  301. package/dist/cli/index.js +9 -0
  302. package/dist/core-3VCCUFVX.js +32 -0
  303. package/dist/core-4BZQQSHS.js +33 -0
  304. package/dist/core-4VT4MHNB.js +38 -0
  305. package/dist/core-5535KXRD.js +40 -0
  306. package/dist/core-5HQBPCHL.js +35 -0
  307. package/dist/core-6RYHWUJO.js +35 -0
  308. package/dist/core-7BZJCIXN.js +35 -0
  309. package/dist/core-AJTVU6X7.js +37 -0
  310. package/dist/core-C6YUSTZI.js +57 -0
  311. package/dist/core-EEB7HTCL.js +33 -0
  312. package/dist/core-EFMVDWNH.js +38 -0
  313. package/dist/core-ETAGQBZO.js +34 -0
  314. package/dist/core-FVR3WZEC.js +36 -0
  315. package/dist/core-GCTFVYMH.js +29 -0
  316. package/dist/core-GES44OTS.js +33 -0
  317. package/dist/core-GGQREDSI.js +47 -0
  318. package/dist/core-HRYOV6QD.js +38 -0
  319. package/dist/core-IKD3EE3S.js +38 -0
  320. package/dist/core-JM4R426L.js +32 -0
  321. package/dist/core-KKQS3WI2.js +40 -0
  322. package/dist/core-LA6XDYG7.js +40 -0
  323. package/dist/core-MJ7JWQT5.js +37 -0
  324. package/dist/core-MLROKJ2M.js +53 -0
  325. package/dist/core-MR52YBRX.js +31 -0
  326. package/dist/core-NP4VHWXL.js +29 -0
  327. package/dist/core-NQLNZDX5.js +41 -0
  328. package/dist/core-NSIJEKLI.js +44 -0
  329. package/dist/core-OJUQLIQ5.js +35 -0
  330. package/dist/core-PB3VUQSS.js +32 -0
  331. package/dist/core-Q6VLFFYC.js +56 -0
  332. package/dist/core-QY7AVIKZ.js +51 -0
  333. package/dist/core-SBQMHWTA.js +52 -0
  334. package/dist/core-UHECQHJ2.js +38 -0
  335. package/dist/core-V5FV4NWL.js +56 -0
  336. package/dist/core-WGM4XUN3.js +58 -0
  337. package/dist/core-WUQVFARS.js +34 -0
  338. package/dist/core-Z2F3IGSR.js +42 -0
  339. package/dist/dataTable-3CPPIHB3.js +58 -0
  340. package/dist/engine-FXFBCWHB.js +961 -0
  341. package/dist/fixtures.d.ts +1 -0
  342. package/dist/fixtures.js +41 -0
  343. package/dist/fontTables-WYCZNRE7.js +18 -0
  344. package/dist/fonts.d.ts +1 -0
  345. package/dist/fonts.js +19 -0
  346. package/dist/geo/dach.d.ts +1 -0
  347. package/dist/geo/dach.js +14 -0
  348. package/dist/geo/de-states.d.ts +1 -0
  349. package/dist/geo/de-states.js +14 -0
  350. package/dist/geo/eu27.d.ts +1 -0
  351. package/dist/geo/eu27.js +14 -0
  352. package/dist/geo/europe.d.ts +1 -0
  353. package/dist/geo/europe.js +14 -0
  354. package/dist/geo/index.d.ts +1 -0
  355. package/dist/geo/index.js +41 -0
  356. package/dist/geo/us-states.d.ts +1 -0
  357. package/dist/geo/us-states.js +14 -0
  358. package/dist/geo/world.d.ts +1 -0
  359. package/dist/geo/world.js +14 -0
  360. package/dist/index.d.ts +1 -0
  361. package/dist/index.js +364 -0
  362. package/dist/main-YLKBTHJP.js +569 -0
  363. package/dist/mcp/server.js +1025 -0
  364. package/dist/module-SVEW5ZUE.js +137233 -0
  365. package/dist/react/bar.d.ts +1 -0
  366. package/dist/react/bar.js +81 -0
  367. package/dist/react/bartable.d.ts +1 -0
  368. package/dist/react/bartable.js +70 -0
  369. package/dist/react/box.d.ts +1 -0
  370. package/dist/react/box.js +65 -0
  371. package/dist/react/bullet.d.ts +1 -0
  372. package/dist/react/bullet.js +72 -0
  373. package/dist/react/butterfly.d.ts +1 -0
  374. package/dist/react/butterfly.js +66 -0
  375. package/dist/react/choropleth.d.ts +1 -0
  376. package/dist/react/choropleth.js +67 -0
  377. package/dist/react/cohort.d.ts +1 -0
  378. package/dist/react/cohort.js +70 -0
  379. package/dist/react/column.d.ts +1 -0
  380. package/dist/react/column.js +86 -0
  381. package/dist/react/combo.d.ts +1 -0
  382. package/dist/react/combo.js +86 -0
  383. package/dist/react/creative.d.ts +1 -0
  384. package/dist/react/creative.js +61 -0
  385. package/dist/react/diagram.d.ts +1 -0
  386. package/dist/react/diagram.js +60 -0
  387. package/dist/react/dimswitch.d.ts +1 -0
  388. package/dist/react/dimswitch.js +72 -0
  389. package/dist/react/dot.d.ts +1 -0
  390. package/dist/react/dot.js +70 -0
  391. package/dist/react/export.d.ts +1 -0
  392. package/dist/react/export.js +658 -0
  393. package/dist/react/funnel.d.ts +1 -0
  394. package/dist/react/funnel.js +63 -0
  395. package/dist/react/gantt.d.ts +1 -0
  396. package/dist/react/gantt.js +62 -0
  397. package/dist/react/grid.d.ts +1 -0
  398. package/dist/react/grid.js +67 -0
  399. package/dist/react/heatmap.d.ts +1 -0
  400. package/dist/react/heatmap.js +68 -0
  401. package/dist/react/histogram.d.ts +1 -0
  402. package/dist/react/histogram.js +86 -0
  403. package/dist/react/index.d.ts +1 -0
  404. package/dist/react/index.js +504 -0
  405. package/dist/react/kpi.d.ts +1 -0
  406. package/dist/react/kpi.js +67 -0
  407. package/dist/react/likert.d.ts +1 -0
  408. package/dist/react/likert.js +83 -0
  409. package/dist/react/line.d.ts +1 -0
  410. package/dist/react/line.js +81 -0
  411. package/dist/react/mekko.d.ts +1 -0
  412. package/dist/react/mekko.js +71 -0
  413. package/dist/react/pareto.d.ts +1 -0
  414. package/dist/react/pareto.js +90 -0
  415. package/dist/react/pie.d.ts +1 -0
  416. package/dist/react/pie.js +64 -0
  417. package/dist/react/prepare.d.ts +1 -0
  418. package/dist/react/prepare.js +278 -0
  419. package/dist/react/pvm.d.ts +1 -0
  420. package/dist/react/pvm.js +68 -0
  421. package/dist/react/pyramid.d.ts +1 -0
  422. package/dist/react/pyramid.js +67 -0
  423. package/dist/react/sankey.d.ts +1 -0
  424. package/dist/react/sankey.js +59 -0
  425. package/dist/react/scatter.d.ts +1 -0
  426. package/dist/react/scatter.js +63 -0
  427. package/dist/react/slope.d.ts +1 -0
  428. package/dist/react/slope.js +64 -0
  429. package/dist/react/sparkline.d.ts +1 -0
  430. package/dist/react/sparkline.js +59 -0
  431. package/dist/react/spec.d.ts +1 -0
  432. package/dist/react/spec.js +379 -0
  433. package/dist/react/status.d.ts +1 -0
  434. package/dist/react/status.js +64 -0
  435. package/dist/react/story.d.ts +1 -0
  436. package/dist/react/story.js +140 -0
  437. package/dist/react/table.d.ts +1 -0
  438. package/dist/react/table.js +69 -0
  439. package/dist/react/theme.d.ts +1 -0
  440. package/dist/react/theme.js +53 -0
  441. package/dist/react/tilemap.d.ts +1 -0
  442. package/dist/react/tilemap.js +66 -0
  443. package/dist/react/treemap.d.ts +1 -0
  444. package/dist/react/treemap.js +61 -0
  445. package/dist/react/variance.d.ts +1 -0
  446. package/dist/react/variance.js +65 -0
  447. package/dist/react/waffle.d.ts +1 -0
  448. package/dist/react/waffle.js +62 -0
  449. package/dist/react/waterfall.d.ts +1 -0
  450. package/dist/react/waterfall.js +68 -0
  451. package/dist/resvg-ZOVDIZTV.js +23 -0
  452. package/dist/rows.d.ts +1 -0
  453. package/dist/rows.js +23 -0
  454. package/dist/rowsModule-YVLAROIP.js +27 -0
  455. package/dist/schema-2K6C3U24.js +23 -0
  456. package/dist/schema-2KIHLTYI.js +23 -0
  457. package/dist/schema-4HY2MWZC.js +30 -0
  458. package/dist/schema-4S5CXHAO.js +24 -0
  459. package/dist/schema-5BKQV56C.js +27 -0
  460. package/dist/schema-5HA5DSYN.js +24 -0
  461. package/dist/schema-5NKJPSBD.js +23 -0
  462. package/dist/schema-65FOKNHK.js +43 -0
  463. package/dist/schema-6OHZWHUI.js +23 -0
  464. package/dist/schema-6RYJS2GM.js +24 -0
  465. package/dist/schema-6W4M3WJ4.js +23 -0
  466. package/dist/schema-7TLSFG6M.js +24 -0
  467. package/dist/schema-AMFRKUFS.js +27 -0
  468. package/dist/schema-B7CZPPB4.js +28 -0
  469. package/dist/schema-BNRNHGHQ.js +26 -0
  470. package/dist/schema-E4MRCGPZ.js +24 -0
  471. package/dist/schema-F3WYTR65.js +26 -0
  472. package/dist/schema-FA6XIHTW.js +23 -0
  473. package/dist/schema-GZNOW4LX.js +23 -0
  474. package/dist/schema-HEIDGCSL.js +23 -0
  475. package/dist/schema-JB2H6KPA.js +23 -0
  476. package/dist/schema-MPXZNWV3.js +23 -0
  477. package/dist/schema-NHNQK6XO.js +23 -0
  478. package/dist/schema-NN6UPDPW.js +23 -0
  479. package/dist/schema-O4YNAGIY.js +23 -0
  480. package/dist/schema-O7AKK232.js +29 -0
  481. package/dist/schema-OJCML6LV.js +24 -0
  482. package/dist/schema-ORTRMYI6.js +24 -0
  483. package/dist/schema-PJ6P52BC.js +23 -0
  484. package/dist/schema-RTWES6NR.js +24 -0
  485. package/dist/schema-S36SRYGO.js +24 -0
  486. package/dist/schema-S3TCLTYD.js +23 -0
  487. package/dist/schema-SWWMOLOR.js +54 -0
  488. package/dist/schema-WOSEZNKG.js +26 -0
  489. package/dist/schema-Y6KBWUUR.js +23 -0
  490. package/dist/schema-YQYTLKSW.js +23 -0
  491. package/dist/schema-ZUUUY3QS.js +33 -0
  492. package/dist/specValidation-VNWIKLHH.js +49 -0
  493. package/dist/theme.d.ts +1 -0
  494. package/dist/theme.js +24 -0
  495. package/dist/themeShapeRules-2D3KWSPQ.js +11 -0
  496. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  497. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  498. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  499. package/dist/types/core/a11y/types.d.ts +116 -0
  500. package/dist/types/core/annotate.d.ts +300 -0
  501. package/dist/types/core/annotateArms.d.ts +37 -0
  502. package/dist/types/core/annotateFields.d.ts +30 -0
  503. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  504. package/dist/types/core/annotateLinks.d.ts +47 -0
  505. package/dist/types/core/annotateTargets.d.ts +90 -0
  506. package/dist/types/core/axis.d.ts +179 -0
  507. package/dist/types/core/bandSelect.d.ts +10 -0
  508. package/dist/types/core/bands.d.ts +14 -0
  509. package/dist/types/core/calendarLabels.d.ts +101 -0
  510. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  511. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  512. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  513. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  514. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  515. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  516. package/dist/types/core/charts/box/types.d.ts +110 -0
  517. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  518. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  519. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  520. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  521. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  522. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  523. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  524. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  525. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  526. package/dist/types/core/charts/column/layout.d.ts +116 -0
  527. package/dist/types/core/charts/column/model.d.ts +295 -0
  528. package/dist/types/core/charts/column/types.d.ts +56 -0
  529. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  530. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  531. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  532. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  533. package/dist/types/core/charts/creative/types.d.ts +73 -0
  534. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  535. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  536. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  537. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  538. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  540. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  541. package/dist/types/core/charts/gantt/layout.d.ts +63 -0
  542. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  543. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  544. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  545. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  546. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  547. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  548. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  549. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  550. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  551. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  552. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  553. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  554. package/dist/types/core/charts/line/types.d.ts +6 -0
  555. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  556. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  557. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  558. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  559. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  560. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  561. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  562. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  563. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  564. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  565. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  566. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  567. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  568. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  569. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  570. package/dist/types/core/charts/status/layout.d.ts +71 -0
  571. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  572. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  573. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  574. package/dist/types/core/charts/table/view.d.ts +156 -0
  575. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  576. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  577. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  578. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  579. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  580. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  581. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  582. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  583. package/dist/types/core/claims/browser.d.ts +49 -0
  584. package/dist/types/core/claims/manifest.d.ts +22 -0
  585. package/dist/types/core/dateFormat.d.ts +39 -0
  586. package/dist/types/core/deferred.d.ts +121 -0
  587. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  588. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  589. package/dist/types/core/doc/bareChart.d.ts +2 -0
  590. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  591. package/dist/types/core/doc/docExpand.d.ts +39 -0
  592. package/dist/types/core/doc/document.d.ts +43 -0
  593. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  594. package/dist/types/core/doc/specError.d.ts +6 -0
  595. package/dist/types/core/emptyData.d.ts +27 -0
  596. package/dist/types/core/eventLane.d.ts +208 -0
  597. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  598. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  599. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  600. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  601. package/dist/types/core/footer.d.ts +59 -0
  602. package/dist/types/core/format.d.ts +149 -0
  603. package/dist/types/core/formatPrecision.d.ts +136 -0
  604. package/dist/types/core/formatSpec.d.ts +304 -0
  605. package/dist/types/core/frame.d.ts +583 -0
  606. package/dist/types/core/geo/packs/all.d.ts +7 -0
  607. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  608. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  609. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  610. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  611. package/dist/types/core/geo/packs/index.d.ts +22 -0
  612. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  613. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  614. package/dist/types/core/geo/packs/world.d.ts +16 -0
  615. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  616. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  617. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  618. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  619. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  620. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  621. package/dist/types/core/geo/types.d.ts +146 -0
  622. package/dist/types/core/geometry.d.ts +102 -0
  623. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  624. package/dist/types/core/icons.d.ts +227 -0
  625. package/dist/types/core/inputError.d.ts +14 -0
  626. package/dist/types/core/isoDate.d.ts +2 -0
  627. package/dist/types/core/isoTime.d.ts +7 -0
  628. package/dist/types/core/label/categoryRow.d.ts +332 -0
  629. package/dist/types/core/label/occupied.d.ts +41 -0
  630. package/dist/types/core/label/ownership.d.ts +83 -0
  631. package/dist/types/core/label/solver.d.ts +384 -0
  632. package/dist/types/core/label/tickRow.d.ts +78 -0
  633. package/dist/types/core/live/types.d.ts +50 -0
  634. package/dist/types/core/normalize/shared.d.ts +56 -0
  635. package/dist/types/core/notes.d.ts +174 -0
  636. package/dist/types/core/othersShade.d.ts +9 -0
  637. package/dist/types/core/periodYears.d.ts +9 -0
  638. package/dist/types/core/polyline.d.ts +11 -0
  639. package/dist/types/core/rangeRules.d.ts +19 -0
  640. package/dist/types/core/ratioTier.d.ts +120 -0
  641. package/dist/types/core/readerStrings.d.ts +13 -0
  642. package/dist/types/core/reading.d.ts +120 -0
  643. package/dist/types/core/registry.d.ts +178 -0
  644. package/dist/types/core/repaintGeometry.d.ts +19 -0
  645. package/dist/types/core/request.d.ts +124 -0
  646. package/dist/types/core/rows.d.ts +47 -0
  647. package/dist/types/core/scale.d.ts +106 -0
  648. package/dist/types/core/schema/capability.d.ts +229 -0
  649. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  650. package/dist/types/core/schema/reference.d.ts +31 -0
  651. package/dist/types/core/schema/refusals.d.ts +45 -0
  652. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  653. package/dist/types/core/seriesIdentity.d.ts +120 -0
  654. package/dist/types/core/shareRounding.d.ts +49 -0
  655. package/dist/types/core/sizing.d.ts +330 -0
  656. package/dist/types/core/staticFooter.d.ts +6 -0
  657. package/dist/types/core/story.d.ts +41 -0
  658. package/dist/types/core/structureCounts.d.ts +10 -0
  659. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  660. package/dist/types/core/target.d.ts +89 -0
  661. package/dist/types/core/text.d.ts +113 -0
  662. package/dist/types/core/theme.d.ts +478 -0
  663. package/dist/types/core/themeFields.d.ts +11 -0
  664. package/dist/types/core/themeRules.d.ts +111 -0
  665. package/dist/types/core/themeShape.d.ts +87 -0
  666. package/dist/types/core/themeValidate.d.ts +15 -0
  667. package/dist/types/core/timeAxis.d.ts +106 -0
  668. package/dist/types/core/types/annotations.d.ts +227 -0
  669. package/dist/types/core/types/cell.d.ts +82 -0
  670. package/dist/types/core/types/data.d.ts +314 -0
  671. package/dist/types/core/types/diagram.d.ts +234 -0
  672. package/dist/types/core/types/index.d.ts +8 -0
  673. package/dist/types/core/types/options.d.ts +1583 -0
  674. package/dist/types/core/types/scene.d.ts +990 -0
  675. package/dist/types/core/types/sizing.d.ts +51 -0
  676. package/dist/types/core/types/table.d.ts +873 -0
  677. package/dist/types/core/types/theme.d.ts +806 -0
  678. package/dist/types/core/zoom.d.ts +106 -0
  679. package/dist/types/fixtures/index.d.ts +40 -0
  680. package/dist/types/fixtures/registry.d.ts +15 -0
  681. package/dist/types/fonts.d.ts +10 -0
  682. package/dist/types/index.d.ts +70 -0
  683. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  684. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  685. package/dist/types/react/ScaleGroup.d.ts +31 -0
  686. package/dist/types/react/SceneRenderer.d.ts +23 -0
  687. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  688. package/dist/types/react/StoryFrame.d.ts +42 -0
  689. package/dist/types/react/TableChart.d.ts +220 -0
  690. package/dist/types/react/a11ySurface.d.ts +20 -0
  691. package/dist/types/react/barrelCharts.d.ts +1023 -0
  692. package/dist/types/react/charts/bar.d.ts +28 -0
  693. package/dist/types/react/charts/bartable.d.ts +27 -0
  694. package/dist/types/react/charts/box.d.ts +27 -0
  695. package/dist/types/react/charts/bullet.d.ts +28 -0
  696. package/dist/types/react/charts/butterfly.d.ts +28 -0
  697. package/dist/types/react/charts/choropleth.d.ts +27 -0
  698. package/dist/types/react/charts/cohort.d.ts +52 -0
  699. package/dist/types/react/charts/column.d.ts +27 -0
  700. package/dist/types/react/charts/combo.d.ts +7 -0
  701. package/dist/types/react/charts/creative.d.ts +27 -0
  702. package/dist/types/react/charts/diagram.d.ts +162 -0
  703. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  704. package/dist/types/react/charts/dot.d.ts +28 -0
  705. package/dist/types/react/charts/funnel.d.ts +28 -0
  706. package/dist/types/react/charts/gantt.d.ts +28 -0
  707. package/dist/types/react/charts/grid.d.ts +29 -0
  708. package/dist/types/react/charts/heatmap.d.ts +28 -0
  709. package/dist/types/react/charts/histogram.d.ts +27 -0
  710. package/dist/types/react/charts/kpi.d.ts +28 -0
  711. package/dist/types/react/charts/likert.d.ts +27 -0
  712. package/dist/types/react/charts/line.d.ts +28 -0
  713. package/dist/types/react/charts/mekko.d.ts +28 -0
  714. package/dist/types/react/charts/pareto.d.ts +28 -0
  715. package/dist/types/react/charts/pie.d.ts +28 -0
  716. package/dist/types/react/charts/pvm.d.ts +27 -0
  717. package/dist/types/react/charts/pyramid.d.ts +27 -0
  718. package/dist/types/react/charts/sankey.d.ts +27 -0
  719. package/dist/types/react/charts/scatter.d.ts +28 -0
  720. package/dist/types/react/charts/slope.d.ts +28 -0
  721. package/dist/types/react/charts/sparkline.d.ts +28 -0
  722. package/dist/types/react/charts/status.d.ts +27 -0
  723. package/dist/types/react/charts/table.d.ts +6 -0
  724. package/dist/types/react/charts/tilemap.d.ts +27 -0
  725. package/dist/types/react/charts/treemap.d.ts +27 -0
  726. package/dist/types/react/charts/variance.d.ts +28 -0
  727. package/dist/types/react/charts/waffle.d.ts +28 -0
  728. package/dist/types/react/charts/waterfall.d.ts +28 -0
  729. package/dist/types/react/createChartComponent.d.ts +135 -0
  730. package/dist/types/react/export/clipboard.d.ts +8 -0
  731. package/dist/types/react/export/csv.d.ts +2 -0
  732. package/dist/types/react/export/frame.d.ts +35 -0
  733. package/dist/types/react/export/index.d.ts +7 -0
  734. package/dist/types/react/export/png.d.ts +14 -0
  735. package/dist/types/react/export/svg.d.ts +5 -0
  736. package/dist/types/react/export/types.d.ts +69 -0
  737. package/dist/types/react/export/useExport.d.ts +17 -0
  738. package/dist/types/react/exportLink.d.ts +49 -0
  739. package/dist/types/react/footerFrame.d.ts +25 -0
  740. package/dist/types/react/hover/dataTable.d.ts +13 -0
  741. package/dist/types/react/hover/engine.d.ts +210 -0
  742. package/dist/types/react/hover/keyboard.d.ts +44 -0
  743. package/dist/types/react/hover/labelCard.d.ts +170 -0
  744. package/dist/types/react/hover/placement.d.ts +49 -0
  745. package/dist/types/react/index.d.ts +16 -0
  746. package/dist/types/react/parseChartSpec.d.ts +16 -0
  747. package/dist/types/react/prepare.d.ts +32 -0
  748. package/dist/types/react/prepared.d.ts +53 -0
  749. package/dist/types/react/preparedTable.d.ts +15 -0
  750. package/dist/types/react/rowsInput.d.ts +55 -0
  751. package/dist/types/react/rowsModule.d.ts +18 -0
  752. package/dist/types/react/rowsStore.d.ts +50 -0
  753. package/dist/types/react/scale-group.d.ts +2 -0
  754. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  755. package/dist/types/react/scenePaint.d.ts +10 -0
  756. package/dist/types/react/scrollState.d.ts +26 -0
  757. package/dist/types/react/spec.d.ts +82 -0
  758. package/dist/types/react/specValidation.d.ts +45 -0
  759. package/dist/types/react/story.d.ts +15 -0
  760. package/dist/types/react/theme.d.ts +9 -0
  761. package/dist/types/react/themeContext.d.ts +44 -0
  762. package/dist/types/react/useChartLayout.d.ts +22 -0
  763. package/dist/types/react/useContainerSize.d.ts +57 -0
  764. package/dist/types/react/useHover.d.ts +100 -0
  765. package/dist/types/react/useZoom.d.ts +50 -0
  766. package/dist/types/rows.d.ts +63 -0
  767. package/dist/types/tableLooks.d.ts +6 -0
  768. package/dist/types/theme.d.ts +3 -0
  769. package/dist/types/validate.d.ts +3 -0
  770. package/dist/validate.d.ts +1 -0
  771. package/dist/validate.js +223 -0
  772. package/docs/FONTS.md +68 -0
  773. package/docs/TELEMETRY.md +94 -0
  774. package/docs/manual.md +850 -0
  775. package/docs/reference/bar.md +222 -0
  776. package/docs/reference/bartable.md +143 -0
  777. package/docs/reference/box.md +93 -0
  778. package/docs/reference/bullet.md +118 -0
  779. package/docs/reference/butterfly.md +117 -0
  780. package/docs/reference/choropleth.md +148 -0
  781. package/docs/reference/cohort.md +149 -0
  782. package/docs/reference/column.md +275 -0
  783. package/docs/reference/combo.md +219 -0
  784. package/docs/reference/creative.md +147 -0
  785. package/docs/reference/diagram.md +191 -0
  786. package/docs/reference/dimswitch.md +1395 -0
  787. package/docs/reference/dot.md +117 -0
  788. package/docs/reference/fixtures.md +1089 -0
  789. package/docs/reference/funnel.md +121 -0
  790. package/docs/reference/gantt.md +138 -0
  791. package/docs/reference/grid.md +302 -0
  792. package/docs/reference/heatmap.md +127 -0
  793. package/docs/reference/histogram.md +77 -0
  794. package/docs/reference/kpi.md +115 -0
  795. package/docs/reference/likert.md +113 -0
  796. package/docs/reference/line.md +436 -0
  797. package/docs/reference/mekko.md +114 -0
  798. package/docs/reference/options.md +313 -0
  799. package/docs/reference/pareto.md +102 -0
  800. package/docs/reference/pie.md +114 -0
  801. package/docs/reference/pvm.md +114 -0
  802. package/docs/reference/pyramid.md +99 -0
  803. package/docs/reference/react.md +706 -0
  804. package/docs/reference/reading.md +28 -0
  805. package/docs/reference/sankey.md +110 -0
  806. package/docs/reference/scatter.md +211 -0
  807. package/docs/reference/slope.md +126 -0
  808. package/docs/reference/sparkline.md +74 -0
  809. package/docs/reference/status.md +107 -0
  810. package/docs/reference/table.md +673 -0
  811. package/docs/reference/theme.md +361 -0
  812. package/docs/reference/tilemap.md +121 -0
  813. package/docs/reference/treemap.md +86 -0
  814. package/docs/reference/variance.md +126 -0
  815. package/docs/reference/waffle.md +106 -0
  816. package/docs/reference/waterfall.md +164 -0
  817. package/llms.txt +57 -0
  818. package/package.json +437 -4
@@ -0,0 +1,2937 @@
1
+ import {
2
+ clipTrendToDomain,
3
+ olsFit,
4
+ olsMoments
5
+ } from "./chunk-7X65ZQN4.js";
6
+ import {
7
+ numericViewportRange
8
+ } from "./chunk-BWTX7LUG.js";
9
+ import {
10
+ runAnnotatePass
11
+ } from "./chunk-KZS46KDY.js";
12
+ import {
13
+ breakUnsupported,
14
+ chartPalette,
15
+ chartTheme
16
+ } from "./chunk-3QWZAEW5.js";
17
+ import {
18
+ structureCount
19
+ } from "./chunk-LFX7W4B7.js";
20
+ import {
21
+ emptyIdRecord
22
+ } from "./chunk-LINZPU5D.js";
23
+ import {
24
+ HARD_COMPACT_PLOT,
25
+ applyAxisBounds,
26
+ atHardMinimum,
27
+ chartSizing,
28
+ layoutValueAxis,
29
+ linearScale,
30
+ measureValueAxisWidth,
31
+ niceDomain,
32
+ plotFloorRows,
33
+ sweepHide
34
+ } from "./chunk-RL3NUWMY.js";
35
+ import {
36
+ PRIORITY,
37
+ authoredNotes,
38
+ composedTextRole,
39
+ createOccupiedIndex,
40
+ defaultAnnotationId,
41
+ frameTextOptions,
42
+ hiddenNoteWith,
43
+ inkBox,
44
+ labelCtx,
45
+ labelsToNodes,
46
+ leaderCrosses,
47
+ leaderPieces,
48
+ markNotedLabels,
49
+ nearestIsOwn,
50
+ normalizeLegendOption,
51
+ noteLine,
52
+ omittedKey,
53
+ plotHeightAfter,
54
+ rectContains,
55
+ rectsOverlap,
56
+ seatLeader,
57
+ solveFrame,
58
+ solveLabels
59
+ } from "./chunk-SS42FJVN.js";
60
+ import {
61
+ disclosureNote,
62
+ disclosuresShown
63
+ } from "./chunk-BPKXEMRE.js";
64
+ import {
65
+ MAGNITUDE_DIVISOR,
66
+ exampleSpec,
67
+ formatWithSpec,
68
+ formatterFromExample,
69
+ neededDecimals,
70
+ roundedNumber,
71
+ trendRateFormatter
72
+ } from "./chunk-RGZGLKFB.js";
73
+ import {
74
+ autoDecimals,
75
+ chartStrings,
76
+ formatAutomaticNumber,
77
+ numberRange,
78
+ roundHalfUp,
79
+ seriesValueFormatter
80
+ } from "./chunk-53OYF4ZT.js";
81
+ import {
82
+ cellMeta,
83
+ cellValue,
84
+ isDateCell,
85
+ isPctCell
86
+ } from "./chunk-O3VN6BTL.js";
87
+ import {
88
+ canvasMargin,
89
+ dashToken,
90
+ emphasisWeight,
91
+ markRolePaint,
92
+ mutedMarkPaint,
93
+ paintColor,
94
+ panelTypeClass,
95
+ secondaryFont,
96
+ seriesPaint,
97
+ spaceTokens,
98
+ strokeToken
99
+ } from "./chunk-CWDHCSL2.js";
100
+ import {
101
+ PALETTE_NORMAL_FLOOR
102
+ } from "./chunk-HA4IPWMM.js";
103
+ import {
104
+ cubicPoint,
105
+ fmtPathNumber,
106
+ monotoneSegments
107
+ } from "./chunk-WLZ54FWG.js";
108
+ import {
109
+ NormalizeError,
110
+ TARGET_SIZE,
111
+ accessibleTitle,
112
+ normalizeCell,
113
+ normalizeScenario,
114
+ resolveHighlight,
115
+ resolveSize
116
+ } from "./chunk-SGD3ZHID.js";
117
+ import {
118
+ maxOf,
119
+ minOf,
120
+ pushAll
121
+ } from "./chunk-WYJEOMNY.js";
122
+ import {
123
+ defaultMeasurer,
124
+ wrapText
125
+ } from "./chunk-AG2CJ4JY.js";
126
+
127
+ // src/core/strings/scatter.ts
128
+ var EN = {
129
+ // reader-facing wording linked only by its consumers.
130
+ medianName: "Median",
131
+ lower: "lower",
132
+ higher: "higher",
133
+ axesNonzero: "Axes do not start at zero ({v1}).",
134
+ scatterTitle: "{v1} chart: {v2} points",
135
+ bubbleName: "Bubble",
136
+ scatterName: "Scatter",
137
+ groupsCount: "{v1} group{v2}",
138
+ gridCellsCount: "{v1} grid cells",
139
+ authoredRegionsCount: "{v1} authored regions",
140
+ pointsCount: "{v1} point{v2}",
141
+ paretoLine: "Pareto line",
142
+ trendFitLabel: "{v1}{v2}: slope {v3}, r\xB2 {v4}",
143
+ axesUntitled: "Axes without a title",
144
+ horizontal: "horizontal",
145
+ vertical: "vertical",
146
+ notDrawnScale: "Not drawn to scale: {v1}.",
147
+ pointLabelsOff: "Labels off beyond {v1} points.",
148
+ bottom: "bottom",
149
+ middle: "middle",
150
+ top: "top",
151
+ rowCount: "row {v1}",
152
+ left: "left",
153
+ right: "right",
154
+ columnCount: "column {v1}",
155
+ quadrantEquality: "A unit exactly on a cut point is counted to the right of it and above it.",
156
+ quadrantWeights: "Computed cut points weight every unit equally; bubble size does not enter them.",
157
+ quadrantOutsideRange: "The {v1} cut point ({v2}) does not fall strictly inside the plotted range {v3} to {v4}: no divider is drawn on that axis and the exhibit is a 1x2, not a 2x2.",
158
+ quadrantOnThreshold: "{v1} exactly on a cut point ({v2}).",
159
+ oneUnitSits: "One unit sits",
160
+ unitsSit: "{v1} units sit",
161
+ quadrantAllUnits: "All {v1} units fall in the {v2} box; the other three are empty.",
162
+ zoneDesc: "{v1}: X {v2} to {v3}, Y {v4} to {v5}",
163
+ zoneName: "Zone {v1}, {v2}",
164
+ regionBoundaryDesc: "{v1}: strategy region spanning {v2} boundary points",
165
+ scatterDescStart: "{v1} chart with {v2} points",
166
+ scatterGroupDesc: " in {v1} group{v2} ({v3})",
167
+ scatterAxesDesc: ". X from {v1} to {v2}{v3}, Y from {v4} to {v5}{v6}.",
168
+ logScaleClause: " on a log scale",
169
+ bubbleSizeDesc: " Bubble {v1} encodes size; largest: {v2} ({v3}).",
170
+ areaName: "area",
171
+ diameterName: "diameter",
172
+ quadrantDesc: " Quadrants: horizontal cut at {v1} ({v2}), vertical cut at {v3} ({v4}); ",
173
+ strategyZonesDesc: " Strategy zones: {v1}. {v2}",
174
+ trendLineDesc: " A dashed least-squares trend line {v1} across {v2} points{v3}.",
175
+ fallsLower: "falls",
176
+ risesLower: "rises",
177
+ runsFlat: "runs flat",
178
+ ofGroupClause: " of {v1}",
179
+ frontierDesc: " A dotted Pareto line joins the {v1} points no other point beats on both axes ({v2} x and {v3} y are better): {v4}.",
180
+ linearTrend: "Linear trend",
181
+ sizeZeroRing: "a ring is size 0",
182
+ sizeAbsentPlus: "a plus has no size",
183
+ sizeInvalidCross: "a cross has a size that is not a non-negative number, read as 0",
184
+ minimumDotSize: "the smallest dot is larger than its size",
185
+ quadrantCutX: "Quadrant cut points: horizontal axis at {v1} ({v2}), ",
186
+ // The short method line, with authored axis names.
187
+ quadrantCutShort: "Cuts: {v1} at {v2} and {v3} at {v4}; a point on a cut counts right and above.",
188
+ quadrantCutY: "vertical axis at {v1} ({v2}). ",
189
+ cutProvenance: "{v1} of the {v2} plotted values",
190
+ declaredLower: "declared",
191
+ andMore: "{v1} and {v2} more",
192
+ clippedPointsNote: "{v1} clipped at {v2} ({v3}).",
193
+ droppedPointsNote: "{v1} with a count below {v2} dropped: {v3}.",
194
+ noPositionNote: "{v1} with no x or y not drawn: {v2}.",
195
+ clippedPointsDesc: " {v1} {v2} {v3} drawn at the ",
196
+ clippedPointsEdge: "{v1} edge: {v2}{v3}.",
197
+ moreInTable: ", and {v1} more in the data table",
198
+ clipBelow: "below",
199
+ clipAbove: "above",
200
+ clipLeftOf: "left of",
201
+ clipRightOf: "right of",
202
+ clipBottom: "bottom",
203
+ clipTop: "top",
204
+ clipLeft: "left",
205
+ clipRight: "right",
206
+ topLeft: "top-left",
207
+ topRight: "top-right",
208
+ bottomLeft: "bottom-left",
209
+ bottomRight: "bottom-right",
210
+ cutMedian: "median",
211
+ cutMean: "mean",
212
+ cutAt: "Cut at",
213
+ cutMeanCapital: "Mean",
214
+ pointsCountRight: ", points on it count right",
215
+ pointsCountAbove: ", points on it count above"
216
+ }, DE = {
217
+ // reader-facing wording linked only by its consumers.
218
+ medianName: "Median",
219
+ lower: "niedriger",
220
+ higher: "h\xF6her",
221
+ axesNonzero: "Achsen beginnen nicht bei null ({v1}).",
222
+ scatterTitle: "{v1}diagramm: {v2} {v2|Punkt|Punkte}",
223
+ bubbleName: "Blasen",
224
+ scatterName: "Streu",
225
+ groupsCount: "{v1} {v1|Gruppe|Gruppen}",
226
+ gridCellsCount: "{v1} {v1|Rasterzelle|Rasterzellen}",
227
+ authoredRegionsCount: "{v1} {v1|angegebener Bereich|angegebene Bereiche}",
228
+ pointsCount: "{v1} {v1|Punkt|Punkte}",
229
+ paretoLine: "Pareto-Linie",
230
+ trendFitLabel: "{v1}{v2}: Steigung {v3}, r\xB2 {v4}",
231
+ axesUntitled: "Achsen ohne Titel",
232
+ horizontal: "horizontal",
233
+ vertical: "vertikal",
234
+ notDrawnScale: "Nicht ma\xDFstabsgetreu: {v1}.",
235
+ pointLabelsOff: "Beschriftungen ab mehr als {v1} {v1|Punkt|Punkten} aus.",
236
+ bottom: "unten",
237
+ middle: "Mitte",
238
+ top: "oben",
239
+ rowCount: "Zeile {v1}",
240
+ left: "links",
241
+ right: "rechts",
242
+ columnCount: "Spalte {v1}",
243
+ quadrantEquality: "Eine Einheit genau auf einem Trennpunkt z\xE4hlt rechts davon und dar\xFCber.",
244
+ quadrantWeights: "Berechnete Trennpunkte gewichten jede Einheit gleich. Die Blasengr\xF6\xDFe z\xE4hlt dabei nicht.",
245
+ quadrantOutsideRange: "Der Trennpunkt auf {v1} ({v2}) liegt nicht strikt in der Spanne {v3} bis {v4}. Auf dieser Achse wird keine Trennlinie gezeichnet. Die Darstellung hat 1\xD72 Felder statt 2\xD72.",
246
+ quadrantOnThreshold: "{v1} genau auf einem Trennpunkt ({v2}).",
247
+ oneUnitSits: "Eine Einheit liegt",
248
+ unitsSit: "{v1} {v1|Einheit|Einheiten} {v1|liegt|liegen}",
249
+ quadrantAllUnits: "{v1|Die|Alle} {v1} {v1|Einheit|Einheiten} {v1|liegt|liegen} im Feld {v2}. Die anderen drei sind leer.",
250
+ zoneDesc: "{v1}: X {v2} bis {v3}, Y {v4} bis {v5}",
251
+ zoneName: "Bereich {v1}, {v2}",
252
+ regionBoundaryDesc: "{v1}: Strategiebereich mit {v2} {v2|Grenzpunkt|Grenzpunkten}",
253
+ scatterDescStart: "{v1}diagramm mit {v2} {v2|Punkt|Punkten}",
254
+ scatterGroupDesc: " in {v1} {v1|Gruppe|Gruppen} ({v3})",
255
+ scatterAxesDesc: ". X von {v1} bis {v2}{v3}, Y von {v4} bis {v5}{v6}.",
256
+ logScaleClause: " auf logarithmischer Skala",
257
+ bubbleSizeDesc: " {v1} der Blasen zeigt die Gr\xF6\xDFe; gr\xF6\xDFte: {v2} ({v3}).",
258
+ areaName: "Fl\xE4che",
259
+ diameterName: "Durchmesser",
260
+ quadrantDesc: " Quadranten: horizontaler Trennpunkt {v1} ({v2}), vertikaler Trennpunkt {v3} ({v4}); ",
261
+ strategyZonesDesc: " Strategiebereiche: {v1}. {v2}",
262
+ trendLineDesc: " Eine gestrichelte Trendlinie nach kleinsten Quadraten {v1} \xFCber {v2} {v2|Punkt|Punkte}{v3}.",
263
+ fallsLower: "f\xE4llt",
264
+ risesLower: "steigt",
265
+ runsFlat: "bleibt gleich",
266
+ ofGroupClause: " von {v1}",
267
+ frontierDesc: " Eine gepunktete Pareto-Linie verbindet {v1} {v1|Punkt|Punkte}, {v1|den|die} kein anderer Punkt auf beiden Achsen \xFCbertrifft ({v2} x und {v3} y sind besser): {v4}.",
268
+ linearTrend: "Linearer Verlauf",
269
+ sizeZeroRing: "ein Ring hat Gr\xF6\xDFe 0",
270
+ sizeAbsentPlus: "ein Plus hat keine Gr\xF6\xDFe",
271
+ sizeInvalidCross: "ein Kreuz hat keine g\xFCltige nichtnegative Gr\xF6\xDFe; als 0 gelesen",
272
+ minimumDotSize: "der kleinste Punkt ist gr\xF6\xDFer als sein Wert",
273
+ quadrantCutX: "Quadranten-Trennpunkte: horizontale Achse bei {v1} ({v2}), ",
274
+ // The short method line, with authored axis names.
275
+ quadrantCutShort: "Trennpunkte: {v1} bei {v2} und {v3} bei {v4}; ein Punkt auf einem Trennpunkt z\xE4hlt rechts und oben.",
276
+ quadrantCutY: "vertikale Achse bei {v1} ({v2}). ",
277
+ cutProvenance: "{v1} der {v2} gezeichneten Werte",
278
+ declaredLower: "angegeben",
279
+ andMore: "{v1} und {v2} weitere",
280
+ clippedPointsNote: "{v1} bei {v2} begrenzt ({v3}).",
281
+ droppedPointsNote: "{v1} mit einer Anzahl unter {v2} entfernt: {v3}.",
282
+ noPositionNote: "{v1} ohne x oder y nicht gezeichnet: {v2}.",
283
+ clippedPointsDesc: " {v1} {v2} {v3} am Rand ",
284
+ clippedPointsEdge: "{v1} gezeichnet: {v2}{v3}.",
285
+ moreInTable: ", und {v1} weitere in der Datentabelle",
286
+ clipBelow: "unter",
287
+ clipAbove: "\xFCber",
288
+ clipLeftOf: "links von",
289
+ clipRightOf: "rechts von",
290
+ clipBottom: "unten",
291
+ clipTop: "oben",
292
+ clipLeft: "links",
293
+ clipRight: "rechts",
294
+ topLeft: "oben links",
295
+ topRight: "oben rechts",
296
+ bottomLeft: "unten links",
297
+ bottomRight: "unten rechts",
298
+ cutMedian: "Median",
299
+ cutMean: "Mittelwert",
300
+ cutAt: "Trennpunkt bei",
301
+ cutMeanCapital: "Mittelwert",
302
+ pointsCountRight: ", Punkte darauf z\xE4hlen rechts",
303
+ pointsCountAbove: ", Punkte darauf z\xE4hlen oben"
304
+ }, { chartString } = chartStrings(EN, DE);
305
+
306
+ // src/core/charts/scatter/clamp.ts
307
+ var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
308
+ function axisName(axis, titles) {
309
+ return titles[axis] ?? axis;
310
+ }
311
+ function readClampBounds(clamp) {
312
+ let bare = {
313
+ ...typeof clamp.min == "number" ? { min: clamp.min } : {},
314
+ ...typeof clamp.max == "number" ? { max: clamp.max } : {}
315
+ }, named = (axis) => clamp[axis] ?? {};
316
+ if (Object.keys(bare).length > 0 && Object.keys(named("y")).length > 0)
317
+ throw new NormalizeError(
318
+ "clamp-ambiguous",
319
+ "options.valueAxis.clamp",
320
+ "valueAxis.clamp states the vertical bound twice, once as clamp.min/clamp.max and once as clamp.y",
321
+ "keep one of the two: clamp.min and clamp.max are the y axis on a scatter, and clamp.y says the same thing explicitly",
322
+ void 0,
323
+ ["options", "valueAxis", "clamp"]
324
+ );
325
+ return { x: named("x"), y: Object.keys(bare).length > 0 ? bare : named("y") };
326
+ }
327
+ function refuseClampConflicts(bounds, input) {
328
+ if (input.hasViewDomain)
329
+ throw new NormalizeError(
330
+ "clamp-view-domain-conflict",
331
+ "options.valueAxis.clamp",
332
+ "valueAxis.clamp and viewDomain both narrow the scatter domain, and they treat the points outside it differently: viewDomain leaves them out, clamp draws them at the edge and counts them",
333
+ "use viewDomain to zoom, or valueAxis.clamp to cap the axis and mark the outliers, not both",
334
+ void 0,
335
+ ["options", "valueAxis", "clamp"]
336
+ );
337
+ for (let bound of ["min", "max"])
338
+ if (bounds.y[bound] !== void 0 && input.valueAxisBounds[bound] !== void 0)
339
+ throw new NormalizeError(
340
+ "clamp-bound-conflict",
341
+ `options.valueAxis.clamp.${bound}`,
342
+ `valueAxis.${bound} widens the vertical domain so nothing is cut off, and valueAxis.clamp.${bound} caps it so outliers are cut off at ${input.valueAxisBounds[bound]}; one of the two has to go`,
343
+ `drop valueAxis.${bound} to cap the axis, or drop valueAxis.clamp.${bound} to keep every point at its own position`,
344
+ void 0,
345
+ ["options", "valueAxis", "clamp", bound]
346
+ );
347
+ for (let axis of ["x", "y"]) {
348
+ let { min, max } = bounds[axis];
349
+ if (min !== void 0 && max !== void 0 && min >= max)
350
+ throw new NormalizeError(
351
+ "clamp-empty-range",
352
+ `options.valueAxis.clamp${axis === "y" ? "" : ".x"}`,
353
+ `the ${axis} clamp keeps values from ${min} up to ${max}, which is an empty range`,
354
+ "set the lower bound below the upper one",
355
+ void 0,
356
+ ["options", "valueAxis", "clamp"]
357
+ );
358
+ }
359
+ }
360
+ function clippedAt(points, axis, bound, limit) {
361
+ return points.filter((point) => bound === "max" ? point[axis] > limit : point[axis] < limit).map((point) => ({ id: point.id, label: point.label, value: point[axis] }));
362
+ }
363
+ function planScatterClamp(points, input, disclose) {
364
+ if (!input.clamp || typeof input.clamp != "object") return;
365
+ let bounds = readClampBounds(input.clamp);
366
+ refuseClampConflicts(bounds, input);
367
+ let applied = { x: {}, y: {} }, edges = { x: {}, y: {} }, clipped = /* @__PURE__ */ new Set(), records = [];
368
+ for (let axis of ["x", "y"])
369
+ for (let bound of ["min", "max"]) {
370
+ let raw = bounds[axis][bound];
371
+ if (raw === void 0) continue;
372
+ let { value: limit, text: limitText } = disclose(raw, axis);
373
+ applied[axis][bound] = limit;
374
+ let beyond = clippedAt(points, axis, bound, limit);
375
+ if (beyond.length !== 0) {
376
+ edges[axis][bound] = limit;
377
+ for (let point of beyond) clipped.add(point.id);
378
+ records.push({
379
+ axis,
380
+ bound,
381
+ limit,
382
+ limitText,
383
+ count: beyond.length,
384
+ points: beyond,
385
+ note: disclosureNote(chartString(input.options, "clippedPointsNote", { v1: chartString(input.options, "pointsCount", { v1: beyond.length, v2: beyond.length === 1 ? "" : "s" }), v2: limitText, v3: axisName(axis, input.axisTitles) }))
386
+ });
387
+ }
388
+ }
389
+ let project = (axis) => (value) => {
390
+ let { min, max } = applied[axis];
391
+ return max !== void 0 && value > max ? max : min !== void 0 && value < min ? min : value;
392
+ };
393
+ return {
394
+ project: { x: project("x"), y: project("y") },
395
+ clipped,
396
+ records,
397
+ edges,
398
+ applied,
399
+ axisNames: { x: axisName("x", input.axisTitles), y: axisName("y", input.axisTitles) },
400
+ notes: records.map((record) => record.note)
401
+ };
402
+ }
403
+ function applyMinCount(points, minCount, discloseCount, options) {
404
+ if (minCount === void 0) return { kept: points };
405
+ let counted = points.filter((point) => point.count !== null);
406
+ if (counted.length === 0)
407
+ throw new NormalizeError(
408
+ "min-count-unsupported",
409
+ "options.minCount",
410
+ "options.minCount filters on points[].count, and no point carries one",
411
+ "add count to the points this threshold should filter, or drop options.minCount",
412
+ void 0,
413
+ ["options", "minCount"]
414
+ );
415
+ if (counted.length < points.length) {
416
+ let missing = points.filter((point) => point.count === null), named = missing.slice(0, 3).map((point) => `'${point.id}'`).join(", ");
417
+ throw new NormalizeError(
418
+ "min-count-partial",
419
+ "points",
420
+ `options.minCount filters on points[].count, and ${plural(missing.length, "point")} carry none (${named}${missing.length > 3 ? ", \u2026" : ""}); the engine cannot tell whether they are above or below the threshold`,
421
+ "give every point a count, or drop options.minCount",
422
+ void 0,
423
+ ["data", "points"]
424
+ );
425
+ }
426
+ let { value: threshold, text: thresholdText } = discloseCount(minCount), kept = points.filter((point) => point.count >= threshold), dropped = points.filter((point) => point.count < threshold);
427
+ if (kept.length === 0)
428
+ throw new NormalizeError(
429
+ "min-count-empty",
430
+ "options.minCount",
431
+ `options.minCount is ${minCount} and every one of the ${points.length} points is below it, so there is nothing left to plot`,
432
+ "lower options.minCount below the largest count in the data",
433
+ void 0,
434
+ ["options", "minCount"]
435
+ );
436
+ return dropped.length === 0 ? { kept } : {
437
+ kept,
438
+ record: {
439
+ minCount: threshold,
440
+ count: dropped.length,
441
+ points: dropped.map((point) => ({ id: point.id, label: point.label, count: point.count })),
442
+ // The note names the points it dropped.
443
+ note: disclosureNote(chartString(options, "droppedPointsNote", { v1: chartString(options, "pointsCount", { v1: dropped.length, v2: dropped.length === 1 ? "" : "s" }), v2: thresholdText, v3: dropped.map((point) => point.label).join(", ") }))
444
+ }
445
+ };
446
+ }
447
+ function clampSeed(plan, axis, lo, hi) {
448
+ if (!plan) return [lo, hi];
449
+ let { min, max } = plan.applied[axis], into = (value) => max !== void 0 && value > max ? max : min !== void 0 && value < min ? min : value;
450
+ return [into(lo), into(hi)];
451
+ }
452
+ function clampStateOf(plan, id) {
453
+ if (!plan?.clipped.has(id)) return;
454
+ let records = plan.records.filter((entry) => entry.points.some((point) => point.id === id));
455
+ return records.length === 1 ? `clipped at ${records[0].limitText}` : `clipped at ${records.map((record) => `${record.limitText} (${plan.axisNames[record.axis]})`).join(" and at ")}`;
456
+ }
457
+ function boundBeyond(plan, axis, value) {
458
+ let { min, max } = plan.applied[axis];
459
+ if (max !== void 0 && value > max) return { bound: "max", limit: max };
460
+ if (min !== void 0 && value < min) return { bound: "min", limit: min };
461
+ }
462
+ var clampPath = (axis, bound) => `valueAxis.clamp.${axis === "y" ? "" : "x."}${bound}`;
463
+ function refuseClampedRegions(plan, regions) {
464
+ if (!(!plan || !regions))
465
+ for (let region of regions)
466
+ for (let vertex of region.points)
467
+ for (let axis of ["x", "y"]) {
468
+ let beyond = boundBeyond(plan, axis, vertex[axis]);
469
+ if (beyond)
470
+ throw new NormalizeError(
471
+ "clamp-zone-conflict",
472
+ "options.zones.regions",
473
+ `strategy region '${region.id}' reaches ${axis} ${vertex[axis]}, beyond ${clampPath(axis, beyond.bound)} ${beyond.limit}, so it would be drawn past the end of the axis`,
474
+ `keep the region inside the clamped range, or move ${clampPath(axis, beyond.bound)} past the region`,
475
+ void 0,
476
+ ["options", "zones", "regions"]
477
+ );
478
+ }
479
+ }
480
+ function refuseClampedValueLines(plan, lines, format) {
481
+ if (plan)
482
+ for (let line of lines) {
483
+ let beyond = boundBeyond(plan, "y", line.value);
484
+ if (!beyond) continue;
485
+ let what = line.isMean ? `the mean of the plotted points (${format(line.value)})` : `its value ${format(line.value)}`;
486
+ throw new NormalizeError(
487
+ "clamp-value-line-conflict",
488
+ `annotations[${line.index}]`,
489
+ `valueLine '${line.id}' sits at ${what}, beyond ${clampPath("y", beyond.bound)} ${beyond.limit}, so the line would be drawn outside the plot`,
490
+ `move ${clampPath("y", beyond.bound)} past the line, or drop the value line`,
491
+ void 0,
492
+ ["annotations", line.index]
493
+ );
494
+ }
495
+ }
496
+ function refuseClampedQuadrants(plan, points, cuts) {
497
+ if (!(!plan || !cuts))
498
+ for (let axis of ["x", "y"]) {
499
+ let cut = cuts[axis], { min, max } = plan.edges[axis], hidden = max !== void 0 && cut >= max ? points.filter((point) => point[axis] >= cut) : min !== void 0 && cut <= min ? points.filter((point) => point[axis] < cut) : [];
500
+ if (hidden.length === 0) continue;
501
+ let bound = max !== void 0 && cut >= max ? "max" : "min";
502
+ throw new NormalizeError(
503
+ "clamp-quadrant-conflict",
504
+ "options.quadrants",
505
+ `the ${axis} cut point ${axis === "x" ? cuts.xText : cuts.yText} lies on or beyond ${clampPath(axis, bound)} ${plan.edges[axis][bound]}, and ${plural(hidden.length, "point")} counted on its far side ${hidden.length === 1 ? "is" : "are"} drawn at the edge on its near side`,
506
+ `declare the cut point inside the clamped range, or move ${clampPath(axis, bound)} past it`,
507
+ void 0,
508
+ ["options", "quadrants", axis]
509
+ );
510
+ }
511
+ }
512
+ function clampDescription(records, format, reversedY, options) {
513
+ return records.map((record) => {
514
+ let flip = reversedY && record.axis === "y", side = chartString(options, { "x.min": "clipLeftOf", "x.max": "clipRightOf", "y.min": "clipBelow", "y.max": "clipAbove" }[`${record.axis}.${record.bound}`]), drawnBound = flip ? record.bound === "min" ? "max" : "min" : record.bound, edge = chartString(options, { "x.min": "clipLeft", "x.max": "clipRight", "y.min": "clipBottom", "y.max": "clipTop" }[`${record.axis}.${drawnBound}`]), named = record.points.slice(0, 5).map((point) => `${point.label} (${format[record.axis](point.value)})`).join(", "), rest = record.points.length - 5;
515
+ return chartString(options, "clippedPointsDesc", { v1: chartString(options, "pointsCount", { v1: record.count, v2: record.count === 1 ? "" : "s" }), v2: side, v3: record.limitText }) + chartString(options, "clippedPointsEdge", { v1: edge, v2: named, v3: rest > 0 ? chartString(options, "moreInTable", { v1: rest }) : "" });
516
+ }).join("");
517
+ }
518
+
519
+ // src/core/charts/scatter/valueLines.ts
520
+ function drawnValueLines(annotations, meanY) {
521
+ let lines = [];
522
+ return (annotations ?? []).forEach((ann, index) => {
523
+ if (ann.kind !== "valueLine" || ann.axis === "secondary") return;
524
+ let spanned = ann.from !== void 0 || ann.to !== void 0, isMean = ann.value === "mean" || ann.value === void 0;
525
+ if (isMean && (ann.seriesId !== void 0 || spanned) || !isMean && ann.seriesId !== void 0 || !isMean && spanned && ann.tolerance === void 0 && ann.attainment === void 0) return;
526
+ let value = isMean ? meanY : ann.value;
527
+ Number.isFinite(value) && lines.push({ index, id: defaultAnnotationId(ann, index), value, isMean });
528
+ }), lines;
529
+ }
530
+ function withValueLines(lines, lo, hi) {
531
+ return lines.reduce(([a, b], line) => [Math.min(a, line.value), Math.max(b, line.value)], [lo, hi]);
532
+ }
533
+ function refuseValueLinesOutsideAxis(lines, domain, bounds, format) {
534
+ for (let line of lines) {
535
+ let bound = line.value > domain[1] ? "max" : line.value < domain[0] ? "min" : void 0;
536
+ if (!bound || bounds[bound] === void 0) continue;
537
+ let what = line.isMean ? `the mean of the plotted points (${format(line.value)})` : format(line.value);
538
+ throw new NormalizeError(
539
+ "value-line-outside-axis",
540
+ `annotations[${line.index}]`,
541
+ `valueLine '${line.id}' sits at ${what}, ${bound === "max" ? "above" : "below"} the vertical axis, which valueAxis.${bound} ends at ${format(domain[bound === "max" ? 1 : 0])}, so the line would be drawn outside the plot`,
542
+ `move valueAxis.${bound} past ${format(line.value)}, or drop valueAxis.${bound} and let the axis extend to the line`,
543
+ void 0,
544
+ ["annotations", line.index]
545
+ );
546
+ }
547
+ }
548
+ function valueLinesInView(annotations, lines, window, warnings, format) {
549
+ let all = annotations ?? [];
550
+ if (!window) return [...all];
551
+ let outside = new Set(
552
+ lines.filter((line) => line.value < window[0] || line.value > window[1]).map((line) => line.index)
553
+ );
554
+ if (outside.size === 0) return [...all];
555
+ for (let line of lines)
556
+ outside.has(line.index) && warnings.push({
557
+ code: "value-line-outside-view",
558
+ severity: "warn",
559
+ message: `valueLine '${line.id}' at ${format(line.value)} lies outside the vertical viewDomain ${format(window[0])} to ${format(window[1])}, so it is not drawn`,
560
+ suggest: "widen viewDomain.y to include the line, or drop viewDomain to show the whole range"
561
+ });
562
+ return all.map((ann, index) => ({ ...ann, id: defaultAnnotationId(ann, index) })).filter((_, index) => !outside.has(index));
563
+ }
564
+
565
+ // src/core/charts/scatter/logAxis.ts
566
+ function logScale(domain, range) {
567
+ let [d0, d1] = domain, [r0, r1] = range, l0 = Math.log10(d0), dl = Math.log10(d1) - l0 || 1, scale = ((value) => r0 + (Math.log10(value) - l0) / dl * (r1 - r0));
568
+ return scale.domain = [d0, d1], scale.range = [r0, r1], scale.log = !0, scale.invert = (px) => 10 ** (l0 + (px - r0) / (r1 - r0 || 1) * dl), scale.ticks = () => logTickTiers(Math.min(d0, d1), Math.max(d0, d1))[0], scale;
569
+ }
570
+ function decimal(m, e) {
571
+ return +`${m}e${e}`;
572
+ }
573
+ function logRung(v, dir, strict = !1) {
574
+ let e = Math.floor(Math.log10(v)), m = v / 10 ** e;
575
+ m >= 10 - 1e-9 && (e += 1, m /= 10);
576
+ let k = dir === "down" ? Math.floor(m + 1e-9) : Math.ceil(m - 1e-9);
577
+ return strict && Math.abs(k - m) < 1e-9 && (k += dir === "down" ? -1 : 1), k < 1 ? decimal(9, e - 1) : k > 9 ? decimal(1, e + 1) : decimal(k, e);
578
+ }
579
+ function logTickTiers(lo, hi) {
580
+ if (!(lo > 0) || !(hi > lo) || !Number.isFinite(hi)) return [[lo, hi].filter((v) => Number.isFinite(v))];
581
+ let e0 = Math.floor(Math.log10(lo)), e1 = Math.ceil(Math.log10(hi)), ladder = (mantissas, every = 1) => {
582
+ let inside = [];
583
+ for (let e = e0; e <= e1; e++)
584
+ if ((e - e0) % every === 0)
585
+ for (let m of mantissas) {
586
+ let v = decimal(m, e);
587
+ v > lo * (1 + 1e-9) && v < hi * (1 - 1e-9) && inside.push(v);
588
+ }
589
+ return [lo, ...inside, hi];
590
+ }, tiers = Math.log10(hi / lo) < 1 ? [ladder([1, 2, 3, 4, 5, 6, 8])] : [];
591
+ tiers.push(ladder([1, 2, 5]), ladder([1]));
592
+ for (let every = 2; every < e1 - e0; every++) tiers.push(ladder([1], every));
593
+ return tiers;
594
+ }
595
+ function logAxesOf(log) {
596
+ return { x: log === "x" || log === "both", y: log === !0 || log === "y" || log === "both" };
597
+ }
598
+ var LOG_EDGE = 5e-3;
599
+ function logDomain(min, max) {
600
+ let lo = logRung(min, "down"), hi = logRung(max, "up"), span = Math.log10(max / min);
601
+ return Math.log10(min / lo) < LOG_EDGE * span && (lo = logRung(lo, "down", !0)), Math.log10(hi / max) < LOG_EDGE * span && (hi = logRung(hi, "up", !0)), hi > lo ? [lo, hi] : [logRung(lo, "down", !0), logRung(hi, "up", !0)];
602
+ }
603
+ function logSpecFormat(spec) {
604
+ let divisor = MAGNITUDE_DIVISOR[spec.magnitude];
605
+ return (value) => formatWithSpec(value, { ...spec, wholeFrom: void 0, decimals: neededDecimals(value / divisor, 12) });
606
+ }
607
+ function fitLogTicks(scale, orient, format, font, measure, gap = 4) {
608
+ let [lo, hi] = [Math.min(...scale.domain), Math.max(...scale.domain)], tiers = logTickTiers(lo, hi);
609
+ for (let ticks of tiers) {
610
+ let items = ticks.map((tick, index) => {
611
+ let size = measure(format(tick), font), pos = scale(tick), extent = orient === "x" ? size.width : size.height;
612
+ return { start: orient === "y" ? pos - extent / 2 : index === 0 ? pos : index === ticks.length - 1 ? pos - extent : pos - extent / 2, size: extent, priority: 0 };
613
+ }), ends = [items[0], items[items.length - 1]], clears = (a, b) => a.start >= b.start + b.size + gap || b.start >= a.start + a.size + gap, inner = items.slice(1, -1).filter((item) => ends.every((end) => clears(item, end)));
614
+ if (sweepHide(inner, gap).every(Boolean)) return ticks;
615
+ }
616
+ return tiers[tiers.length - 1];
617
+ }
618
+ function dropLogFix(log, axis) {
619
+ return log === "both" ? [{ op: "replace", path: "/options/valueAxis/log", value: axis === "x" ? "y" : "x" }] : [{ op: "remove", path: "/options/valueAxis/log" }];
620
+ }
621
+ function refuseNonPositiveOnLog(options, axes, pts) {
622
+ if (!axes.x && !axes.y) return;
623
+ let log = options.valueAxis?.log, side = (axis) => axis === "x" ? "horizontal" : "vertical", refuse = (axis, what, value, segments, remove) => {
624
+ let keep = log === "both" ? ` (log: '${axis === "x" ? "y" : "x"}' keeps the ${side(axis === "x" ? "y" : "x")} axis on a log scale)` : "";
625
+ throw new NormalizeError(
626
+ "log-nonpositive",
627
+ what,
628
+ `${what} is ${value}, and the ${side(axis)} axis is on a log scale, which has no place for zero or a negative value`,
629
+ `${remove}, or drop valueAxis.log${keep}`,
630
+ dropLogFix(log, axis),
631
+ segments
632
+ );
633
+ };
634
+ for (let axis of ["x", "y"]) {
635
+ if (!axes[axis]) continue;
636
+ for (let p of pts)
637
+ p[axis] <= 0 && refuse(axis, `points[${p.id}].${axis}`, p[axis], ["data", "points", p.idx, axis], "remove the point");
638
+ let view = options.viewDomain?.[axis];
639
+ view && Math.min(...view) <= 0 && refuse(axis, `options.viewDomain.${axis}`, `[${view.join(", ")}]`, ["options", "viewDomain", axis], `start viewDomain.${axis} above zero`);
640
+ let clamp = options.valueAxis?.clamp, bounds = axis === "y" ? { min: clamp?.min, max: clamp?.max, ...clamp?.y } : { ...clamp?.x };
641
+ for (let bound of ["min", "max"]) {
642
+ let value = bounds[bound];
643
+ value !== void 0 && value <= 0 && refuse(axis, `options.valueAxis.clamp.${axis}.${bound}`, value, ["options", "valueAxis", "clamp"], "clamp at a value above zero");
644
+ }
645
+ for (let [index, region] of (options.zones?.regions ?? []).entries()) {
646
+ let at = region.points.findIndex((point) => point[axis] <= 0);
647
+ at >= 0 && refuse(axis, `options.zones.regions[${index}].points[${at}].${axis}`, region.points[at][axis], ["options", "zones", "regions", index, "points", at, axis], "move the region above zero");
648
+ }
649
+ let cut = options.quadrants?.[axis];
650
+ typeof cut == "number" && cut <= 0 && refuse(axis, `options.quadrants.${axis}`, cut, ["options", "quadrants", axis], "cut above zero");
651
+ }
652
+ if (!axes.y) return;
653
+ let va = options.valueAxis ?? {};
654
+ for (let bound of ["min", "max"]) {
655
+ let value = va[bound];
656
+ value !== void 0 && value <= 0 && refuse("y", `options.valueAxis.${bound}`, value, ["options", "valueAxis", bound], `drop valueAxis.${bound}`);
657
+ }
658
+ va.includeZero && refuse("y", "options.valueAxis.includeZero", "true", ["options", "valueAxis", "includeZero"], "drop valueAxis.includeZero");
659
+ let meanY = pts.reduce((sum, p) => sum + p.y, 0) / pts.length;
660
+ for (let line of drawnValueLines(options.annotations, meanY)) {
661
+ let ann = options.annotations[line.index], low = typeof ann.tolerance == "number" ? line.value - ann.tolerance : ann.tolerance?.low ?? line.value;
662
+ Math.min(line.value, low) <= 0 && refuse("y", `annotations[${line.index}]`, Math.min(line.value, low), ["annotations", line.index], "move the value line and its band above zero");
663
+ }
664
+ }
665
+
666
+ // src/core/charts/scatter/model.ts
667
+ var QUADRANT_BOXES = ["tl", "tr", "bl", "br"], QUADRANT_BOX_NAME = {
668
+ tl: "top-left",
669
+ tr: "top-right",
670
+ bl: "bottom-left",
671
+ br: "bottom-right"
672
+ };
673
+ function quadrantBoxName(box, options) {
674
+ return chartString(options, { tl: "topLeft", tr: "topRight", bl: "bottomLeft", br: "bottomRight" }[box]);
675
+ }
676
+
677
+ // src/core/charts/scatter/quadrants.ts
678
+ function quadrantMedian(values) {
679
+ let sorted = [...values].sort((a, b) => a - b), n = sorted.length, mid = n >> 1;
680
+ return n % 2 === 1 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
681
+ }
682
+ function resolveCut(threshold, axis, values, warnings) {
683
+ let nonfinite = (value2) => {
684
+ warnings.push({
685
+ code: "quadrant-threshold-nonfinite",
686
+ severity: "error",
687
+ message: `the ${axis} quadrant cut point resolved to ${String(value2)} \u2014 no dividers, no assignment and no claims were produced. A non-finite threshold cannot classify anything, and publishing a box count against it would be an invented number.`,
688
+ suggest: `declare quadrants.${axis} as a finite number`
689
+ });
690
+ };
691
+ if (typeof threshold == "number")
692
+ return Number.isFinite(threshold) ? { value: threshold, source: "declared" } : (nonfinite(threshold), null);
693
+ if (values.length < 3)
694
+ return warnings.push({
695
+ code: "quadrant-stat-underpowered",
696
+ severity: "error",
697
+ message: `quadrants.${axis} asks for the ${threshold.stat} of ${values.length} plotted point(s) \u2014 refused. A median of two points is the midpoint of the two: it reads as analysis and is not.`,
698
+ suggest: `plot at least 3 points, or declare quadrants.${axis} as a number`
699
+ }), null;
700
+ let value = threshold.stat === "median" ? quadrantMedian(values) : values.reduce((a, v) => a + v, 0) / values.length;
701
+ return Number.isFinite(value) ? { value, source: threshold.stat } : (nonfinite(value), null);
702
+ }
703
+ function resolveCuts(pts, env, warnings) {
704
+ let qOpt = env.options.quadrants, rawX = resolveCut(qOpt.x, "x", pts.map((p) => p.x), warnings), rawY = resolveCut(qOpt.y, "y", pts.map((p) => p.y), warnings), cutX = rawX ? { ...rawX, ...env.discloseCut(rawX.value, "x") } : void 0, cutY = rawY ? { ...rawY, ...env.discloseCut(rawY.value, "y") } : void 0;
705
+ for (let [axis, raw, disclosed] of [
706
+ ["horizontal", rawX, cutX],
707
+ ["vertical", rawY, cutY]
708
+ ])
709
+ !raw || !disclosed || disclosed.exact || warnings.push({
710
+ code: "quadrant-threshold-unprintable",
711
+ severity: "warn",
712
+ message: `the ${axis} cut point cannot be printed exactly at any decimal count, so it was applied at the value the exhibit prints (${disclosed.text}) rather than at ${String(raw.value)} \u2014 classifying at a number no reader can see would file points against a boundary the exhibit does not state.`,
713
+ suggest: `declare the ${axis} cut point at a magnitude the chart format can print`
714
+ });
715
+ return cutX && cutY ? { x: cutX, y: cutY } : null;
716
+ }
717
+ function classifyQuadrants(pts, cutX, cutY) {
718
+ let counts = { tl: 0, tr: 0, bl: 0, br: 0 }, assignment = emptyIdRecord(), onThreshold = [];
719
+ for (let p of pts) {
720
+ let right = p.x >= cutX.value, box = p.y >= cutY.value ? right ? "tr" : "tl" : right ? "br" : "bl";
721
+ assignment[p.id] = box, counts[box] += 1, (p.x === cutX.value || p.y === cutY.value) && onThreshold.push(p);
722
+ }
723
+ return { derived: {
724
+ x: cutX.value,
725
+ y: cutY.value,
726
+ xText: cutX.text,
727
+ yText: cutY.text,
728
+ xSource: cutX.source,
729
+ ySource: cutY.source,
730
+ counts,
731
+ assignment
732
+ }, onThreshold };
733
+ }
734
+ function quadrantMethodNotes(cutX, cutY, pointCount, bubbleMode, env, notes, warnings) {
735
+ let provenance = (source) => source === "declared" ? chartString(env.options, "declaredLower") : chartString(env.options, "cutProvenance", { v1: source, v2: pointCount }), names = env.options.quadrants?.axisNames;
736
+ names?.x && names.y && cutX.source === "declared" && cutY.source === "declared" ? notes.push(chartString(env.options, "quadrantCutShort", { v1: names.x, v2: cutX.text, v3: names.y, v4: cutY.text })) : notes.push(
737
+ chartString(env.options, "quadrantCutX", { v1: cutX.text, v2: provenance(cutX.source) }) + chartString(env.options, "quadrantCutY", { v1: cutY.text, v2: provenance(cutY.source) }) + chartString(env.options, "quadrantEquality")
738
+ ), bubbleMode && (cutX.source !== "declared" || cutY.source !== "declared") && (notes.push(chartString(env.options, "quadrantWeights")), warnings.push({
739
+ code: "quadrant-stat-unweighted",
740
+ severity: "info",
741
+ message: "points carry a size channel, but the computed cut point weights every unit equally \u2014 with a size channel present an unweighted statistic is a choice, not a default. No size-weighted statistic is offered: a weighted median needs declared weight semantics and there is no honest default.",
742
+ suggest: "declare the cut point as a number if a size-weighted threshold is intended"
743
+ }));
744
+ }
745
+ function quadrantsOffDomain(cuts, plan, dx, dy, env, warnings) {
746
+ let voided = /* @__PURE__ */ new Set();
747
+ for (let [axis, key, cut, cutLabel, isDrawn, lo, hi] of [
748
+ ["horizontal", "x", cuts.x.value, cuts.x.text, plan.drawX, dx[0], dx[1]],
749
+ ["vertical", "y", cuts.y.value, cuts.y.text, plan.drawY, dy[0], dy[1]]
750
+ ]) {
751
+ if (isDrawn) continue;
752
+ let loLabel = env.discloseCut(lo, key).text, hiLabel = env.discloseCut(hi, key).text;
753
+ warnings.push({
754
+ code: "quadrant-divider-outside-domain",
755
+ severity: "warn",
756
+ message: `the ${axis} cut point ${cutLabel} does not fall strictly inside the plotted domain ${loLabel} to ${hiLabel} \u2014 no divider is drawn on that axis, so the exhibit is a 1x2, not a 2x2: every plotted unit sits on one side of that cut point.`,
757
+ suggest: `move the ${axis} cut point strictly inside the plotted range, or drop it`
758
+ }), plan.notes.push(
759
+ chartString(env.options, "quadrantOutsideRange", { v1: axis, v2: cutLabel, v3: loLabel, v4: hiLabel })
760
+ ), (axis === "horizontal" ? cut > hi ? ["tr", "br"] : ["tl", "bl"] : cut > hi ? ["tl", "tr"] : ["bl", "br"]).forEach((box) => voided.add(box));
761
+ }
762
+ return voided;
763
+ }
764
+ function quadrantEdgeCases(derived, onThreshold, pts, env, notes, warnings) {
765
+ if (onThreshold.length > 0) {
766
+ let named = onThreshold.slice(0, 3).map((p) => p.label).join(", "), rest = onThreshold.length - Math.min(3, onThreshold.length), list = rest > 0 ? chartString(env.options, "andMore", { v1: named, v2: rest }) : named;
767
+ warnings.push({
768
+ code: "quadrant-on-threshold",
769
+ severity: "info",
770
+ message: `${onThreshold.length} point(s) sit exactly on a cut point (${onThreshold.map((p) => p.id).join(", ")}) \u2014 the half-open rule counts them to the right and above; a different tie rule would move them`
771
+ }), notes.push(chartString(env.options, "quadrantOnThreshold", { v1: onThreshold.length === 1 ? chartString(env.options, "oneUnitSits") : chartString(env.options, "unitsSit", { v1: onThreshold.length }), v2: list }));
772
+ }
773
+ env.va.show === !1 && warnings.push({
774
+ code: "quadrant-axes-hidden",
775
+ severity: "warn",
776
+ message: "valueAxis.show is false while quadrants are drawn: the cut points are tagged, but without ticks a reader cannot check where either axis starts, so the box sizes and every unit position become unverifiable",
777
+ suggest: "show the value axes (the scatter default) whenever quadrants are on"
778
+ });
779
+ let soleBox = QUADRANT_BOXES.find((box) => derived.counts[box] === pts.length);
780
+ soleBox && (warnings.push({
781
+ code: "quadrant-degenerate",
782
+ severity: "info",
783
+ message: `all ${pts.length} plotted points fall in the ${QUADRANT_BOX_NAME[soleBox]} box; the other three are empty \u2014 an empty-box result is a finding, not a rendering fault`
784
+ }), notes.push(chartString(env.options, "quadrantAllUnits", { v1: pts.length, v2: quadrantBoxName(soleBox, env.options) })));
785
+ }
786
+ function quadrantRefusal(env) {
787
+ let qOpt = env.options.quadrants, missing = [...qOpt.x === void 0 ? ["x"] : [], ...qOpt.y === void 0 ? ["y"] : []];
788
+ if (missing.length > 0)
789
+ return {
790
+ code: "quadrant-threshold-undeclared",
791
+ severity: "error",
792
+ message: `options.quadrants is missing ${missing.join(" and ")} \u2014 no quadrants were derived. Where the dividing lines go decides which unit is a star and which is a dog, so a guessed cut point silently re-sorts the whole portfolio; the engine refuses to guess one.`,
793
+ suggest: missing.map(
794
+ (axis) => `declare quadrants.${axis} as a number (e.g. { ${axis}: 1 }) or as a statistic over the plotted points (e.g. { ${axis}: { stat: 'median' } }, also { stat: 'mean' })`
795
+ ).join("; ")
796
+ };
797
+ if (env.va.reverse)
798
+ return {
799
+ code: "quadrant-scale-unsupported",
800
+ severity: "error",
801
+ message: "options.quadrants supports non-reversed axes only; valueAxis.reverse was requested \u2014 no quadrants were derived. Quadrant MEMBERSHIP is scale-invariant: reversing an axis cannot move a point across a cut point, so the answer would not change \u2014 only the geometry would, and the boxes would swap sides.",
802
+ suggest: "remove valueAxis.reverse, or drop options.quadrants"
803
+ };
804
+ }
805
+ function deriveQuadrants(pts, bubbleMode, dx, dy, env, warnings) {
806
+ let plan = { notes: [], voidBoxes: /* @__PURE__ */ new Set(), drawX: !1, drawY: !1 };
807
+ if (!env.options.quadrants) return plan;
808
+ let refusal = quadrantRefusal(env);
809
+ if (refusal)
810
+ return warnings.push(refusal), plan;
811
+ let cuts = resolveCuts(pts, env, warnings);
812
+ if (!cuts) return plan;
813
+ let { derived, onThreshold } = classifyQuadrants(pts, cuts.x, cuts.y);
814
+ return plan.derived = derived, plan.drawX = cuts.x.value > dx[0] && cuts.x.value < dx[1], plan.drawY = cuts.y.value > dy[0] && cuts.y.value < dy[1], quadrantMethodNotes(cuts.x, cuts.y, pts.length, bubbleMode, env, plan.notes, warnings), plan.voidBoxes = quadrantsOffDomain(cuts, plan, dx, dy, env, warnings), quadrantEdgeCases(derived, onThreshold, pts, env, plan.notes, warnings), plan;
815
+ }
816
+
817
+ // src/core/charts/scatter/frontier.ts
818
+ var FRONTIER_EXTEND = 24;
819
+ function paretoFront(points, better) {
820
+ let sx = better.x === "min" ? -1 : 1, sy = better.y === "min" ? -1 : 1, beats = (q, p) => sx * q.x >= sx * p.x && sy * q.y >= sy * p.y && (sx * q.x > sx * p.x || sy * q.y > sy * p.y);
821
+ return points.filter((p) => !points.some((q) => beats(q, p))).sort((a, b) => a.x - b.x || a.y - b.y);
822
+ }
823
+ function planFrontier(env, drawn, warnings) {
824
+ let frontier = env.options.frontier;
825
+ if (!frontier) return;
826
+ let groups = frontier.groups === void 0 || frontier.groups === "all" ? void 0 : new Set(frontier.groups), missing = groups ? [...groups].filter((id) => !drawn.some((p) => p.group === id)) : [];
827
+ missing.length && warnings.push({
828
+ code: "frontier-group-empty",
829
+ severity: "warn",
830
+ message: `the Pareto line skips group${missing.length === 1 ? "" : "s"} ${missing.map((id) => `'${id}'`).join(", ")}: no drawn point belongs to ${missing.length === 1 ? "it" : "them"}`,
831
+ suggest: "correct the group id in frontier.groups, or drop it",
832
+ field: ["options", "frontier", "groups"]
833
+ });
834
+ let front = paretoFront(groups ? drawn.filter((p) => p.group !== void 0 && groups.has(p.group)) : drawn, frontier);
835
+ if (front.length < 2) {
836
+ warnings.push({
837
+ code: "frontier-single-point",
838
+ severity: "warn",
839
+ message: front.length ? `no Pareto line: '${front[0].label}' beats every other point on both axes, so the frontier is that one point` : "no Pareto line: no drawn point to run it through",
840
+ field: ["options", "frontier"]
841
+ });
842
+ return;
843
+ }
844
+ return { x: frontier.x, y: frontier.y, ids: front.map((p) => p.id) };
845
+ }
846
+ function reachInside(from, dir, plot, max) {
847
+ let along = (pos, d, lo, hi) => d > 0 ? (hi - pos) / d : d < 0 ? (lo - pos) / d : 1 / 0;
848
+ return Math.max(0, Math.min(max, along(from.x, dir.x, plot.x, plot.x + plot.w), along(from.y, dir.y, plot.y, plot.y + plot.h)));
849
+ }
850
+ function extendPast(prev, end, plot) {
851
+ let len = Math.hypot(end.x - prev.x, end.y - prev.y);
852
+ if (len === 0) return end;
853
+ let dir = { x: (end.x - prev.x) / len, y: (end.y - prev.y) / len }, t = reachInside(end, dir, plot, FRONTIER_EXTEND);
854
+ return { x: end.x + dir.x * t, y: end.y + dir.y * t };
855
+ }
856
+ function drawFrontier(plan, env, pts, clamp, area, nodes, claims) {
857
+ if (!plan) return;
858
+ let byId = new Map(pts.map((p) => [p.id, p])), at = (p) => ({ x: area.x(clamp ? clamp.project.x(p.x) : p.x), y: area.y(clamp ? clamp.project.y(p.y) : p.y) }), path = plan.ids.map((id) => at(byId.get(id)));
859
+ env.options.frontier?.extend && (path.unshift(extendPast(path[1], path[0], area.plot)), path.push(extendPast(path[path.length - 2], path[path.length - 1], area.plot)));
860
+ let d = path.map((pt, k) => `${k === 0 ? "M" : "L"}${fmtPathNumber(pt.x)} ${fmtPathNumber(pt.y)}`).join("");
861
+ nodes.push({ t: "path", id: "frontier", d, stroke: { token: "ink" }, width: strokeToken(env.theme, "rule"), dash: dashToken(env.theme, "dotted"), lineCap: "round", owner: {}, part: "frontierLine" });
862
+ for (let k = 1; k < path.length; k++) {
863
+ let from = path[k - 1], to = path[k], slices = Math.max(1, Math.ceil(Math.hypot(to.x - from.x, to.y - from.y) / 8));
864
+ for (let s = 0; s < slices; s++) {
865
+ let x0 = from.x + (to.x - from.x) * s / slices, x1 = from.x + (to.x - from.x) * (s + 1) / slices, y0 = from.y + (to.y - from.y) * s / slices, y1 = from.y + (to.y - from.y) * (s + 1) / slices;
866
+ claims.claim({ x: Math.min(x0, x1) - 1, y: Math.min(y0, y1) - 1, w: Math.abs(x1 - x0) + 2, h: Math.abs(y1 - y0) + 2 }, "annotation", { annotationId: "frontier" }, "trendLine");
867
+ }
868
+ }
869
+ }
870
+
871
+ // src/core/charts/scatter/trend.ts
872
+ var CURVE_SAMPLES = 24;
873
+ function fitScatterTrends(env, drawn, groupOrder, warnings) {
874
+ let trend = env.options.trend;
875
+ if (!trend) return [];
876
+ let groups = trend === !0 ? "all" : trend.groups ?? "all", buckets = groups === "all" ? [["all", void 0, [...drawn]]] : (groups === "each" ? eachGroup(drawn, groupOrder) : groups).map((group) => [
877
+ group ?? "ungrouped",
878
+ group,
879
+ drawn.filter((p) => p.group === group)
880
+ ]), fits = [];
881
+ for (let [id, group, points] of buckets) {
882
+ let moments = olsMoments(points), fit = moments.n >= 3 ? olsFit(moments) : null;
883
+ if (!fit) {
884
+ warnings.push({
885
+ code: "trend-undefined",
886
+ severity: "warn",
887
+ message: `no trend line for ${group === void 0 ? "the points" : `group '${group}'`}: ${moments.n < 3 ? `a fit needs at least 3 drawn points, it has ${moments.n}` : "every drawn point has the same x"}`,
888
+ field: ["options", "trend"]
889
+ });
890
+ continue;
891
+ }
892
+ let xs = points.map((p) => p.x);
893
+ fits.push({ id, ...group === void 0 ? {} : { group }, ...moments, ...fit, x0: minOf(xs), x1: maxOf(xs) });
894
+ }
895
+ return fits;
896
+ }
897
+ function eachGroup(drawn, groupOrder) {
898
+ let present = new Set(drawn.map((p) => p.group));
899
+ return [...groupOrder.filter((id) => present.has(id)), ...present.has(void 0) ? [void 0] : []];
900
+ }
901
+ function drawScatterTrends(theme, fits, domain, area, paints, nodes, claims) {
902
+ let lines = [];
903
+ for (let fit of fits) {
904
+ let span = clipTrendToDomain(fit, domain.dx, domain.dy);
905
+ if (!span) continue;
906
+ let at = (x) => ({ x: area.x(x), y: area.y(fit.intercept + fit.slope * x) }), from = at(span[0]), to = at(span[1]), nodeId = `trend:${fit.id}`, stroke = fit.group === void 0 ? { token: "ink" } : paints.group(fit.group), curved = area.x.log === !0 || area.y.log === !0, yAt = curved ? (px) => area.y(fit.intercept + fit.slope * area.x.invert(px)) : (px) => from.y + (to.y - from.y) * (px - from.x) / (to.x - from.x || 1), slices = curved ? CURVE_SAMPLES : 12, vertices = Array.from({ length: slices + 1 }, (_, k) => {
907
+ if (curved && (k === 0 || k === slices)) return k === 0 ? from : to;
908
+ let px = from.x + (to.x - from.x) * k / slices;
909
+ return { x: px, y: curved ? yAt(px) : from.y + (to.y - from.y) * k / slices };
910
+ });
911
+ nodes.push(curved ? { t: "path", id: nodeId, d: vertices.map((v, k) => `${k === 0 ? "M" : "L"}${fmtPathNumber(v.x)} ${fmtPathNumber(v.y)}`).join(""), stroke, width: strokeToken(theme, "data"), dash: dashToken(theme, "reference"), owner: {}, part: "trendLine" } : { t: "line", id: nodeId, x1: from.x, y1: from.y, x2: to.x, y2: to.y, stroke, width: strokeToken(theme, "data"), dash: dashToken(theme, "reference"), owner: {}, part: "trendLine" });
912
+ for (let k = 0; k < slices; k++) {
913
+ let { x: x0, y: y0 } = vertices[k], { x: x1, y: y1 } = vertices[k + 1];
914
+ claims.claim({ x: Math.min(x0, x1), y: Math.min(y0, y1) - 1.5, w: Math.max(Math.abs(x1 - x0), 1), h: Math.abs(y1 - y0) + 3 }, "annotation", { annotationId: nodeId }, "trendLine");
915
+ }
916
+ lines.push({ fit, nodeId, from, to, yAt });
917
+ }
918
+ return lines;
919
+ }
920
+
921
+ // src/core/charts/scatter/zones.ts
922
+ var ZONE_BAND_GAP = 5, CELL_GAP = 2;
923
+ function gridZones(options) {
924
+ return options.zones !== void 0 && "grid" in options.zones && options.zones.grid !== void 0;
925
+ }
926
+ function bandedAxes(env, domain) {
927
+ let zones = env.options.zones, grid = zones && "grid" in zones ? zones.grid : void 0;
928
+ return {
929
+ x: (grid?.xLabels?.length ?? 0) > 0 && domain.evenGrid?.x === !0,
930
+ y: (grid?.yLabels?.length ?? 0) > 0 && domain.evenGrid?.y === !0
931
+ };
932
+ }
933
+ function refuseUnkeyableZone(zone, path) {
934
+ if ((zone.labelAt ?? "plot") !== "plot" && (!zone.label || zone.tone === "none"))
935
+ throw new NormalizeError(
936
+ "zone-key-unkeyable",
937
+ `${path}.labelAt`,
938
+ `strategy zone '${zone.id}' is keyed in the legend (labelAt '${zone.labelAt}') ${zone.label ? "with tone 'none', so its swatch would be empty" : "without a label to key it by"}`,
939
+ zone.label ? "give the zone a tone, or keep labelAt 'plot'" : "add a label, or keep labelAt 'plot'"
940
+ );
941
+ }
942
+ function validateStrategyZones(options) {
943
+ let zones = options.zones;
944
+ if (!zones) return;
945
+ if (zones.grid) {
946
+ let { grid } = zones;
947
+ for (let axis of ["x", "y"]) {
948
+ if (!Array.isArray(grid[axis]) || grid[axis].length === 0)
949
+ throw new NormalizeError(
950
+ "zone-thresholds-empty",
951
+ `options.zones.grid.${axis}`,
952
+ `strategy-zone ${axis} thresholds require at least one value`
953
+ );
954
+ grid[axis].forEach((value, index) => {
955
+ if (!Number.isFinite(value))
956
+ throw new NormalizeError(
957
+ "zone-threshold-nonfinite",
958
+ `options.zones.grid.${axis}[${index}]`,
959
+ "strategy-zone thresholds must be finite"
960
+ );
961
+ if (index > 0 && !(value > grid[axis][index - 1]))
962
+ throw new NormalizeError(
963
+ "zone-threshold-order",
964
+ `options.zones.grid.${axis}[${index}]`,
965
+ "strategy-zone thresholds must be strictly increasing"
966
+ );
967
+ });
968
+ }
969
+ for (let [axis, labels, expected] of [
970
+ ["x", grid.xLabels, grid.x.length + 1],
971
+ ["y", grid.yLabels, grid.y.length + 1]
972
+ ])
973
+ if (labels && labels.length !== expected)
974
+ throw new NormalizeError(
975
+ "zone-band-label-count",
976
+ `options.zones.grid.${axis}Labels`,
977
+ `strategy-zone ${axis} band labels require exactly ${expected} entries`
978
+ );
979
+ let ids2 = /* @__PURE__ */ new Set(), positions = /* @__PURE__ */ new Set();
980
+ for (let [index, cell] of (grid.cells ?? []).entries()) {
981
+ if (ids2.has(cell.id))
982
+ throw new NormalizeError(
983
+ "duplicate-id",
984
+ `options.zones.grid.cells[${index}]`,
985
+ `duplicate strategy-zone cell id '${cell.id}'`
986
+ );
987
+ if (ids2.add(cell.id), cell.column > grid.x.length || cell.row > grid.y.length)
988
+ throw new NormalizeError(
989
+ "zone-cell-outside-grid",
990
+ `options.zones.grid.cells[${index}]`,
991
+ `strategy-zone cell '${cell.id}' addresses row ${cell.row}, column ${cell.column} outside the derived grid`
992
+ );
993
+ let position = `${cell.column}:${cell.row}`;
994
+ if (positions.has(position))
995
+ throw new NormalizeError(
996
+ "zone-cell-duplicate-position",
997
+ `options.zones.grid.cells[${index}]`,
998
+ `more than one strategy-zone cell addresses row ${cell.row}, column ${cell.column}`
999
+ );
1000
+ positions.add(position), refuseUnkeyableZone(cell, `options.zones.grid.cells[${index}]`);
1001
+ }
1002
+ return;
1003
+ }
1004
+ if (!Array.isArray(zones.regions) || zones.regions.length === 0)
1005
+ throw new NormalizeError(
1006
+ "zone-regions-empty",
1007
+ "options.zones.regions",
1008
+ "strategy zones require at least one region"
1009
+ );
1010
+ let ids = /* @__PURE__ */ new Set();
1011
+ for (let [index, region] of zones.regions.entries()) {
1012
+ if (validateZoneRegion(region, index), refuseUnkeyableZone(region, `options.zones.regions[${index}]`), ids.has(region.id))
1013
+ throw new NormalizeError(
1014
+ "duplicate-id",
1015
+ `options.zones.regions[${index}]`,
1016
+ `duplicate strategy-zone region id '${region.id}'`
1017
+ );
1018
+ ids.add(region.id);
1019
+ }
1020
+ }
1021
+ function validateZoneRegion(region, index) {
1022
+ if (!region.id)
1023
+ throw new NormalizeError(
1024
+ "missing-id",
1025
+ `options.zones.regions[${index}]`,
1026
+ "strategy-zone region requires an id"
1027
+ );
1028
+ if (!Array.isArray(region.points) || region.points.length < 3)
1029
+ throw new NormalizeError(
1030
+ "zone-region-too-short",
1031
+ `options.zones.regions[${index}].points`,
1032
+ "strategy-zone polygon requires at least three points"
1033
+ );
1034
+ region.points.forEach((point, pointIndex) => {
1035
+ if (!Number.isFinite(point.x) || !Number.isFinite(point.y))
1036
+ throw new NormalizeError(
1037
+ "zone-region-nonfinite",
1038
+ `options.zones.regions[${index}].points[${pointIndex}]`,
1039
+ "strategy-zone polygon points must be finite"
1040
+ );
1041
+ });
1042
+ }
1043
+ function zoneToneToken(tone, fill = !1) {
1044
+ return tone === "good" ? fill ? "goodFill" : "good" : tone === "bad" ? fill ? "badFill" : "bad" : tone === "warn" ? fill ? "warnFill" : "warn" : tone === "info" ? "focus" : "neutral";
1045
+ }
1046
+ var neutralWash = { token: "neutral", theme: { kind: "visible-tint", base: { token: "neutral" }, amount: 0.91, floor: 1.1 } }, zoneFill = (tone) => {
1047
+ if (tone === "none") return;
1048
+ if (tone === void 0 || tone === "neutral") return neutralWash;
1049
+ let token = zoneToneToken(tone, !0);
1050
+ return { token, theme: { kind: "visible-tint", base: { token }, amount: 0.91, floor: 1.1, darkApartFrom: { paint: neutralWash, distance: PALETTE_NORMAL_FLOOR } } };
1051
+ };
1052
+ function zoneKeyItems(options) {
1053
+ let zones = options.zones;
1054
+ return [...zones?.grid?.cells ?? [], ...zones?.regions ?? []].filter((zone) => (zone.labelAt ?? "plot") !== "plot" && zone.label).map((zone) => ({ id: `zone:${zone.id}`, label: zone.label, paint: zoneFill(zone.tone) ?? neutralWash, key: "box" }));
1055
+ }
1056
+ var captionedInPlot = (zone) => zone?.label !== void 0 && (zone.labelAt ?? "plot") !== "key", zoneStroke = (tone) => ({
1057
+ token: zoneToneToken(tone),
1058
+ tint: 0.55
1059
+ });
1060
+ function gridZoneCells(grid, bounds, area, fmt, nodes, out, options) {
1061
+ let { x, y } = area, { x: xBounds, y: yBounds } = bounds, cellByPosition = new Map((grid.cells ?? []).map((cell) => [`${cell.column}:${cell.row}`, cell]));
1062
+ for (let row = 0; row < yBounds.length - 1; row++)
1063
+ for (let column = 0; column < xBounds.length - 1; column++) {
1064
+ let authored = cellByPosition.get(`${column}:${row}`), id = authored?.id ?? `r${row + 1}-c${column + 1}`, left = x(xBounds[column]), right = x(xBounds[column + 1]), top = y(yBounds[row + 1]), bottom = y(yBounds[row]), rect = {
1065
+ x: Math.min(left, right),
1066
+ y: Math.min(top, bottom),
1067
+ w: Math.abs(right - left),
1068
+ h: Math.abs(bottom - top)
1069
+ }, nodeId = `zone:cell:${id}`, description = authored?.a11y ?? chartString(options, "zoneDesc", { v1: authored?.label ?? chartString(options, "zoneName", { v1: row + 1, v2: column + 1 }), v2: fmt.x(xBounds[column]), v3: fmt.x(xBounds[column + 1]), v4: fmt.y(yBounds[row]), v5: fmt.y(yBounds[row + 1]) }), fill = zoneFill(authored?.tone);
1070
+ fill && nodes.push({
1071
+ t: "rect",
1072
+ id: nodeId,
1073
+ rect,
1074
+ fill,
1075
+ owner: { categoryId: `zone:${id}` },
1076
+ part: "strategyZoneCell",
1077
+ display: { state: description }
1078
+ });
1079
+ let captioned = captionedInPlot(authored);
1080
+ out.marks.push({
1081
+ id,
1082
+ kind: "cell",
1083
+ ...fill ? { nodeId } : {},
1084
+ ...captioned ? { labelId: `zone:label:${id}` } : {},
1085
+ description
1086
+ }), out.descriptions.push(description), captioned && out.labels.push({ kind: "cell", id: `zone:label:${id}`, text: authored.label, box: rect });
1087
+ }
1088
+ }
1089
+ function gridZoneRules(grid, bounds, area, nodes, labels) {
1090
+ let { x, y, plot } = area;
1091
+ for (let threshold of grid.x) {
1092
+ let px = x(threshold);
1093
+ nodes.push({
1094
+ t: "line",
1095
+ id: `zone:grid:x:${threshold}`,
1096
+ x1: px,
1097
+ y1: plot.y,
1098
+ x2: px,
1099
+ y2: plot.y + plot.h,
1100
+ // A page-colour rule leaves a gap between the tinted cells (scatter.matrix).
1101
+ stroke: { token: "background" },
1102
+ width: CELL_GAP,
1103
+ owner: {},
1104
+ part: "strategyZoneBoundary"
1105
+ });
1106
+ }
1107
+ for (let threshold of grid.y) {
1108
+ let py = y(threshold);
1109
+ nodes.push({
1110
+ t: "line",
1111
+ id: `zone:grid:y:${threshold}`,
1112
+ x1: plot.x,
1113
+ y1: py,
1114
+ x2: plot.x + plot.w,
1115
+ y2: py,
1116
+ stroke: { token: "background" },
1117
+ width: CELL_GAP,
1118
+ owner: {},
1119
+ part: "strategyZoneBoundary"
1120
+ });
1121
+ }
1122
+ grid.xLabels?.forEach((text, column) => {
1123
+ let left = x(bounds.x[column]), right = x(bounds.x[column + 1]);
1124
+ labels.push({
1125
+ kind: "xBand",
1126
+ id: `zone:x-band:${column}`,
1127
+ text,
1128
+ ...area.xBandLines?.[column] ? { lines: area.xBandLines[column] } : {},
1129
+ box: { x: Math.min(left, right), y: plot.y + plot.h + area.xAxisH, w: Math.abs(right - left), h: area.xBandH }
1130
+ });
1131
+ }), grid.yLabels?.forEach((text, row) => {
1132
+ let top = y(bounds.y[row + 1]), bottom = y(bounds.y[row]);
1133
+ labels.push({
1134
+ kind: "yBand",
1135
+ id: `zone:y-band:${row}`,
1136
+ text,
1137
+ ...area.yBandLines?.[row] ? { lines: area.yBandLines[row] } : {},
1138
+ box: { x: area.inner.x, y: Math.min(top, bottom), w: area.yBandW, h: Math.abs(bottom - top) }
1139
+ });
1140
+ });
1141
+ }
1142
+ function regionZones(theme, regions, area, nodes, claims, out, options) {
1143
+ for (let region of regions) {
1144
+ let points = region.points.map((point) => ({ x: area.x(point.x), y: area.y(point.y) })), d = region.smooth ? smoothClosedZonePath(points) : polygonPath(points), nodeId = `zone:region:${region.id}`, description = region.a11y ?? chartString(options, "regionBoundaryDesc", { v1: region.label ?? region.id, v2: region.points.length }), fill = zoneFill(region.tone);
1145
+ nodes.push({
1146
+ t: "path",
1147
+ id: nodeId,
1148
+ d,
1149
+ ...fill ? { fill } : {},
1150
+ stroke: zoneStroke(region.tone),
1151
+ width: strokeToken(theme, "rule"),
1152
+ owner: { categoryId: `zone:${region.id}` },
1153
+ part: "strategyZoneRegion",
1154
+ display: { state: description }
1155
+ }), claimZoneBoundary(points, region.smooth ?? !1, claims, { categoryId: `zone:${region.id}` }), out.marks.push({
1156
+ id: region.id,
1157
+ kind: "region",
1158
+ nodeId,
1159
+ ...captionedInPlot(region) ? { labelId: `zone:label:${region.id}` } : {},
1160
+ description
1161
+ }), out.descriptions.push(description), captionedInPlot(region) && out.labels.push({ kind: "region", id: `zone:label:${region.id}`, text: region.label, box: pointBounds(points) });
1162
+ }
1163
+ }
1164
+ function layoutScatterZones(env, domain, area, nodes, claims) {
1165
+ let zones = env.options.zones, out = { marks: [], descriptions: [], labels: [] };
1166
+ if (zones && "grid" in zones && zones.grid) {
1167
+ let grid = zones.grid, bounds = { x: [domain.dx[0], ...grid.x, domain.dx[1]], y: [domain.dy[0], ...grid.y, domain.dy[1]] };
1168
+ gridZoneCells(grid, bounds, area, env.axisFmt, nodes, out, env.options), gridZoneRules(grid, bounds, area, nodes, out.labels), out.derived = { kind: "grid", descriptions: out.descriptions, cellCount: out.marks.length };
1169
+ } else zones?.regions && (regionZones(env.theme, zones.regions, area, nodes, claims, out, env.options), out.derived = { kind: "regions", descriptions: out.descriptions, regionCount: out.marks.length });
1170
+ return out;
1171
+ }
1172
+ function pointBounds(points) {
1173
+ let xs = points.map((point) => point.x), ys = points.map((point) => point.y), x = minOf(xs), y = minOf(ys);
1174
+ return {
1175
+ x,
1176
+ y,
1177
+ w: maxOf(xs) - x,
1178
+ h: maxOf(ys) - y
1179
+ };
1180
+ }
1181
+ function polygonPath(points) {
1182
+ return `${points.map((point, index) => `${index === 0 ? "M" : "L"}${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("")}Z`;
1183
+ }
1184
+ function claimZoneBoundary(points, smooth, occupied, owner) {
1185
+ let cubics = smooth ? smoothClosedZoneSegments(points) : [], samples = cubics.length ? cubics.flatMap(
1186
+ (segment) => Array.from({ length: 9 }, (_, index) => cubicPoint(segment, index / 8))
1187
+ ) : points.flatMap((point, index) => {
1188
+ let next = points[(index + 1) % points.length];
1189
+ return Array.from({ length: 9 }, (_, sample) => ({
1190
+ x: point.x + (next.x - point.x) * sample / 8,
1191
+ y: point.y + (next.y - point.y) * sample / 8
1192
+ }));
1193
+ });
1194
+ for (let index = 1; index < samples.length; index += 1) {
1195
+ let from = samples[index - 1], to = samples[index];
1196
+ occupied.claim(
1197
+ {
1198
+ x: Math.min(from.x, to.x) - 0.5,
1199
+ y: Math.min(from.y, to.y) - 0.5,
1200
+ w: Math.abs(to.x - from.x) + 1,
1201
+ h: Math.abs(to.y - from.y) + 1
1202
+ },
1203
+ "axis",
1204
+ owner,
1205
+ "strategyZoneBoundary"
1206
+ );
1207
+ }
1208
+ }
1209
+ function smoothClosedZonePath(points) {
1210
+ if (points.length < 3) return polygonPath(points);
1211
+ let segments = smoothClosedZoneSegments(points);
1212
+ return `M${fmtPathNumber(points[0].x)} ${fmtPathNumber(points[0].y)}` + segments.map(
1213
+ (segment) => `C${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.to.x)} ${fmtPathNumber(segment.to.y)}`
1214
+ ).join("") + "Z";
1215
+ }
1216
+ function smoothClosedZoneSegments(points) {
1217
+ let cyclic = [points[points.length - 1], ...points, points[0], points[1]], xSeries = cyclic.map((point, index) => ({ x: index - 1, y: point.x })), ySeries = cyclic.map((point, index) => ({ x: index - 1, y: point.y })), xSegments = monotoneSegments(xSeries).slice(1, points.length + 1), ySegments = monotoneSegments(ySeries).slice(1, points.length + 1);
1218
+ return xSegments.map((segment, index) => {
1219
+ let ySegment = ySegments[index];
1220
+ return {
1221
+ from: { x: segment.from.y, y: ySegment.from.y },
1222
+ c1: { x: segment.c1.y, y: ySegment.c1.y },
1223
+ c2: { x: segment.c2.y, y: ySegment.c2.y },
1224
+ to: { x: segment.to.y, y: ySegment.to.y }
1225
+ };
1226
+ });
1227
+ }
1228
+
1229
+ // src/core/charts/scatter/domain.ts
1230
+ function scatterFormatter(options, format = options.format) {
1231
+ let decimalsOf = options.valueAxis?.log ? (v) => v !== 0 && Math.abs(v) < 1 ? Math.max(1, neededDecimals(v, 1 - Math.floor(Math.log10(Math.abs(v))))) : autoDecimals(v) : autoDecimals, formatValue = format ? formatterFromExample(format, options.locale?.language) : (v) => formatAutomaticNumber(v, { locale: options.locale?.language, decimals: decimalsOf(v) }), formattedValues = /* @__PURE__ */ new Map();
1232
+ return (value) => {
1233
+ let text = formattedValues.get(value);
1234
+ return text === void 0 && (text = formatValue(value), formattedValues.set(value, text)), text;
1235
+ };
1236
+ }
1237
+ var MAX_DISCLOSED_DECIMALS = 20;
1238
+ function plainNumberSpec(locale) {
1239
+ return {
1240
+ decimals: 0,
1241
+ locale,
1242
+ thousandsSep: ",",
1243
+ decimalSep: ".",
1244
+ magnitude: "none",
1245
+ prefix: "",
1246
+ suffix: "",
1247
+ negative: "minus",
1248
+ signed: !1
1249
+ };
1250
+ }
1251
+ function discloseNumber(raw, spec, authoredFormat) {
1252
+ let scaled = Math.abs(raw / MAGNITUDE_DIVISOR[spec.magnitude]), base = authoredFormat ? spec.decimals : autoDecimals(raw), decimals = base;
1253
+ for (; decimals < MAX_DISCLOSED_DECIMALS && Number(scaled.toFixed(decimals)) !== scaled; )
1254
+ decimals += 1;
1255
+ let exact = Number(scaled.toFixed(decimals)) === scaled, applied = { ...spec, decimals: exact ? decimals : base }, value = exact ? raw : roundedNumber(raw, applied);
1256
+ return { value, text: formatWithSpec(value, applied), exact };
1257
+ }
1258
+ function resolveScatterEnv(options, warnings) {
1259
+ if (options.zones && options.quadrants)
1260
+ throw new NormalizeError(
1261
+ "zones-quadrants-conflict",
1262
+ "options.zones",
1263
+ "scatter strategy zones and quadrants are mutually exclusive"
1264
+ );
1265
+ breakUnsupported("scatter", options, warnings);
1266
+ let theme = chartTheme(options), paletteRamp = chartPalette(theme, options.palette, warnings), size = resolveSize(options.size), measure = options.measure ?? defaultMeasurer, fmt = scatterFormatter(options), axisFormat = { x: options.axisFormat?.x ?? options.format, y: options.axisFormat?.y ?? options.format }, axisFmt = {
1267
+ x: options.axisFormat?.x ? scatterFormatter(options, axisFormat.x) : fmt,
1268
+ y: options.axisFormat?.y ? scatterFormatter(options, axisFormat.y) : fmt
1269
+ }, countSpec = plainNumberSpec(options.locale?.language), axisSpecOf = (format) => format ? exampleSpec(format, options.locale?.language) : countSpec, axisSpec = { x: axisSpecOf(axisFormat.x), y: axisSpecOf(axisFormat.y) };
1270
+ return {
1271
+ options,
1272
+ theme,
1273
+ palette: paletteRamp ? options.palette : void 0,
1274
+ size,
1275
+ measure,
1276
+ fmt,
1277
+ axisFmt,
1278
+ axisSpec,
1279
+ discloseCut: (raw, axis) => discloseNumber(raw, axisSpec[axis], axisFormat[axis] !== void 0),
1280
+ discloseCount: (raw) => discloseNumber(raw, countSpec, !1),
1281
+ highlights: new Set(resolveHighlight(options.highlight)),
1282
+ va: options.valueAxis ?? {},
1283
+ log: logAxesOf(options.valueAxis?.log)
1284
+ };
1285
+ }
1286
+ function normalizePoint(raw, i, seenIds, groupMap, warnings, hasAuthoredLabels) {
1287
+ if (!raw?.id) throw new NormalizeError("missing-id", `points[${i}]`, "point requires an id");
1288
+ if (seenIds.has(raw.id))
1289
+ throw new NormalizeError("duplicate-id", `points[${raw.id}]`, `duplicate point id '${raw.id}'`);
1290
+ seenIds.add(raw.id);
1291
+ let path = `points[${raw.id}]`, xCell = normalizeCell(raw.x, `${path}.x`), yCell = normalizeCell(raw.y, `${path}.y`);
1292
+ if (xCell !== null && isDateCell(xCell) || yCell !== null && isDateCell(yCell))
1293
+ return warnings.push({
1294
+ code: "date-axis-unsupported",
1295
+ severity: "warn",
1296
+ message: `point '${raw.id}': date cells on scatter axes are not supported in v1 \u2014 point dropped`,
1297
+ owner: { pointId: raw.id }
1298
+ }), null;
1299
+ for (let [axis, cell] of [["x", xCell], ["y", yCell]])
1300
+ cellMeta(cell)?.label !== void 0 && warnings.push({
1301
+ code: "cell-label-unsupported",
1302
+ severity: "warn",
1303
+ message: `point '${raw.id}': ${axis}.label is ignored \u2014 a scatter point's drawn label is points[].label`,
1304
+ owner: { pointId: raw.id },
1305
+ suggest: `set label on the point itself: { id: '${raw.id}', label: '\u2026', ${axis}: \u2026 }`
1306
+ });
1307
+ let xv = cellValue(xCell), yv = cellValue(yCell);
1308
+ if (xv === null || yv === null)
1309
+ return warnings.push({
1310
+ code: "missing-value",
1311
+ severity: "info",
1312
+ message: `point '${raw.id}': missing x or y \u2014 point dropped`,
1313
+ owner: { pointId: raw.id }
1314
+ }), null;
1315
+ raw.group !== void 0 && !groupMap.has(raw.group) && groupMap.set(raw.group, { id: raw.group, label: raw.group, idx: groupMap.size });
1316
+ let sizeVal = raw.size ?? null;
1317
+ sizeVal !== null && (!Number.isFinite(sizeVal) || sizeVal < 0) && (warnings.push({
1318
+ code: "size-invalid",
1319
+ severity: "warn",
1320
+ message: `point '${raw.id}': size ${sizeVal} is not a non-negative number \u2014 treated as 0`,
1321
+ owner: { pointId: raw.id }
1322
+ }), sizeVal = 0);
1323
+ let sizeInvalid = raw.size !== void 0 && raw.size !== null && (!Number.isFinite(raw.size) || raw.size < 0), group = raw.group !== void 0 ? groupMap.get(raw.group) : void 0;
1324
+ return {
1325
+ id: raw.id,
1326
+ group: raw.group,
1327
+ label: raw.label ?? (hasAuthoredLabels ? "" : raw.id),
1328
+ x: xv,
1329
+ y: yv,
1330
+ ...isPctCell(yCell) ? { yIsPct: !0 } : {},
1331
+ size: sizeVal,
1332
+ ...sizeInvalid ? { sizeInvalid: !0 } : {},
1333
+ fill: raw.fill,
1334
+ marker: raw.marker ?? group?.marker ?? "circle",
1335
+ scenario: normalizeScenario(raw.scenario, `${path}.scenario`),
1336
+ count: raw.count ?? null,
1337
+ idx: i
1338
+ };
1339
+ }
1340
+ function normalizeScatterData(data, warnings) {
1341
+ if (!data || !Array.isArray(data.points) || data.points.length === 0)
1342
+ throw new NormalizeError("empty-data", "points", "scatter requires at least one point");
1343
+ let groupMap = /* @__PURE__ */ new Map();
1344
+ (data.groups ?? []).forEach((g, i) => {
1345
+ if (!g?.id) throw new NormalizeError("missing-id", `groups[${i}]`, "group requires an id");
1346
+ if (groupMap.has(g.id))
1347
+ throw new NormalizeError("duplicate-id", `groups[${g.id}]`, `duplicate group id '${g.id}'`);
1348
+ groupMap.set(g.id, {
1349
+ id: g.id,
1350
+ label: g.label ?? g.id,
1351
+ colorRole: g.colorRole,
1352
+ marker: g.marker,
1353
+ idx: groupMap.size
1354
+ });
1355
+ });
1356
+ let seenIds = /* @__PURE__ */ new Set(), plottable = [], hasAuthoredLabels = data.points.some((point) => typeof point?.label == "string"), noPosition = [];
1357
+ if (data.points.forEach((raw, i) => {
1358
+ let p = normalizePoint(raw, i, seenIds, groupMap, warnings, hasAuthoredLabels);
1359
+ p ? plottable.push(p) : raw?.id !== void 0 && (cellValue(normalizeCell(raw.x, `points[${raw.id}].x`)) === null || cellValue(normalizeCell(raw.y, `points[${raw.id}].y`)) === null) && noPosition.push(raw.label ?? raw.id);
1360
+ }), plottable.length === 0)
1361
+ throw new NormalizeError("empty-data", "points", "scatter has no plottable points (all x/y missing)");
1362
+ let declared = new Set((data.groups ?? []).map((g) => g.id)), undeclared = [...groupMap.keys()].filter((id) => !declared.has(id));
1363
+ return declared.size > 0 && undeclared.length > 0 && warnings.push({
1364
+ code: "group-undeclared",
1365
+ severity: "warn",
1366
+ message: `points name group${undeclared.length === 1 ? "" : "s"} ${undeclared.map((id) => `'${id}'`).join(", ")} missing from data.groups; each is keyed under its id`,
1367
+ suggest: "declare the group in data.groups, or correct the point's group id"
1368
+ }), { groupMap, plottable, noPosition };
1369
+ }
1370
+ function pointExtents(pts) {
1371
+ let xMin = 1 / 0, xMax = -1 / 0, yMin = 1 / 0, yMax = -1 / 0;
1372
+ for (let p of pts)
1373
+ xMin = Math.min(xMin, p.x), xMax = Math.max(xMax, p.x), yMin = Math.min(yMin, p.y), yMax = Math.max(yMax, p.y);
1374
+ return { xMin, xMax, yMin, yMax };
1375
+ }
1376
+ function scatterAxisDomain(input, env, warnings) {
1377
+ let { options, va } = env, fmt = env.axisFmt.y, { clamp, valueLines } = input, domainXMin = input.xMin, domainXMax = input.xMax, domainYMin = input.yMin, domainYMax = input.yMax;
1378
+ if (options.zones?.regions)
1379
+ for (let region of options.zones.regions)
1380
+ for (let point of region.points)
1381
+ domainXMin = Math.min(domainXMin, point.x), domainXMax = Math.max(domainXMax, point.x), domainYMin = Math.min(domainYMin, point.y), domainYMax = Math.max(domainYMax, point.y);
1382
+ let padFrac = input.bubbleMode ? 0.08 : 0.05, padOf = (lo, hi) => {
1383
+ let span = hi - lo;
1384
+ return span > 0 ? span * padFrac : Math.abs(hi) > 0 ? Math.abs(hi) * padFrac : 1;
1385
+ }, pyBound = padOf(...clampSeed(clamp, "y", domainYMin, domainYMax));
1386
+ [domainYMin, domainYMax] = withValueLines(valueLines, domainYMin, domainYMax), [domainXMin, domainXMax] = clampSeed(clamp, "x", domainXMin, domainXMax), [domainYMin, domainYMax] = clampSeed(clamp, "y", domainYMin, domainYMax);
1387
+ let px = padOf(domainXMin, domainXMax), py = padOf(domainYMin, domainYMax), [dxLo, dxHi] = env.log.x ? logDomain(domainXMin, domainXMax) : niceDomain(domainXMin - px, domainXMax + px, 5, {
1388
+ dataExtent: [domainXMin, domainXMax],
1389
+ preserveDataSideOfZero: !0,
1390
+ maxWasteFraction: 0.15,
1391
+ maxTotalWasteFraction: 0.15
1392
+ }), [dyLo, dyHi] = env.log.y ? logDomain(domainYMin, domainYMax) : niceDomain(domainYMin - py, domainYMax + py, 5, {
1393
+ dataExtent: [domainYMin, domainYMax],
1394
+ preserveDataSideOfZero: !0,
1395
+ maxWasteFraction: 0.15,
1396
+ maxTotalWasteFraction: 0.2
1397
+ });
1398
+ [dyLo, dyHi] = applyAxisBounds([dyLo, dyHi], [env.log.y ? input.yMin : input.yMin - pyBound, env.log.y ? input.yMax : input.yMax + pyBound], va, warnings), va.includeZero && (dyLo = Math.min(dyLo, 0), dyHi = Math.max(dyHi, 0));
1399
+ let ticks, evenGrid;
1400
+ if (plainDotAxes(input, env)) {
1401
+ let ax = tickAlignedAxis(domainXMin, domainXMax), ay = tickAlignedAxis(va.includeZero ? Math.min(domainYMin, 0) : domainYMin, va.includeZero ? Math.max(domainYMax, 0) : domainYMax);
1402
+ ax && ay && ([dxLo, dxHi] = ax.domain, [dyLo, dyHi] = ay.domain, ticks = { x: ax.ticks, y: ay.ticks });
1403
+ } else if (gridAxes(input, env)) {
1404
+ let grid = options.zones.grid, ex = evenGridDomain(grid.x, input.xMin, input.xMax), ey = evenGridDomain(grid.y, input.yMin, input.yMax);
1405
+ ex && ([dxLo, dxHi] = ex), ey && ([dyLo, dyHi] = ey), evenGrid = { x: ex !== void 0, y: ey !== void 0 };
1406
+ } else if (quadrantAxes(input, env)) {
1407
+ let pad = input.bubbleMode ? BUBBLE_TICK_END_PAD : TICK_END_PAD, from = (lo, hi) => lo >= 0 && lo < ZERO_START_SHARE * hi ? 0 : lo, ax = tickAlignedAxis(from(domainXMin, domainXMax), domainXMax, pad), ay = tickAlignedAxis(from(domainYMin, domainYMax), domainYMax, pad);
1408
+ ax && ay && ([dxLo, dxHi] = ax.domain, [dyLo, dyHi] = ay.domain, ticks = { x: ax.ticks, y: ay.ticks });
1409
+ }
1410
+ [dxLo, dxHi] = numericViewportRange(options.viewDomain?.x, [dxLo, dxHi]), [dyLo, dyHi] = numericViewportRange(options.viewDomain?.y, [dyLo, dyHi]), clamp?.edges.x.min !== void 0 && (dxLo = clamp.edges.x.min), clamp?.edges.x.max !== void 0 && (dxHi = clamp.edges.x.max), clamp?.edges.y.min !== void 0 && (dyLo = clamp.edges.y.min), clamp?.edges.y.max !== void 0 && (dyHi = clamp.edges.y.max);
1411
+ let viewY = options.viewDomain?.y ? [dyLo, dyHi] : void 0;
1412
+ refuseValueLinesOutsideAxis(valueLines, [dyLo, dyHi], viewY ? {} : { min: va.min, max: va.max }, fmt);
1413
+ let annotations = valueLinesInView(options.annotations, valueLines, viewY, warnings, fmt);
1414
+ return { dx: [dxLo, dxHi], dy: [dyLo, dyHi], annotations, ...ticks ? { ticks } : {}, ...evenGrid ? { evenGrid } : {} };
1415
+ }
1416
+ function plainDotAxes(input, env) {
1417
+ let { options, va } = env;
1418
+ return !input.bubbleMode && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && options.zones === void 0 && options.quadrants === void 0 && options.qualitativeAxes !== !0;
1419
+ }
1420
+ function quadrantAxes(input, env) {
1421
+ let { options, va } = env;
1422
+ return options.quadrants !== void 0 && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && !va.reverse && options.qualitativeAxes !== !0;
1423
+ }
1424
+ function gridAxes(input, env) {
1425
+ let { options, va } = env;
1426
+ return options.zones !== void 0 && "grid" in options.zones && options.zones.grid !== void 0 && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && !va.reverse;
1427
+ }
1428
+ var EVEN_CUT_TOLERANCE = 0.02;
1429
+ function evenGridDomain(cuts, dataLo, dataHi) {
1430
+ if (cuts.length === 0) return;
1431
+ let sorted = [...cuts].sort((a, b) => a - b), steps = sorted.slice(1).map((c, i) => c - sorted[i]), step = steps.length ? steps.reduce((a, b) => a + b, 0) / steps.length : void 0;
1432
+ if (step === void 0 || !(step > 0) || steps.some((d) => Math.abs(d - step) > EVEN_CUT_TOLERANCE * step)) return;
1433
+ let unit = 10 ** Math.floor(Math.log10(step)), snap = (v) => {
1434
+ let round = Math.round(v / unit) * unit;
1435
+ return Math.abs(round - v) <= EVEN_CUT_TOLERANCE * step ? Number(round.toPrecision(12)) : v;
1436
+ }, lo = snap(sorted[0] - step), hi = snap(sorted[sorted.length - 1] + step);
1437
+ return dataLo >= lo && dataHi <= hi ? [lo, hi] : void 0;
1438
+ }
1439
+ var ZERO_START_SHARE = 0.2, BUBBLE_TICK_END_PAD = 0.08, TICK_STEP_MANTISSAS = [1, 2, 5], TICK_STEP_COST = 0.01, TICK_END_PAD = 0.03;
1440
+ function tickAlignedAxis(lo, hi, padShare = TICK_END_PAD) {
1441
+ let span = hi - lo;
1442
+ if (!(span > 0) || !Number.isFinite(span)) return;
1443
+ let pad = span * padShare, a = lo >= 0 ? Math.max(0, lo - pad) : lo - pad, b = hi <= 0 ? Math.min(0, hi + pad) : hi + pad, decade = Math.floor(Math.log10(span)), best;
1444
+ for (let e = decade - 2; e <= decade + 1; e++)
1445
+ for (let m of TICK_STEP_MANTISSAS) {
1446
+ let step = m * 10 ** e, sLo = Math.floor(a / step + 1e-9) * step, sHi = Math.ceil(b / step - 1e-9) * step, steps = Math.round((sHi - sLo) / step);
1447
+ if (steps < 5 || steps > 10) continue;
1448
+ let waste = 1 - span / (sHi - sLo) + TICK_STEP_COST * (steps - 5);
1449
+ (!best || waste < best.waste - 1e-9 || Math.abs(waste - best.waste) <= 1e-9 && step > best.step) && (best = { lo: sLo, hi: sHi, step, waste });
1450
+ }
1451
+ if (!best) return;
1452
+ let digits = Math.max(0, -Math.floor(Math.log10(best.step)) + 2), round = (v) => Number(v.toFixed(digits)), count = Math.round((best.hi - best.lo) / best.step);
1453
+ return { domain: [round(best.lo), round(best.hi)], ticks: Array.from({ length: count + 1 }, (_, i) => round(best.lo + i * best.step)) };
1454
+ }
1455
+ function zeroBaselineNotes(dx, dy, fmt, log, options) {
1456
+ let [dxLo, dxHi] = dx, [dyLo, dyHi] = dy, baselineNotes = [], horizontalNonZero = !log.x && (dxLo > 0 || dxHi < 0), verticalNonZero = !log.y && (dyLo > 0 || dyHi < 0);
1457
+ if (horizontalNonZero || verticalNonZero) {
1458
+ let axes = [
1459
+ ...horizontalNonZero ? [`x ${numberRange(fmt.x(dxLo), fmt.x(dxHi))}`] : [],
1460
+ ...verticalNonZero ? [`y ${numberRange(fmt.y(dyLo), fmt.y(dyHi))}`] : []
1461
+ ];
1462
+ baselineNotes.push(disclosureNote(chartString(options, "axesNonzero", { v1: axes.join(", ") })));
1463
+ }
1464
+ return baselineNotes;
1465
+ }
1466
+ function refuseZoneThresholdsOutsideDomain(options, dx, dy) {
1467
+ if (options.zones?.grid) {
1468
+ for (let [axis, thresholds, lo, hi] of [
1469
+ ["x", options.zones.grid.x, dx[0], dx[1]],
1470
+ ["y", options.zones.grid.y, dy[0], dy[1]]
1471
+ ])
1472
+ for (let threshold of thresholds)
1473
+ if (threshold <= lo || threshold >= hi)
1474
+ throw new NormalizeError(
1475
+ "zone-threshold-outside-domain",
1476
+ `options.zones.grid.${axis}`,
1477
+ `strategy-zone threshold ${threshold} must fall strictly inside the plotted ${axis} domain ${lo} to ${hi}`
1478
+ );
1479
+ }
1480
+ }
1481
+ function resolveScatterDomain(data, env, warnings) {
1482
+ let { options } = env, { groupMap, plottable, noPosition } = normalizeScatterData(data, warnings), { kept: pts, record: dropped } = applyMinCount(plottable, options.minCount, env.discloseCount, options);
1483
+ refuseNonPositiveOnLog(options, env.log, pts);
1484
+ let clamp = planScatterClamp(
1485
+ pts,
1486
+ {
1487
+ options,
1488
+ clamp: options.valueAxis?.clamp,
1489
+ axisTitles: options.axisTitles ?? {},
1490
+ valueAxisBounds: { min: options.valueAxis?.min, max: options.valueAxis?.max },
1491
+ hasViewDomain: options.viewDomain !== void 0
1492
+ },
1493
+ env.discloseCut
1494
+ ), meanY = pts.reduce((a, p) => a + p.y, 0) / pts.length, valueLines = drawnValueLines(options.annotations, meanY);
1495
+ refuseClampedValueLines(clamp, valueLines, env.axisFmt.y);
1496
+ let noPositionNote = noPosition.length === 0 ? void 0 : disclosureNote(chartString(options, "noPositionNote", { v1: chartString(options, "pointsCount", { v1: noPosition.length, v2: noPosition.length === 1 ? "" : "s" }), v2: noPosition.join(", ") })), omitted = [...dropped ? [dropped.note] : [], ...noPositionNote ? [noPositionNote] : []], derivedNotes = [...omitted, ...clamp?.notes ?? []], keptGroups = new Set(pts.map((p) => p.group)), emptied = new Set(dropped ? plottable.map((p) => p.group).filter((g) => !keptGroups.has(g)) : []), shownGroups = [...groupMap.values()].filter((g) => !emptied.has(g.id)), { xMin, xMax, yMin, yMax } = pointExtents(pts), bubbleMode = pts.some((p) => p.size !== null), sizeMax = bubbleMode ? pts.reduce((a, p) => Math.max(a, p.size ?? 0), 0) : void 0, sizeless = bubbleMode ? pts.filter((p) => p.size === null) : [];
1497
+ if (sizeless.length > 0 && warnings.push({
1498
+ code: "size-missing",
1499
+ severity: "warn",
1500
+ message: `bubble chart: point${sizeless.length === 1 ? "" : "s"} ${sizeless.map((p) => `'${p.id}'`).join(", ")} carr${sizeless.length === 1 ? "ies" : "y"} no size and ${sizeless.length === 1 ? "is" : "are"} drawn at the smallest bubble, which reads as a small value`,
1501
+ owner: { pointId: sizeless[0].id },
1502
+ suggest: "give every point a size, or drop size from all points for a plain scatter"
1503
+ }), refuseSizeLegend(options, sizeMax, warnings), validateStrategyZones(options), refuseClampedRegions(clamp, options.zones?.regions), options.zones && options.valueAxis?.reverse)
1504
+ throw new NormalizeError(
1505
+ "zone-scale-unsupported",
1506
+ "options.zones",
1507
+ "strategy zones require non-reversed scatter axes"
1508
+ );
1509
+ let axes = scatterAxisDomain({ xMin, xMax, yMin, yMax, bubbleMode, clamp, valueLines }, env, warnings), baselineNotes = zeroBaselineNotes(axes.dx, axes.dy, env.axisFmt, env.log, env.options);
1510
+ refuseZoneThresholdsOutsideDomain(options, axes.dx, axes.dy);
1511
+ let quadrants = deriveQuadrants(pts, bubbleMode, axes.dx, axes.dy, env, warnings);
1512
+ refuseClampedQuadrants(clamp, pts, quadrants.derived);
1513
+ let q = quadrants.derived, ticks = axes.ticks && q ? {
1514
+ x: withCutTick(axes.ticks.x, quadrants.drawX && q.xSource === "declared" ? q.x : void 0),
1515
+ y: withCutTick(axes.ticks.y, quadrants.drawY && q.ySource === "declared" ? q.y : void 0)
1516
+ } : axes.ticks, drawn = pts.filter((p) => inView(options, axes.dx, axes.dy, p)), trends = fitScatterTrends(env, drawn, shownGroups.map((g) => g.id), warnings), frontier = planFrontier(env, drawn, warnings);
1517
+ return {
1518
+ pts,
1519
+ groups: groupMap,
1520
+ shownGroups,
1521
+ dropped,
1522
+ clamp,
1523
+ meanY,
1524
+ xMin,
1525
+ xMax,
1526
+ yMin,
1527
+ yMax,
1528
+ bubbleMode,
1529
+ sizeMax,
1530
+ dx: axes.dx,
1531
+ dy: axes.dy,
1532
+ ...ticks ? { ticks } : {},
1533
+ ...axes.evenGrid ? { evenGrid: axes.evenGrid } : {},
1534
+ annotations: axes.annotations,
1535
+ baselineNotes,
1536
+ derivedNotes,
1537
+ omitted,
1538
+ quadrants,
1539
+ trends,
1540
+ ...frontier ? { frontier } : {}
1541
+ };
1542
+ }
1543
+ function withCutTick(ticks, cut) {
1544
+ return cut === void 0 || ticks.some((t) => Math.abs(t - cut) < 1e-9) ? ticks : [...ticks, cut].sort((a, b) => a - b);
1545
+ }
1546
+ function refuseSizeLegend(options, sizeMax, warnings) {
1547
+ if (options.sizeLegend !== !1) {
1548
+ if (sizeMax === void 0 || sizeMax <= 0) {
1549
+ if (!options.sizeLegend) return;
1550
+ throw new NormalizeError(
1551
+ "size-legend-without-sizes",
1552
+ "options.sizeLegend",
1553
+ "options.sizeLegend keys bubble sizes, and no point carries a positive size",
1554
+ "add size to the points, or drop options.sizeLegend",
1555
+ void 0,
1556
+ ["options", "sizeLegend"]
1557
+ );
1558
+ }
1559
+ (typeof options.sizeLegend != "object" || !options.sizeLegend.label) && warnings.push({
1560
+ code: "size-legend-unnamed",
1561
+ severity: "info",
1562
+ message: "the size key shows bubble sizes but not what they measure",
1563
+ suggest: "name the measure with sizeLegend.label, e.g. { label: 'Revenue, \u20ACbn' }",
1564
+ field: ["options", "sizeLegend"]
1565
+ });
1566
+ }
1567
+ }
1568
+ function inView(options, dx, dy, p) {
1569
+ return !options.viewDomain || p.x >= dx[0] && p.x <= dx[1] && p.y >= dy[0] && p.y <= dy[1];
1570
+ }
1571
+
1572
+ // src/core/charts/scatter/nameReading.ts
1573
+ function nameReadsAsOwn(rect, leader, own, marks, texts = [], fontSize) {
1574
+ return leader !== void 0 ? !leaderCrosses(leader, own, marks, texts) : nearestIsOwn(inkBox(rect, fontSize), own, marks);
1575
+ }
1576
+
1577
+ // src/core/charts/scatter/plot.ts
1578
+ var DOT_R = 3.5, DOT_R_SPARSE = 4.5, DOT_R_WIDE = 5.5, WIDE_CARD = 720, DOT_DENSE_COUNT = 20, KEY_DOT_R = 5, MIN_R = 2, MAX_R_FRACTION = 0.065, MAX_R_FRACTION_NARROW = 0.055, SPARSE_BUBBLES = 8, SPARSE_R_FLOOR = 17, SPARSE_R_CAP = 0.08, SPARSE_R_CAP_NARROW_GRID = 0.06, NARROW_PLOT = 420, GRID_ROW_PAD = 10, Y_BAND_SHARE = 0.2;
1579
+ function bandLines(labels, font, measure, maxW) {
1580
+ if (labels.every((label) => measure(label, font).width <= maxW)) return labels.map((label) => [label]);
1581
+ let word = maxOf(labels.flatMap((label) => label.split(/\s+/)).map((w) => measure(w, font).width));
1582
+ return labels.map((label) => {
1583
+ let wrapped = wrapText(label, font, Math.max(word, maxW), 2, measure);
1584
+ return wrapped.truncated ? [label] : wrapped.lines;
1585
+ });
1586
+ }
1587
+ var CAPTION_TRACKING = 0.5, AXIS_TITLE_RESERVE = 2;
1588
+ function yTitleBand(title, ends, titleFont, tickFont, measure) {
1589
+ let tickH = Math.max(...ends.map((text) => measure(text, tickFont).height));
1590
+ return measure(title, titleFont).height + tickH / 2 + AXIS_TITLE_RESERVE;
1591
+ }
1592
+ function scatterDotRadius(env, domain) {
1593
+ return domain.ticks && domain.pts.length <= DOT_DENSE_COUNT ? env.size.width >= WIDE_CARD ? DOT_R_WIDE : DOT_R_SPARSE : DOT_R;
1594
+ }
1595
+ var LARGE_MARK = 12;
1596
+ function markerSide(marker, r) {
1597
+ return marker === "circle" ? 2 * r : marker === "square" ? 1.8 * r : marker === "triangle" ? 2.2 * r : marker === "diamond" ? 2.6 * r : 0;
1598
+ }
1599
+ function scatterPaints(env, groups, pts = [], dotR) {
1600
+ let { theme, palette, highlights } = env, large = (p) => dotR !== void 0 && p.scenario !== "PL" && p.scenario !== "FC" && markerSide(p.marker, dotR) >= LARGE_MARK, groupLarge = /* @__PURE__ */ new Map();
1601
+ for (let gid of groups.keys()) {
1602
+ let drawn = pts.filter((p) => p.group === gid && p.marker !== "none");
1603
+ groupLarge.set(gid, drawn.length > 0 && drawn.every(large));
1604
+ }
1605
+ let rolePaint = (gid, fill) => {
1606
+ let g = groups.get(gid);
1607
+ return g.colorRole === "others" ? mutedMarkPaint() : g.colorRole ? markRolePaint(g.colorRole, fill) : void 0;
1608
+ }, group = (gid) => {
1609
+ if (gid === void 0) return seriesPaint(0, palette);
1610
+ let g = groups.get(gid);
1611
+ return rolePaint(gid, groupLarge.get(gid) ?? !1) ?? seriesPaint(g.idx, palette);
1612
+ }, highlighted = (p) => highlights.has(p.id) || p.group !== void 0 && highlights.has(p.group), point = (p) => p.fill ? { css: p.fill } : p.group !== void 0 ? (large(p) ? rolePaint(p.group, !0) : void 0) ?? group(p.group) : !p.scenario && groups.size > 0 ? { token: "neutralMark" } : p.scenario ? seriesPaint(0, palette, p.scenario) : group(p.group), hollow = (p) => p.scenario === "PL" || p.scenario === "FC", insideFill = (p) => hollow(p) ? theme.color.background : paintColor(theme, point(p)), recipe = { kind: "focus-apart", apartFrom: [...new Map(pts.map((p) => [JSON.stringify(point(p)), point(p)])).values()] }, ring = { token: paintColor(theme, { token: "ink", theme: recipe }) === theme.color.ink ? "ink" : "focus", theme: recipe };
1613
+ return { group, point, hollow, insideFill, highlighted, ring };
1614
+ }
1615
+ function valueLineLabelRight(env, domain) {
1616
+ let format = env.options.axisFormat?.y ?? env.options.format, fmt = format ? formatterFromExample(format, env.options.locale?.language) : (v) => formatAutomaticNumber(v), font = { family: env.theme.type.family, ...env.theme.type.label }, width = 0;
1617
+ for (let line of drawnValueLines(domain.annotations, domain.meanY)) {
1618
+ let ann = domain.annotations[line.index];
1619
+ if (ann.kind !== "valueLine" || ann.label === !1 || (ann.side ?? "right") !== "right") continue;
1620
+ let text = ann.label ?? (line.isMean ? `\xD8 ${fmt(line.value)}` : fmt(line.value));
1621
+ text && (width = Math.max(width, env.measure(text, font).width + 8));
1622
+ }
1623
+ return width;
1624
+ }
1625
+ function groupKeyShape(domain, gid) {
1626
+ let members = domain.pts.filter((p) => p.group === gid), marker = groupMarker(domain, gid), hollow = members.length > 0 && members.every((p) => p.scenario === "PL" || p.scenario === "FC");
1627
+ return markerKeyShape(marker, hollow);
1628
+ }
1629
+ var groupMarker = (domain, gid) => {
1630
+ let own = domain.groups.get(gid)?.marker;
1631
+ if (own !== void 0 && own !== "none") return own;
1632
+ let members = domain.pts.filter((p) => p.group === gid);
1633
+ return members.length === 0 ? own ?? "circle" : members.find((p) => p.marker !== "none")?.marker ?? "none";
1634
+ };
1635
+ function markerKeyShape(marker, hollow) {
1636
+ return marker === "circle" ? { key: "marker", radius: KEY_DOT_R } : marker === "triangle" ? { key: "triangle" } : marker === "diamond" ? { key: "diamond" } : hollow ? { hollow: !0 } : {};
1637
+ }
1638
+ function pointKeyItems(domain, paints) {
1639
+ let drawn = domain.pts.filter((p) => p.marker !== "none"), odd = drawn.filter((p) => p.group !== void 0 && p.marker !== (domain.groups.get(p.group)?.marker ?? "circle")), loose = drawn.filter((p) => p.group === void 0), item = (p, label) => ({
1640
+ id: `point:${p.id}`,
1641
+ label,
1642
+ paint: paints.point(p),
1643
+ ...markerKeyShape(p.marker, paints.hollow(p))
1644
+ });
1645
+ return [
1646
+ ...odd.map((p) => item(p, `${domain.groups.get(p.group)?.label ?? p.group}: ${p.label}`)),
1647
+ ...loose.length <= 3 ? loose.map((p) => item(p, p.label)) : [item(loose[0], `Without a group: ${loose.map((p) => p.label).join(", ")}`)]
1648
+ ];
1649
+ }
1650
+ var UNPINNED_PLOT_BASE = 175, UNPINNED_PLOT_SHARE = 0.225, UNPINNED_PLOT_CAP = 280;
1651
+ function solveScatterFrame(env, domain, paints, keyItems = [], lateNotes = [], hiddenNote) {
1652
+ let { options, theme, size } = env, tokenMargin = canvasMargin(theme, size.width), margin = {
1653
+ ...tokenMargin,
1654
+ right: Math.max(tokenMargin.right, valueLineLabelRight(env, domain)),
1655
+ ...options.margin
1656
+ }, legendInput, named = options.legend !== void 0, keyedGroups = domain.shownGroups.filter((g) => groupMarker(domain, g.id) !== "none"), groupsKeyed = named && options.legend !== "none" && keyedGroups.length > 0;
1657
+ if (options.legend !== "none" && (groupsKeyed || keyItems.length > 0)) {
1658
+ let legendOpts = (named ? normalizeLegendOption(options.legend) : void 0) ?? { position: "top" }, items = groupsKeyed ? [...keyedGroups.map((g) => ({
1659
+ id: g.id,
1660
+ label: g.label,
1661
+ paint: paints.group(g.id),
1662
+ ...groupKeyShape(domain, g.id)
1663
+ })), ...pointKeyItems(domain, paints)] : [];
1664
+ if (legendOpts.order) {
1665
+ let oi = (id) => {
1666
+ let k = legendOpts.order.indexOf(id);
1667
+ return k === -1 ? Number.MAX_SAFE_INTEGER : k;
1668
+ };
1669
+ items = [...items].sort((a, b) => oi(a.id) - oi(b.id));
1670
+ }
1671
+ legendInput = { options: legendOpts, items: [...items, ...keyItems] };
1672
+ }
1673
+ let claims = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height });
1674
+ return { frame: solveFrame(
1675
+ {
1676
+ size,
1677
+ margin,
1678
+ ...frameTextOptions(options),
1679
+ footnotes: [
1680
+ ...options.methodNote === !0 ? [...domain.baselineNotes, ...domain.quadrants.notes] : [],
1681
+ ...domain.derivedNotes,
1682
+ ...lateNotes,
1683
+ ...hiddenNote?.footnotes ?? authoredNotes(options),
1684
+ ...hiddenNote?.line ?? []
1685
+ ],
1686
+ legend: legendInput,
1687
+ theme,
1688
+ measure: env.measure
1689
+ },
1690
+ claims
1691
+ ), claims };
1692
+ }
1693
+ var QUALITATIVE_GAP = 8;
1694
+ function qualitativeColumn(env, fonts, plotW) {
1695
+ let strings = env.options.strings, low = strings?.axisLow ?? "Lower", high = strings?.axisHigh ?? "Higher", bold = fonts.axisTitle, ends = Math.max(env.measure(low, fonts.tick).width, env.measure(high, fonts.tick).width), title = env.options.axisTitles?.y ?? "", width = Math.max(ends, Math.min(env.measure(title, bold).width, Math.max(ends, plotW * 0.1))), lines = title ? wrapText(title, bold, width, 4, env.measure).lines : [];
1696
+ return { width: Math.max(width, ...lines.map((line) => env.measure(line, bold).width)), lines, low, high };
1697
+ }
1698
+ function scatterFonts(theme) {
1699
+ return {
1700
+ tick: { family: theme.type.family, ...theme.type.axis },
1701
+ label: {
1702
+ family: theme.type.family,
1703
+ ...theme.type.label
1704
+ },
1705
+ // A quadrant caption names a REGION of the plot; a point label names one
1706
+ // unit. Set in the same face they were indistinguishable, and a reader counts
1707
+ // "Stars" as a sixth company. So the caption takes the repo's region-furniture
1708
+ // register — the same one band annotations already use (`annotate.ts`
1709
+ // uppercase at axis size) and table headers use (uppercase, regular, tracked):
1710
+ // uppercase, axis size, regular, tracked, muted ink. Four signals, each
1711
+ // legible on its own at 96 dpi, none of them a color a reader must decode.
1712
+ caption: {
1713
+ family: theme.type.family,
1714
+ ...theme.type.axis,
1715
+ weight: theme.type.axis.weight,
1716
+ letterSpacing: CAPTION_TRACKING
1717
+ },
1718
+ // Axis titles: the x title sits centred under the tick row, the y title
1719
+ // reads horizontally above the axis column (no rotated text on an exhibit).
1720
+ axisTitle: { family: theme.type.family, ...theme.type.axis }
1721
+ };
1722
+ }
1723
+ function scatterPlotArea(env, domain, frame, warnings) {
1724
+ let { options, theme, measure, va } = env, fmt = env.axisFmt.y, [dxLo, dxHi] = domain.dx, [dyLo, dyHi] = domain.dy, fonts = scatterFonts(theme), showAxes = va.show ?? !0, tickH = measure("0", fonts.tick).height, zoneGrid = options.zones && "grid" in options.zones ? options.zones.grid : void 0, banded = bandedAxes(env, domain), yBandLines = zoneGrid?.yLabels?.length ? bandLines(zoneGrid.yLabels, fonts.tick, measure, Y_BAND_SHARE * frame.plot.w) : void 0, yBandW = yBandLines ? maxOf(yBandLines.flat().map((line) => measure(line, fonts.tick).width)) + ZONE_BAND_GAP : 0, yFmt = env.log.y ? logSpecFormat(env.axisSpec.y) : fmt, axisTitles = options.axisTitles ?? {}, qualitative = showAxes && options.qualitativeAxes === !0, yAxisW = qualitative ? qualitativeColumn(env, fonts, frame.plot.w).width + QUALITATIVE_GAP : showAxes && !banded.y ? measureValueAxisWidth([dyLo, dyHi], yFmt, theme, measure, 5, env.log.y ? void 0 : env.axisSpec.y, env.log.y ? logTickTiers(dyLo, dyHi)[0] : void 0) : 0, xAxisH = showAxes && !banded.x ? tickH + 6 : 0, xTitleH = showAxes && axisTitles.x && !qualitative ? tickH + 4 : 0, yTitleH = showAxes && axisTitles.y && !qualitative ? banded.y ? measure(axisTitles.y, fonts.axisTitle).height + AXIS_TITLE_RESERVE : yTitleBand(axisTitles.y, ["0", yFmt(dyLo), yFmt(dyHi)], fonts.axisTitle, fonts.tick, measure) : 0;
1725
+ showAxes && (!axisTitles.x || !axisTitles.y) && warnings.push({
1726
+ code: "scatter-axis-untitled",
1727
+ severity: "warn",
1728
+ message: "scatter axes without titles: the reader has to guess which axis is which",
1729
+ suggest: "set axisTitles: { x: '...', y: '...' } (the subtitle measure names the pair, not the sides)"
1730
+ });
1731
+ for (let axis of ["x", "y"]) {
1732
+ let title = axisTitles[axis];
1733
+ !showAxes || !env.log[axis] || !title || /\blog/i.test(title) || warnings.push({
1734
+ code: "log-axis-unnamed",
1735
+ severity: "info",
1736
+ message: `the ${axis === "x" ? "horizontal" : "vertical"} axis is on a log scale and its title does not say so`,
1737
+ suggest: `add it to the title, e.g. axisTitles.${axis}: '${title}, log scale'`,
1738
+ field: ["options", "axisTitles", axis]
1739
+ });
1740
+ }
1741
+ let plotX = frame.plot.x + yBandW + yAxisW, plotW = Math.max(10, frame.plot.w - yBandW - yAxisW), x = (env.log.x ? logScale : linearScale)([dxLo, dxHi], [plotX, plotX + plotW]), xBounds = zoneGrid ? [dxLo, ...zoneGrid.x, dxHi] : [], xBandLines = zoneGrid?.xLabels?.length ? zoneGrid.xLabels.map((label, i) => bandLines([label], fonts.tick, measure, Math.abs(x(xBounds[i + 1] ?? dxHi) - x(xBounds[i] ?? dxLo)) - 2 * ZONE_BAND_GAP)[0]) : void 0, xBandH = xBandLines ? maxOf(xBandLines.map((lines) => lines.length)) * tickH + ZONE_BAND_GAP : 0, plot = {
1742
+ x: plotX,
1743
+ y: frame.plot.y + 8 + yTitleH,
1744
+ w: plotW,
1745
+ h: plotHeightAfter(frame, env.size.height, frame.plot.h - 8 - yTitleH - xAxisH - xTitleH - xBandH)
1746
+ }, yScale = env.log.y ? logScale : linearScale, y = va.reverse ? yScale([dyLo, dyHi], [plot.y, plot.y + plot.h]) : yScale([dyLo, dyHi], [plot.y + plot.h, plot.y]), labelH = measure("0", fonts.label).height, minPlot = Math.max(plotFloorRows(options) * labelH + 8, atHardMinimum(options) ? HARD_COMPACT_PLOT : 0);
1747
+ if (domain.quadrants.derived && options.quadrants?.labels) {
1748
+ let split = yScale([dyLo, dyHi], [0, 1])(domain.quadrants.derived.y), shares = [split, 1 - split].filter((share) => share > 0 && share < 1);
1749
+ shares.length && (minPlot = Math.max(
1750
+ minPlot,
1751
+ (2 * fonts.caption.size * (fonts.caption.lineHeight ?? 1.2) + 12 + labelH + 4) / Math.min(...shares)
1752
+ ));
1753
+ }
1754
+ if (zoneGrid) {
1755
+ let captionH = fonts.caption.size * (fonts.caption.lineHeight ?? 1.2);
1756
+ minPlot = Math.max(minPlot, (zoneGrid.y.length + 1) * (captionH + labelH + GRID_ROW_PAD));
1757
+ }
1758
+ let rawHeight = frame.plot.h - 8 - yTitleH - xAxisH - xTitleH - xBandH, wish = Math.min(UNPINNED_PLOT_CAP, Math.round(UNPINNED_PLOT_BASE + UNPINNED_PLOT_SHARE * plotW));
1759
+ options[TARGET_SIZE]?.fixed.height === !1 && panelTypeClass(options) === void 0 && rawHeight < wish && (minPlot = Math.max(minPlot, wish)), frame.frame.plotMinHeight = Math.max(
1760
+ frame.frame.plotMinHeight ?? 0,
1761
+ env.size.height + (frame.deficit ?? 0) + minPlot - rawHeight
1762
+ );
1763
+ let rFraction = plot.w < NARROW_PLOT ? MAX_R_FRACTION_NARROW : MAX_R_FRACTION, { bubbleMode, sizeMax } = domain, plotMin = Math.min(plot.w, plot.h), boxGrid = domain.quadrants.derived !== void 0 || zoneGrid !== void 0, cap = zoneGrid !== void 0 && plot.w < NARROW_PLOT ? SPARSE_R_CAP_NARROW_GRID : SPARSE_R_CAP, sparseFloor = bubbleMode && boxGrid && domain.pts.length <= SPARSE_BUBBLES ? Math.min(SPARSE_R_FLOOR, cap * plotMin) : 0, rMax = Math.max(MIN_R + 2, rFraction * plotMin, sparseFloor), sizeBy = options.sizeBy ?? "area", dotR = scatterDotRadius(env, domain), radiusOf = (p) => {
1764
+ if (!bubbleMode) return dotR;
1765
+ if (p.size === null || sizeMax === void 0 || sizeMax <= 0) return MIN_R + 0.5;
1766
+ let frac = p.size / sizeMax;
1767
+ return frac <= 0 ? MIN_R : Math.max(MIN_R, sizeBy === "diameter" ? frac * rMax : Math.sqrt(frac) * rMax);
1768
+ };
1769
+ return {
1770
+ plot,
1771
+ inner: frame.plot,
1772
+ fonts,
1773
+ showAxes,
1774
+ qualitative,
1775
+ axisTitles,
1776
+ xAxisH,
1777
+ yAxisW,
1778
+ xBandH,
1779
+ yBandW,
1780
+ ...xBandLines ? { xBandLines } : {},
1781
+ ...yBandLines ? { yBandLines } : {},
1782
+ x,
1783
+ y,
1784
+ radiusOf
1785
+ };
1786
+ }
1787
+
1788
+ // src/core/charts/scatter/marks.ts
1789
+ var HIGHLIGHT_RING_GAP = 4, BUBBLE_RING_GAP = 3, BUBBLE_X_TICKS = 8, X_TICK_MARK = 4, BUBBLE_OUTLINE_MIN_R = 8;
1790
+ function sizeMarkerOf(p) {
1791
+ return p.sizeInvalid ? "invalid" : p.size === null ? "missing" : p.size === 0 ? "zero" : void 0;
1792
+ }
1793
+ function sizeMarkerNode(theme, kind, input) {
1794
+ let { id, cx, cy, owner, display, paint } = input, r = Math.max(3.5, input.r + 1);
1795
+ if (kind === "zero") return { t: "circle", id, cx, cy, r, fill: { token: "background" }, stroke: paint, strokeWidth: strokeToken(theme, "mark"), owner, part: "point", display };
1796
+ let k = kind === "invalid" ? r * Math.SQRT1_2 : r, d = kind === "invalid" ? `M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy - k)}L${fmtPathNumber(cx + k)} ${fmtPathNumber(cy + k)}M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy + k)}L${fmtPathNumber(cx + k)} ${fmtPathNumber(cy - k)}` : `M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy)}H${fmtPathNumber(cx + k)}M${fmtPathNumber(cx)} ${fmtPathNumber(cy - k)}V${fmtPathNumber(cy + k)}`;
1797
+ return { t: "path", id, d, stroke: paint, width: strokeToken(theme, "mark"), owner, part: "point", display };
1798
+ }
1799
+ function pointMarkNode(theme, input) {
1800
+ let { id, marker, cx, cy, r, owner, display } = input, shared = { id, owner, part: "point", display }, side = r * 1.8, d = marker === "circle" ? `M${fmtPathNumber(cx - r)} ${fmtPathNumber(cy)}A${fmtPathNumber(r)} ${fmtPathNumber(r)} 0 1 0 ${fmtPathNumber(cx + r)} ${fmtPathNumber(cy)}A${fmtPathNumber(r)} ${fmtPathNumber(r)} 0 1 0 ${fmtPathNumber(cx - r)} ${fmtPathNumber(cy)}Z` : marker === "square" ? `M${fmtPathNumber(cx - side / 2)} ${fmtPathNumber(cy - side / 2)}H${fmtPathNumber(cx + side / 2)}V${fmtPathNumber(cy + side / 2)}H${fmtPathNumber(cx - side / 2)}Z` : marker === "triangle" ? `M${fmtPathNumber(cx)} ${fmtPathNumber(cy - r * 1.2)}L${fmtPathNumber(cx + r * 1.15)} ${fmtPathNumber(cy + r)}L${fmtPathNumber(cx - r * 1.15)} ${fmtPathNumber(cy + r)}Z` : `M${fmtPathNumber(cx)} ${fmtPathNumber(cy - r * 1.3)}L${fmtPathNumber(cx + r * 1.3)} ${fmtPathNumber(cy)}L${fmtPathNumber(cx)} ${fmtPathNumber(cy + r * 1.3)}L${fmtPathNumber(cx - r * 1.3)} ${fmtPathNumber(cy)}Z`;
1801
+ if (input.clipped)
1802
+ return { t: "path", ...shared, d, stroke: input.paint, width: strokeToken(theme, "mark"), dash: dashToken(theme, "dotted"), lineCap: "round" };
1803
+ let fill = input.hollow ? { token: "background" } : input.paint, stroke = input.hollow ? input.paint : void 0;
1804
+ return marker === "circle" ? { t: "circle", ...shared, cx, cy, r, fill, ...stroke ? { stroke, strokeWidth: strokeToken(theme, "mark") } : { stroke: { token: "background" }, strokeWidth: strokeToken(theme, "rule") } } : marker === "square" ? {
1805
+ t: "rect",
1806
+ ...shared,
1807
+ rect: { x: cx - side / 2, y: cy - side / 2, w: side, h: side },
1808
+ ...input.hollow ? { fill: input.paint, pattern: "hollow" } : { fill }
1809
+ } : { t: "path", ...shared, d, fill, ...stroke ? { stroke, width: strokeToken(theme, "mark") } : {} };
1810
+ }
1811
+ function scatterAxes(env, domain, area, nodes, claims) {
1812
+ let { theme, measure, axisFmt, va } = env, { plot, x, y, axisTitles, fonts } = area, axes = [];
1813
+ if (!area.showAxes) return axes;
1814
+ if (area.qualitative)
1815
+ return qualitativeAxes(env, area, nodes, claims), axes;
1816
+ let ticksOf = (scale, orient) => {
1817
+ let spec = env.axisSpec[orient];
1818
+ if (!scale.log) return { format: axisFmt[orient], formatSpec: spec, ...domain.ticks ? { ticks: domain.ticks[orient], ...domain.quadrants.derived ? { keepEndTicks: !0 } : {} } : {} };
1819
+ let tickFmt = logSpecFormat(spec);
1820
+ return { format: tickFmt, ticks: fitLogTicks(scale, orient, tickFmt, fonts.tick, measure) };
1821
+ }, banded = bandedAxes(env, domain), bandless = (axis, orient) => {
1822
+ if (!banded[orient]) return axis;
1823
+ let labels = new Set(axis.axis.ticks.map((t) => t.labelId));
1824
+ return { ...axis, nodes: axis.nodes.filter((n) => !(n.t === "text" && labels.has(n.id))), axis: { ...axis.axis, ticks: axis.axis.ticks.map(({ labelId: _label, ...t }) => t) } };
1825
+ }, scratch = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), yAxis = bandless(layoutValueAxis(
1826
+ // A dot scatter whose axes end on ticks draws a light rule at each y tick.
1827
+ { scale: y, plot, orient: "y", gridlines: va.gridlines ?? tickGrid(domain), ...ticksOf(y, "y"), theme, measure },
1828
+ banded.y ? scratch : claims
1829
+ ), "y");
1830
+ nodes.push(...yAxis.nodes), axes.push(yAxis.axis);
1831
+ let grid = env.options.zones !== void 0 && "grid" in env.options.zones, xAxis = bandless(layoutValueAxis(
1832
+ { scale: x, plot, orient: "x", gridlines: va.gridlines ?? !1, ...ticksOf(x, "x"), ...domain.bubbleMode && !grid ? { tickCount: BUBBLE_X_TICKS } : {}, theme, measure, canvasWidth: env.size.width },
1833
+ banded.x ? scratch : claims
1834
+ ), "x");
1835
+ if (nodes.push(...xAxis.nodes), axes.push(xAxis.axis), axisTitles.x) {
1836
+ let size = measure(axisTitles.x, fonts.axisTitle), rect = { x: plot.x + plot.w / 2 - size.width / 2, y: plot.y + plot.h + area.xAxisH + area.xBandH + 2, w: size.width, h: size.height };
1837
+ nodes.push({ t: "text", id: "axis:x:title", x: plot.x + plot.w / 2, y: rect.y, lines: [axisTitles.x], align: "middle", typeRole: "secondary", font: secondaryFont(env.theme), ink: { token: "ink" }, owner: {}, part: "axisTitle" }), claims.claim(rect, "axis", {}, "axisTitle");
1838
+ }
1839
+ if (axisTitles.y) {
1840
+ let size = measure(axisTitles.y, fonts.axisTitle), rect = { x: plot.x - area.yAxisW - (banded.y ? area.yBandW : 0), y: area.inner.y + 8, w: size.width, h: size.height };
1841
+ nodes.push({ t: "text", id: "axis:y:title", x: rect.x, y: rect.y, lines: [axisTitles.y], align: "start", typeRole: "secondary", font: secondaryFont(env.theme), ink: { token: "ink" }, owner: {}, part: "axisTitle" }), claims.claim(rect, "axis", {}, "axisTitle");
1842
+ }
1843
+ let axisInk = grid ? { token: "axis" } : { token: "inkMuted" }, frameLine = (id, x1, y1, x2, y2) => ({ t: "line", id, x1, y1, x2, y2, stroke: axisInk, width: strokeToken(theme, "rule"), owner: {}, part: "axisLine" });
1844
+ if (banded.x || (nodes.push(frameLine("axis:x:line", plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h)), claims.claim({ x: plot.x, y: plot.y + plot.h - 1, w: plot.w, h: 2 }, "axis", {})), !grid)
1845
+ for (let tick of xAxis.axis.ticks)
1846
+ typeof tick.at == "number" && nodes.push({ t: "line", id: `axis:x:tickMark:${tick.at}`, x1: tick.pos, y1: plot.y + plot.h, x2: tick.pos, y2: plot.y + plot.h + X_TICK_MARK, stroke: axisInk, width: strokeToken(theme, "rule"), owner: {}, part: "tickMark" });
1847
+ return !banded.y && !(tickGrid(domain) && (va.gridlines ?? !0)) && (nodes.push(frameLine("axis:y:line", plot.x, plot.y, plot.x, plot.y + plot.h)), claims.claim({ x: plot.x - 1, y: plot.y, w: 2, h: plot.h }, "axis", {})), axes;
1848
+ }
1849
+ function tickGrid(domain) {
1850
+ return domain.ticks !== void 0 && domain.quadrants.derived === void 0;
1851
+ }
1852
+ function cutTickLabels(env, domain, axes, nodes) {
1853
+ let decimal2 = formatAutomaticNumber(1.5, { locale: env.options.locale?.language, decimals: 1 }).replace(/\d/g, ""), q = domain.quadrants.derived;
1854
+ if (!q || !domain.ticks) return {};
1855
+ let found = {};
1856
+ for (let axis of axes) {
1857
+ let orient = axis.axis === "x" ? "x" : "y", drawn = orient === "x" ? domain.quadrants.drawX : domain.quadrants.drawY, source = orient === "x" ? q.xSource : q.ySource;
1858
+ if (!drawn || source !== "declared") continue;
1859
+ let cut = q[orient], tick = axis.ticks.find((t) => typeof t.at == "number" && Math.abs(t.at - cut) < 1e-9), node = tick?.labelId === void 0 ? void 0 : nodes.find((n) => n.t === "text" && n.id === tick.labelId);
1860
+ node?.t === "text" && node.lines.length === 1 && samePrintedNumber(node.lines[0], orient === "x" ? q.xText : q.yText, decimal2) && (found[orient] = node.id);
1861
+ }
1862
+ return found;
1863
+ }
1864
+ function samePrintedNumber(a, b, decimal2) {
1865
+ let mark = decimal2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), trim = (text) => text.replace(new RegExp(`(${mark}\\d*?)0+(?!\\d)`, "g"), "$1").replace(new RegExp(`${mark}(?!\\d)`, "g"), "");
1866
+ return a === b || decimal2.length === 1 && trim(a) === trim(b);
1867
+ }
1868
+ function boldCutTicks(env, domain, axes, nodes) {
1869
+ let found = cutTickLabels(env, domain, axes, nodes), ids = new Set(Object.values(found));
1870
+ return nodes.forEach((node, i) => {
1871
+ node.t === "text" && ids.has(node.id) && (nodes[i] = { ...node, font: { ...node.font, weight: emphasisWeight(env.theme) } });
1872
+ }), { x: found.x !== void 0, y: found.y !== void 0 };
1873
+ }
1874
+ function arrow(theme, id, x1, y1, x2, y2) {
1875
+ let len = Math.hypot(x2 - x1, y2 - y1);
1876
+ if (len < ARROW_HEAD * 2) return [];
1877
+ let ux = (x2 - x1) / len, uy = (y2 - y1) / len, bx = x2 - ux * ARROW_HEAD, by = y2 - uy * ARROW_HEAD, half = ARROW_HEAD * 0.55;
1878
+ return [
1879
+ { t: "line", id, x1, y1, x2: bx, y2: by, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: {}, part: "axisArrow" },
1880
+ { t: "path", id: `${id}:head`, d: `M${fmtPathNumber(x2)} ${fmtPathNumber(y2)}L${fmtPathNumber(bx - uy * half)} ${fmtPathNumber(by + ux * half)}L${fmtPathNumber(bx + uy * half)} ${fmtPathNumber(by - ux * half)}Z`, fill: { token: "axis" }, owner: {}, part: "axisArrow" }
1881
+ ];
1882
+ }
1883
+ var ARROW_HEAD = 7;
1884
+ function qualitativeAxes(env, area, nodes, claims) {
1885
+ let { measure } = env, { plot, fonts, axisTitles } = area, column = qualitativeColumn(env, fonts, area.inner.w), bold = fonts.axisTitle, gap = env.theme.space.labelPad * 2, text = (id, x, y, lines, align, font) => {
1886
+ let w = Math.max(...lines.map((line) => measure(line, font).width)), h = lines.length * font.size * (font.lineHeight ?? 1.2);
1887
+ nodes.push({ t: "text", id, x, y, lines, align, typeRole: "axis", font, ink: { token: "ink" }, owner: {}, ...id.endsWith(":title") ? { part: "axisTitle" } : { part: "axisEnd", role: "axis" } }), claims.claim({ x: align === "start" ? x : align === "end" ? x - w : x - w / 2, y, w, h }, "axis", {}, "axisTitle");
1888
+ }, lineH = (font) => font.size * (font.lineHeight ?? 1.2), rowY = plot.y + plot.h + 6, midY = rowY + lineH(fonts.tick) / 2, lowW = measure(column.low, fonts.tick).width, highW = measure(column.high, fonts.tick).width, cx = plot.x + plot.w / 2;
1889
+ text("axis:x:low", plot.x, rowY, [column.low], "start", fonts.tick), text("axis:x:high", plot.x + plot.w, rowY, [column.high], "end", fonts.tick);
1890
+ let titleW = axisTitles.x ? measure(axisTitles.x, bold).width : 0;
1891
+ axisTitles.x && text("axis:x:title", cx, rowY, [axisTitles.x], "middle", bold), nodes.push(...arrow(env.theme, "axis:x:arrow-low", cx - titleW / 2 - gap, midY, plot.x + lowW + gap, midY)), nodes.push(...arrow(env.theme, "axis:x:arrow-high", cx + titleW / 2 + gap, midY, plot.x + plot.w - highW - gap, midY));
1892
+ let colX = plot.x - QUALITATIVE_GAP - column.width / 2, tickH = lineH(fonts.tick), topY = plot.y, bottomY = plot.y + plot.h - tickH, [highY, lowY] = env.va.reverse ? [bottomY, topY] : [topY, bottomY];
1893
+ text("axis:y:high", colX, highY, [column.high], "middle", fonts.tick), text("axis:y:low", colX, lowY, [column.low], "middle", fonts.tick);
1894
+ let titleH = column.lines.length * lineH(bold), titleY = plot.y + plot.h / 2 - titleH / 2;
1895
+ column.lines.length && text("axis:y:title", colX, titleY, column.lines, "middle", bold);
1896
+ let toTop = arrow(env.theme, env.va.reverse ? "axis:y:arrow-low" : "axis:y:arrow-high", colX, titleY - gap, colX, plot.y + tickH + gap), toBottom = arrow(env.theme, env.va.reverse ? "axis:y:arrow-high" : "axis:y:arrow-low", colX, titleY + titleH + gap, colX, plot.y + plot.h - tickH - gap);
1897
+ nodes.push(...toTop, ...toBottom);
1898
+ let frameLine = (id, x1, y1, x2, y2) => ({ t: "line", id, x1, y1, x2, y2, stroke: { token: "axis" }, width: strokeToken(env.theme, "rule"), owner: {}, part: "axisLine" });
1899
+ nodes.push(
1900
+ frameLine("axis:x:line", plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h),
1901
+ frameLine("axis:y:line", plot.x, plot.y, plot.x, plot.y + plot.h),
1902
+ frameLine("axis:top:line", plot.x, plot.y, plot.x + plot.w, plot.y),
1903
+ frameLine("axis:right:line", plot.x + plot.w, plot.y, plot.x + plot.w, plot.y + plot.h)
1904
+ ), claims.claim({ x: plot.x, y: plot.y + plot.h - 1, w: plot.w, h: 2 }, "axis", {}), claims.claim({ x: plot.x - 1, y: plot.y, w: 2, h: plot.h }, "axis", {}), claims.claim({ x: plot.x, y: plot.y - 1, w: plot.w, h: 2 }, "axis", {}), claims.claim({ x: plot.x + plot.w - 1, y: plot.y, w: 2, h: plot.h }, "axis", {});
1905
+ }
1906
+ function quadrantBoxRect(box, plot, split) {
1907
+ return {
1908
+ x: box === "tl" || box === "bl" ? plot.x : split.x,
1909
+ y: box === "tl" || box === "tr" ? plot.y : split.y,
1910
+ w: box === "tl" || box === "bl" ? split.x - plot.x : plot.x + plot.w - split.x,
1911
+ h: box === "tl" || box === "tr" ? split.y - plot.y : plot.y + plot.h - split.y
1912
+ };
1913
+ }
1914
+ var QUADRANT_TINT = 0.65, DIVIDER_TINT = 0.12;
1915
+ function quadrantTint(plot, split, nodes) {
1916
+ let wash = { token: "neutralLight", tint: QUADRANT_TINT };
1917
+ for (let box of ["tl", "br"]) {
1918
+ let rect = quadrantBoxRect(box, plot, split);
1919
+ rect.w <= 0 || rect.h <= 0 || nodes.push({ t: "rect", id: `quadrant:tint:${box}`, rect, fill: wash, owner: {}, part: "quadrantTint" });
1920
+ }
1921
+ }
1922
+ function zeroLines(theme, domain, area, nodes, claims) {
1923
+ let { plot, x, y } = area, q = domain.quadrants, [dxLo, dxHi] = domain.dx, [dyLo, dyHi] = domain.dy, rule = (id, x1, y1, x2, y2) => (
1924
+ // Solid and light: a zero line is scaffolding, apart from the dashed reference lines (value lines, trends).
1925
+ { t: "line", id, x1, y1, x2, y2, stroke: { token: "neutralLight" }, width: strokeToken(theme, "rule"), owner: {}, part: "zeroLine" }
1926
+ );
1927
+ if (dxLo < 0 && dxHi > 0 && !(q.drawX && q.derived.x === 0)) {
1928
+ let zx = x(0);
1929
+ nodes.push(rule("axis:x:zero", zx, plot.y, zx, plot.y + plot.h)), claims.claim({ x: zx - 1, y: plot.y, w: 2, h: plot.h }, "axis", {}, "referenceLine");
1930
+ }
1931
+ if (dyLo < 0 && dyHi > 0 && !(q.drawY && q.derived.y === 0)) {
1932
+ let zy = y(0);
1933
+ nodes.push(rule("axis:y:zero", plot.x, zy, plot.x + plot.w, zy)), claims.claim({ x: plot.x, y: zy - 1, w: plot.w, h: 2 }, "axis", {}, "referenceLine");
1934
+ }
1935
+ }
1936
+ var DENSE_POINTS = 5e3, DENSE_ROW = 8;
1937
+ function denseDots(theme, domain, paints, drawOrder) {
1938
+ if (domain.bubbleMode || drawOrder.length <= DENSE_POINTS) return;
1939
+ let runs = /* @__PURE__ */ new Map(), drawn = /* @__PURE__ */ new Map(), halo = strokeToken(theme, "rule") / 2;
1940
+ for (let { p, cx, cy, r } of drawOrder) {
1941
+ if (p.marker !== "circle" || paints.hollow(p) || paints.highlighted(p) || clampStateOf(domain.clamp, p.id) !== void 0) continue;
1942
+ let paint = paints.point(p), key = `${JSON.stringify(paint)}\0${r}`, run = runs.get(key);
1943
+ run || runs.set(key, run = { paint, r: Math.max(r - halo, 0.5), dots: [] }), run.dots.push({ x: Math.round((cx - run.r) * 100), y: Math.round(cy * 100), idx: p.idx, p });
1944
+ }
1945
+ return runs.size === 0 ? void 0 : { nodes: [...runs.values()].sort((a, b) => b.dots.length - a.dots.length).map(({ paint, r, dots }, k) => {
1946
+ let row = (y2) => Math.floor(y2 / (DENSE_ROW * 100));
1947
+ dots.sort((a, b) => row(a.y) - row(b.y) || (row(a.y) % 2 === 0 ? a.x - b.x : b.x - a.x) || a.y - b.y || a.idx - b.idx);
1948
+ let rr = fmtPathNumber(r), dd = fmtPathNumber(2 * r), circle = `a${rr} ${rr} 0 1 0 ${dd} 0a${rr} ${rr} 0 1 0-${dd} 0`, parts = [], x = 0, y = 0;
1949
+ for (let dot of dots)
1950
+ parts.push(parts.length === 0 ? `M${hundredths(dot.x)} ${hundredths(dot.y)}` : `m${hundredths(dot.x - x)}${dot.y - y < 0 ? "" : " "}${hundredths(dot.y - y)}`, circle), x = dot.x, y = dot.y;
1951
+ let id = `mark:dense:${k + 1}`;
1952
+ for (let dot of dots) drawn.set(dot.p, id);
1953
+ return { t: "path", id, d: parts.join(""), fill: paint, owner: {}, part: "point" };
1954
+ }), drawn };
1955
+ }
1956
+ function hundredths(v) {
1957
+ let sign = v < 0 ? "-" : "", a = Math.abs(v), whole = Math.floor(a / 100), frac = a % 100;
1958
+ return frac === 0 ? `${sign}${whole}` : `${sign}${whole}.${frac < 10 ? `0${frac}` : String(frac).replace(/0$/, "")}`;
1959
+ }
1960
+ function pointMarks(env, domain, area, paints, nodes, claims) {
1961
+ let { options, fmt, axisFmt } = env, { clamp } = domain, { x, y } = area, placed = domain.pts.filter((p) => inView(options, domain.dx, domain.dy, p)).map((p) => ({ p, cx: x(clamp ? clamp.project.x(p.x) : p.x), cy: y(clamp ? clamp.project.y(p.y) : p.y), r: area.radiusOf(p) })), drawOrder = [...placed].sort((a, b) => b.r - a.r || a.p.idx - b.p.idx), ringGap = domain.bubbleMode ? BUBBLE_RING_GAP : HIGHLIGHT_RING_GAP, nodeIdOf = /* @__PURE__ */ new Map(), dense = denseDots(env.theme, domain, paints, drawOrder);
1962
+ dense && pushAll(nodes, dense.nodes);
1963
+ for (let { p, cx, cy, r } of drawOrder) {
1964
+ let denseId = dense?.drawn.get(p);
1965
+ if (denseId) {
1966
+ nodeIdOf.set(p.id, denseId), claims.claim({ x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, "mark", { pointId: p.id });
1967
+ continue;
1968
+ }
1969
+ if (p.marker === "none") continue;
1970
+ let nodeId = `mark:${p.id}`;
1971
+ nodeIdOf.set(p.id, nodeId);
1972
+ let owner = { pointId: p.id }, clippedAt2 = clampStateOf(clamp, p.id), display = {
1973
+ // The REAL coordinates, on a clipped point too: the mark moved, the
1974
+ // value did not, and this string is what the hover card and the
1975
+ // accessible data table read.
1976
+ value: [
1977
+ `X ${axisFmt.x(p.x)}`,
1978
+ `Y ${axisFmt.y(p.y)}`,
1979
+ ...p.size === null ? [] : [`Size ${fmt(p.size)}`]
1980
+ ].join(", "),
1981
+ ...clippedAt2 ? { state: clippedAt2 } : {}
1982
+ }, odd = domain.bubbleMode ? sizeMarkerOf(p) : void 0;
1983
+ if (nodes.push(odd ? sizeMarkerNode(env.theme, odd, { id: nodeId, cx, cy, r, paint: paints.point(p), owner, display }) : pointMarkNode(env.theme, {
1984
+ id: nodeId,
1985
+ marker: p.marker,
1986
+ cx,
1987
+ cy,
1988
+ r,
1989
+ paint: paints.point(p),
1990
+ hollow: paints.hollow(p),
1991
+ clipped: clippedAt2 !== void 0,
1992
+ owner,
1993
+ display
1994
+ })), paints.highlighted(p)) {
1995
+ let rr = r + ringGap;
1996
+ nodes.push({ t: "path", id: `${nodeId}:ring`, d: `M${fmtPathNumber(cx - rr)} ${fmtPathNumber(cy)}A${fmtPathNumber(rr)} ${fmtPathNumber(rr)} 0 1 0 ${fmtPathNumber(cx + rr)} ${fmtPathNumber(cy)}A${fmtPathNumber(rr)} ${fmtPathNumber(rr)} 0 1 0 ${fmtPathNumber(cx - rr)} ${fmtPathNumber(cy)}Z`, stroke: paints.ring, width: strokeToken(env.theme, "mark"), owner, part: "highlightRing" });
1997
+ }
1998
+ let reach = r + (paints.highlighted(p) ? ringGap + strokeToken(env.theme, "mark") : 0), outline = domain.bubbleMode && !odd && reach >= BUBBLE_OUTLINE_MIN_R ? Array.from({ length: 32 }, (_, k) => ({ x: cx + reach / Math.cos(Math.PI / 32) * Math.cos(k * Math.PI / 16), y: cy + reach / Math.cos(Math.PI / 32) * Math.sin(k * Math.PI / 16) })) : void 0;
1999
+ claims.claim({ x: cx - reach, y: cy - reach, w: 2 * reach, h: 2 * reach }, "mark", owner, void 0, outline);
2000
+ }
2001
+ return { placed, nodeIdOf, densePoints: dense?.drawn.size ?? 0 };
2002
+ }
2003
+ function quadrantDividers(theme, q, drawn, area, nodes, claims) {
2004
+ let { plot } = area, divider = (axis, x1, y1, x2, y2) => ({ t: "line", id: `quadrant:divider:${axis}`, x1, y1, x2, y2, stroke: { token: "neutral", tint: DIVIDER_TINT }, width: strokeToken(theme, "rule"), owner: {}, part: "quadrantDivider" });
2005
+ if (drawn.drawX) {
2006
+ let qx = area.x(q.x);
2007
+ nodes.push(divider("x", qx, plot.y, qx, plot.y + plot.h)), claims.claim({ x: qx - 1, y: plot.y, w: 2, h: plot.h }, "axis", {});
2008
+ }
2009
+ if (drawn.drawY) {
2010
+ let qy = area.y(q.y);
2011
+ nodes.push(divider("y", plot.x, qy, plot.x + plot.w, qy)), claims.claim({ x: plot.x, y: qy - 1, w: plot.w, h: 2 }, "axis", {});
2012
+ }
2013
+ }
2014
+ function claimValueLines(domain, area, claims) {
2015
+ let ys = [];
2016
+ return domain.annotations.forEach((ann, n) => {
2017
+ if (ann.kind !== "valueLine") return;
2018
+ let annId = ann.id ?? `valueLine-${n + 1}`, v = ann.value === "mean" || ann.value === void 0 ? domain.meanY : ann.value;
2019
+ v !== void 0 && (ys.push(area.y(v)), claims.claim({ x: area.plot.x, y: area.y(v) - 1, w: area.plot.w, h: 2 }, "annotation", { annotationId: annId }, "referenceLine"));
2020
+ }), ys;
2021
+ }
2022
+ function layoutScatterMarks(env, domain, area, paints) {
2023
+ let { plot } = area, q = domain.quadrants.derived, nodes = [], claims = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), zones = layoutScatterZones(env, domain, area, nodes, claims), axes = scatterAxes(env, domain, area, nodes, claims), cutTicks = boldCutTicks(env, domain, axes, nodes), split = {
2024
+ x: q ? Math.min(Math.max(area.x(q.x), plot.x), plot.x + plot.w) : 0,
2025
+ y: q ? Math.min(Math.max(area.y(q.y), plot.y), plot.y + plot.h) : 0
2026
+ };
2027
+ q && (env.options.quadrants?.tint ?? "none") === "alternating" && quadrantTint(plot, split, nodes), zeroLines(env.theme, domain, area, nodes, claims);
2028
+ let trendLines = drawScatterTrends(env.theme, domain.trends, domain, area, paints, nodes, claims);
2029
+ drawFrontier(domain.frontier, env, domain.pts, domain.clamp, area, nodes, claims);
2030
+ let { placed, nodeIdOf, densePoints } = pointMarks(env, domain, area, paints, nodes, claims);
2031
+ q && quadrantDividers(env.theme, q, domain.quadrants, area, nodes, claims);
2032
+ let valueLineYs = claimValueLines(domain, area, claims), rules = { x: [], y: valueLineYs };
2033
+ for (let node of nodes)
2034
+ node.t !== "line" || node.part !== "zeroLine" && node.part !== "quadrantDivider" || (node.x1 === node.x2 ? rules.x.push(node.x1) : rules.y.push(node.y1));
2035
+ let marks = {
2036
+ points: placed.map(({ p, cx, cy, r }) => ({
2037
+ id: p.id,
2038
+ cx,
2039
+ cy,
2040
+ r: p.marker === "none" ? 0 : r,
2041
+ ...nodeIdOf.has(p.id) ? { nodeId: nodeIdOf.get(p.id) } : {},
2042
+ ...domain.clamp?.clipped.has(p.id) ? { clipped: !0 } : {}
2043
+ })),
2044
+ ...zones.marks.length ? { zones: zones.marks } : {}
2045
+ };
2046
+ return { nodes, claims, axes, zones, placed, marks, split, trendLines, rules, cutTicks, ...densePoints > 0 ? { densePoints } : {} };
2047
+ }
2048
+
2049
+ // src/core/charts/scatter/labels.ts
2050
+ var RING1_GAP = 4, NAME_GAP = 6, RULE_GAP = 4, RING2_GAP = 16, RING3_GAP = 30, RING4_GAP = 46, CAPTION_PAD = 6, DIVIDER_TAG_GAP = 4, PRIORITY_DIVIDER_TAG = PRIORITY.grandTotal + 60, PRIORITY_QUADRANT_CAPTION = PRIORITY.grandTotal;
2051
+ function dividerTagCandidates(tsize, rectAt, leaderTo) {
2052
+ let stations = [
2053
+ ["End", 0],
2054
+ ["Quarter", 0.25],
2055
+ ["Mid", 0.5],
2056
+ ["ThreeQuarter", 0.75],
2057
+ ["FarEnd", 1]
2058
+ ], out = [];
2059
+ for (let standoff of [0, 1, 2, 3])
2060
+ for (let [station, along] of stations)
2061
+ for (let side of ["near", "far"]) {
2062
+ let rect = rectAt(side, along, standoff * (tsize.height + 5));
2063
+ out.push({
2064
+ slot: `${side}${station}${standoff ? `Standoff${standoff}` : ""}`,
2065
+ rect,
2066
+ penalty: out.length,
2067
+ ...standoff >= 2 ? { leaderFrom: leaderTo(rect) } : {}
2068
+ });
2069
+ }
2070
+ return out;
2071
+ }
2072
+ function spiralCandidates(cx, cy, r, tsize, insideFill, fine = !1, slide = !1) {
2073
+ let w = tsize.width, h = tsize.height, out = [], penalty = 0;
2074
+ insideFill !== void 0 && w <= 2 * r * 0.85 && h <= 1.4 * r && out.push({
2075
+ slot: "insideCenter",
2076
+ rect: { x: cx - w / 2, y: cy - h / 2, w, h },
2077
+ penalty: penalty++,
2078
+ insideFill
2079
+ });
2080
+ let diag = Math.SQRT1_2, dirs = [
2081
+ ["right", 1, 0],
2082
+ ["left", -1, 0],
2083
+ ["above", 0, -1],
2084
+ ["below", 0, 1],
2085
+ ["aboveRight", diag, -diag],
2086
+ ["aboveLeft", -diag, -diag],
2087
+ ["belowRight", diag, diag],
2088
+ ["belowLeft", -diag, diag]
2089
+ ], rectFor = (ux, uy, dist) => {
2090
+ let ax = cx + ux * dist, ay = cy + uy * dist, rx = ux > 0.01 ? ax : ux < -0.01 ? ax - w : ax - w / 2, ry = uy > 0.01 ? ay : uy < -0.01 ? ay - h : ay - h / 2;
2091
+ return { x: rx, y: ry, w, h };
2092
+ };
2093
+ for (let [slot, ux, uy] of dirs)
2094
+ out.push({ slot, rect: rectFor(ux, uy, r + RING1_GAP), penalty: penalty++ });
2095
+ if (slide && w > 2 * r)
2096
+ for (let [slot, uy] of [["above", -1], ["below", 1]]) {
2097
+ let base = rectFor(0, uy, r + RING1_GAP);
2098
+ for (let [side, dx] of [["Left", -(w / 2)], ["Right", w / 2]])
2099
+ out.push({ slot: `${slot}Slide${side}`, rect: { ...base, x: base.x + dx }, penalty: penalty++ });
2100
+ }
2101
+ let [c, s] = [Math.cos(Math.PI / 8), Math.sin(Math.PI / 8)], fineDirs = fine ? [["rightHigh", c, -s], ["rightLow", c, s], ["leftHigh", -c, -s], ["leftLow", -c, s]] : [];
2102
+ for (let [ring, baseGap] of [["Far", RING2_GAP], ["Far3", RING3_GAP], ["Far4", RING4_GAP]])
2103
+ for (let [slot, ux, uy] of [...dirs.filter(([, ux2]) => ux2 !== 0), ...fineDirs]) {
2104
+ let gap = Math.max(baseGap, (h + 1) / Math.abs(ux));
2105
+ out.push({
2106
+ slot: `${slot}${ring}`,
2107
+ rect: rectFor(ux, uy, r + gap),
2108
+ penalty: penalty++,
2109
+ leaderFrom: { x: cx + ux * r, y: cy + uy * r }
2110
+ });
2111
+ }
2112
+ return out;
2113
+ }
2114
+ var CELL_CAPTION_PAD = 6, CELL_CAPTION_BOTTOM_PAD = 1;
2115
+ function zoneLabelCandidates(site, area, env, placed = []) {
2116
+ let { box } = site;
2117
+ if (site.kind === "xBand" || site.kind === "yBand") {
2118
+ let lines = site.lines ?? [site.text], lineH = env.measure("0", area.fonts.tick).height, measured2 = { width: Math.max(...lines.map((line) => env.measure(line, area.fonts.tick).width)), height: lines.length * lineH };
2119
+ return [{ slot: "axisBand", rect: site.kind === "xBand" ? { x: box.x + (box.w - measured2.width) / 2, y: box.y + ZONE_BAND_GAP, w: measured2.width, h: measured2.height } : { x: box.x + box.w - ZONE_BAND_GAP - measured2.width, y: box.y + (box.h - measured2.height) / 2, w: measured2.width, h: measured2.height }, penalty: 0 }];
2120
+ }
2121
+ let measured = env.measure(site.text, area.fonts.caption);
2122
+ if (site.kind === "cell") {
2123
+ let pad = CELL_CAPTION_PAD, bottomPad = box.y + box.h < area.plot.y + area.plot.h - 0.5 ? CELL_CAPTION_BOTTOM_PAD : pad, clear = (rect) => placed.every((m) => Math.hypot(Math.max(rect.x - m.cx, 0, m.cx - rect.x - rect.w), Math.max(rect.y - m.cy, 0, m.cy - rect.y - rect.h)) >= m.r), at2 = (slot, rx, ry) => {
2124
+ let rect = { x: rx, y: ry, w: measured.width, h: measured.height };
2125
+ return { slot, rect, penalty: 0, ...placed.length > 0 && clear(rect) ? { pad: 0 } : {} };
2126
+ };
2127
+ return [
2128
+ at2("topLeft", box.x + pad, box.y + pad),
2129
+ at2("bottomLeft", box.x + pad, box.y + box.h - bottomPad - measured.height),
2130
+ at2("bottomRight", box.x + box.w - pad - measured.width, box.y + box.h - bottomPad - measured.height),
2131
+ at2("topRight", box.x + box.w - pad - measured.width, box.y + pad),
2132
+ at2("centre", box.x + (box.w - measured.width) / 2, box.y + (box.h - measured.height) / 2)
2133
+ ].map((candidate, index) => ({ ...candidate, penalty: index }));
2134
+ }
2135
+ let at = (slot, xFraction, yFraction, penalty) => ({
2136
+ slot,
2137
+ rect: {
2138
+ x: box.x + box.w * xFraction - measured.width / 2,
2139
+ y: box.y + box.h * yFraction - measured.height / 2,
2140
+ w: measured.width,
2141
+ h: measured.height
2142
+ },
2143
+ penalty
2144
+ });
2145
+ return [
2146
+ at("centre", 0.5, 0.5, 0),
2147
+ at("upperCentre", 0.5, 0.25, 1),
2148
+ at("lowerCentre", 0.5, 0.75, 2),
2149
+ at("centreLeft", 0.25, 0.5, 3),
2150
+ at("centreRight", 0.75, 0.5, 4),
2151
+ at("upperLeft", 0.25, 0.25, 5),
2152
+ at("upperRight", 0.75, 0.25, 6),
2153
+ at("lowerLeft", 0.25, 0.75, 7),
2154
+ at("lowerRight", 0.75, 0.75, 8)
2155
+ ];
2156
+ }
2157
+ function zoneLabelRequests(sites, area, env, placed = []) {
2158
+ return sites.map((site) => ({
2159
+ id: site.id,
2160
+ kind: "category",
2161
+ owner: { categoryId: String(site.id) },
2162
+ text: site.text,
2163
+ // A cell caption prints as written.
2164
+ lines: site.lines ?? [site.text],
2165
+ ...site.kind === "yBand" ? { align: "end" } : site.kind === "xBand" ? { align: "middle" } : {},
2166
+ typeRole: "axis",
2167
+ font: area.fonts.caption,
2168
+ priority: site.kind === "xBand" || site.kind === "yBand" ? PRIORITY.valueLine : PRIORITY.total,
2169
+ candidates: zoneLabelCandidates(site, area, env, placed).filter((candidate) => rectContains(site.box, candidate.rect, 0))
2170
+ }));
2171
+ }
2172
+ function dividerTagRequests(q, area, env, requests, pts, printed) {
2173
+ let quadrants = q.derived, { plot } = area, font = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, tie = {
2174
+ x: pts.some((p) => p.x === quadrants.x) ? chartString(env.options, "pointsCountRight") : "",
2175
+ y: pts.some((p) => p.y === quadrants.y) ? chartString(env.options, "pointsCountAbove") : ""
2176
+ }, tag = (id, source, text, candidates) => {
2177
+ let line = `${chartString(env.options, source === "declared" ? "cutAt" : source === "median" ? "medianName" : "cutMeanCapital")} ${text}${tie[id]}`;
2178
+ return {
2179
+ id: `quadrant:cut:${id}`,
2180
+ kind: "valueLine",
2181
+ role: composedTextRole(line),
2182
+ owner: { valueLineId: `quadrant:${id}` },
2183
+ text: line,
2184
+ lines: [line],
2185
+ typeRole: "label",
2186
+ font,
2187
+ priority: PRIORITY_DIVIDER_TAG,
2188
+ candidates: candidates(env.measure(line, font))
2189
+ };
2190
+ }, tagged = { x: !printed.x || tie.x !== "", y: !printed.y || tie.y !== "" };
2191
+ if (q.drawX && tagged.x) {
2192
+ let qx = area.x(quadrants.x);
2193
+ requests.push(tag("x", quadrants.xSource, quadrants.xText, (tsize) => dividerTagCandidates(
2194
+ tsize,
2195
+ (side, along, offset) => ({
2196
+ x: side === "near" ? qx + DIVIDER_TAG_GAP + offset : qx - DIVIDER_TAG_GAP - offset - tsize.width,
2197
+ y: Math.min(plot.y + plot.h - 2 - tsize.height, plot.y + 2 + along * (plot.h - 4 - tsize.height)),
2198
+ w: tsize.width,
2199
+ h: tsize.height
2200
+ }),
2201
+ (rect) => ({ x: qx, y: rect.y + rect.h / 2 })
2202
+ )));
2203
+ }
2204
+ if (q.drawY && tagged.y) {
2205
+ let qy = area.y(quadrants.y);
2206
+ requests.push(tag("y", quadrants.ySource, quadrants.yText, (tsize) => dividerTagCandidates(
2207
+ tsize,
2208
+ (side, along, offset) => ({
2209
+ x: Math.max(plot.x + 2, plot.x + plot.w - 2 - tsize.width - along * (plot.w - 4 - tsize.width)),
2210
+ y: side === "near" ? qy - DIVIDER_TAG_GAP - offset - tsize.height : qy + DIVIDER_TAG_GAP + offset,
2211
+ w: tsize.width,
2212
+ h: tsize.height
2213
+ }),
2214
+ (rect) => ({ x: rect.x + rect.w / 2, y: qy })
2215
+ )));
2216
+ }
2217
+ }
2218
+ function quadrantCaptionRequests(env, domain, area, split, requests, warnings, placed = []) {
2219
+ let quadrants = domain.quadrants.derived, captionFont = area.fonts.caption, captions = env.options.quadrants?.labels ?? {}, centreFirst = (env.options.quadrants?.captionPlacement ?? "corner") === "centre";
2220
+ for (let box of QUADRANT_BOXES) {
2221
+ let authored = captions[box];
2222
+ if (authored === void 0 || authored === "") continue;
2223
+ if (domain.quadrants.voidBoxes.has(box)) {
2224
+ warnings.push({
2225
+ code: "quadrant-caption-void-box",
2226
+ severity: "info",
2227
+ message: `caption '${authored}' for the ${QUADRANT_BOX_NAME[box]} box was not placed: a cut point outside the plotted domain leaves that box no area, and it holds 0 of ${domain.pts.length} units. The footnote states the collapse.`
2228
+ });
2229
+ continue;
2230
+ }
2231
+ let rect = quadrantBoxRect(box, area.plot, split), wrapped = wrapText(authored, captionFont, Math.max(1, rect.w - 2 * CAPTION_PAD), 2, env.measure), lines = [
2232
+ ...wrapped.truncated ? [authored] : wrapped.lines,
2233
+ `n = ${formatAutomaticNumber(quadrants.counts[box], { locale: env.options.locale?.language, decimals: 0 })}`
2234
+ ], w = Math.max(...lines.map((l) => env.measure(l, captionFont).width)), lineH = captionFont.size * (captionFont.lineHeight ?? 1.2), h = lineH * lines.length, left = rect.x + CAPTION_PAD, right = rect.x + rect.w - CAPTION_PAD - w, top = rect.y + CAPTION_PAD, bottom = rect.y + rect.h - CAPTION_PAD - h, cx = rect.x + rect.w / 2 - w / 2, cy = rect.y + rect.h / 2 - h / 2, corners = box === "tl" ? [["topLeft", left, top], ["bottomLeft", left, bottom], ["topRight", right, top]] : box === "tr" ? [["topRight", right, top], ["bottomRight", right, bottom], ["topLeft", left, top]] : box === "bl" ? [["topLeft", left, top], ["bottomLeft", left, bottom], ["bottomRight", right, bottom]] : [["topRight", right, top], ["bottomRight", right, bottom], ["bottomLeft", left, bottom]], ordered = centreFirst ? [["centre", cx, cy], ...corners] : [...corners, ["centre", cx, cy]], candidates = [], endAligned = box === "tr" || box === "br", clearOfBubbles = (x, y) => lines.every((line, i) => {
2235
+ let lw = env.measure(line, captionFont).width, lr = { x: endAligned ? x + w - lw : x, y: y + i * lineH, w: lw, h: lineH };
2236
+ return placed.every((m) => Math.hypot(Math.max(lr.x - m.cx, 0, m.cx - lr.x - lr.w), Math.max(lr.y - m.cy, 0, m.cy - lr.y - lr.h)) >= m.r + CAPTION_PAD);
2237
+ });
2238
+ ordered.forEach(([slot, rx, ry]) => {
2239
+ let candidate = { x: rx, y: ry, w, h };
2240
+ rectContains(rect, candidate, 0) && candidates.push({ slot, rect: candidate, penalty: candidates.length, ...placed.length > 0 && clearOfBubbles(rx, ry) ? { pad: 0 } : {} });
2241
+ }), requests.push({
2242
+ id: `quadrant:caption:${box}`,
2243
+ kind: "category",
2244
+ owner: { categoryId: `quadrant:${box}` },
2245
+ text: lines.join(" "),
2246
+ lines,
2247
+ typeRole: "axis",
2248
+ font: captionFont,
2249
+ // A right-hand box sets its caption flush right, on the box's outer edge.
2250
+ ...box === "tr" || box === "br" ? { align: "end" } : {},
2251
+ priority: PRIORITY_QUADRANT_CAPTION,
2252
+ candidates
2253
+ });
2254
+ }
2255
+ }
2256
+ var groupFormats = /* @__PURE__ */ new WeakMap();
2257
+ function pointValueText(env, domain, p, field) {
2258
+ let value = p[field];
2259
+ if (value === null) return;
2260
+ if (field === "y" && (env.options.format || env.options.axisFormat?.y || env.log.y)) return env.axisFmt.y(value);
2261
+ let byGroup = groupFormats.get(domain.pts);
2262
+ byGroup || groupFormats.set(domain.pts, byGroup = /* @__PURE__ */ new Map());
2263
+ let key = `${field}\0${p.group ?? ""}`, fmt = byGroup.get(key);
2264
+ return fmt || byGroup.set(key, fmt = seriesValueFormatter(domain.pts.filter((q) => q.group === p.group).map((q) => q[field]), env.options.locale?.language)), fmt(value);
2265
+ }
2266
+ function pointLabelRequests(env, domain, area, placed, rules, paints, requests, warnings, seatMemo = /* @__PURE__ */ new Map(), paintMemo = /* @__PURE__ */ new Map()) {
2267
+ let { options, highlights } = env, { bubbleMode, sizeMax } = domain, maxPointLabels = options.maxPointLabels ?? 300, pointLabelsOn = options.labels !== !1 && options.labels?.point !== !1, field = options.labels !== !1 && options.labels?.value === !0 ? bubbleMode ? "size" : "y" : void 0;
2268
+ if ((pointLabelsOn || field) && placed.length > maxPointLabels) {
2269
+ warnings.push({
2270
+ code: "labels-auto-off",
2271
+ severity: "info",
2272
+ message: `point labels auto-disabled: ${domain.pts.length} points exceed maxPointLabels (${maxPointLabels})`
2273
+ });
2274
+ return;
2275
+ }
2276
+ if (!pointLabelsOn && !field) return;
2277
+ let q = domain.quadrants, zeroRules = {
2278
+ x: domain.dx[0] < 0 && domain.dx[1] > 0 && !(q.drawX && q.derived?.x === 0) ? [area.x(0)] : [],
2279
+ y: domain.dy[0] < 0 && domain.dy[1] > 0 && !(q.drawY && q.derived?.y === 0) ? [area.y(0)] : []
2280
+ }, dividerY = q.drawY && q.derived ? area.y(q.derived.y) : void 0, valueLineYs = rules.y.filter((ry) => !zeroRules.y.includes(ry) && ry !== dividerY), marks = placed.map(({ p, cx, cy, r }) => ({ id: p.id, cx, cy, r }));
2281
+ for (let { p, cx, cy, r } of placed) {
2282
+ let extreme = p.x === domain.xMin || p.x === domain.xMax || p.y === domain.yMin || p.y === domain.yMax, sizeBonus = bubbleMode && sizeMax && sizeMax > 0 && p.size !== null ? Math.min(99, Math.round(99 * p.size / sizeMax)) : 0, hl = highlights.has(p.id) || p.group !== void 0 && highlights.has(p.group), priority = (extreme ? PRIORITY.extreme : PRIORITY.interior) + sizeBonus + (hl ? PRIORITY.highlightBonus : 0), value = field ? pointValueText(env, domain, p, field) : void 0, reach = hl && !bubbleMode ? r + HIGHLIGHT_RING_GAP + strokeToken(env.theme, "mark") : r, ownMark = { id: p.id, cx, cy, r: reach }, pointPaint = paintMemo.get(p.id);
2283
+ pointPaint || paintMemo.set(p.id, pointPaint = {});
2284
+ let memo = pointPaint, insidePaint = () => memo.inside ??= paints.hollow(p) ? { token: "background" } : paints.point(p), insideFill = () => (memo.fillKnown || (memo.fill = paints.insideFill(p), memo.fillKnown = !0), memo.fill), nameFont = hl && (!bubbleMode || gridZones(options)) ? { ...area.fonts.label, weight: emphasisWeight(env.theme) } : area.fonts.label, boxSideWidth = (box) => {
2285
+ let qx = q.drawX && q.derived ? area.x(q.derived.x) : void 0;
2286
+ return qx === void 0 ? area.plot.w : box === "tr" || box === "br" ? area.plot.x + area.plot.w - qx : qx - area.plot.x;
2287
+ }, boxedSeats = (raw) => {
2288
+ if (!q.derived) return raw;
2289
+ let box = q.derived.assignment[p.id], qx = q.drawX ? area.x(q.derived.x) : void 0, onRight = box === "tr" || box === "br", lo = onRight && qx !== void 0 ? qx + RULE_GAP : area.plot.x + RULE_GAP, hi = !onRight && qx !== void 0 ? qx - RULE_GAP : area.plot.x + area.plot.w - RULE_GAP, own = { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r };
2290
+ return raw.flatMap((c) => {
2291
+ let { rect } = c;
2292
+ if (c.insideFill !== void 0 || c.leaderFrom !== void 0 || rect.w > hi - lo || rect.x >= lo && rect.x + rect.w <= hi) return [c];
2293
+ let x = Math.min(Math.max(rect.x, lo), hi - rect.w), moved = { ...rect, x };
2294
+ return Math.abs(x - rect.x) > rect.w / 2 || rectsOverlap(moved, own) ? [c] : [c, { ...c, slot: `${c.slot}Boxed`, rect: moved }];
2295
+ });
2296
+ }, seats = (text, insideFill2, fine = !1, font = area.fonts.label, block, name = !1) => {
2297
+ let key = `${String(p.id)}\0${text}\0${insideFill2}\0${fine}\0${font.size}/${font.weight}\0${block ? `${block.width}x${block.height}` : ""}\0${name}`, known = seatMemo.get(key);
2298
+ if (known) return [...known];
2299
+ let built = buildSeats(text, insideFill2, fine, font, block).filter((c) => !name || nameReadsAsOwn(c.rect, c.leaderFrom ? seatLeader(c.rect, c.leaderFrom)?.d : void 0, ownMark, marks, [], font.size));
2300
+ return seatMemo.set(key, built), [...built];
2301
+ }, buildSeats = (text, insideFill2, fine, font, block) => {
2302
+ let plotSlid = (c) => c.slot.includes("Slide") ? { ...c, rect: { ...c.rect, x: Math.min(Math.max(c.rect.x, area.plot.x + RULE_GAP), area.plot.x + area.plot.w - RULE_GAP - c.rect.w) } } : c, candidates = boxedSeats(spiralCandidates(cx, cy, reach, block ?? env.measure(text, font), insideFill2, fine, bubbleMode).map(plotSlid)).filter((candidate) => rectContains(area.inner, candidate.rect) && candidate.rect.y + candidate.rect.h <= area.plot.y + area.plot.h && candidate.rect.x >= area.plot.x).map((candidate) => ({ ...candidate, insidePaint: insidePaint() })), across = (rect) => rules.x.some((rx) => Math.abs(cx - rx) > r && (cx < rx ? rect.x + rect.w > rx : rect.x < rx)) || rules.y.some((ry) => Math.abs(cy - ry) > r && (cy < ry ? rect.y + rect.h > ry : rect.y < ry)), slid = (c) => {
2303
+ let { rect } = c;
2304
+ for (let rx of rules.x) {
2305
+ if (Math.abs(cx - rx) <= r || rect.x >= rx + RULE_GAP || rect.x + rect.w <= rx - RULE_GAP) continue;
2306
+ let x = cx < rx ? rx - RULE_GAP - rect.w : rx + RULE_GAP;
2307
+ if (Math.abs(x - rect.x) <= rect.w / 2) return [{ ...c, slot: `${c.slot}Slid`, rect: { ...rect, x } }];
2308
+ }
2309
+ for (let ry of rules.y) {
2310
+ if (Math.abs(cy - ry) <= r || rect.y >= ry + RULE_GAP || rect.y + rect.h <= ry - RULE_GAP) continue;
2311
+ let y = cy < ry ? ry - RULE_GAP - rect.h : ry + RULE_GAP;
2312
+ if (Math.abs(y - rect.y) <= rect.h / 2) return [{ ...c, slot: `${c.slot}Slid`, rect: { ...rect, y } }];
2313
+ }
2314
+ return [];
2315
+ }, own = { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, kept = candidates.flatMap((c) => [c, ...slid(c).filter((s) => rectContains(area.inner, s.rect) && !rectsOverlap(s.rect, own))]);
2316
+ if (q.derived) {
2317
+ let box = q.derived.assignment[p.id], onRight = box === "tr" || box === "br", onTop = box === "tl" || box === "tr", qx = area.x(q.derived.x), qy = area.y(q.derived.y);
2318
+ kept = kept.filter((c) => !(q.drawX && (onRight ? c.rect.x < qx : c.rect.x + c.rect.w > qx) || q.drawY && (onTop ? c.rect.y + c.rect.h > qy : c.rect.y < qy)));
2319
+ }
2320
+ let ownLines = valueLineYs.filter((ry) => Math.abs(cy - ry) <= r), onZero = (rect) => zeroRules.x.some((rx) => rx > rect.x && rx < rect.x + rect.w) || [...zeroRules.y, ...ownLines].some((ry) => ry > rect.y && ry < rect.y + rect.h), over = kept.filter((c) => c.insideFill === void 0 && onZero(c.rect)).map((c) => ({ ...c, slot: `${c.slot}Over`, overRules: !0 })), all = [...kept, ...over], tier = (c) => c.overRules ? c.leaderFrom ? 5 : 2 : (c.leaderFrom ? 3 : 0) + (across(c.rect) ? 1 : 0);
2321
+ return [0, 1, 2, 3, 4, 5].flatMap((t) => all.filter((c) => tier(c) === t)).map((candidate) => ({ ...candidate, penalty: tier(candidate) }));
2322
+ }, named = pointLabelsOn && !!p.label, valueSize = value !== void 0 && bubbleMode && insideFill() !== void 0 ? env.measure(value, area.fonts.label) : void 0, inside = valueSize && valueSize.width <= 2 * r * 0.85 && valueSize.height <= 1.4 * r ? { x: cx - valueSize.width / 2, y: cy - valueSize.height / 2, w: valueSize.width, h: valueSize.height } : void 0, covered = (rect) => placed.some((o) => o.p.id !== p.id && o.r > 0 && Math.hypot(Math.max(rect.x - o.cx, 0, o.cx - rect.x - rect.w), Math.max(rect.y - o.cy, 0, o.cy - rect.y - rect.h)) < o.r), hiddenBehind = (offset, along, from, to) => {
2323
+ let half = Math.sqrt(Math.max(0, r * r - offset * offset));
2324
+ return bubbleMode && half > 0 && from >= along - half && to <= along + half;
2325
+ }, fitsInside = inside !== void 0 && !rules.x.some((rx) => rx > inside.x - RULE_GAP && rx < inside.x + inside.w + RULE_GAP && !(zeroRules.x.includes(rx) && hiddenBehind(rx - cx, cy, inside.y, inside.y + inside.h))) && !rules.y.some((ry) => ry > inside.y - RULE_GAP && ry < inside.y + inside.h + RULE_GAP && !(zeroRules.y.includes(ry) && hiddenBehind(ry - cy, cx, inside.x, inside.x + inside.w))) && !covered(inside), behindZero = fitsInside && (zeroRules.x.some((rx) => rx > inside.x - RULE_GAP && rx < inside.x + inside.w + RULE_GAP) || zeroRules.y.some((ry) => ry > inside.y - RULE_GAP && ry < inside.y + inside.h + RULE_GAP)), dropped = bubbleMode && ((env.valueTier === 1 || env.valueInsideOnly?.has(p.id) === !0) && !fitsInside || env.valueTier === 2), joined = named && value !== void 0 && !fitsInside && !dropped ? value : void 0;
2326
+ if (named) {
2327
+ let box = q.derived?.assignment[p.id], straddles = box !== void 0 && (q.drawX && Math.abs(cx - area.x(q.derived.x)) < r || q.drawY && Math.abs(cy - area.y(q.derived.y)) < r), clipped = (domain.clamp?.records ?? []).filter((record) => record.points.some((point) => point.id === p.id)), real = clipped.length ? ` ${[...new Set(clipped.map((record) => record.axis))].map((axis) => env.axisFmt[axis](p[axis])).join(", ")}` : "", plain = straddles ? `${p.label}${real} (${options.quadrants?.labels?.[box] ?? QUADRANT_BOX_NAME[box]})` : `${p.label}${real}`, name = joined === void 0 ? plain : `${plain} ${joined}`, room = box === void 0 ? 1 / 0 : boxSideWidth(box) - 2 * RULE_GAP, wrapped = env.measure(name, nameFont).width > room ? wrapText(name, nameFont, room, 2, env.measure) : void 0, nameLines = wrapped && !wrapped.truncated && wrapped.lines.length === 2 ? wrapped.lines : [name], callout = nameLines.length === 1 ? env.callouts?.get(p.id) : void 0, boldFont = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, nameW = env.measure(name, nameFont).width, wrappedCallout = callout !== void 0 && env.calloutWrap ? wrapText(callout, boldFont, Math.max(nameW, ...callout.split(/\s+/).map((word) => env.measure(word, boldFont).width)), 3, env.measure) : void 0, calloutLines = callout === void 0 ? [] : wrappedCallout && !wrappedCallout.truncated ? wrappedCallout.lines : [callout], lines = callout === void 0 ? nameLines : [name, ...calloutLines], font = callout === void 0 ? nameFont : boldFont, lineH = nameFont.size * (nameFont.lineHeight ?? 1.2), block = callout !== void 0 ? { width: Math.max(nameW, ...calloutLines.map((line) => env.measure(line, boldFont).width)), height: lines.length * lineH } : lines.length > 1 ? { width: Math.max(...lines.map((line) => env.measure(line, nameFont).width)), height: lines.length * lineH } : void 0;
2328
+ requests.push({
2329
+ id: `point:${p.id}`,
2330
+ kind: "point",
2331
+ owner: { pointId: p.id },
2332
+ text: callout === void 0 ? name : `${name} ${callout}`,
2333
+ lines,
2334
+ typeRole: "label",
2335
+ font,
2336
+ ...callout !== void 0 ? { headLines: 1, headWeight: nameFont.weight } : {},
2337
+ // An authored callout outranks the plain names.
2338
+ priority: callout === void 0 ? priority : priority + PRIORITY.highlightBonus,
2339
+ // With a value printed, the bubble's centre is the value's seat.
2340
+ candidates: seats(name, bubbleMode && value === void 0 && !block ? insideFill() : void 0, !1, nameFont, block, !0),
2341
+ labelGap: NAME_GAP,
2342
+ // The authored point name, not a value.
2343
+ role: "category",
2344
+ // The nearest-mark rule: a seat nearer another point waits, or
2345
+ // takes a leader from this one.
2346
+ anchor: { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r },
2347
+ // A bubble's leader crosses no other label; no name's leader does either.
2348
+ leaderClear: !0
2349
+ });
2350
+ }
2351
+ if (value === void 0 || joined !== void 0) continue;
2352
+ let valueSeats = dropped ? [] : seats(value, bubbleMode ? insideFill() : void 0, bubbleMode).filter((candidate) => bubbleMode ? candidate.insideFill !== void 0 || !named && candidate.leaderFrom !== void 0 : candidate.leaderFrom === void 0).map((candidate) => fitsInside && candidate.slot === "insideCenter" ? { ...candidate, pad: 0, ...behindZero ? { overRules: !0 } : {} } : candidate);
2353
+ requests.push({
2354
+ id: `value:${p.id}`,
2355
+ kind: "point",
2356
+ owner: { pointId: p.id },
2357
+ text: value,
2358
+ lines: [value],
2359
+ typeRole: "label",
2360
+ font: area.fonts.label,
2361
+ // Names go before values. A value ranks below every name, so a
2362
+ // small point keeps its name before a large one prints its number; a
2363
+ // highlighted point's value keeps its rank.
2364
+ priority: hl ? priority - 1 : priority - 1 - PRIORITY.extreme,
2365
+ candidates: valueSeats,
2366
+ labelGap: NAME_GAP,
2367
+ role: "value",
2368
+ ...bubbleMode ? { anchor: { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, leaderClear: !0 } : {}
2369
+ });
2370
+ }
2371
+ }
2372
+ function planScatterLabels(env, domain, area, geometry, paints, warnings) {
2373
+ let bubbles = domain.bubbleMode ? geometry.placed : [], requests = zoneLabelRequests(geometry.zones.labels, area, env, bubbles);
2374
+ return domain.quadrants.derived && (dividerTagRequests(domain.quadrants, area, env, requests, domain.pts, geometry.cutTicks), quadrantCaptionRequests(env, domain, area, geometry.split, requests, warnings, bubbles)), pointLabelRequests(env, domain, area, geometry.placed, geometry.rules, paints, requests, warnings, geometry.seatMemo ??= /* @__PURE__ */ new Map(), geometry.paintMemo ??= /* @__PURE__ */ new Map()), trendLabelRequest(env, area, geometry, requests), requests;
2375
+ }
2376
+ function trendLabelRequest(env, area, geometry, requests) {
2377
+ let trend = env.options.trend, text = typeof trend == "object" ? trend.label : void 0, line = geometry.trendLines[0];
2378
+ if (!text || !line) return;
2379
+ let font = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, { width: w, height: h } = env.measure(text, font), { from, to, yAt } = line, GAP = 4, onLine = (x0, side) => {
2380
+ let lo = Math.max(x0, from.x), hi = Math.min(x0 + w, to.x), ys = lo <= hi ? [yAt(lo), yAt(hi)] : [x0 + w < from.x ? from.y : to.y];
2381
+ return { x: x0, y: side === "above" ? Math.min(...ys) - GAP - h : Math.max(...ys) + GAP, w, h };
2382
+ }, seats = [
2383
+ ["endRight", { x: to.x + GAP + 2, y: to.y - h / 2, w, h }],
2384
+ ["endAbove", onLine(to.x - w, "above")],
2385
+ ["endBelow", onLine(to.x - w, "below")],
2386
+ ["endAboveCentre", onLine(to.x - w / 2, "above")],
2387
+ ["endBelowCentre", onLine(to.x - w / 2, "below")],
2388
+ ["startLeft", { x: from.x - GAP - 2 - w, y: from.y - h / 2, w, h }],
2389
+ ["startAbove", onLine(from.x, "above")],
2390
+ ["startBelow", onLine(from.x, "below")],
2391
+ ...[0.75, 0.5, 0.25].flatMap((t) => {
2392
+ let x0 = from.x + (to.x - from.x) * t - w / 2;
2393
+ return [[`above${t * 100}`, onLine(x0, "above")], [`below${t * 100}`, onLine(x0, "below")]];
2394
+ })
2395
+ ], clear = (rect) => geometry.placed.every(({ cx, cy, r }) => !rectsOverlap(rect, { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, 8)), candidates = [...seats.filter(([, rect]) => clear(rect)), ...seats.filter(([, rect]) => !clear(rect))].map(([slot, rect], penalty) => ({ slot, rect, penalty }));
2396
+ requests.push({
2397
+ id: `trend:${line.fit.id}`,
2398
+ kind: "valueLine",
2399
+ owner: { annotationId: line.nodeId },
2400
+ text,
2401
+ lines: [text],
2402
+ typeRole: "label",
2403
+ font,
2404
+ // Before the interior point names, so an end seat is still free; the
2405
+ // extreme points, which usually sit at the line's ends, keep theirs.
2406
+ priority: PRIORITY.extreme - 1,
2407
+ role: "note",
2408
+ candidates: candidates.filter((candidate) => rectContains(area.plot, candidate.rect))
2409
+ });
2410
+ }
2411
+ function scatterSolveCtx(env, area) {
2412
+ let { options, size, theme } = env;
2413
+ return labelCtx(theme, size, options, {
2414
+ measure: env.measure,
2415
+ plot: area.plot,
2416
+ labelPad: 2
2417
+ });
2418
+ }
2419
+
2420
+ // src/core/charts/scatter/sizeKey.ts
2421
+ function sizeKeyValues(env, sizeMin, sizeMax, fits, warnings, nested = !1) {
2422
+ let authored = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.values : void 0, kept = authored?.filter((value) => value <= sizeMax && fits(value)) ?? [], above = authored?.filter((value) => value > sizeMax) ?? [], tooLarge = authored?.filter((value) => value <= sizeMax && !fits(value)) ?? [], below = kept.filter((value) => value < sizeMin), are = (values) => `${values.join(", ")} ${values.length === 1 ? "is" : "are"}`, warn = (severity, message, suggest) => {
2423
+ warnings.push({ code: "size-legend-value-out-of-range", severity, message, suggest, field: ["options", "sizeLegend", "values"] });
2424
+ };
2425
+ if (above.length && warn(
2426
+ "warn",
2427
+ `sizeLegend.values ${are(above)} above the largest bubble (${sizeMax}), so the key leaves ${above.length === 1 ? "it" : "them"} out${kept.length ? "" : " and shows its default sizes"}`,
2428
+ `key sizes up to ${sizeMax}, or drop sizeLegend.values for the default`
2429
+ ), tooLarge.length) {
2430
+ let largestFit = roundBelow(sizeMax).find(fits);
2431
+ warn(
2432
+ "warn",
2433
+ `sizeLegend.values ${are(tooLarge)} larger than the key row can draw at scale${largestFit === void 0 ? "" : `; the largest round size it draws is ${largestFit}`}, so the key leaves ${tooLarge.length === 1 ? "it" : "them"} out${kept.length ? "" : " and shows its default sizes"}`,
2434
+ largestFit === void 0 ? "drop sizeLegend.values for the default" : `key sizes up to ${largestFit}, or drop sizeLegend.values for the default`
2435
+ );
2436
+ }
2437
+ if (below.length && warn(
2438
+ "info",
2439
+ `sizeLegend.values ${are(below)} below the smallest bubble (${sizeMin}); the key draws ${below.length === 1 ? "it" : "them"} at scale`,
2440
+ `key sizes from ${sizeMin} to ${sizeMax} to show the bubbles' own range`
2441
+ ), kept.length) return [...kept].sort((a, b) => b - a);
2442
+ let large = roundBelow(sizeMax).filter((value) => value >= sizeMin).find(fits) ?? sizeMax, small = roundBelow(large / (nested ? 4 : 2)).find((value) => value >= sizeMin);
2443
+ return small !== void 0 && small < large ? [large, small] : [large];
2444
+ }
2445
+ function roundBelow(v) {
2446
+ let out = [];
2447
+ for (let power = 10 ** Math.floor(Math.log10(v)), k = 0; k < 8; k++, power /= 10)
2448
+ for (let digit = 9; digit >= 1; digit--) digit * power <= v * (1 + 1e-9) && out.push(Number((digit * power).toPrecision(1)));
2449
+ return out;
2450
+ }
2451
+ function sizeKeyItems(env, sizeMin, sizeMax, radiusOf, maxRadius, warnings) {
2452
+ let title = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.label : void 0, values = sizeKeyValues(env, sizeMin, sizeMax, (size) => radiusOf(size) <= maxRadius, warnings), heading = title !== void 0, rings = values.map((value, index) => {
2453
+ let decimals = 0;
2454
+ for (; decimals < 20 && Math.abs(Number(roundHalfUp(value, decimals)) - value) > value * 1e-12; ) decimals++;
2455
+ let text = formatAutomaticNumber(value, { locale: env.options.locale?.language, decimals });
2456
+ return {
2457
+ id: `size:${index}`,
2458
+ label: index === 0 && title && !heading ? `${title}: ${text}` : text,
2459
+ paint: { token: "inkMuted" },
2460
+ key: "sizes",
2461
+ radii: [radiusOf(value)]
2462
+ };
2463
+ });
2464
+ return heading ? [{ id: "size:title", label: title, paint: { token: "ink" }, key: "heading" }, ...rings] : rings;
2465
+ }
2466
+ var KEY_INSET = 4, KEY_TICK_PAST = 8, KEY_TEXT_GAP = 3;
2467
+ function keyText(env, value) {
2468
+ let decimals = 0;
2469
+ for (; decimals < 20 && Math.abs(Number(roundHalfUp(value, decimals)) - value) > value * 1e-12; ) decimals++;
2470
+ return formatAutomaticNumber(value, { locale: env.options.locale?.language, decimals });
2471
+ }
2472
+ function plotSizeKey(env, area, sizeMin, sizeMax, claims, warnings, boxes = []) {
2473
+ let { plot, fonts } = area, values = sizeKeyValues(env, sizeMin, sizeMax, () => !0, warnings, !0), radii = values.map((size) => area.radiusOf({ size })), R = Math.max(...radii), texts = values.map((value) => keyText(env, value)), font = fonts.tick, textW = Math.max(...texts.map((text) => env.measure(text, font).width)), textH = env.measure("0", font).height, title = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.label : void 0, titleSize = title ? env.measure(title, font) : { width: 0, height: 0 }, ringsW = 2 * R + KEY_TICK_PAST + KEY_TEXT_GAP + textW, ringsH = textH / 2 + 2 * R, titleGap = 3, w = Math.max(ringsW, titleSize.width);
2474
+ if (!boxes.length && (w + 2 * KEY_INSET > plot.w / 2 || ringsH + titleSize.height + titleGap + 2 * KEY_INSET > plot.h / 2)) return;
2475
+ let snapshot = claims.snapshot(), rule = (c) => c.kind === "annotation" || c.part === "referenceLine" || c.part === "quadrantDivider", blocked = snapshot.filter((c) => c.kind === "mark" || rule(c)), free = (box) => !blocked.some((c) => rectsOverlap(c.rect, { x: box.x - KEY_INSET, y: box.y - KEY_INSET, w: box.w + 2 * KEY_INSET, h: box.h + 2 * KEY_INSET })), place = (side, edge, region = plot) => {
2476
+ if (region !== plot && (w + 2 * KEY_INSET > region.w || ringsH + titleSize.height + titleGap + 2 * KEY_INSET > region.h)) return;
2477
+ let r = side === "right" ? region.x + region.w - KEY_INSET : region.x + KEY_INSET + w, ringsTop = edge === "bottom" ? region.y + region.h - KEY_INSET - ringsH : region.y + KEY_INSET + (title ? titleSize.height + titleGap : 0), rings = { x: r - ringsW, y: ringsTop, w: ringsW, h: ringsH };
2478
+ for (let tries = 0; tries < 2 && edge === "bottom"; tries++) {
2479
+ let hit = blocked.find((c) => rule(c) && c.rect.w > c.rect.h && rectsOverlap(c.rect, { x: rings.x - KEY_INSET, y: rings.y - KEY_INSET, w: rings.w + 2 * KEY_INSET, h: rings.h + 2 * KEY_INSET }));
2480
+ if (!hit) break;
2481
+ let y = hit.rect.y - KEY_INSET - ringsH - 0.5;
2482
+ if (y < region.y + region.h / 2) return;
2483
+ rings = { ...rings, y };
2484
+ }
2485
+ if (!free(rings)) return;
2486
+ let ringsTopAt = rings.y;
2487
+ if (!title) return { rings };
2488
+ let box = { x: r - titleSize.width, y: ringsTopAt - titleGap - titleSize.height, w: titleSize.width, h: titleSize.height };
2489
+ for (let tries = 0; tries < 3 && box.y >= region.y; tries++) {
2490
+ let hit = blocked.find((c) => rectsOverlap(c.rect, { x: box.x - KEY_INSET, y: box.y - KEY_INSET, w: box.w + 2 * KEY_INSET, h: box.h + 2 * KEY_INSET }));
2491
+ if (!hit) return { rings, title: box };
2492
+ if (!rule(hit) || hit.rect.w < hit.rect.h || edge === "top") return;
2493
+ box = { ...box, y: hit.rect.y - KEY_INSET - titleSize.height - 0.5 };
2494
+ }
2495
+ }, inBox = boxes.reduce((found, box) => found ?? place(box.x + box.w / 2 >= plot.x + plot.w / 2 ? "right" : "left", "bottom", box), void 0), at = boxes.length ? inBox : place("right", "bottom") ?? place("right", "top") ?? place("left", "top") ?? place("left", "bottom");
2496
+ if (!at) return;
2497
+ let cx = at.rings.x + ringsW - ringsW + R, bottom = at.rings.y + ringsH, owner = {}, nodes = [];
2498
+ title && at.title && nodes.push({ t: "text", id: "sizeKey:title", x: at.title.x + at.title.w, y: at.title.y, lines: [title], align: "end", typeRole: "axis", role: "caption", font, ink: { token: "inkMuted" }, owner, part: "sizeKeyTitle" }), radii.forEach((r, i) => {
2499
+ nodes.push({ t: "circle", id: `sizeKey:ring:${i}`, cx, cy: bottom - r, r, fill: { token: "background" }, stroke: { token: "inkMuted" }, strokeWidth: strokeToken(env.theme, "rule"), owner, part: "sizeKeyRing" });
2500
+ }), radii.forEach((r, i) => {
2501
+ let top = bottom - 2 * r, tickEnd = cx + R + KEY_TICK_PAST;
2502
+ nodes.push({ t: "line", id: `sizeKey:tick:${i}`, x1: cx, y1: top, x2: tickEnd, y2: top, stroke: { token: "inkMuted" }, width: strokeToken(env.theme, "hair"), owner, part: "sizeKeyTick" }), nodes.push({ t: "text", id: `sizeKey:value:${i}`, x: tickEnd + KEY_TEXT_GAP, y: top - textH / 2, lines: [texts[i]], align: "start", typeRole: "axis", font, ink: { token: "inkMuted" }, owner, part: "sizeKeyValue" });
2503
+ });
2504
+ let rects = [at.rings, ...at.title ? [at.title] : []];
2505
+ return { nodes, rects };
2506
+ }
2507
+
2508
+ // src/core/charts/scatter/layout.ts
2509
+ function scatterDescription(input) {
2510
+ let { fmt, axisFmt, extent, quadrants, zones, options } = input;
2511
+ return chartString(options, "scatterDescStart", { v1: chartString(options, input.bubbleMode ? "bubbleName" : "scatterName"), v2: input.pointCount }) + (input.groupNames.length ? chartString(options, "scatterGroupDesc", { v1: input.groupNames.length, v2: input.groupNames.length === 1 ? "" : "s", v3: input.groupNames.join(", ") }) : "") + chartString(options, "scatterAxesDesc", { v1: axisFmt.x(extent.xMin), v2: axisFmt.x(extent.xMax), v3: input.log.x ? chartString(options, "logScaleClause") : "", v4: axisFmt.y(extent.yMin), v5: axisFmt.y(extent.yMax), v6: input.log.y ? chartString(options, "logScaleClause") : "" }) + (input.biggest ? chartString(options, "bubbleSizeDesc", { v1: input.sizeBy === "area" ? chartString(options, "areaName") : chartString(options, "diameterName"), v2: input.biggest.label, v3: fmt(input.biggest.size) }) : "") + (quadrants ? chartString(options, "quadrantDesc", { v1: quadrants.xText, v2: chartString(options, quadrants.xSource === "declared" ? "declaredLower" : quadrants.xSource === "median" ? "cutMedian" : "cutMean"), v3: quadrants.yText, v4: chartString(options, quadrants.ySource === "declared" ? "declaredLower" : quadrants.ySource === "median" ? "cutMedian" : "cutMean") }) + QUADRANT_BOXES.map((box) => `${quadrantBoxName(box, options)} ${quadrants.counts[box]}`).join(", ") + "." : "") + (zones ? chartString(options, "strategyZonesDesc", { v1: zones.kind === "grid" ? chartString(options, "gridCellsCount", { v1: zones.cellCount }) : chartString(options, "authoredRegionsCount", { v1: zones.regionCount }), v2: input.zoneDescriptions.join(" ") }) : "") + clampDescription(input.clipped, axisFmt, input.reversedY, options) + (input.dropped ? ` ${input.dropped.note}` : "") + input.trends.map((fit) => chartString(options, "trendLineDesc", { v1: fit.slope < 0 ? chartString(options, "fallsLower") : fit.slope > 0 ? chartString(options, "risesLower") : chartString(options, "runsFlat"), v2: fit.n, v3: fit.group === void 0 ? "" : chartString(options, "ofGroupClause", { v1: input.groupLabel(fit.group) }) })).join("") + (input.frontier ? chartString(options, "frontierDesc", { v1: input.frontier.ids.length, v2: chartString(options, input.frontier.x === "min" ? "lower" : "higher"), v3: chartString(options, input.frontier.y === "min" ? "lower" : "higher"), v4: input.frontier.ids.map(input.pointLabel).join(", ") }) : "");
2512
+ }
2513
+ function nameCallouts(env, domain, geometry) {
2514
+ let callouts = /* @__PURE__ */ new Map(), { options } = env;
2515
+ if (options.labels === !1 || options.labels?.point === !1) return { callouts, annotations: domain.annotations };
2516
+ let named = new Set(geometry.placed.filter((e) => !!e.p.label).map((e) => e.p.id)), annotations = domain.annotations.flatMap((ann, index) => {
2517
+ if (ann.kind === "callout" && !ann.headline && !ann.arrow && !ann.icon && !ann.status && ann.text && !ann.text.includes("${")) {
2518
+ let at = typeof ann.at == "string" ? ann.at : "pointId" in ann.at ? ann.at.pointId : void 0;
2519
+ if (at !== void 0 && named.has(at) && !callouts.has(at))
2520
+ return callouts.set(at, ann.text), [];
2521
+ }
2522
+ return [{ ...ann, id: defaultAnnotationId(ann, index) }];
2523
+ });
2524
+ return callouts.size ? { callouts, annotations } : { callouts, annotations: domain.annotations };
2525
+ }
2526
+ function annotateScatter(env, domain, area, geometry, occupied, solveCtx) {
2527
+ let ptById = new Map(geometry.placed.map((e) => [e.p.id, e])), resolveAnchor = (ref) => {
2528
+ let norm = typeof ref == "string" ? { pointId: ref } : ref;
2529
+ if (!("pointId" in norm)) return null;
2530
+ let e = ptById.get(norm.pointId);
2531
+ return e ? {
2532
+ x: e.cx,
2533
+ y: e.cy - e.r - 1,
2534
+ value: e.p.y,
2535
+ owner: { pointId: e.p.id },
2536
+ markBox: { x: e.cx - e.r, y: e.cy - e.r, w: 2 * e.r, h: 2 * e.r }
2537
+ } : null;
2538
+ };
2539
+ return runAnnotatePass({
2540
+ target: env.options.target,
2541
+ annotations: domain.annotations,
2542
+ resolve: resolveAnchor,
2543
+ occupied,
2544
+ plot: area.plot,
2545
+ theme: env.theme,
2546
+ measure: env.measure,
2547
+ format: env.options.axisFormat?.y ?? env.options.format,
2548
+ locale: env.options.locale?.language,
2549
+ strings: env.options.strings,
2550
+ valueLinePercentLevels: env.options.unit === "%" || domain.pts.length > 0 && domain.pts.every((point) => point.yIsPct),
2551
+ solveCtx,
2552
+ yScale: area.y,
2553
+ meanValue: domain.meanY,
2554
+ calloutLeaderClear: !0
2555
+ });
2556
+ }
2557
+ function scatterLabels(theme, area, solved, annotated, boldIds = /* @__PURE__ */ new Set()) {
2558
+ let { fonts } = area, isQuadrantCaption = (id) => String(id).startsWith("quadrant:caption:"), isZoneLabel = (id) => String(id).startsWith("zone:"), isZoneBandLabel = (id) => String(id).startsWith("zone:x-band:") || String(id).startsWith("zone:y-band:"), labels = [
2559
+ ...solved.placed.map(
2560
+ (l) => isQuadrantCaption(l.id) || isZoneLabel(l.id) ? { ...l, ink: { token: "inkMuted" } } : l
2561
+ ),
2562
+ ...annotated.labels
2563
+ ], nodes = labelsToNodes(
2564
+ theme,
2565
+ labels,
2566
+ (l) => isQuadrantCaption(l.id) ? fonts.caption : isZoneBandLabel(l.id) ? fonts.tick : isZoneLabel(l.id) ? fonts.caption : l.kind === "annotation" || l.kind === "valueLine" || boldIds.has(l.id) || l.headLines !== void 0 ? { ...fonts.label, weight: emphasisWeight(theme) } : fonts.label
2567
+ );
2568
+ return { labels, nodes };
2569
+ }
2570
+ function assembleScatterGeometry(input) {
2571
+ let { env, domain, frame, geometry, solved, annotated } = input, { bubbleMode, pts, xMin, xMax, yMin, yMax, sizeMax, clamp, dropped } = domain, quadrants = domain.quadrants.derived, zonesDerived = geometry.zones.derived, boldIds = new Set(bubbleMode && !gridZones(env.options) ? [] : pts.filter((p) => env.highlights.has(p.id) || p.group !== void 0 && env.highlights.has(p.group)).map((p) => `point:${p.id}`)), emitted = scatterLabels(input.env.theme, input.area, solved, annotated, boldIds), biggest = bubbleMode ? [...geometry.placed].sort((a, b) => (b.p.size ?? 0) - (a.p.size ?? 0) || a.p.idx - b.p.idx)[0] : void 0, a11yDesc = scatterDescription({
2572
+ options: env.options,
2573
+ bubbleMode,
2574
+ pointCount: pts.length,
2575
+ groupNames: domain.shownGroups.map((g) => g.label),
2576
+ extent: { xMin, xMax, yMin, yMax },
2577
+ log: env.log,
2578
+ fmt: env.fmt,
2579
+ axisFmt: env.axisFmt,
2580
+ sizeBy: env.options.sizeBy ?? "area",
2581
+ ...bubbleMode && biggest ? { biggest: { label: biggest.p.label, size: biggest.p.size ?? 0 } } : {},
2582
+ quadrants,
2583
+ zones: zonesDerived,
2584
+ zoneDescriptions: geometry.zones.descriptions,
2585
+ clipped: clamp?.records ?? [],
2586
+ reversedY: env.va.reverse === !0,
2587
+ dropped,
2588
+ trends: domain.trends,
2589
+ frontier: domain.frontier,
2590
+ pointLabel: (id) => pts.find((p) => p.id === id)?.label ?? id,
2591
+ groupLabel: (id) => domain.groups.get(id)?.label ?? id
2592
+ });
2593
+ return {
2594
+ type: "scatter",
2595
+ size: env.size,
2596
+ plot: input.area.plot,
2597
+ scene: [...frame.nodes, ...geometry.nodes, ...annotated.nodes, ...emitted.nodes],
2598
+ labels: emitted.labels,
2599
+ axes: geometry.axes,
2600
+ annotations: annotated.placed,
2601
+ legend: frame.legend,
2602
+ frame: frame.frame,
2603
+ marks: geometry.marks,
2604
+ derived: {
2605
+ xExtent: [xMin, xMax],
2606
+ yExtent: [yMin, yMax],
2607
+ ...sizeMax !== void 0 ? { sizeMax } : {},
2608
+ ...quadrants ? { quadrants } : {},
2609
+ ...zonesDerived ? { zones: zonesDerived } : {},
2610
+ ...clamp && clamp.records.length > 0 ? { clipped: clamp.records } : {},
2611
+ ...dropped ? { dropped } : {},
2612
+ ...domain.trends.length > 0 ? { trends: domain.trends } : {},
2613
+ ...domain.frontier ? { frontier: domain.frontier } : {}
2614
+ },
2615
+ a11y: {
2616
+ title: accessibleTitle(env.options.title, chartString(env.options, "scatterTitle", { v1: bubbleMode ? chartString(env.options, "bubbleName") : chartString(env.options, "scatterName"), v2: pts.length })),
2617
+ counts: [
2618
+ structureCount("points", pts.length, void 0, env.options),
2619
+ ...domain.shownGroups.length ? [structureCount("groups", domain.shownGroups.length, chartString(env.options, "groupsCount", { v1: domain.shownGroups.length, v2: domain.shownGroups.length === 1 ? "" : "s" }))] : [],
2620
+ ...quadrants ? QUADRANT_BOXES.map((box) => structureCount("points", quadrants.counts[box], `${quadrantBoxName(box, env.options)} ${quadrants.counts[box]}`)) : [],
2621
+ ...zonesDerived ? [zonesDerived.kind === "grid" ? structureCount("cells", zonesDerived.cellCount, chartString(env.options, "gridCellsCount", { v1: zonesDerived.cellCount })) : structureCount("regions", zonesDerived.regionCount, chartString(env.options, "authoredRegionsCount", { v1: zonesDerived.regionCount }))] : [],
2622
+ ...(clamp?.records ?? []).map((record) => structureCount("points", record.count, chartString(env.options, "pointsCount", { v1: record.count, v2: record.count === 1 ? "" : "s" }))),
2623
+ ...dropped ? [structureCount("points", dropped.count, chartString(env.options, "pointsCount", { v1: dropped.count, v2: dropped.count === 1 ? "" : "s" }))] : [],
2624
+ ...domain.trends.map((fit) => structureCount("points", fit.n, void 0, env.options)),
2625
+ ...domain.frontier ? [structureCount("points", domain.frontier.ids.length, void 0, env.options)] : []
2626
+ ],
2627
+ desc: a11yDesc
2628
+ },
2629
+ warnings: input.warnings,
2630
+ debug: {
2631
+ occupied: input.occupied.snapshot(),
2632
+ decisions: [...solved.decisions, ...annotated.decisions]
2633
+ }
2634
+ };
2635
+ }
2636
+ function notListed(geometry) {
2637
+ let text = geometry.scene.flatMap((node) => node.t === "text" && node.part === "footnote" ? node.lines : []).join(" ");
2638
+ return geometry.labels.some((label) => label.hidden && /^(point|value):/.test(String(label.id)) && !text.includes(label.text));
2639
+ }
2640
+ var NAME_APART_ROUNDS = 3;
2641
+ function readsAsOne(a, b) {
2642
+ let h = Math.min(a.h, b.h), sameLine = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y) > h / 2, gap = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
2643
+ return sameLine && gap < 2 * h;
2644
+ }
2645
+ function probeSolveOn(requests, occupied, ctx, size) {
2646
+ let index = copyOccupied(occupied, size);
2647
+ return { result: solveLabels(requests, index, ctx), index };
2648
+ }
2649
+ function keepNamesApart(requests, occupied, ctx, size, first) {
2650
+ let names = new Map(requests.filter((r) => String(r.id).startsWith("point:")).map((r) => [r.id, r])), start = first ?? probeSolveOn(requests, occupied, ctx, size);
2651
+ if (names.size < 2) return start;
2652
+ let original = /* @__PURE__ */ new Map(), probeSolve = () => probeSolveOn(requests, occupied, ctx, size).result.placed.filter((l) => names.has(l.id)), all = start.result.placed.filter((l) => names.has(l.id)), hiddenAtStart = all.filter((l) => l.hidden).length;
2653
+ for (let round = 0; round < NAME_APART_ROUNDS; round++) {
2654
+ let placed = all.filter((l) => !l.hidden), losers = /* @__PURE__ */ new Set();
2655
+ for (let i = 0; i < placed.length; i++)
2656
+ for (let j = i + 1; j < placed.length; j++) {
2657
+ let a = placed[i], b = placed[j];
2658
+ if (!readsAsOne(a.rect, b.rect)) continue;
2659
+ let ra = names.get(a.id), rb = names.get(b.id), [label, request, other] = ra.priority < rb.priority || ra.priority === rb.priority && a.id > b.id ? [a, ra, b] : [b, rb, a];
2660
+ losers.has(label.id) || request.candidates.length < 2 || (losers.add(label.id), original.has(label.id) || original.set(label.id, request.candidates), request.candidates = request.candidates.filter((c) => c.slot !== label.slot && !readsAsOne(c.rect, other.rect)));
2661
+ }
2662
+ if (losers.size === 0) break;
2663
+ all = probeSolve();
2664
+ }
2665
+ if (original.size === 0) return start;
2666
+ if (all.filter((l) => l.hidden).length > hiddenAtStart) {
2667
+ for (let [id, candidates] of original) names.get(id).candidates = candidates;
2668
+ return start;
2669
+ }
2670
+ }
2671
+ function seatLostNames(requests, occupied, ctx, size, first, dots = !1) {
2672
+ let names = new Map(requests.filter((r) => String(r.id).startsWith("point:")).map((r) => [r.id, r])), all = first, seated;
2673
+ if (names.size < 2 || seatProbe.left <= 0) return;
2674
+ let pad = ctx.labelPad ?? 2, lostNames = (placed) => placed.filter((l) => l.hidden && names.has(l.id));
2675
+ lost: for (let lost of lostNames(all)) {
2676
+ let request = names.get(lost.id), hiddenBefore = lostNames(all).length;
2677
+ for (let seat of request.candidates) {
2678
+ if (occupied.hitsWhich(seat.rect, seat.pad ?? pad).some((o) => !(seat.overRules && o.part === "referenceLine") && !(o.kind === "mark" && o.owner.pointId === request.owner.pointId))) continue;
2679
+ let blockers = all.filter((l) => !l.hidden && names.has(l.id) && l.id !== lost.id && rectsOverlap(l.rect, seat.rect, pad));
2680
+ if (blockers.length === 0 || blockers.length > 2) continue;
2681
+ let saved = blockers.map((l) => [names.get(l.id), names.get(l.id).candidates]);
2682
+ for (let [other] of saved) other.candidates = other.candidates.filter((c) => !rectsOverlap(c.rect, seat.rect, pad));
2683
+ let free = (other) => other.candidates.some((c) => !occupied.hitsWhich(c.rect, c.pad ?? pad).some((o) => !(o.kind === "mark" && o.owner.pointId === other.owner.pointId)) && !all.some((l) => !l.hidden && names.has(l.id) && l.id !== other.id && rectsOverlap(l.rect, c.rect, pad)));
2684
+ if (saved.every(([other]) => other.candidates.length > 0 && (!dots || free(other)))) {
2685
+ if (seatProbe.left <= 0) {
2686
+ for (let [other, candidates] of saved) other.candidates = candidates;
2687
+ break lost;
2688
+ }
2689
+ seatProbe.left--;
2690
+ let probe = probeSolveOn(requests, occupied, ctx, size), next = probe.result.placed;
2691
+ if (lostNames(next).length < hiddenBefore && !next.find((l) => l.id === lost.id)?.hidden) {
2692
+ all = next, seated = probe;
2693
+ break;
2694
+ }
2695
+ }
2696
+ for (let [other, candidates] of saved) other.candidates = candidates;
2697
+ }
2698
+ }
2699
+ return seated;
2700
+ }
2701
+ function commitClaims(occupied, phase) {
2702
+ for (let c of phase.snapshot()) occupied.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
2703
+ }
2704
+ function copyOccupied(occupied, size) {
2705
+ let copy = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height });
2706
+ return commitClaims(copy, occupied), occupied.tickColumns && (copy.tickColumns = [...occupied.tickColumns]), copy;
2707
+ }
2708
+ var SIZE_KEY_MAX_SHARE = 0.125;
2709
+ function scatterKeyItems(env, domain, paints, area, warnings, sizesInRow = !0) {
2710
+ let items = [];
2711
+ items.push(...zoneKeyItems(env.options)), domain.frontier && items.push({ id: "frontier", label: env.options.frontier?.label ?? chartString(env.options, "paretoLine"), paint: { token: "ink" }, key: "line", dash: dashToken(env.theme, "dotted"), lineCap: "round", width: strokeToken(env.theme, "rule") });
2712
+ let trend = env.options.trend, named = typeof trend == "object" && trend.label ? trend.label : chartString(env.options, "linearTrend"), rate = trendRateFormatter(
2713
+ env.options.axisFormat?.y ?? env.options.format,
2714
+ env.options.locale?.language,
2715
+ domain.pts.some((p) => p.yIsPct) ? "%" : env.options.unit
2716
+ );
2717
+ for (let fit of domain.trends) {
2718
+ let group = fit.group === void 0 ? "" : `, ${domain.groups.get(fit.group)?.label ?? fit.group}`, slope = rate(fit.slope), r2 = fit.r2 === null ? "undefined" : formatAutomaticNumber(fit.r2, { locale: env.options.locale?.language, decimals: 2 });
2719
+ items.push({
2720
+ id: `trend:${fit.id}`,
2721
+ // The fit's own numbers, printed where the line is keyed.
2722
+ label: chartString(env.options, "trendFitLabel", { v1: named, v2: group, v3: slope, v4: r2 }),
2723
+ paint: fit.group === void 0 ? { token: "ink" } : paints.group(fit.group),
2724
+ key: "line",
2725
+ dash: dashToken(env.theme, "reference"),
2726
+ width: strokeToken(env.theme, "rule")
2727
+ });
2728
+ }
2729
+ if (domain.omitted.length > 0 && !disclosuresShown(env.options) && items.push(omittedKey("__omitted", domain.omitted.join(" "))), sizesInRow && area && domain.bubbleMode && domain.sizeMax && env.options.sizeLegend !== !1) {
2730
+ let rowH = spaceTokens(env.theme, env.size.width).legendRowH, maxRadius = Math.max(rowH, SIZE_KEY_MAX_SHARE * env.size.height) / 2, sizeMin = domain.pts.reduce((min, p) => p.size !== null && p.size > 0 ? Math.min(min, p.size) : min, 1 / 0);
2731
+ items.push(...sizeKeyItems(env, sizeMin, domain.sizeMax, (size) => area.radiusOf({ size }), maxRadius, warnings));
2732
+ }
2733
+ return items;
2734
+ }
2735
+ function sizeKeyInPlot(env, domain) {
2736
+ let { options } = env;
2737
+ return domain.bubbleMode && domain.sizeMax !== void 0 && domain.sizeMax > 0 && options.sizeLegend !== !1 && options.legend !== "none" && options.zones === void 0;
2738
+ }
2739
+ function scatterLateNotes(env, domain, area) {
2740
+ let notes = [], titles = env.options.axisTitles ?? {};
2741
+ if (area.showAxes && notes.push(...noteLine(chartString(env.options, "axesUntitled"), [...titles.x ? [] : [chartString(env.options, "horizontal")], ...titles.y ? [] : [chartString(env.options, "vertical")]])), domain.bubbleMode) {
2742
+ let drawn = domain.pts.filter((p) => inView(env.options, domain.dx, domain.dy, p) && p.marker !== "none"), names = (pick) => drawn.filter(pick).map((p) => p.label).join(", "), parts = [
2743
+ [chartString(env.options, "sizeZeroRing"), names((p) => sizeMarkerOf(p) === "zero")],
2744
+ [chartString(env.options, "sizeAbsentPlus"), names((p) => sizeMarkerOf(p) === "missing")],
2745
+ [chartString(env.options, "sizeInvalidCross"), names((p) => sizeMarkerOf(p) === "invalid")],
2746
+ [chartString(env.options, "minimumDotSize"), names((p) => sizeMarkerOf(p) === void 0 && (p.size ?? 0) > 0 && area.radiusOf(p) <= area.radiusOf({ size: 0 }) + 1e-9)]
2747
+ ].filter(([, who]) => who).map(([what, who]) => `${what} (${who})`);
2748
+ parts.length && notes.push(disclosureNote(chartString(env.options, "notDrawnScale", { v1: parts.join("; ") })));
2749
+ }
2750
+ let maxPointLabels = env.options.maxPointLabels ?? 300;
2751
+ return env.options.labels !== !1 && (env.options.labels?.point !== !1 || env.options.labels?.value === !0) && domain.pts.filter((p) => inView(env.options, domain.dx, domain.dy, p)).length > maxPointLabels && notes.push(disclosureNote(chartString(env.options, "pointLabelsOff", { v1: maxPointLabels }))), notes;
2752
+ }
2753
+ var KEY_LABEL_GAP = 12;
2754
+ function rectGap(a, b) {
2755
+ let dx = Math.max(0, a.x - (b.x + b.w), b.x - (a.x + a.w)), dy = Math.max(0, a.y - (b.y + b.h), b.y - (a.y + a.h));
2756
+ return Math.hypot(dx, dy);
2757
+ }
2758
+ var SEAT_PROBE_BUDGET = 8, DOT_SEAT_PROBES = 1, seatProbe = { left: SEAT_PROBE_BUDGET, dotLeft: DOT_SEAT_PROBES, depth: 0 };
2759
+ function layoutScatter(...args) {
2760
+ seatProbe.depth === 0 && (seatProbe.left = SEAT_PROBE_BUDGET, seatProbe.dotLeft = DOT_SEAT_PROBES), seatProbe.depth++;
2761
+ try {
2762
+ return layoutScatterRun(...args);
2763
+ } finally {
2764
+ seatProbe.depth--;
2765
+ }
2766
+ }
2767
+ function layoutScatterRun(data, options = {}, hiddenNames, run = 0, hideListed = !1, valueTier = 0, sizeKeyInRow = !1, calloutMode = "line", valueInsideOnly, keepKeyInPlot = !1) {
2768
+ let warnings = [], hiddenNote = hiddenNoteWith(options, (hiddenNames ?? []).map((text, i) => ({ id: `scatter:${i}`, text }))), env = { ...resolveScatterEnv(options, warnings), valueTier, valueInsideOnly }, domain = resolveScatterDomain(data, env, warnings);
2769
+ if (env.options.legend === "none" && domain.bubbleMode && domain.sizeMax && env.options.sizeLegend !== !1) {
2770
+ let sizeKey = typeof env.options.sizeLegend == "object" && env.options.sizeLegend.label ? env.options.sizeLegend.label : "bubble size";
2771
+ warnings.push({
2772
+ code: "legend-off",
2773
+ severity: "info",
2774
+ message: `legend: 'none' left the size key off: ${sizeKey}. Set legend to a value that shows it, or set sizeLegend: false to drop it on purpose.`
2775
+ });
2776
+ }
2777
+ let paints = scatterPaints(env, domain.groups, domain.pts, domain.bubbleMode ? void 0 : scatterDotRadius(env, domain)), occupied = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), area, solvedFrame, ringRow = 0, keyInPlot = !sizeKeyInRow && sizeKeyInPlot(env, domain);
2778
+ for (let pass = 0; pass < 6; pass++) {
2779
+ let passWarnings = [], keyed = scatterKeyItems(env, domain, paints, area, passWarnings, !keyInPlot);
2780
+ ringRow = Math.max(pass >= 2 ? ringRow : 0, maxOf(keyed.map((item) => item.key === "sizes" ? Math.ceil(2 * Math.max(0.5, ...item.radii ?? [])) : 0)));
2781
+ let items = keyed.map((item) => item.key === "sizes" ? { ...item, ringRow } : item);
2782
+ solvedFrame = solveScatterFrame(env, domain, paints, items, area ? scatterLateNotes(env, domain, area) : [], hiddenNote);
2783
+ let next = scatterPlotArea(env, domain, solvedFrame.frame, passWarnings), stable = area !== void 0 && next.plot.w === area.plot.w && next.plot.h === area.plot.h;
2784
+ if (area = next, stable || pass === 5) {
2785
+ pushAll(warnings, passWarnings);
2786
+ break;
2787
+ }
2788
+ }
2789
+ let { frame, claims } = solvedFrame;
2790
+ commitClaims(occupied, claims);
2791
+ let geometry = layoutScatterMarks(env, domain, area, paints);
2792
+ geometry.densePoints && warnings.push({
2793
+ code: "scatter-dense-paths",
2794
+ severity: "info",
2795
+ message: `${geometry.densePoints} of ${geometry.placed.length} points are drawn as one path per colour (more than ${DENSE_POINTS}): dots carry no outline, so overlaps cannot be counted, and these points have no SVG element of their own`,
2796
+ suggest: "aggregate the points (a heatmap or histogram of the two values) where the reader must see how many overlap"
2797
+ });
2798
+ let plotKey;
2799
+ if (keyInPlot) {
2800
+ let sizeMin = domain.pts.reduce((min, p) => p.size !== null && p.size > 0 ? Math.min(min, p.size) : min, 1 / 0), boxes = domain.quadrants.derived ? ["tr", "br", "tl", "bl"].filter((box) => !domain.quadrants.voidBoxes.has(box)).map((box) => quadrantBoxRect(box, area.plot, geometry.split)) : [];
2801
+ if (plotKey = plotSizeKey(env, area, sizeMin, domain.sizeMax, geometry.claims, warnings, boxes), !plotKey) return layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
2802
+ if (run === 0 && !hideListed && domain.quadrants.derived) {
2803
+ let lostWith = (rects) => {
2804
+ let probe = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height });
2805
+ commitClaims(probe, occupied), commitClaims(probe, geometry.claims);
2806
+ for (let rect of rects) probe.claim(rect, "legend", {}, "sizeKey");
2807
+ return occupied.tickColumns && (probe.tickColumns = [...occupied.tickColumns]), solveLabels(planScatterLabels(env, domain, area, geometry, paints, []), probe, scatterSolveCtx(env, area)).placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).length;
2808
+ };
2809
+ if (lostWith(plotKey.rects) > lostWith([])) return layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
2810
+ }
2811
+ geometry.nodes.push(...plotKey.nodes);
2812
+ for (let rect of plotKey.rects) geometry.claims.claim(rect, "legend", {}, "sizeKey");
2813
+ }
2814
+ commitClaims(occupied, geometry.claims);
2815
+ let solveCtx = scatterSolveCtx(env, area), merged = calloutMode !== "off" ? nameCallouts(env, domain, geometry) : { callouts: /* @__PURE__ */ new Map(), annotations: domain.annotations };
2816
+ env.callouts = merged.callouts, env.calloutWrap = calloutMode === "wrap";
2817
+ let isZero = (c) => c.kind === "axis" && c.part === "referenceLine", annIndex = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height });
2818
+ for (let c of occupied.snapshot()) isZero(c) || annIndex.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
2819
+ occupied.tickColumns && (annIndex.tickColumns = [...occupied.tickColumns]);
2820
+ let claimedBefore = annIndex.snapshot().length, annotated = annotateScatter(env, { ...domain, annotations: merged.annotations }, area, geometry, annIndex, solveCtx);
2821
+ for (let c of annIndex.snapshot().slice(claimedBefore)) occupied.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
2822
+ let zeros = occupied.snapshot().filter(isZero);
2823
+ for (let label of annotated.labels) !label.hidden && zeros.some((z) => rectsOverlap(z.rect, label.rect)) && (label.halo = !0);
2824
+ for (let label of annotated.labels)
2825
+ if (!(label.hidden || !label.leader))
2826
+ for (let [a, b] of leaderPieces(label.leader.d, 16))
2827
+ occupied.claim({ x: Math.min(a.x, b.x) - 1, y: Math.min(a.y, b.y) - 1, w: Math.abs(b.x - a.x) + 2, h: Math.abs(b.y - a.y) + 2 }, "annotation", label.owner, "leader");
2828
+ let probes = /* @__PURE__ */ new Map(), probeKey = (tier, insideOnly) => `${tier}|${[...insideOnly ?? []].map(String).sort().join("\0")}`, probeAt = (tier, insideOnly) => {
2829
+ let key = probeKey(tier, insideOnly), probe = probes.get(key);
2830
+ return probe || (probe = probeSolveOn(planScatterLabels({ ...env, valueTier: tier, valueInsideOnly: insideOnly }, domain, area, geometry, paints, []), occupied, solveCtx, env.size), probes.set(key, probe)), probe.result.placed;
2831
+ }, seatless = (label) => label.hidden !== void 0 && label.slot === "none" && String(label.id).startsWith("point:"), demoteValues = (start) => {
2832
+ let insideOnly = new Set(start);
2833
+ for (let round = 0; round < 4; round++) {
2834
+ let before2 = insideOnly.size;
2835
+ for (let label of probeAt(0, insideOnly)) {
2836
+ let id = label.owner.pointId;
2837
+ !label.hidden || id === void 0 || !/^(point|value):/.test(String(label.id)) || seatless(label) || insideOnly.add(id);
2838
+ }
2839
+ if (insideOnly.size === before2) break;
2840
+ }
2841
+ return insideOnly;
2842
+ };
2843
+ if (run === 0 && !hideListed && valueTier < 2 && domain.bubbleMode && options.labels !== !1 && options.labels?.value === !0) {
2844
+ let lostAt = (tier, insideOnly) => {
2845
+ let placed = probeAt(tier, insideOnly), hidden = (prefix) => placed.filter((label) => label.hidden && String(label.id).startsWith(prefix) && !seatless(label)).length;
2846
+ return 1e3 * hidden("point:") + hidden("value:");
2847
+ }, best = { tier: valueTier, lost: lostAt(valueTier, valueInsideOnly), insideOnly: valueInsideOnly };
2848
+ if (valueTier === 0 && best.lost > 0) {
2849
+ let insideOnly = demoteValues(valueInsideOnly), lost2 = lostAt(0, insideOnly);
2850
+ lost2 < best.lost && (best = { tier: 0, lost: lost2, insideOnly });
2851
+ }
2852
+ for (let tier = valueTier + 1; tier <= 2 && best.lost > 0; tier++) {
2853
+ let lost2 = lostAt(tier);
2854
+ lost2 <= best.lost && (best = { tier, lost: lost2 });
2855
+ }
2856
+ env.valueTier = best.tier, env.valueInsideOnly = best.insideOnly;
2857
+ }
2858
+ let requests = planScatterLabels(env, domain, area, geometry, paints, warnings), byId = new Map(domain.pts.map((p) => [p.id, p])), valueText = new Map(requests.flatMap((request) => request.id.startsWith("value:") && request.owner.pointId !== void 0 ? [[request.owner.pointId, request.text]] : []));
2859
+ if (domain.bubbleMode && options.labels !== !1 && options.labels?.value === !0)
2860
+ for (let p of domain.pts) !valueText.has(p.id) && p.size !== null && valueText.set(p.id, pointValueText(env, domain, p, "size"));
2861
+ let listed = new Set(hiddenNames ?? []), named = new Set(requests.flatMap((request) => request.id.startsWith("point:") && request.owner.pointId !== void 0 ? [request.owner.pointId] : [])), noteText = (id, owner, text) => {
2862
+ let box = String(id).replace(/^quadrant:caption:/, "");
2863
+ if (String(id).startsWith("quadrant:caption:")) return { idx: -1, text: `${text} (${quadrantBoxName(box, env.options)})` };
2864
+ if (String(id).startsWith("zone:")) {
2865
+ let grid = options.zones?.grid, cell = grid?.cells?.find((cell2) => String(id) === `zone:label:${cell2.id}`);
2866
+ return { idx: -1, text: cell ? `${text} (${grid.y.length === 2 ? [chartString(env.options, "bottom"), chartString(env.options, "middle"), chartString(env.options, "top")][cell.row] : chartString(env.options, "rowCount", { v1: cell.row + 1 })} ${grid.x.length === 2 ? [chartString(env.options, "left"), chartString(env.options, "middle"), chartString(env.options, "right")][cell.column] : chartString(env.options, "columnCount", { v1: cell.column + 1 })})` : text };
2867
+ }
2868
+ let p = /^(point|value):/.test(String(id)) ? byId.get(owner.pointId) : void 0;
2869
+ if (!p) return;
2870
+ let value = valueText.get(p.id);
2871
+ if (String(id).startsWith("value:") && named.has(p.id) && value !== void 0)
2872
+ return { idx: p.idx, text: `${p.label}\xA0${value}`, valueFor: p.id };
2873
+ let sp = "\xA0";
2874
+ return { idx: p.idx, text: `${p.label}${sp}(${env.axisFmt.x(p.x)},${sp}${env.axisFmt.y(p.y)})${value !== void 0 && domain.bubbleMode ? `${sp}${value}` : ""}` };
2875
+ };
2876
+ if (hideListed)
2877
+ for (let request of requests) {
2878
+ let pointText = request.id.startsWith("value:") ? noteText(`point:${request.owner.pointId}`, request.owner, request.text)?.text : void 0;
2879
+ !listed.has(noteText(request.id, request.owner, request.text)?.text ?? "") && !(pointText !== void 0 && listed.has(pointText)) || (request.redundant = !0, request.suppressedAs = "density");
2880
+ }
2881
+ let unmoved = keepNamesApart(requests, occupied, solveCtx, env.size, hideListed ? void 0 : probes.get(probeKey(env.valueTier ?? 0, env.valueInsideOnly))), before = occupied, solved;
2882
+ unmoved ? (solved = unmoved.result, occupied = unmoved.index) : (occupied = copyOccupied(before, env.size), solved = solveLabels(requests, occupied, solveCtx));
2883
+ let lostPoints = solved.placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).length, spare = domain.bubbleMode ? 0 : Math.max(0, seatProbe.left - seatProbe.dotLeft);
2884
+ seatProbe.left -= spare;
2885
+ let leftBefore = seatProbe.left, seated = lostPoints > 0 && (domain.bubbleMode || lostPoints === 1) ? seatLostNames(requests, before, solveCtx, env.size, solved.placed, !domain.bubbleMode) : void 0;
2886
+ domain.bubbleMode || (seatProbe.dotLeft -= leftBefore - seatProbe.left), seatProbe.left += spare, seated && (solved = seated.result, occupied = seated.index);
2887
+ let lostIn = (labels) => labels.reduce((sum, label) => sum + (label.hidden ? String(label.id).startsWith("point:") ? 1e3 : String(label.id).startsWith("value:") ? 1 : 0 : 0), 0), rowAlternative;
2888
+ if (plotKey && !sizeKeyInRow && !keepKeyInPlot && run === 0 && !hideListed && solved.placed.some((label) => !label.hidden && String(label.id).startsWith("point:") && plotKey.rects.some((rect) => rectGap(rect, label.rect) < KEY_LABEL_GAP))) {
2889
+ let inRow = layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
2890
+ if (!domain.bubbleMode || domain.quadrants.derived || lostIn(inRow.labels) < 1e3) return inRow;
2891
+ rowAlternative = { geo: inRow, lost: lostIn(inRow.labels) };
2892
+ }
2893
+ let keepKey = keepKeyInPlot || rowAlternative !== void 0, pick = (inPlot) => !rowAlternative || lostIn(inPlot.labels) < rowAlternative.lost ? inPlot : rowAlternative.geo;
2894
+ if (merged.callouts.size > 0 && solved.placed.some((label) => label.hidden && String(label.id).startsWith("point:") && merged.callouts.has(label.owner.pointId)))
2895
+ return pick(layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, sizeKeyInRow, calloutMode === "line" ? "wrap" : "off", valueInsideOnly, keepKey));
2896
+ let lostNames = new Set(solved.placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).map((label) => label.owner.pointId)), entryFor = (label) => {
2897
+ let entry = noteText(label.id, label.owner, label.text);
2898
+ return entry?.valueFor !== void 0 && lostNames.has(entry.valueFor) ? noteText(`point:${entry.valueFor}`, label.owner, label.text) : entry;
2899
+ }, lost = solved.placed.flatMap((label) => {
2900
+ let entry = label.hidden ? entryFor(label) : void 0;
2901
+ return entry ? [entry] : [];
2902
+ }), lostTexts = [...new Set(lost.sort((a, b) => a.idx - b.idx).map((entry) => entry.text))], complete = lostTexts.every((text) => listed.has(text)), exact = complete && lostTexts.length === listed.size;
2903
+ if (!exact && run < 4 && (lostTexts.length > 0 || listed.size > 0)) {
2904
+ let next = complete ? lostTexts : run === 3 ? [.../* @__PURE__ */ new Set([...listed, ...lostTexts])] : lostTexts;
2905
+ if (next.length !== listed.size || next.some((text) => !listed.has(text))) {
2906
+ let attempt = layoutScatter(data, options, next, run + 1, hideListed, env.valueTier, sizeKeyInRow, calloutMode, env.valueInsideOnly, keepKey);
2907
+ if (!complete || !notListed(attempt)) return pick(attempt);
2908
+ }
2909
+ }
2910
+ if (complete && !exact && !hideListed) return pick(layoutScatter(data, options, hiddenNames, run, !0, env.valueTier, sizeKeyInRow, calloutMode, env.valueInsideOnly, keepKey));
2911
+ let own = solved.placed.filter((label) => label.hidden && listed.has(entryFor(label)?.text ?? "")), notedIds = new Set([...solved.placed.filter((label) => label.noted), ...own].map((label) => label.id));
2912
+ pushAll(warnings, solved.warnings.map((warning) => warning.code === "label-hidden" && notedIds.has(warning.message.match(/label '([^']+)'/)?.[1] ?? "") ? { ...warning, severity: "info" } : warning)), pushAll(warnings, annotated.warnings);
2913
+ let drawn = assembleScatterGeometry({ env, domain, frame, area, geometry, solved, annotated, occupied, warnings }), names = [...hiddenNames ?? []], counted = new Set([...hiddenNote.counted].filter((id) => !id.startsWith("scatter:")));
2914
+ for (let label of own) {
2915
+ let at = names.indexOf(entryFor(label)?.text ?? "");
2916
+ hiddenNote.counted.has(`scatter:${at}`) && counted.add(label.id);
2917
+ }
2918
+ markNotedLabels(drawn, new Set([...hiddenNote.ids].filter((id) => !id.startsWith("scatter:")).concat(own.map((label) => label.id))), counted);
2919
+ for (let label of own) label.noted = !0;
2920
+ return pick(drawn);
2921
+ }
2922
+
2923
+ // src/core/charts/scatter/core.ts
2924
+ var scatterCore = {
2925
+ type: "scatter",
2926
+ sizing: chartSizing("scatter"),
2927
+ title: "Scatter / bubble",
2928
+ summary: "XY point cloud with group colors, spiral point labels, and area-true bubbles",
2929
+ aliases: ["bubble"],
2930
+ layout: layoutScatter,
2931
+ defaults: { sizeBy: "area", maxPointLabels: 300 },
2932
+ annotationKinds: ["diff", "delta", "abs", "note", "callout", "valueLine"]
2933
+ };
2934
+
2935
+ export {
2936
+ scatterCore
2937
+ };