minerva-design 1.4.0 → 1.6.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 (824) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +21 -21
  3. package/custom-elements.json +3072 -611
  4. package/dist/angular/fesm2022/minerva-angular.mjs +1491 -5
  5. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  6. package/dist/angular/types/minerva-angular.d.ts +595 -5
  7. package/dist/charts/canvas.d.cts +4 -3
  8. package/dist/charts/canvas.d.ts +4 -3
  9. package/dist/charts/core.cjs +1 -1
  10. package/dist/charts/core.d.cts +6 -4
  11. package/dist/charts/core.d.ts +6 -4
  12. package/dist/charts/core.js +24 -16
  13. package/dist/charts/engine/axis.cjs +1 -1
  14. package/dist/charts/engine/axis.cjs.map +1 -1
  15. package/dist/charts/engine/axis.js +42 -19
  16. package/dist/charts/engine/axis.js.map +1 -1
  17. package/dist/charts/engine/canvas.cjs +1 -1
  18. package/dist/charts/engine/canvas.cjs.map +1 -1
  19. package/dist/charts/engine/canvas.js +155 -127
  20. package/dist/charts/engine/canvas.js.map +1 -1
  21. package/dist/charts/engine/chart.cjs +1 -1
  22. package/dist/charts/engine/chart.cjs.map +1 -1
  23. package/dist/charts/engine/chart.js +370 -255
  24. package/dist/charts/engine/chart.js.map +1 -1
  25. package/dist/charts/engine/color.cjs +1 -1
  26. package/dist/charts/engine/color.cjs.map +1 -1
  27. package/dist/charts/engine/color.d.cts +18 -0
  28. package/dist/charts/engine/color.d.ts +18 -0
  29. package/dist/charts/engine/color.js +48 -2
  30. package/dist/charts/engine/color.js.map +1 -1
  31. package/dist/charts/engine/controller.cjs +2 -2
  32. package/dist/charts/engine/controller.cjs.map +1 -1
  33. package/dist/charts/engine/controller.d.cts +34 -1
  34. package/dist/charts/engine/controller.d.ts +34 -1
  35. package/dist/charts/engine/controller.js +318 -273
  36. package/dist/charts/engine/controller.js.map +1 -1
  37. package/dist/charts/engine/data.cjs +1 -1
  38. package/dist/charts/engine/data.cjs.map +1 -1
  39. package/dist/charts/engine/data.d.cts +3 -1
  40. package/dist/charts/engine/data.d.ts +3 -1
  41. package/dist/charts/engine/data.js +6 -4
  42. package/dist/charts/engine/data.js.map +1 -1
  43. package/dist/charts/engine/defaults.cjs +2 -0
  44. package/dist/charts/engine/defaults.cjs.map +1 -0
  45. package/dist/charts/engine/defaults.d.cts +20 -0
  46. package/dist/charts/engine/defaults.d.ts +20 -0
  47. package/dist/charts/engine/defaults.js +35 -0
  48. package/dist/charts/engine/defaults.js.map +1 -0
  49. package/dist/charts/engine/format.cjs +1 -1
  50. package/dist/charts/engine/format.cjs.map +1 -1
  51. package/dist/charts/engine/format.d.cts +6 -0
  52. package/dist/charts/engine/format.d.ts +6 -0
  53. package/dist/charts/engine/format.js +15 -2
  54. package/dist/charts/engine/format.js.map +1 -1
  55. package/dist/charts/engine/graph/chart.cjs +2 -0
  56. package/dist/charts/engine/graph/chart.cjs.map +1 -0
  57. package/dist/charts/engine/graph/chart.d.cts +3 -0
  58. package/dist/charts/engine/graph/chart.d.ts +3 -0
  59. package/dist/charts/engine/graph/chart.js +1708 -0
  60. package/dist/charts/engine/graph/chart.js.map +1 -0
  61. package/dist/charts/engine/graph/circular.cjs +2 -0
  62. package/dist/charts/engine/graph/circular.cjs.map +1 -0
  63. package/dist/charts/engine/graph/circular.d.cts +16 -0
  64. package/dist/charts/engine/graph/circular.d.ts +16 -0
  65. package/dist/charts/engine/graph/circular.js +62 -0
  66. package/dist/charts/engine/graph/circular.js.map +1 -0
  67. package/dist/charts/engine/graph/dag.cjs +2 -0
  68. package/dist/charts/engine/graph/dag.cjs.map +1 -0
  69. package/dist/charts/engine/graph/dag.d.cts +34 -0
  70. package/dist/charts/engine/graph/dag.d.ts +34 -0
  71. package/dist/charts/engine/graph/dag.js +339 -0
  72. package/dist/charts/engine/graph/dag.js.map +1 -0
  73. package/dist/charts/engine/graph/dom.cjs +2 -0
  74. package/dist/charts/engine/graph/dom.cjs.map +1 -0
  75. package/dist/charts/engine/graph/dom.d.cts +23 -0
  76. package/dist/charts/engine/graph/dom.d.ts +23 -0
  77. package/dist/charts/engine/graph/dom.js +158 -0
  78. package/dist/charts/engine/graph/dom.js.map +1 -0
  79. package/dist/charts/engine/graph/force.cjs +2 -0
  80. package/dist/charts/engine/graph/force.cjs.map +1 -0
  81. package/dist/charts/engine/graph/force.d.cts +76 -0
  82. package/dist/charts/engine/graph/force.d.ts +76 -0
  83. package/dist/charts/engine/graph/force.js +423 -0
  84. package/dist/charts/engine/graph/force.js.map +1 -0
  85. package/dist/charts/engine/graph/geometry.cjs +2 -0
  86. package/dist/charts/engine/graph/geometry.cjs.map +1 -0
  87. package/dist/charts/engine/graph/geometry.d.cts +50 -0
  88. package/dist/charts/engine/graph/geometry.d.ts +50 -0
  89. package/dist/charts/engine/graph/geometry.js +197 -0
  90. package/dist/charts/engine/graph/geometry.js.map +1 -0
  91. package/dist/charts/engine/graph/index.cjs +1 -0
  92. package/dist/charts/engine/graph/index.d.cts +6 -0
  93. package/dist/charts/engine/graph/index.d.ts +6 -0
  94. package/dist/charts/engine/graph/index.js +6 -0
  95. package/dist/charts/engine/graph/labels.cjs +2 -0
  96. package/dist/charts/engine/graph/labels.cjs.map +1 -0
  97. package/dist/charts/engine/graph/labels.d.cts +12 -0
  98. package/dist/charts/engine/graph/labels.d.ts +12 -0
  99. package/dist/charts/engine/graph/labels.js +128 -0
  100. package/dist/charts/engine/graph/labels.js.map +1 -0
  101. package/dist/charts/engine/graph/model.cjs +2 -0
  102. package/dist/charts/engine/graph/model.cjs.map +1 -0
  103. package/dist/charts/engine/graph/model.d.cts +52 -0
  104. package/dist/charts/engine/graph/model.d.ts +52 -0
  105. package/dist/charts/engine/graph/model.js +108 -0
  106. package/dist/charts/engine/graph/model.js.map +1 -0
  107. package/dist/charts/engine/graph/sizing.cjs +2 -0
  108. package/dist/charts/engine/graph/sizing.cjs.map +1 -0
  109. package/dist/charts/engine/graph/sizing.d.cts +33 -0
  110. package/dist/charts/engine/graph/sizing.d.ts +33 -0
  111. package/dist/charts/engine/graph/sizing.js +60 -0
  112. package/dist/charts/engine/graph/sizing.js.map +1 -0
  113. package/dist/charts/engine/graph/tree.cjs +2 -0
  114. package/dist/charts/engine/graph/tree.cjs.map +1 -0
  115. package/dist/charts/engine/graph/tree.d.cts +30 -0
  116. package/dist/charts/engine/graph/tree.d.ts +30 -0
  117. package/dist/charts/engine/graph/tree.js +218 -0
  118. package/dist/charts/engine/graph/tree.js.map +1 -0
  119. package/dist/charts/engine/graph/types.d.cts +640 -0
  120. package/dist/charts/engine/graph/types.d.ts +640 -0
  121. package/dist/charts/engine/graph/worker.cjs +52 -0
  122. package/dist/charts/engine/graph/worker.cjs.map +1 -0
  123. package/dist/charts/engine/graph/worker.d.cts +36 -0
  124. package/dist/charts/engine/graph/worker.d.ts +36 -0
  125. package/dist/charts/engine/graph/worker.js +135 -0
  126. package/dist/charts/engine/graph/worker.js.map +1 -0
  127. package/dist/charts/engine/items.cjs +1 -1
  128. package/dist/charts/engine/items.cjs.map +1 -1
  129. package/dist/charts/engine/items.d.cts +15 -2
  130. package/dist/charts/engine/items.d.ts +15 -2
  131. package/dist/charts/engine/items.js +131 -112
  132. package/dist/charts/engine/items.js.map +1 -1
  133. package/dist/charts/engine/labels.cjs +1 -1
  134. package/dist/charts/engine/labels.cjs.map +1 -1
  135. package/dist/charts/engine/labels.d.cts +17 -0
  136. package/dist/charts/engine/labels.d.ts +17 -0
  137. package/dist/charts/engine/labels.js +28 -4
  138. package/dist/charts/engine/labels.js.map +1 -1
  139. package/dist/charts/engine/layout.cjs +1 -1
  140. package/dist/charts/engine/layout.cjs.map +1 -1
  141. package/dist/charts/engine/layout.d.cts +9 -0
  142. package/dist/charts/engine/layout.d.ts +9 -0
  143. package/dist/charts/engine/layout.js +11 -2
  144. package/dist/charts/engine/layout.js.map +1 -1
  145. package/dist/charts/engine/model.cjs +1 -1
  146. package/dist/charts/engine/model.cjs.map +1 -1
  147. package/dist/charts/engine/model.d.cts +73 -3
  148. package/dist/charts/engine/model.d.ts +73 -3
  149. package/dist/charts/engine/model.js +258 -154
  150. package/dist/charts/engine/model.js.map +1 -1
  151. package/dist/charts/engine/orderbook/field.cjs +37 -0
  152. package/dist/charts/engine/orderbook/field.cjs.map +1 -0
  153. package/dist/charts/engine/orderbook/field.d.cts +92 -0
  154. package/dist/charts/engine/orderbook/field.d.ts +92 -0
  155. package/dist/charts/engine/orderbook/field.js +297 -0
  156. package/dist/charts/engine/orderbook/field.js.map +1 -0
  157. package/dist/charts/engine/orderbook/format.cjs +1 -1
  158. package/dist/charts/engine/orderbook/format.cjs.map +1 -1
  159. package/dist/charts/engine/orderbook/format.d.cts +3 -2
  160. package/dist/charts/engine/orderbook/format.d.ts +3 -2
  161. package/dist/charts/engine/orderbook/format.js +5 -5
  162. package/dist/charts/engine/orderbook/format.js.map +1 -1
  163. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  164. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  165. package/dist/charts/engine/orderbook/heatmap.js +566 -475
  166. package/dist/charts/engine/orderbook/heatmap.js.map +1 -1
  167. package/dist/charts/engine/orderbook/host.cjs +1 -1
  168. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  169. package/dist/charts/engine/orderbook/host.d.cts +8 -1
  170. package/dist/charts/engine/orderbook/host.d.ts +8 -1
  171. package/dist/charts/engine/orderbook/host.js +27 -5
  172. package/dist/charts/engine/orderbook/host.js.map +1 -1
  173. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  174. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  175. package/dist/charts/engine/orderbook/ladder.js +1 -1
  176. package/dist/charts/engine/orderbook/ladder.js.map +1 -1
  177. package/dist/charts/engine/orderbook/layout.cjs +2 -0
  178. package/dist/charts/engine/orderbook/layout.cjs.map +1 -0
  179. package/dist/charts/engine/orderbook/layout.d.cts +42 -0
  180. package/dist/charts/engine/orderbook/layout.d.ts +42 -0
  181. package/dist/charts/engine/orderbook/layout.js +76 -0
  182. package/dist/charts/engine/orderbook/layout.js.map +1 -0
  183. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  184. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  185. package/dist/charts/engine/orderbook/tape.js +4 -4
  186. package/dist/charts/engine/orderbook/tape.js.map +1 -1
  187. package/dist/charts/engine/orderbook/types.d.cts +27 -3
  188. package/dist/charts/engine/orderbook/types.d.ts +27 -3
  189. package/dist/charts/engine/overlay.cjs +1 -1
  190. package/dist/charts/engine/overlay.cjs.map +1 -1
  191. package/dist/charts/engine/overlay.d.cts +27 -0
  192. package/dist/charts/engine/overlay.d.ts +27 -0
  193. package/dist/charts/engine/overlay.js +34 -12
  194. package/dist/charts/engine/overlay.js.map +1 -1
  195. package/dist/charts/engine/presets.cjs +2 -2
  196. package/dist/charts/engine/presets.cjs.map +1 -1
  197. package/dist/charts/engine/presets.d.cts +35 -3
  198. package/dist/charts/engine/presets.d.ts +35 -3
  199. package/dist/charts/engine/presets.js +121 -101
  200. package/dist/charts/engine/presets.js.map +1 -1
  201. package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
  202. package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
  203. package/dist/charts/engine/renderers/canvas2d.js +13 -9
  204. package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
  205. package/dist/charts/engine/renderers/detect.cjs +1 -1
  206. package/dist/charts/engine/renderers/detect.cjs.map +1 -1
  207. package/dist/charts/engine/renderers/detect.d.cts +2 -1
  208. package/dist/charts/engine/renderers/detect.d.ts +2 -1
  209. package/dist/charts/engine/renderers/detect.js +23 -21
  210. package/dist/charts/engine/renderers/detect.js.map +1 -1
  211. package/dist/charts/engine/renderers/follow.cjs +2 -0
  212. package/dist/charts/engine/renderers/follow.cjs.map +1 -0
  213. package/dist/charts/engine/renderers/follow.d.cts +8 -0
  214. package/dist/charts/engine/renderers/follow.d.ts +8 -0
  215. package/dist/charts/engine/renderers/follow.js +10 -0
  216. package/dist/charts/engine/renderers/follow.js.map +1 -0
  217. package/dist/charts/engine/renderers/gl-budget.cjs +2 -0
  218. package/dist/charts/engine/renderers/gl-budget.cjs.map +1 -0
  219. package/dist/charts/engine/renderers/gl-budget.d.cts +32 -0
  220. package/dist/charts/engine/renderers/gl-budget.d.ts +32 -0
  221. package/dist/charts/engine/renderers/gl-budget.js +95 -0
  222. package/dist/charts/engine/renderers/gl-budget.js.map +1 -0
  223. package/dist/charts/engine/renderers/gl.cjs +1 -1
  224. package/dist/charts/engine/renderers/gl.cjs.map +1 -1
  225. package/dist/charts/engine/renderers/gl.js +1 -1
  226. package/dist/charts/engine/renderers/gl.js.map +1 -1
  227. package/dist/charts/engine/renderers/shaders.cjs +9 -6
  228. package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
  229. package/dist/charts/engine/renderers/shaders.d.cts +1 -1
  230. package/dist/charts/engine/renderers/shaders.d.ts +1 -1
  231. package/dist/charts/engine/renderers/shaders.js +9 -6
  232. package/dist/charts/engine/renderers/shaders.js.map +1 -1
  233. package/dist/charts/engine/renderers/types.cjs.map +1 -1
  234. package/dist/charts/engine/renderers/types.d.cts +2 -0
  235. package/dist/charts/engine/renderers/types.d.ts +2 -0
  236. package/dist/charts/engine/renderers/types.js.map +1 -1
  237. package/dist/charts/engine/renderers/webgl.cjs +1 -1
  238. package/dist/charts/engine/renderers/webgl.cjs.map +1 -1
  239. package/dist/charts/engine/renderers/webgl.js +85 -64
  240. package/dist/charts/engine/renderers/webgl.js.map +1 -1
  241. package/dist/charts/engine/renderers/webgl2.cjs +1 -1
  242. package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
  243. package/dist/charts/engine/renderers/webgl2.js +72 -58
  244. package/dist/charts/engine/renderers/webgl2.js.map +1 -1
  245. package/dist/charts/engine/renderers/webgpu.cjs +1 -1
  246. package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
  247. package/dist/charts/engine/renderers/webgpu.js +1 -1
  248. package/dist/charts/engine/renderers/webgpu.js.map +1 -1
  249. package/dist/charts/engine/scene.cjs +1 -1
  250. package/dist/charts/engine/scene.cjs.map +1 -1
  251. package/dist/charts/engine/scene.d.cts +104 -4
  252. package/dist/charts/engine/scene.d.ts +104 -4
  253. package/dist/charts/engine/scene.js +412 -193
  254. package/dist/charts/engine/scene.js.map +1 -1
  255. package/dist/charts/engine/shapes/bullet.cjs +1 -1
  256. package/dist/charts/engine/shapes/bullet.cjs.map +1 -1
  257. package/dist/charts/engine/shapes/bullet.js +110 -110
  258. package/dist/charts/engine/shapes/bullet.js.map +1 -1
  259. package/dist/charts/engine/shapes/chart.cjs +1 -1
  260. package/dist/charts/engine/shapes/chart.cjs.map +1 -1
  261. package/dist/charts/engine/shapes/chart.js +4 -1
  262. package/dist/charts/engine/shapes/chart.js.map +1 -1
  263. package/dist/charts/engine/shapes/chord.cjs +2 -0
  264. package/dist/charts/engine/shapes/chord.cjs.map +1 -0
  265. package/dist/charts/engine/shapes/chord.d.cts +18 -0
  266. package/dist/charts/engine/shapes/chord.d.ts +18 -0
  267. package/dist/charts/engine/shapes/chord.js +419 -0
  268. package/dist/charts/engine/shapes/chord.js.map +1 -0
  269. package/dist/charts/engine/shapes/draw.cjs +1 -1
  270. package/dist/charts/engine/shapes/draw.cjs.map +1 -1
  271. package/dist/charts/engine/shapes/draw.d.cts +5 -1
  272. package/dist/charts/engine/shapes/draw.d.ts +5 -1
  273. package/dist/charts/engine/shapes/draw.js +47 -17
  274. package/dist/charts/engine/shapes/draw.js.map +1 -1
  275. package/dist/charts/engine/shapes/hit.cjs +1 -1
  276. package/dist/charts/engine/shapes/hit.cjs.map +1 -1
  277. package/dist/charts/engine/shapes/hit.d.cts +3 -1
  278. package/dist/charts/engine/shapes/hit.d.ts +3 -1
  279. package/dist/charts/engine/shapes/hit.js +75 -46
  280. package/dist/charts/engine/shapes/hit.js.map +1 -1
  281. package/dist/charts/engine/shapes/index.d.cts +3 -2
  282. package/dist/charts/engine/shapes/index.d.ts +3 -2
  283. package/dist/charts/engine/shapes/labels.cjs +1 -1
  284. package/dist/charts/engine/shapes/labels.cjs.map +1 -1
  285. package/dist/charts/engine/shapes/labels.js +12 -4
  286. package/dist/charts/engine/shapes/labels.js.map +1 -1
  287. package/dist/charts/engine/shapes/layout.cjs +2 -2
  288. package/dist/charts/engine/shapes/layout.cjs.map +1 -1
  289. package/dist/charts/engine/shapes/layout.d.cts +3 -1
  290. package/dist/charts/engine/shapes/layout.d.ts +3 -1
  291. package/dist/charts/engine/shapes/layout.js +106 -78
  292. package/dist/charts/engine/shapes/layout.js.map +1 -1
  293. package/dist/charts/engine/shapes/scene.cjs +1 -1
  294. package/dist/charts/engine/shapes/scene.cjs.map +1 -1
  295. package/dist/charts/engine/shapes/scene.d.cts +33 -3
  296. package/dist/charts/engine/shapes/scene.d.ts +33 -3
  297. package/dist/charts/engine/shapes/scene.js +62 -19
  298. package/dist/charts/engine/shapes/scene.js.map +1 -1
  299. package/dist/charts/engine/shapes/types.d.cts +121 -8
  300. package/dist/charts/engine/shapes/types.d.ts +121 -8
  301. package/dist/charts/engine/signature.cjs +1 -1
  302. package/dist/charts/engine/signature.cjs.map +1 -1
  303. package/dist/charts/engine/signature.js +1 -1
  304. package/dist/charts/engine/signature.js.map +1 -1
  305. package/dist/charts/engine/three-d/canvas2d.cjs +1 -1
  306. package/dist/charts/engine/three-d/canvas2d.cjs.map +1 -1
  307. package/dist/charts/engine/three-d/canvas2d.d.cts +41 -3
  308. package/dist/charts/engine/three-d/canvas2d.d.ts +41 -3
  309. package/dist/charts/engine/three-d/canvas2d.js +166 -67
  310. package/dist/charts/engine/three-d/canvas2d.js.map +1 -1
  311. package/dist/charts/engine/three-d/chart.cjs +1 -1
  312. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  313. package/dist/charts/engine/three-d/chart.js +219 -215
  314. package/dist/charts/engine/three-d/chart.js.map +1 -1
  315. package/dist/charts/engine/three-d/detect.cjs +1 -1
  316. package/dist/charts/engine/three-d/detect.cjs.map +1 -1
  317. package/dist/charts/engine/three-d/detect.d.cts +3 -2
  318. package/dist/charts/engine/three-d/detect.d.ts +3 -2
  319. package/dist/charts/engine/three-d/detect.js +22 -20
  320. package/dist/charts/engine/three-d/detect.js.map +1 -1
  321. package/dist/charts/engine/three-d/geometry.cjs +1 -1
  322. package/dist/charts/engine/three-d/geometry.cjs.map +1 -1
  323. package/dist/charts/engine/three-d/geometry.d.cts +6 -0
  324. package/dist/charts/engine/three-d/geometry.d.ts +6 -0
  325. package/dist/charts/engine/three-d/geometry.js +106 -90
  326. package/dist/charts/engine/three-d/geometry.js.map +1 -1
  327. package/dist/charts/engine/three-d/model.cjs +1 -1
  328. package/dist/charts/engine/three-d/model.cjs.map +1 -1
  329. package/dist/charts/engine/three-d/model.d.cts +2 -0
  330. package/dist/charts/engine/three-d/model.d.ts +2 -0
  331. package/dist/charts/engine/three-d/model.js +2 -0
  332. package/dist/charts/engine/three-d/model.js.map +1 -1
  333. package/dist/charts/engine/three-d/oit.cjs +109 -0
  334. package/dist/charts/engine/three-d/oit.cjs.map +1 -0
  335. package/dist/charts/engine/three-d/oit.d.cts +34 -0
  336. package/dist/charts/engine/three-d/oit.d.ts +34 -0
  337. package/dist/charts/engine/three-d/oit.js +111 -0
  338. package/dist/charts/engine/three-d/oit.js.map +1 -0
  339. package/dist/charts/engine/three-d/overlay.cjs +1 -1
  340. package/dist/charts/engine/three-d/overlay.cjs.map +1 -1
  341. package/dist/charts/engine/three-d/overlay.js +43 -36
  342. package/dist/charts/engine/three-d/overlay.js.map +1 -1
  343. package/dist/charts/engine/three-d/render-types.cjs +1 -1
  344. package/dist/charts/engine/three-d/render-types.cjs.map +1 -1
  345. package/dist/charts/engine/three-d/render-types.d.cts +37 -3
  346. package/dist/charts/engine/three-d/render-types.d.ts +37 -3
  347. package/dist/charts/engine/three-d/render-types.js +6 -10
  348. package/dist/charts/engine/three-d/render-types.js.map +1 -1
  349. package/dist/charts/engine/three-d/shaders.cjs +109 -48
  350. package/dist/charts/engine/three-d/shaders.cjs.map +1 -1
  351. package/dist/charts/engine/three-d/shaders.d.cts +12 -5
  352. package/dist/charts/engine/three-d/shaders.d.ts +12 -5
  353. package/dist/charts/engine/three-d/shaders.js +118 -55
  354. package/dist/charts/engine/three-d/shaders.js.map +1 -1
  355. package/dist/charts/engine/three-d/sort.cjs +1 -1
  356. package/dist/charts/engine/three-d/sort.cjs.map +1 -1
  357. package/dist/charts/engine/three-d/sort.d.cts +18 -5
  358. package/dist/charts/engine/three-d/sort.d.ts +18 -5
  359. package/dist/charts/engine/three-d/sort.js +129 -43
  360. package/dist/charts/engine/three-d/sort.js.map +1 -1
  361. package/dist/charts/engine/three-d/types.d.cts +36 -0
  362. package/dist/charts/engine/three-d/types.d.ts +36 -0
  363. package/dist/charts/engine/three-d/webgl.cjs +1 -1
  364. package/dist/charts/engine/three-d/webgl.cjs.map +1 -1
  365. package/dist/charts/engine/three-d/webgl.d.cts +9 -0
  366. package/dist/charts/engine/three-d/webgl.d.ts +9 -0
  367. package/dist/charts/engine/three-d/webgl.js +199 -74
  368. package/dist/charts/engine/three-d/webgl.js.map +1 -1
  369. package/dist/charts/engine/three-d/webgpu.cjs +1 -1
  370. package/dist/charts/engine/three-d/webgpu.cjs.map +1 -1
  371. package/dist/charts/engine/three-d/webgpu.js +231 -94
  372. package/dist/charts/engine/three-d/webgpu.js.map +1 -1
  373. package/dist/charts/engine/trading/chart.cjs +1 -1
  374. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  375. package/dist/charts/engine/trading/chart.d.cts +10 -1
  376. package/dist/charts/engine/trading/chart.d.ts +10 -1
  377. package/dist/charts/engine/trading/chart.js +1677 -813
  378. package/dist/charts/engine/trading/chart.js.map +1 -1
  379. package/dist/charts/engine/trading/drawings.cjs +2 -1
  380. package/dist/charts/engine/trading/drawings.cjs.map +1 -1
  381. package/dist/charts/engine/trading/drawings.d.cts +53 -9
  382. package/dist/charts/engine/trading/drawings.d.ts +53 -9
  383. package/dist/charts/engine/trading/drawings.js +346 -71
  384. package/dist/charts/engine/trading/drawings.js.map +1 -1
  385. package/dist/charts/engine/trading/format.cjs +1 -1
  386. package/dist/charts/engine/trading/format.cjs.map +1 -1
  387. package/dist/charts/engine/trading/format.d.cts +19 -0
  388. package/dist/charts/engine/trading/format.d.ts +19 -0
  389. package/dist/charts/engine/trading/format.js +65 -21
  390. package/dist/charts/engine/trading/format.js.map +1 -1
  391. package/dist/charts/engine/trading/geometry.cjs +1 -1
  392. package/dist/charts/engine/trading/geometry.cjs.map +1 -1
  393. package/dist/charts/engine/trading/geometry.d.cts +16 -0
  394. package/dist/charts/engine/trading/geometry.d.ts +16 -0
  395. package/dist/charts/engine/trading/geometry.js +19 -4
  396. package/dist/charts/engine/trading/geometry.js.map +1 -1
  397. package/dist/charts/engine/trading/index.cjs +1 -1
  398. package/dist/charts/engine/trading/index.d.cts +2 -1
  399. package/dist/charts/engine/trading/index.d.ts +2 -1
  400. package/dist/charts/engine/trading/index.js +4 -3
  401. package/dist/charts/engine/trading/indicators.cjs +1 -1
  402. package/dist/charts/engine/trading/indicators.cjs.map +1 -1
  403. package/dist/charts/engine/trading/indicators.d.cts +180 -10
  404. package/dist/charts/engine/trading/indicators.d.ts +180 -10
  405. package/dist/charts/engine/trading/indicators.js +449 -173
  406. package/dist/charts/engine/trading/indicators.js.map +1 -1
  407. package/dist/charts/engine/trading/labels.cjs +1 -1
  408. package/dist/charts/engine/trading/labels.cjs.map +1 -1
  409. package/dist/charts/engine/trading/labels.js +104 -4
  410. package/dist/charts/engine/trading/labels.js.map +1 -1
  411. package/dist/charts/engine/trading/store.cjs +1 -1
  412. package/dist/charts/engine/trading/store.cjs.map +1 -1
  413. package/dist/charts/engine/trading/store.d.cts +21 -0
  414. package/dist/charts/engine/trading/store.d.ts +21 -0
  415. package/dist/charts/engine/trading/store.js +22 -1
  416. package/dist/charts/engine/trading/store.js.map +1 -1
  417. package/dist/charts/engine/trading/studies.cjs +1 -1
  418. package/dist/charts/engine/trading/studies.cjs.map +1 -1
  419. package/dist/charts/engine/trading/studies.d.cts +49 -8
  420. package/dist/charts/engine/trading/studies.d.ts +49 -8
  421. package/dist/charts/engine/trading/studies.js +352 -93
  422. package/dist/charts/engine/trading/studies.js.map +1 -1
  423. package/dist/charts/engine/trading/sync.cjs +2 -0
  424. package/dist/charts/engine/trading/sync.cjs.map +1 -0
  425. package/dist/charts/engine/trading/sync.d.cts +8 -0
  426. package/dist/charts/engine/trading/sync.d.ts +8 -0
  427. package/dist/charts/engine/trading/sync.js +25 -0
  428. package/dist/charts/engine/trading/sync.js.map +1 -0
  429. package/dist/charts/engine/trading/types.d.cts +514 -16
  430. package/dist/charts/engine/trading/types.d.ts +514 -16
  431. package/dist/charts/engine/types.d.cts +106 -11
  432. package/dist/charts/engine/types.d.ts +106 -11
  433. package/dist/charts/index.cjs +1 -1
  434. package/dist/charts/index.d.cts +3 -2
  435. package/dist/charts/index.d.ts +3 -2
  436. package/dist/charts/index.js +30 -22
  437. package/dist/charts/react/charts.cjs +1 -1
  438. package/dist/charts/react/charts.cjs.map +1 -1
  439. package/dist/charts/react/charts.js +51 -34
  440. package/dist/charts/react/charts.js.map +1 -1
  441. package/dist/charts/react/graph.cjs +2 -0
  442. package/dist/charts/react/graph.cjs.map +1 -0
  443. package/dist/charts/react/graph.d.cts +219 -0
  444. package/dist/charts/react/graph.d.ts +219 -0
  445. package/dist/charts/react/graph.js +160 -0
  446. package/dist/charts/react/graph.js.map +1 -0
  447. package/dist/charts/react/orderbook.cjs +1 -1
  448. package/dist/charts/react/orderbook.cjs.map +1 -1
  449. package/dist/charts/react/orderbook.d.cts +3 -1
  450. package/dist/charts/react/orderbook.d.ts +3 -1
  451. package/dist/charts/react/orderbook.js +1 -0
  452. package/dist/charts/react/orderbook.js.map +1 -1
  453. package/dist/charts/react/shapes.cjs +1 -1
  454. package/dist/charts/react/shapes.cjs.map +1 -1
  455. package/dist/charts/react/shapes.d.cts +88 -4
  456. package/dist/charts/react/shapes.d.ts +88 -4
  457. package/dist/charts/react/shapes.js +55 -12
  458. package/dist/charts/react/shapes.js.map +1 -1
  459. package/dist/charts/react/three-d.cjs +1 -1
  460. package/dist/charts/react/three-d.cjs.map +1 -1
  461. package/dist/charts/react/three-d.d.cts +7 -0
  462. package/dist/charts/react/three-d.d.ts +7 -0
  463. package/dist/charts/react/three-d.js +14 -13
  464. package/dist/charts/react/three-d.js.map +1 -1
  465. package/dist/charts/react/trading.cjs +1 -1
  466. package/dist/charts/react/trading.cjs.map +1 -1
  467. package/dist/charts/react/trading.d.cts +54 -2
  468. package/dist/charts/react/trading.d.ts +54 -2
  469. package/dist/charts/react/trading.js +68 -37
  470. package/dist/charts/react/trading.js.map +1 -1
  471. package/dist/charts/react/types.d.cts +11 -0
  472. package/dist/charts/react/types.d.ts +11 -0
  473. package/dist/core/contracts.cjs +1 -1
  474. package/dist/core/contracts.cjs.map +1 -1
  475. package/dist/core/contracts.js +1 -1
  476. package/dist/core/contracts.js.map +1 -1
  477. package/dist/native/charts/src/canvas.cjs +1 -1
  478. package/dist/native/charts/src/canvas.js +5 -4
  479. package/dist/native/charts/src/engine/axis.cjs +1 -1
  480. package/dist/native/charts/src/engine/axis.cjs.map +1 -1
  481. package/dist/native/charts/src/engine/axis.js +42 -19
  482. package/dist/native/charts/src/engine/axis.js.map +1 -1
  483. package/dist/native/charts/src/engine/color.cjs +1 -1
  484. package/dist/native/charts/src/engine/color.cjs.map +1 -1
  485. package/dist/native/charts/src/engine/color.js +47 -5
  486. package/dist/native/charts/src/engine/color.js.map +1 -1
  487. package/dist/native/charts/src/engine/controller.cjs +2 -2
  488. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  489. package/dist/native/charts/src/engine/controller.js +296 -251
  490. package/dist/native/charts/src/engine/controller.js.map +1 -1
  491. package/dist/native/charts/src/engine/data.cjs +1 -1
  492. package/dist/native/charts/src/engine/data.cjs.map +1 -1
  493. package/dist/native/charts/src/engine/data.js +6 -4
  494. package/dist/native/charts/src/engine/data.js.map +1 -1
  495. package/dist/native/charts/src/engine/format.cjs +1 -1
  496. package/dist/native/charts/src/engine/format.cjs.map +1 -1
  497. package/dist/native/charts/src/engine/format.js +15 -2
  498. package/dist/native/charts/src/engine/format.js.map +1 -1
  499. package/dist/native/charts/src/engine/labels.cjs +1 -1
  500. package/dist/native/charts/src/engine/labels.cjs.map +1 -1
  501. package/dist/native/charts/src/engine/labels.js +42 -5
  502. package/dist/native/charts/src/engine/labels.js.map +1 -1
  503. package/dist/native/charts/src/engine/layout.cjs +1 -1
  504. package/dist/native/charts/src/engine/layout.cjs.map +1 -1
  505. package/dist/native/charts/src/engine/layout.js +11 -2
  506. package/dist/native/charts/src/engine/layout.js.map +1 -1
  507. package/dist/native/charts/src/engine/model.cjs +1 -1
  508. package/dist/native/charts/src/engine/model.cjs.map +1 -1
  509. package/dist/native/charts/src/engine/model.js +278 -174
  510. package/dist/native/charts/src/engine/model.js.map +1 -1
  511. package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
  512. package/dist/native/charts/src/engine/overlay.js.map +1 -1
  513. package/dist/native/charts/src/engine/presets.cjs +2 -2
  514. package/dist/native/charts/src/engine/presets.cjs.map +1 -1
  515. package/dist/native/charts/src/engine/presets.js +110 -90
  516. package/dist/native/charts/src/engine/presets.js.map +1 -1
  517. package/dist/native/charts/src/engine/scene.cjs +1 -1
  518. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  519. package/dist/native/charts/src/engine/scene.js +421 -202
  520. package/dist/native/charts/src/engine/scene.js.map +1 -1
  521. package/dist/native/charts/src/engine/shapes/bullet.cjs +1 -1
  522. package/dist/native/charts/src/engine/shapes/bullet.cjs.map +1 -1
  523. package/dist/native/charts/src/engine/shapes/bullet.js +110 -110
  524. package/dist/native/charts/src/engine/shapes/bullet.js.map +1 -1
  525. package/dist/native/charts/src/engine/shapes/calendar.cjs +1 -1
  526. package/dist/native/charts/src/engine/shapes/calendar.cjs.map +1 -1
  527. package/dist/native/charts/src/engine/shapes/calendar.js +21 -16
  528. package/dist/native/charts/src/engine/shapes/calendar.js.map +1 -1
  529. package/dist/native/charts/src/engine/shapes/chord.cjs +2 -0
  530. package/dist/native/charts/src/engine/shapes/chord.cjs.map +1 -0
  531. package/dist/native/charts/src/engine/shapes/chord.js +419 -0
  532. package/dist/native/charts/src/engine/shapes/chord.js.map +1 -0
  533. package/dist/native/charts/src/engine/shapes/draw.cjs +1 -1
  534. package/dist/native/charts/src/engine/shapes/draw.cjs.map +1 -1
  535. package/dist/native/charts/src/engine/shapes/draw.js +47 -17
  536. package/dist/native/charts/src/engine/shapes/draw.js.map +1 -1
  537. package/dist/native/charts/src/engine/shapes/hit.cjs +1 -1
  538. package/dist/native/charts/src/engine/shapes/hit.cjs.map +1 -1
  539. package/dist/native/charts/src/engine/shapes/hit.js +73 -44
  540. package/dist/native/charts/src/engine/shapes/hit.js.map +1 -1
  541. package/dist/native/charts/src/engine/shapes/labels.cjs +1 -1
  542. package/dist/native/charts/src/engine/shapes/labels.cjs.map +1 -1
  543. package/dist/native/charts/src/engine/shapes/labels.js +12 -4
  544. package/dist/native/charts/src/engine/shapes/labels.js.map +1 -1
  545. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  546. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  547. package/dist/native/charts/src/engine/shapes/layout.js +136 -94
  548. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  549. package/dist/native/charts/src/engine/shapes/scene.cjs +1 -1
  550. package/dist/native/charts/src/engine/shapes/scene.cjs.map +1 -1
  551. package/dist/native/charts/src/engine/shapes/scene.js +62 -19
  552. package/dist/native/charts/src/engine/shapes/scene.js.map +1 -1
  553. package/dist/native/components/Chart/ChartBase.cjs +1 -1
  554. package/dist/native/components/Chart/ChartBase.cjs.map +1 -1
  555. package/dist/native/components/Chart/ChartBase.js +127 -115
  556. package/dist/native/components/Chart/ChartBase.js.map +1 -1
  557. package/dist/native/components/Chart/charts.cjs +1 -1
  558. package/dist/native/components/Chart/charts.cjs.map +1 -1
  559. package/dist/native/components/Chart/charts.js +8 -5
  560. package/dist/native/components/Chart/charts.js.map +1 -1
  561. package/dist/native/components/Chart/scene.cjs +1 -1
  562. package/dist/native/components/Chart/scene.cjs.map +1 -1
  563. package/dist/native/components/Chart/scene.d.cts +6 -1
  564. package/dist/native/components/Chart/scene.d.ts +6 -1
  565. package/dist/native/components/Chart/scene.js +226 -108
  566. package/dist/native/components/Chart/scene.js.map +1 -1
  567. package/dist/native/components/Chart/types.d.cts +7 -1
  568. package/dist/native/components/Chart/types.d.ts +7 -1
  569. package/dist/native/components/Charts/charts.cjs +1 -1
  570. package/dist/native/components/Charts/charts.cjs.map +1 -1
  571. package/dist/native/components/Charts/charts.js +60 -43
  572. package/dist/native/components/Charts/charts.js.map +1 -1
  573. package/dist/native/components/Charts/types.d.cts +11 -0
  574. package/dist/native/components/Charts/types.d.ts +11 -0
  575. package/dist/native/components/ShapeChart/ShapeChartBase.cjs +1 -1
  576. package/dist/native/components/ShapeChart/ShapeChartBase.cjs.map +1 -1
  577. package/dist/native/components/ShapeChart/ShapeChartBase.d.cts +1 -1
  578. package/dist/native/components/ShapeChart/ShapeChartBase.d.ts +1 -1
  579. package/dist/native/components/ShapeChart/ShapeChartBase.js +97 -106
  580. package/dist/native/components/ShapeChart/ShapeChartBase.js.map +1 -1
  581. package/dist/native/components/ShapeChart/charts.cjs +1 -1
  582. package/dist/native/components/ShapeChart/charts.cjs.map +1 -1
  583. package/dist/native/components/ShapeChart/charts.d.cts +6 -1
  584. package/dist/native/components/ShapeChart/charts.d.ts +6 -1
  585. package/dist/native/components/ShapeChart/charts.js +138 -96
  586. package/dist/native/components/ShapeChart/charts.js.map +1 -1
  587. package/dist/native/components/ShapeChart/draw.cjs +1 -1
  588. package/dist/native/components/ShapeChart/draw.cjs.map +1 -1
  589. package/dist/native/components/ShapeChart/draw.d.cts +1 -1
  590. package/dist/native/components/ShapeChart/draw.d.ts +1 -1
  591. package/dist/native/components/ShapeChart/draw.js +26 -17
  592. package/dist/native/components/ShapeChart/draw.js.map +1 -1
  593. package/dist/native/components/ShapeChart/geometry.cjs +1 -1
  594. package/dist/native/components/ShapeChart/geometry.cjs.map +1 -1
  595. package/dist/native/components/ShapeChart/geometry.js +233 -70
  596. package/dist/native/components/ShapeChart/geometry.js.map +1 -1
  597. package/dist/native/components/ShapeChart/index.cjs +1 -1
  598. package/dist/native/components/ShapeChart/index.d.cts +1 -1
  599. package/dist/native/components/ShapeChart/index.d.ts +1 -1
  600. package/dist/native/components/ShapeChart/index.js +2 -2
  601. package/dist/native/components/ShapeChart/recorder.cjs +1 -1
  602. package/dist/native/components/ShapeChart/recorder.cjs.map +1 -1
  603. package/dist/native/components/ShapeChart/recorder.d.cts +10 -1
  604. package/dist/native/components/ShapeChart/recorder.d.ts +10 -1
  605. package/dist/native/components/ShapeChart/recorder.js +19 -10
  606. package/dist/native/components/ShapeChart/recorder.js.map +1 -1
  607. package/dist/native/components/ShapeChart/types.d.cts +95 -8
  608. package/dist/native/components/ShapeChart/types.d.ts +95 -8
  609. package/dist/native/index.cjs +1 -1
  610. package/dist/native/index.js +2 -2
  611. package/dist/native/source/components/Chart/ChartBase.tsx +19 -6
  612. package/dist/native/source/components/Chart/charts.tsx +10 -3
  613. package/dist/native/source/components/Chart/scene.tsx +243 -14
  614. package/dist/native/source/components/Chart/types.ts +7 -0
  615. package/dist/native/source/components/Charts/charts.tsx +37 -2
  616. package/dist/native/source/components/Charts/types.ts +11 -0
  617. package/dist/native/source/components/ShapeChart/ShapeChartBase.tsx +10 -34
  618. package/dist/native/source/components/ShapeChart/charts.tsx +91 -35
  619. package/dist/native/source/components/ShapeChart/draw.tsx +39 -8
  620. package/dist/native/source/components/ShapeChart/geometry.ts +376 -25
  621. package/dist/native/source/components/ShapeChart/index.ts +1 -0
  622. package/dist/native/source/components/ShapeChart/recorder.ts +20 -5
  623. package/dist/native/source/components/ShapeChart/types.ts +99 -6
  624. package/dist/native/source/manifest.ts +1 -0
  625. package/dist/taro/chart-a11y.d.ts +7 -0
  626. package/dist/taro/charts.d.ts +29 -6
  627. package/dist/taro/index.js +3129 -1902
  628. package/dist/taro/shape-charts.d.ts +99 -5
  629. package/dist/uni/AreaChart.vue +2 -1
  630. package/dist/uni/AreaChart.vue.d.ts +5 -1
  631. package/dist/uni/Badge.vue.d.ts +1 -1
  632. package/dist/uni/BarChart.vue +2 -1
  633. package/dist/uni/BarChart.vue.d.ts +5 -1
  634. package/dist/uni/BoxPlotChart.vue +2 -1
  635. package/dist/uni/BoxPlotChart.vue.d.ts +8 -0
  636. package/dist/uni/BubbleChart.vue +2 -1
  637. package/dist/uni/BubbleChart.vue.d.ts +4 -0
  638. package/dist/uni/BulletChart.vue.d.ts +4 -0
  639. package/dist/uni/CalendarHeatmap.vue.d.ts +2 -0
  640. package/dist/uni/CandlestickChart.vue +2 -1
  641. package/dist/uni/CandlestickChart.vue.d.ts +4 -0
  642. package/dist/uni/Chart.vue +2 -1
  643. package/dist/uni/Chart.vue.d.ts +4 -0
  644. package/dist/uni/ChordChart.vue +93 -0
  645. package/dist/uni/ChordChart.vue.d.ts +136 -0
  646. package/dist/uni/Divider.vue.d.ts +1 -1
  647. package/dist/uni/DonutChart.vue.d.ts +5 -1
  648. package/dist/uni/FunnelChart.vue.d.ts +4 -0
  649. package/dist/uni/GanttChart.vue +2 -1
  650. package/dist/uni/GanttChart.vue.d.ts +15 -0
  651. package/dist/uni/GaugeChart.vue.d.ts +5 -1
  652. package/dist/uni/HeatmapChart.vue +2 -1
  653. package/dist/uni/HeatmapChart.vue.d.ts +8 -2
  654. package/dist/uni/HistogramChart.vue +2 -1
  655. package/dist/uni/HistogramChart.vue.d.ts +4 -0
  656. package/dist/uni/HorizontalBarChart.vue +2 -1
  657. package/dist/uni/HorizontalBarChart.vue.d.ts +3 -1
  658. package/dist/uni/LineChart.vue +2 -1
  659. package/dist/uni/LineChart.vue.d.ts +4 -0
  660. package/dist/uni/MixedChart.vue +2 -1
  661. package/dist/uni/MixedChart.vue.d.ts +4 -0
  662. package/dist/uni/PieChart.vue.d.ts +5 -1
  663. package/dist/uni/QuadrantChart.vue +2 -1
  664. package/dist/uni/QuadrantChart.vue.d.ts +4 -0
  665. package/dist/uni/RadarChart.vue.d.ts +4 -0
  666. package/dist/uni/RadialBarChart.vue.d.ts +4 -0
  667. package/dist/uni/RangeAreaChart.vue +2 -1
  668. package/dist/uni/RangeAreaChart.vue.d.ts +4 -0
  669. package/dist/uni/SankeyChart.vue.d.ts +4 -0
  670. package/dist/uni/ScatterChart.vue +2 -1
  671. package/dist/uni/ScatterChart.vue.d.ts +4 -0
  672. package/dist/uni/Sparkline.vue +2 -1
  673. package/dist/uni/Sparkline.vue.d.ts +4 -0
  674. package/dist/uni/SunburstChart.vue.d.ts +4 -0
  675. package/dist/uni/ToastProvider.vue.d.ts +1 -1
  676. package/dist/uni/TreemapChart.vue.d.ts +4 -0
  677. package/dist/uni/WaterfallChart.vue +2 -1
  678. package/dist/uni/WaterfallChart.vue.d.ts +9 -0
  679. package/dist/uni/chart-a11y.d.ts +7 -0
  680. package/dist/uni/chart-a11y.js +29 -0
  681. package/dist/uni/chart-canvas.d.ts +12 -0
  682. package/dist/uni/chart-canvas.js +15 -1
  683. package/dist/uni/chart-types.d.ts +36 -5
  684. package/dist/uni/chart-types.js +31 -3
  685. package/dist/uni/charts-canvas.js +3 -2
  686. package/dist/uni/index.d.ts +2 -1
  687. package/dist/uni/index.js +1 -0
  688. package/dist/uni/manifest.d.ts +7 -0
  689. package/dist/uni/manifest.js +10 -0
  690. package/dist/uni/named-chart-options.d.ts +11 -2
  691. package/dist/uni/named-chart-options.js +21 -1
  692. package/dist/uni/shape-chart-canvas.d.ts +3 -3
  693. package/dist/uni/shape-chart-canvas.js +17 -58
  694. package/dist/uni/shape-chart-types.d.ts +53 -3
  695. package/dist/uni/shape-chart-types.js +45 -1
  696. package/dist/vue/charts-global.d.ts +48 -0
  697. package/dist/vue/charts.d.ts +18 -0
  698. package/dist/vue/charts.js +56 -0
  699. package/dist/vue/charts.js.map +1 -0
  700. package/dist/vue/components/Chart/Bar3DChart.vue.d.ts +2 -0
  701. package/dist/vue/components/Chart/BoxPlotChart.vue.d.ts +8 -0
  702. package/dist/vue/components/Chart/BoxPlotChart.vue.js.map +1 -1
  703. package/dist/vue/components/Chart/BoxPlotChart.vue_vue_type_script_setup_true_lang.js +8 -2
  704. package/dist/vue/components/Chart/BoxPlotChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  705. package/dist/vue/components/Chart/ChordChart.vue.d.ts +153 -0
  706. package/dist/vue/components/Chart/ChordChart.vue.js +7 -0
  707. package/dist/vue/components/Chart/ChordChart.vue.js.map +1 -0
  708. package/dist/vue/components/Chart/ChordChart.vue_vue_type_script_setup_true_lang.js +81 -0
  709. package/dist/vue/components/Chart/ChordChart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  710. package/dist/vue/components/Chart/DependencyGraph.vue.d.ts +181 -0
  711. package/dist/vue/components/Chart/DependencyGraph.vue.js +7 -0
  712. package/dist/vue/components/Chart/DependencyGraph.vue.js.map +1 -0
  713. package/dist/vue/components/Chart/DependencyGraph.vue_vue_type_script_setup_true_lang.js +65 -0
  714. package/dist/vue/components/Chart/DependencyGraph.vue_vue_type_script_setup_true_lang.js.map +1 -0
  715. package/dist/vue/components/Chart/GanttChart.vue.d.ts +19 -0
  716. package/dist/vue/components/Chart/GanttChart.vue.js.map +1 -1
  717. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js +12 -1
  718. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  719. package/dist/vue/components/Chart/GraphChart.vue.d.ts +186 -0
  720. package/dist/vue/components/Chart/GraphChart.vue.js +7 -0
  721. package/dist/vue/components/Chart/GraphChart.vue.js.map +1 -0
  722. package/dist/vue/components/Chart/GraphChart.vue_vue_type_script_setup_true_lang.js +62 -0
  723. package/dist/vue/components/Chart/GraphChart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  724. package/dist/vue/components/Chart/HeatmapChart.vue.d.ts +9 -5
  725. package/dist/vue/components/Chart/HeatmapChart.vue.js.map +1 -1
  726. package/dist/vue/components/Chart/HeatmapChart.vue_vue_type_script_setup_true_lang.js +3 -1
  727. package/dist/vue/components/Chart/HeatmapChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  728. package/dist/vue/components/Chart/Line3DChart.vue.d.ts +2 -0
  729. package/dist/vue/components/Chart/OrderBookHeatmap.vue.d.ts +2 -0
  730. package/dist/vue/components/Chart/Scatter3DChart.vue.d.ts +2 -0
  731. package/dist/vue/components/Chart/Surface3DChart.vue.d.ts +2 -0
  732. package/dist/vue/components/Chart/TimeAndSales.vue.d.ts +2 -0
  733. package/dist/vue/components/Chart/TradingChart.vue.d.ts +58 -1
  734. package/dist/vue/components/Chart/TradingChart.vue.js.map +1 -1
  735. package/dist/vue/components/Chart/TradingChart.vue_vue_type_script_setup_true_lang.js +31 -0
  736. package/dist/vue/components/Chart/TradingChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  737. package/dist/vue/components/Chart/TreeChart.vue.d.ts +174 -0
  738. package/dist/vue/components/Chart/TreeChart.vue.js +7 -0
  739. package/dist/vue/components/Chart/TreeChart.vue.js.map +1 -0
  740. package/dist/vue/components/Chart/TreeChart.vue_vue_type_script_setup_true_lang.js +56 -0
  741. package/dist/vue/components/Chart/TreeChart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  742. package/dist/vue/components/Chart/WaterfallChart.vue.d.ts +12 -1
  743. package/dist/vue/components/Chart/WaterfallChart.vue.js.map +1 -1
  744. package/dist/vue/components/Chart/WaterfallChart.vue_vue_type_script_setup_true_lang.js +8 -2
  745. package/dist/vue/components/Chart/WaterfallChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  746. package/dist/vue/components/Chart/graph.d.ts +156 -0
  747. package/dist/vue/components/Chart/graph.js +137 -0
  748. package/dist/vue/components/Chart/graph.js.map +1 -0
  749. package/dist/vue/components/Chart/index.d.ts +5 -1
  750. package/dist/vue/components/Chart/index.js +5 -1
  751. package/dist/vue/components/Chart/orderbook.d.ts +5 -1
  752. package/dist/vue/components/Chart/orderbook.js +2 -0
  753. package/dist/vue/components/Chart/orderbook.js.map +1 -1
  754. package/dist/vue/components/Chart/three-d.d.ts +3 -0
  755. package/dist/vue/components/Chart/three-d.js +2 -0
  756. package/dist/vue/components/Chart/three-d.js.map +1 -1
  757. package/dist/vue/components/Chart/trading.d.ts +30 -3
  758. package/dist/vue/components/Chart/trading.js +9 -0
  759. package/dist/vue/components/Chart/trading.js.map +1 -1
  760. package/dist/vue/components/Chart/types.d.ts +74 -2
  761. package/dist/vue/global.d.ts +2 -38
  762. package/dist/vue/groups/charts.js +10 -2
  763. package/dist/vue/groups/charts.js.map +1 -1
  764. package/dist/vue/index.js +6 -2
  765. package/dist/vue/internal/register.d.ts +7 -0
  766. package/dist/vue/internal/register.js +14 -0
  767. package/dist/vue/internal/register.js.map +1 -0
  768. package/dist/vue/plugin.d.ts +9 -4
  769. package/dist/vue/plugin.js +6 -11
  770. package/dist/vue/plugin.js.map +1 -1
  771. package/dist/weapp/area-chart/index.wxml +1 -1
  772. package/dist/weapp/bar-chart/index.wxml +1 -1
  773. package/dist/weapp/box-plot-chart/index.wxml +1 -1
  774. package/dist/weapp/bubble-chart/index.wxml +1 -1
  775. package/dist/weapp/candlestick-chart/index.wxml +1 -1
  776. package/dist/weapp/chart/index.wxml +1 -1
  777. package/dist/weapp/charts/canvas.js +1987 -175
  778. package/dist/weapp/charts/core.js +3 -0
  779. package/dist/weapp/chord-chart/index.js +1 -0
  780. package/dist/weapp/chord-chart/index.json +1 -0
  781. package/dist/weapp/chord-chart/index.wxml +1 -0
  782. package/dist/weapp/chord-chart/index.wxss +1 -0
  783. package/dist/weapp/controls.js +148 -57
  784. package/dist/weapp/gantt-chart/index.wxml +1 -1
  785. package/dist/weapp/heatmap-chart/index.wxml +1 -1
  786. package/dist/weapp/histogram-chart/index.wxml +1 -1
  787. package/dist/weapp/horizontal-bar-chart/index.wxml +1 -1
  788. package/dist/weapp/line-chart/index.wxml +1 -1
  789. package/dist/weapp/mixed-chart/index.wxml +1 -1
  790. package/dist/weapp/quadrant-chart/index.wxml +1 -1
  791. package/dist/weapp/range-area-chart/index.wxml +1 -1
  792. package/dist/weapp/scatter-chart/index.wxml +1 -1
  793. package/dist/weapp/sparkline/index.wxml +1 -1
  794. package/dist/weapp/types.d.ts +96 -4
  795. package/dist/weapp/waterfall-chart/index.wxml +1 -1
  796. package/dist/web-components/components/chart/charts.d.ts +4 -2
  797. package/dist/web-components/components/chart/charts.js +8 -1
  798. package/dist/web-components/components/chart/charts.js.map +1 -1
  799. package/dist/web-components/components/chart/extended.d.ts +21 -7
  800. package/dist/web-components/components/chart/extended.js +29 -9
  801. package/dist/web-components/components/chart/extended.js.map +1 -1
  802. package/dist/web-components/components/chart/shapes-extended.d.ts +37 -1
  803. package/dist/web-components/components/chart/shapes-extended.js +27 -1
  804. package/dist/web-components/components/chart/shapes-extended.js.map +1 -1
  805. package/dist/web-components/components/chart-3d/chart-3d.d.ts +1 -1
  806. package/dist/web-components/components/chart-3d/chart-3d.js.map +1 -1
  807. package/dist/web-components/components/graph/graph.d.ts +156 -0
  808. package/dist/web-components/components/graph/graph.js +150 -0
  809. package/dist/web-components/components/graph/graph.js.map +1 -0
  810. package/dist/web-components/components/trading-chart/trading-chart.d.ts +49 -2
  811. package/dist/web-components/components/trading-chart/trading-chart.js +62 -0
  812. package/dist/web-components/components/trading-chart/trading-chart.js.map +1 -1
  813. package/dist/web-components/elements/chart.d.ts +1 -1
  814. package/dist/web-components/elements/chart.js +6 -5
  815. package/dist/web-components/elements/chart.js.map +1 -1
  816. package/dist/web-components/elements/graph.d.ts +2 -0
  817. package/dist/web-components/elements/graph.js +12 -0
  818. package/dist/web-components/elements/graph.js.map +1 -0
  819. package/dist/web-components/html-custom-data.json +318 -4
  820. package/dist/web-components/types/react.d.ts +63 -4
  821. package/dist/web-components/types/solid.d.ts +55 -8
  822. package/dist/web-components/types/svelte.d.ts +55 -8
  823. package/dist/web-components/types/vue.d.ts +55 -4
  824. package/package.json +16 -1
@@ -124,10 +124,32 @@ var r = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, i = (e) =
124
124
  }));
125
125
  }
126
126
  return a;
127
- }, p = (t, n) => {
127
+ }, p = (e, t) => {
128
+ for (let n of t) {
129
+ let t = n.points, r = t[0];
130
+ if (!r) continue;
131
+ e.strokeStyle = n.color, e.fillStyle = n.color, e.lineWidth = n.width, e.lineJoin = "round", e.setLineDash([]), e.beginPath(), e.moveTo(r.x, r.y);
132
+ for (let n = 1; n < t.length; n++) {
133
+ let r = t[n], i = t[n + 1], a = t[n - 1];
134
+ if (i && typeof e.arcTo == "function") {
135
+ let t = Math.min(4, Math.hypot(r.x - a.x, r.y - a.y) / 2, Math.hypot(i.x - r.x, i.y - r.y) / 2);
136
+ e.arcTo(r.x, r.y, i.x, i.y, t);
137
+ } else e.lineTo(r.x, r.y);
138
+ }
139
+ e.stroke();
140
+ let [i, a, o] = n.head;
141
+ i && a && o && (e.beginPath(), e.moveTo(i.x, i.y), e.lineTo(a.x, a.y), e.lineTo(o.x, o.y), e.closePath(), e.fill());
142
+ }
143
+ }, m = (t, n) => {
128
144
  let { scales: c, theme: l } = n, { plot: u } = c;
129
145
  n.clear !== !1 && t.clearRect(0, 0, n.width, n.height), t.save(), t.beginPath(), t.rect(u.x, u.y, u.width, u.height), t.clip();
130
- let p = e(l.background, .9), m = [], h = l.fontSize + 4;
146
+ for (let e of n.connectors ?? []) {
147
+ t.strokeStyle = e.color, t.lineWidth = e.width, t.setLineDash([...e.dash]), t.beginPath();
148
+ let n = e.y0 === e.y1, r = n ? e.x0 : i(e.x0), a = n ? i(e.y0) : e.y0;
149
+ t.moveTo(r, a), t.lineTo(n ? e.x1 : r, n ? a : e.y1), t.stroke();
150
+ }
151
+ t.setLineDash([]), n.arrows?.length && p(t, n.arrows);
152
+ let m = e(l.background, .9), h = [], g = l.fontSize + 4;
131
153
  for (let a of n.annotations) {
132
154
  if (a.type !== "line") continue;
133
155
  let n = e(a.color);
@@ -135,10 +157,10 @@ var r = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, i = (e) =
135
157
  let o = s(a, c);
136
158
  if (o.vertical) {
137
159
  let e = i(o.at);
138
- t.moveTo(e, u.y), t.lineTo(e, u.y + u.height), t.stroke(), a.label && (t.setLineDash([]), t.font = r(l, l.fontSize, 500), t.textAlign = "left", t.textBaseline = "top", d(t, a.label, e + 5, u.y + 5, n, p));
160
+ t.moveTo(e, u.y), t.lineTo(e, u.y + u.height), t.stroke(), a.label && (t.setLineDash([]), t.font = r(l, l.fontSize, 500), t.textAlign = "left", t.textBaseline = "top", d(t, a.label, e + 5, u.y + 5, n, m));
139
161
  } else {
140
162
  let e = i(o.at);
141
- t.moveTo(u.x, e), t.lineTo(u.x + u.width, e), t.stroke(), a.label && (t.setLineDash([]), t.font = r(l, l.fontSize, 500), t.textAlign = "right", t.textBaseline = "bottom", d(t, a.label, u.x + u.width - 6, e - 3, n, p));
163
+ t.moveTo(u.x, e), t.lineTo(u.x + u.width, e), t.stroke(), a.label && (t.setLineDash([]), t.font = r(l, l.fontSize, 500), t.textAlign = "right", t.textBaseline = "bottom", d(t, a.label, u.x + u.width - 6, e - 3, n, m));
142
164
  }
143
165
  }
144
166
  t.setLineDash([]), t.font = r(l, l.fontSize + 1, 600);
@@ -146,28 +168,28 @@ var r = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, i = (e) =
146
168
  if (r.type !== "rect" || !r.label) continue;
147
169
  let n = o(r, c);
148
170
  if (n.width <= 0 || n.height <= 0) continue;
149
- let i = t.measureText(r.label).width, a = r.labelPosition, s = a.endsWith("left") ? n.x + 10 : a.endsWith("right") ? n.x + n.width - 10 - i : n.x + (n.width - i) / 2, l = a.startsWith("top") ? n.y + 10 : a.startsWith("bottom") ? n.y + n.height - 10 - h : n.y + (n.height - h) / 2;
150
- t.textAlign = "left", t.textBaseline = "top", t.fillStyle = e(r.labelColor), t.fillText(r.label, s, l), m.push({
171
+ let i = t.measureText(r.label).width, a = r.labelPosition, s = a.endsWith("left") ? n.x + 10 : a.endsWith("right") ? n.x + n.width - 10 - i : n.x + (n.width - i) / 2, l = a.startsWith("top") ? n.y + 10 : a.startsWith("bottom") ? n.y + n.height - 10 - g : n.y + (n.height - g) / 2;
172
+ t.textAlign = "left", t.textBaseline = "top", t.fillStyle = e(r.labelColor), t.fillText(r.label, s, l), h.push({
151
173
  x: s,
152
174
  y: l,
153
175
  width: i,
154
- height: h
176
+ height: g
155
177
  });
156
178
  }
157
179
  for (let i of n.annotations) {
158
180
  if (i.type !== "text" || !i.text) continue;
159
181
  t.font = r(l, l.fontSize, i.weight);
160
- let n = a(i, c, t.measureText(i.text).width, h);
161
- t.textAlign = "left", t.textBaseline = "middle", d(t, i.text, n.x, n.y + n.height / 2, e(i.color), p), m.push(n);
182
+ let n = a(i, c, t.measureText(i.text).width, g);
183
+ t.textAlign = "left", t.textBaseline = "middle", d(t, i.text, n.x, n.y + n.height / 2, e(i.color), m), h.push(n);
162
184
  }
163
185
  if (n.pointLabels.length) {
164
186
  t.font = r(l), t.textAlign = "left", t.textBaseline = "middle";
165
- let i = e(l.text, .85), a = f(n.pointLabels, u, (e) => t.measureText(e).width, h - 2, m);
166
- for (let { label: e, box: n } of a) d(t, e.text, n.x, n.y + n.height / 2, i, p);
187
+ let i = e(l.text, .85), a = f(n.pointLabels, u, (e) => t.measureText(e).width, g - 2, h);
188
+ for (let { label: e, box: n } of a) d(t, e.text, n.x, n.y + n.height / 2, i, m);
167
189
  }
168
190
  t.restore();
169
191
  };
170
192
  //#endregion
171
- export { c as drawBackground, p as drawForeground, r as font, s as lineOf, f as placeLabels, o as rectOf, a as textBox };
193
+ export { p as drawArrows, c as drawBackground, m as drawForeground, r as font, s as lineOf, f as placeLabels, o as rectOf, a as textBox };
172
194
 
173
195
  //# sourceMappingURL=overlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.js","names":["font","theme","weight","size","crisp","v","textBox","s","at","toScreen","a","free","px","plot","py","x","width","y","height","rectOf","xLo","xHi","yLo","yHi","along","lo","hi","screenRect","lineOf","drawBackground","input","scales","bottomTicks","yTicks","xTicks","leftTicks","bottomPx","leftPx","ctx","r","toCss","line","base","lastRight","order","i","b","w","text","left","lastBottom","rows","rowHeight","y2","y2Ticks","right","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","above","below","box","c","occupied","o","drawForeground","labelHeight","where","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport { screenRect, toScreen, type Rect, type Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport interface ResolvedText {\n type: \"text\";\n x?: number;\n y?: number;\n text: string;\n anchor: \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n color: Rgba;\n weight: number;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n /**\n * Fixed side (bar values: above / below, left / right of horizontal\n * bars); any free side around the dot otherwise\n */\n placement?: \"above\" | \"below\" | \"left\" | \"right\";\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\n/** Box of a text annotation, kept inside the plot */\nexport const textBox = (\n a: ResolvedText,\n s: Scales,\n width: number,\n height: number,\n): Rect => {\n const { plot } = s;\n const at = toScreen(s, a.x ?? 0, a.y ?? 0);\n const free = s.horizontal\n ? { x: a.y === undefined, y: a.x === undefined }\n : { x: a.x === undefined, y: a.y === undefined };\n const px = free.x ? plot.x + plot.width / 2 : at.x;\n const py = free.y ? plot.y + plot.height / 2 : at.y;\n const gap = 6;\n let x = px - width / 2;\n let y = py - height / 2;\n if (a.anchor === \"top\") y = py + gap;\n else if (a.anchor === \"bottom\") y = py - gap - height;\n else if (a.anchor === \"left\") x = px + gap;\n else if (a.anchor === \"right\") x = px - gap - width;\n x = Math.max(plot.x + gap, Math.min(x, plot.x + plot.width - gap - width));\n y = Math.max(plot.y + 2, Math.min(y, plot.y + plot.height - 2 - height));\n return { x, y, width, height };\n};\n\n/** Screen box of an area annotation, clipped to the plot */\nexport const rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n // clamp every edge to the plot first: an open edge maps to ±Infinity and\n // `Infinity - Infinity` would make the size NaN (nothing drawn)\n const [xLo, xHi] = s.horizontal\n ? [plot.y, plot.y + plot.height]\n : [plot.x, plot.x + plot.width];\n const [yLo, yHi] = s.horizontal\n ? [plot.x, plot.x + plot.width]\n : [plot.y, plot.y + plot.height];\n const along = (px: number, lo: number, hi: number) =>\n px < lo ? lo : px > hi ? hi : px;\n return screenRect(\n s,\n along(s.xToPx(a.x0 ?? -Infinity), xLo, xHi),\n along(s.xToPx(a.x1 ?? Infinity), xLo, xHi),\n along(s.yToPx(a.y0 ?? -Infinity), yLo, yHi),\n along(s.yToPx(a.y1 ?? Infinity), yLo, yHi),\n );\n};\n\n/**\n * Where a reference line goes: `vertical` lines run at screen x `at`,\n * horizontal ones at screen y `at`\n */\nexport const lineOf = (\n a: ResolvedLine,\n s: Scales,\n): { vertical: boolean; at: number } => {\n const vertical = (a.axis === \"x\") !== s.horizontal;\n return {\n vertical,\n at: a.axis === \"x\" ? s.xToPx(a.value) : s.yToPx(a.value),\n };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n /** Right axis (dual axis charts) */\n y2?: AxisModel | null;\n y2Ticks?: AxisTicks | null;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, xTicks, yTicks } = input;\n const { plot } = scales;\n // horizontal charts: the value axis along the bottom, the x axis on the left\n const x = scales.horizontal ? input.y : input.x;\n const y = scales.horizontal ? input.x : input.y;\n const bottomTicks = scales.horizontal ? yTicks : xTicks;\n const leftTicks = scales.horizontal ? xTicks : yTicks;\n const bottomPx = scales.horizontal ? scales.yToPx : scales.xToPx;\n const leftPx = scales.horizontal ? scales.xToPx : scales.yToPx;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of leftTicks.values) {\n const py = crisp(leftPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of bottomTicks.values) {\n const px = crisp(bottomPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = bottomTicks.values\n .map((v, i) => ({ px: bottomPx(v), text: bottomTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n let lastBottom = -Infinity;\n // top to bottom: category rows of horizontal charts never overlap\n const rows = leftTicks.values\n .map((v, i) => ({ py: leftPx(v), text: leftTicks.labels[i] }))\n .sort((a, b) => a.py - b.py);\n const rowHeight = theme.fontSize + 2;\n for (const { py, text } of rows) {\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) continue;\n if (scales.horizontal) {\n if (py - rowHeight / 2 < lastBottom) continue;\n lastBottom = py + rowHeight / 2;\n }\n ctx.fillText(text, plot.x - 8, py);\n }\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n\n // right axis\n const y2 = scales.horizontal ? null : input.y2;\n const y2Ticks = input.y2Ticks;\n if (y2 && y2Ticks && y2.visible) {\n const right = plot.x + plot.width;\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n y2Ticks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(y2Ticks.labels[i], right + 8, py);\n });\n if (y2.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(input.width - line / 2 - 4, plot.y + plot.height / 2);\n ctx.rotate(Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y2.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const above = {\n x: label.x - w / 2,\n y: label.y - gap - height,\n width: w,\n height,\n };\n const below = { x: label.x - w / 2, y: label.y + gap, width: w, height };\n const right = {\n x: label.x + gap,\n y: label.y - height / 2,\n width: w,\n height,\n };\n const left = {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n };\n const candidates: Rect[] =\n label.placement === \"above\"\n ? [above]\n : label.placement === \"below\"\n ? [below]\n : label.placement === \"right\"\n ? [right, left]\n : label.placement === \"left\"\n ? [left, right]\n : [\n {\n x: label.x + gap,\n y: label.y - height / 2,\n width: w,\n height,\n },\n {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n },\n above,\n below,\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n /**\n * Clears the canvas first (off when the layers share one canvas)\n * @default true\n */\n clear?: boolean;\n}\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n if (input.clear !== false) ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n const where = lineOf(a, scales);\n if (!where.vertical) {\n const py = crisp(where.at);\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(where.at);\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // free texts\n for (const a of input.annotations) {\n if (a.type !== \"text\" || !a.text) continue;\n ctx.font = font(theme, theme.fontSize, a.weight);\n const box = textBox(a, scales, ctx.measureText(a.text).width, labelHeight);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n haloText(ctx, a.text, box.x, box.y + box.height / 2, toCss(a.color), halo);\n occupied.push(box);\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;AA0DA,IAAaA,KAAQ,GAAmB,IAAOC,EAAM,UAAU,IAAS,QACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,cAEzBG,KAAS,MAAc,KAAK,MAAMC,CAAC,IAAI,IAGhCC,KACX,GACA,GACA,GACA,MACS;CACT,IAAM,EAAE,YAASC,GACXC,IAAKC,EAASF,GAAGG,EAAE,KAAK,GAAGA,EAAE,KAAK,CAAC,GACnCC,IAAOJ,EAAE,aACX;EAAE,GAAGG,EAAE,MAAM,KAAA;EAAW,GAAGA,EAAE,MAAM,KAAA;CAAU,IAC7C;EAAE,GAAGA,EAAE,MAAM,KAAA;EAAW,GAAGA,EAAE,MAAM,KAAA;CAAU,GAC3CE,IAAKD,EAAK,IAAIE,EAAK,IAAIA,EAAK,QAAQ,IAAIL,EAAG,GAC3CM,IAAKH,EAAK,IAAIE,EAAK,IAAIA,EAAK,SAAS,IAAIL,EAAG,GAE9CO,IAAIH,IAAKI,IAAQ,GACjBC,IAAIH,IAAKI,IAAS;CAOtB,OANIR,EAAE,WAAW,QAAO,IAAII,IAAK,IACxBJ,EAAE,WAAW,WAAU,IAAII,IAAK,IAAMI,IACtCR,EAAE,WAAW,SAAQ,IAAIE,IAAK,IAC9BF,EAAE,WAAW,YAAS,IAAIE,IAAK,IAAMI,IAC9C,IAA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,GAC5BP,EAAS,KAAK;GAAE,GAAGM;GAAI,GAAGC;GAAI,OAAO/B;GAAG,QAAQ2B;EAAY,CAAC;CAC/D;CAGA,KAAK,IAAMhE,KAAKoB,EAAM,aAAa;EACjC,IAAIpB,EAAE,SAAS,UAAU,CAACA,EAAE,MAAM;EAClC,EAAI,OAAOV,EAAKC,GAAOA,EAAM,UAAUS,EAAE,MAAM;EAC/C,IAAM2D,IAAM/D,EAAQI,GAAGqB,GAAQO,EAAI,YAAY5B,EAAE,IAAI,CAAC,CAAC,OAAOgE,CAAW;EAIzE,AAHA,EAAI,YAAY,QAChB,EAAI,eAAe,UACnBhB,EAASpB,GAAK5B,EAAE,MAAM2D,EAAI,GAAGA,EAAI,IAAIA,EAAI,SAAS,GAAG7B,EAAM9B,EAAE,KAAK,GAAGiD,CAAI,GACzEY,EAAS,KAAKF,CAAG;CACnB;CAGA,IAAIvC,EAAM,YAAY,QAAQ;EAG5B,AAFA,EAAI,OAAO9B,EAAKC,CAAK,GACrB,EAAI,YAAY,QAChB,EAAI,eAAe;EACnB,IAAM8E,IAAYvC,EAAMvC,EAAM,MAAM,GAAI,GAClC6D,IAASD,EACb/B,EAAM,aACNjB,IACC,MAAMyB,EAAI,YAAY0C,CAAC,CAAC,CAAC,OAC1BN,IAAc,GACdH,CACF;EACA,KAAK,IAAM,EAAE,UAAO,YAAST,GAC3B,EAASxB,GAAKyB,EAAM,MAAMM,EAAI,GAAGA,EAAI,IAAIA,EAAI,SAAS,GAAGU,GAAWpB,CAAI;CAE5E;CACA,EAAI,QAAQ;AACd"}
1
+ {"version":3,"file":"overlay.js","names":["font","theme","weight","size","crisp","v","textBox","s","at","toScreen","a","free","px","plot","py","x","width","y","height","rectOf","xLo","xHi","yLo","yHi","along","lo","hi","screenRect","lineOf","drawBackground","input","scales","bottomTicks","yTicks","xTicks","leftTicks","bottomPx","leftPx","ctx","r","toCss","line","base","lastRight","order","i","b","w","text","left","lastBottom","rows","rowHeight","y2","y2Ticks","right","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","above","below","box","c","occupied","o","drawArrows","arrows","pts","first","p","next","prev","tip","b0","b1","drawForeground","x0","y0","labelHeight","where","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport { screenRect, toScreen, type Rect, type Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport interface ResolvedText {\n type: \"text\";\n x?: number;\n y?: number;\n text: string;\n anchor: \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n color: Rgba;\n weight: number;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n /**\n * Fixed side (bar values: above / below, left / right of horizontal\n * bars); any free side around the dot otherwise\n */\n placement?: \"above\" | \"below\" | \"left\" | \"right\";\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\n/** Box of a text annotation, kept inside the plot */\nexport const textBox = (\n a: ResolvedText,\n s: Scales,\n width: number,\n height: number,\n): Rect => {\n const { plot } = s;\n const at = toScreen(s, a.x ?? 0, a.y ?? 0);\n const free = s.horizontal\n ? { x: a.y === undefined, y: a.x === undefined }\n : { x: a.x === undefined, y: a.y === undefined };\n const px = free.x ? plot.x + plot.width / 2 : at.x;\n const py = free.y ? plot.y + plot.height / 2 : at.y;\n const gap = 6;\n let x = px - width / 2;\n let y = py - height / 2;\n if (a.anchor === \"top\") y = py + gap;\n else if (a.anchor === \"bottom\") y = py - gap - height;\n else if (a.anchor === \"left\") x = px + gap;\n else if (a.anchor === \"right\") x = px - gap - width;\n x = Math.max(plot.x + gap, Math.min(x, plot.x + plot.width - gap - width));\n y = Math.max(plot.y + 2, Math.min(y, plot.y + plot.height - 2 - height));\n return { x, y, width, height };\n};\n\n/** Screen box of an area annotation, clipped to the plot */\nexport const rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n // clamp every edge to the plot first: an open edge maps to ±Infinity and\n // `Infinity - Infinity` would make the size NaN (nothing drawn)\n const [xLo, xHi] = s.horizontal\n ? [plot.y, plot.y + plot.height]\n : [plot.x, plot.x + plot.width];\n const [yLo, yHi] = s.horizontal\n ? [plot.x, plot.x + plot.width]\n : [plot.y, plot.y + plot.height];\n const along = (px: number, lo: number, hi: number) =>\n px < lo ? lo : px > hi ? hi : px;\n return screenRect(\n s,\n along(s.xToPx(a.x0 ?? -Infinity), xLo, xHi),\n along(s.xToPx(a.x1 ?? Infinity), xLo, xHi),\n along(s.yToPx(a.y0 ?? -Infinity), yLo, yHi),\n along(s.yToPx(a.y1 ?? Infinity), yLo, yHi),\n );\n};\n\n/**\n * Where a reference line goes: `vertical` lines run at screen x `at`,\n * horizontal ones at screen y `at`\n */\nexport const lineOf = (\n a: ResolvedLine,\n s: Scales,\n): { vertical: boolean; at: number } => {\n const vertical = (a.axis === \"x\") !== s.horizontal;\n return {\n vertical,\n at: a.axis === \"x\" ? s.xToPx(a.value) : s.yToPx(a.value),\n };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n /** Right axis (dual axis charts) */\n y2?: AxisModel | null;\n y2Ticks?: AxisTicks | null;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, xTicks, yTicks } = input;\n const { plot } = scales;\n // horizontal charts: the value axis along the bottom, the x axis on the left\n const x = scales.horizontal ? input.y : input.x;\n const y = scales.horizontal ? input.x : input.y;\n const bottomTicks = scales.horizontal ? yTicks : xTicks;\n const leftTicks = scales.horizontal ? xTicks : yTicks;\n const bottomPx = scales.horizontal ? scales.yToPx : scales.xToPx;\n const leftPx = scales.horizontal ? scales.xToPx : scales.yToPx;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of leftTicks.values) {\n const py = crisp(leftPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of bottomTicks.values) {\n const px = crisp(bottomPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = bottomTicks.values\n .map((v, i) => ({ px: bottomPx(v), text: bottomTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n let lastBottom = -Infinity;\n // top to bottom: category rows of horizontal charts never overlap\n const rows = leftTicks.values\n .map((v, i) => ({ py: leftPx(v), text: leftTicks.labels[i] }))\n .sort((a, b) => a.py - b.py);\n const rowHeight = theme.fontSize + 2;\n for (const { py, text } of rows) {\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) continue;\n if (scales.horizontal) {\n if (py - rowHeight / 2 < lastBottom) continue;\n lastBottom = py + rowHeight / 2;\n }\n ctx.fillText(text, plot.x - 8, py);\n }\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n\n // right axis\n const y2 = scales.horizontal ? null : input.y2;\n const y2Ticks = input.y2Ticks;\n if (y2 && y2Ticks && y2.visible) {\n const right = plot.x + plot.width;\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n y2Ticks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(y2Ticks.labels[i], right + 8, py);\n });\n if (y2.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(input.width - line / 2 - 4, plot.y + plot.height / 2);\n ctx.rotate(Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y2.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const above = {\n x: label.x - w / 2,\n y: label.y - gap - height,\n width: w,\n height,\n };\n const below = { x: label.x - w / 2, y: label.y + gap, width: w, height };\n const right = {\n x: label.x + gap,\n y: label.y - height / 2,\n width: w,\n height,\n };\n const left = {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n };\n const candidates: Rect[] =\n label.placement === \"above\"\n ? [above]\n : label.placement === \"below\"\n ? [below]\n : label.placement === \"right\"\n ? [right, left]\n : label.placement === \"left\"\n ? [left, right]\n : [\n {\n x: label.x + gap,\n y: label.y - height / 2,\n width: w,\n height,\n },\n {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n },\n above,\n below,\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n /**\n * Clears the canvas first (off when the layers share one canvas)\n * @default true\n */\n clear?: boolean;\n /** Lines between consecutive bars (waterfall connectors), drawn first */\n connectors?: readonly {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n color: string;\n width: number;\n dash: readonly number[];\n }[];\n /** Dependency arrows (Gantt charts), drawn over the connectors */\n arrows?: readonly ArrowPath[];\n}\n\n/** An elbow arrow in stage pixels (see `dependencyArrows`) */\nexport interface ArrowPath {\n points: readonly { x: number; y: number }[];\n head: readonly { x: number; y: number }[];\n color: string;\n width: number;\n}\n\n/** Elbow arrows: polylines with rounded corners and filled heads */\nexport const drawArrows = (\n ctx: CanvasRenderingContext2D,\n arrows: readonly ArrowPath[],\n) => {\n for (const a of arrows) {\n const pts = a.points;\n const first = pts[0];\n if (!first) continue;\n ctx.strokeStyle = a.color;\n ctx.fillStyle = a.color;\n ctx.lineWidth = a.width;\n ctx.lineJoin = \"round\";\n ctx.setLineDash([]);\n ctx.beginPath();\n ctx.moveTo(first.x, first.y);\n for (let i = 1; i < pts.length; i++) {\n const p = pts[i]!;\n const next = pts[i + 1];\n const prev = pts[i - 1]!;\n if (next && typeof ctx.arcTo === \"function\") {\n // rounded elbow, at most half of the shorter leg\n const r = Math.min(\n 4,\n Math.hypot(p.x - prev.x, p.y - prev.y) / 2,\n Math.hypot(next.x - p.x, next.y - p.y) / 2,\n );\n ctx.arcTo(p.x, p.y, next.x, next.y, r);\n } else {\n ctx.lineTo(p.x, p.y);\n }\n }\n ctx.stroke();\n const [tip, b0, b1] = a.head;\n if (tip && b0 && b1) {\n ctx.beginPath();\n ctx.moveTo(tip.x, tip.y);\n ctx.lineTo(b0.x, b0.y);\n ctx.lineTo(b1.x, b1.y);\n ctx.closePath();\n ctx.fill();\n }\n }\n};\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n if (input.clear !== false) ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n for (const c of input.connectors ?? []) {\n ctx.strokeStyle = c.color;\n ctx.lineWidth = c.width;\n ctx.setLineDash([...c.dash]);\n ctx.beginPath();\n // crisp hairlines along the pixel grid\n const along = c.y0 === c.y1;\n const x0 = along ? c.x0 : crisp(c.x0);\n const y0 = along ? crisp(c.y0) : c.y0;\n ctx.moveTo(x0, y0);\n ctx.lineTo(along ? c.x1 : x0, along ? y0 : c.y1);\n ctx.stroke();\n }\n ctx.setLineDash([]);\n if (input.arrows?.length) drawArrows(ctx, input.arrows);\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n const where = lineOf(a, scales);\n if (!where.vertical) {\n const py = crisp(where.at);\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(where.at);\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // free texts\n for (const a of input.annotations) {\n if (a.type !== \"text\" || !a.text) continue;\n ctx.font = font(theme, theme.fontSize, a.weight);\n const box = textBox(a, scales, ctx.measureText(a.text).width, labelHeight);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n haloText(ctx, a.text, box.x, box.y + box.height / 2, toCss(a.color), halo);\n occupied.push(box);\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;AA0DA,IAAaA,KAAQ,GAAmB,IAAOC,EAAM,UAAU,IAAS,QACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,cAEzBG,KAAS,MAAc,KAAK,MAAMC,CAAC,IAAI,IAGhCC,KACX,GACA,GACA,GACA,MACS;CACT,IAAM,EAAE,YAASC,GACXC,IAAKC,EAASF,GAAGG,EAAE,KAAK,GAAGA,EAAE,KAAK,CAAC,GACnCC,IAAOJ,EAAE,aACX;EAAE,GAAGG,EAAE,MAAM,KAAA;EAAW,GAAGA,EAAE,MAAM,KAAA;CAAU,IAC7C;EAAE,GAAGA,EAAE,MAAM,KAAA;EAAW,GAAGA,EAAE,MAAM,KAAA;CAAU,GAC3CE,IAAKD,EAAK,IAAIE,EAAK,IAAIA,EAAK,QAAQ,IAAIL,EAAG,GAC3CM,IAAKH,EAAK,IAAIE,EAAK,IAAIA,EAAK,SAAS,IAAIL,EAAG,GAE9CO,IAAIH,IAAKI,IAAQ,GACjBC,IAAIH,IAAKI,IAAS;CAOtB,OANIR,EAAE,WAAW,QAAO,IAAII,IAAK,IACxBJ,EAAE,WAAW,WAAU,IAAII,IAAK,IAAMI,IACtCR,EAAE,WAAW,SAAQ,IAAIE,IAAK,IAC9BF,EAAE,WAAW,YAAS,IAAIE,IAAK,IAAMI,IAC9C,IAAI,KAAK,IAAIH,EAAK,IAAI,GAAK,KAAK,IAAIE,GAAGF,EAAK,IAAIA,EAAK,QAAQ,IAAMG,CAAK,CAAC,GACzE,IAAI,KAAK,IAAIH,EAAK,IAAI,GAAG,KAAK,IAAII,GA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,MAAMM,EAAI,GAAGA,EAAI,IAAIA,EAAI,SAAS,GAAGsB,GAAWhC,CAAI;CAE5E;CACA,EAAI,QAAQ;AACd"}
@@ -1,3 +1,3 @@
1
- const e=require("./locale.cjs"),t=require("./scale.cjs");var n={en:{value:`Value`,values:`Values`,count:`Count`,change:`Change`,tasks:`Tasks`,progress:`Progress`,milestones:`Milestones`},zh:{value:`数值`,values:`数值`,count:`数量`,change:`变化`,tasks:`任务`,progress:`进度`,milestones:`里程碑`},ja:{value:`値`,values:`値`,count:`件数`,change:`増減`,tasks:`タスク`,progress:`進捗`,milestones:`マイルストーン`},fr:{value:`Valeur`,values:`Valeurs`,count:`Effectif`,change:`Variation`,tasks:`Tâches`,progress:`Avancement`,milestones:`Jalons`}},r=t=>e.localeLabels(n,t),i=(e,t,n,r)=>e.map(e=>{let i=e.type??t;return{...e,type:i,...n!==void 0&&i===t?{stack:e.stack??n}:{},...r!==void 0&&(i===`line`||i===`area`)?{curve:e.curve??r}:{}}}),a=(e,t=!1,n={})=>i(e,t?`area`:`line`,n.stacked?`stack`:void 0,n.curve),o=(e,t={})=>a(e,!0,t),s=(e,t=!1,n=!1)=>i(e,`bar`,t?`stack`:void 0).map(e=>n&&e.type===`bar`?{...e,showLabels:e.showLabels??!0}:e),c=e=>i(e,`scatter`),l=e=>i(e,`candlestick`),u=(e,t={})=>{let n=e.data.some(e=>typeof e.x==`number`),i=e.data.some(e=>typeof e.y==`number`);return{...t,series:[{id:`heatmap`,name:e.name??r(t.locale).value,type:`heatmap`,data:e.data.map(e=>({x:e.x,y:e.y,value:e.value})),colorScale:e.colorScale,valueRange:e.valueRange,radius:e.radius,format:e.format}],xAxis:{...n?{}:{type:`category`,categories:e.xCategories},grid:!1,...t.xAxis},yAxis:{...i?{}:{type:`category`,categories:e.yCategories},grid:!1,...t.yAxis},legend:t.legend??!1,interaction:t.interaction??{zoom:!1},tooltip:t.tooltip??{mode:`nearest`}}},d=(e,t={})=>{let n=e.type??`line`;return{...t,series:[{id:`sparkline`,name:e.name??r(t.locale).value,type:n,data:e.data,color:e.color,curve:n===`bar`?void 0:e.curve??`smooth`,lineWidth:1.5,opacity:n===`area`?.22:void 0,radius:n===`bar`?1.5:void 0,format:e.format}],xAxis:{visible:!1,grid:!1,...t.xAxis},yAxis:{visible:!1,grid:!1,nice:!1,...t.yAxis},legend:!1,padding:t.padding??{top:4,right:4,bottom:4,left:4},interaction:t.interaction??{zoom:!1},annotations:e.reference===void 0?t.annotations:[...t.annotations??[],{type:`line`,axis:`y`,value:e.reference,dash:[2,3]}]}},f={topLeft:`var(--danger-color, #ef4444)`,topRight:`var(--primary-color, #4f46e5)`,bottomLeft:`var(--warning-color, #f59e0b)`,bottomRight:`var(--text-secondary-color, #64748b)`},p=`var(--border-strong-color, var(--border-color, #cbd5e1))`,m=e=>{let[t,n]=e.xDomain??[0,10],[r,i]=e.yDomain??[0,10];return{x0:t,x1:n,y0:r,y1:i,xs:e.xSplit??(t+n)/2,ys:e.ySplit??(r+i)/2}},h=(e,t,n)=>{let{xs:r,ys:i}=m(e),a=e.reverseX?t<r:t>=r;return n>=i?a?`topRight`:`topLeft`:a?`bottomRight`:`bottomLeft`},g=(e,t)=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=m(e),c=t.endsWith(`Right`);return{x:(e.reverseX?!c:c)?(o+r)/2:(n+o)/2,y:t.startsWith(`top`)?(s+a)/2:(i+s)/2}},_=(e,t={})=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=m(e),c=!!e.reverseX,l=t=>e.quadrants?.[t]?.color??f[t],u=[{type:`scatter`,name:e.name??``,pointSize:e.pointSize??12,showLabels:e.showLabels??!0,opacity:.9,data:e.points.map(t=>({x:t.x,y:t.y,label:t.label,size:t.size,color:t.color??l(h(e,t.x,t.y))}))}],d=c?[o,r]:[n,o],g=c?[n,o]:[o,r],_=(t,[n,r],[i,a],o)=>({type:`rect`,x0:n,x1:r,y0:i,y1:a,color:l(t),opacity:.07,label:e.quadrants?.[t]?.label,labelPosition:o}),v=e.axisLabels??{},y=c?r:n,b=c?n:r,x=[...v.top?[{type:`text`,x:o,y:a,text:v.top,anchor:`top`}]:[],...v.bottom?[{type:`text`,x:o,y:i,text:v.bottom,anchor:`bottom`}]:[],...v.left?[{type:`text`,x:y,y:s,text:v.left,anchor:`left`}]:[],...v.right?[{type:`text`,x:b,y:s,text:v.right,anchor:`right`}]:[]],S=[_(`topLeft`,d,[s,a],`top-left`),_(`topRight`,g,[s,a],`top-right`),_(`bottomLeft`,d,[i,s],`bottom-left`),_(`bottomRight`,g,[i,s],`bottom-right`),{type:`line`,axis:`x`,value:o,dash:[],color:p},{type:`line`,axis:`y`,value:s,dash:[],color:p},...x,...t.annotations??[]],C=e.showTicks??!0,w=t.interaction!==!1&&{zoom:!1,...typeof t.interaction==`object`?t.interaction:{},...e.draggable?{dragPoints:!0}:{}};return{...t,series:u,annotations:S,tooltip:t.tooltip??(C?void 0:{render:t=>{let n=t.items[0];if(!n)return null;let r=e.quadrants?.[h(e,n.x,n.y)]?.label;return[n.label??e.name??``,r??``].filter(Boolean).join(`
2
- `)}}),xAxis:{min:n,max:r,title:e.xLabel,reverse:c,nice:!1,grid:!1,tickCount:4,visible:C||!!e.xLabel,...C?{}:{format:()=>``}},yAxis:{min:i,max:a,title:e.yLabel,nice:!1,grid:!1,tickCount:4,visible:C||!!e.yLabel,...C?{}:{format:()=>``}},legend:t.legend??!1,padding:t.padding??(C?void 0:{top:4,right:4,bottom:4,left:4}),interaction:w}},v=e=>{let t=0;for(let n=0;n<e.length;n++)Number.isFinite(e[n])&&t++;let n=new Float64Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];Number.isFinite(i)&&(n[r++]=i)}return n.sort()},y=(e,t)=>{let n=e.length;if(!n)return NaN;let r=Math.min(1,Math.max(0,t))*(n-1),i=Math.floor(r),a=Math.min(n-1,i+1);return e[i]+(e[a]-e[i])*(r-i)},b=(e,t)=>{let n=v(e);return t.map(e=>y(n,e))},x=1e5,S=(e,n={})=>{let r=0,i=1/0,a=-1/0;for(let t=0;t<e.length;t++){let n=e[t];Number.isFinite(n)&&(r++,n<i&&(i=n),n>a&&(a=n))}let[o,s]=n.domain??[i,a];if(!r||!Number.isFinite(o)||!Number.isFinite(s))return{edges:[0,1],counts:[0],width:1,total:0};o>s&&([o,s]=[s,o]),s===o&&(o-=.5,s+=.5);let c=s-o,l=n.bins??`auto`,u=Math.ceil(Math.log2(r))+1,d;if(typeof l==`number`)d=Math.round(l);else if(l===`sturges`)d=u;else{let t=Math.max(1,Math.floor(e.length/x)),n=[];for(let r=0;r<e.length;r+=t){let t=e[r];Number.isFinite(t)&&n.push(t)}let i=Float64Array.from(n).sort(),a=2*(y(i,.75)-y(i,.25))/Math.cbrt(r);d=a>0?Math.ceil(c/a):u}d=Math.max(1,Math.min(1e3,d||1));let f=c/d,p=o;(n.nice??!0)&&(f=t.tickStep(o,s,d)||f,p=Math.floor(o/f+1e-9)*f,d=Math.max(1,Math.ceil((s-p)/f-1e-9)));let m=p+d*f,h=Array(d).fill(0),g=0;for(let t=0;t<e.length;t++){let n=e[t];if(!(n>=p&&n<=m))continue;let r=Math.min(d-1,Math.floor((n-p)/f));h[r]++,g++}let _=[];for(let e=0;e<=d;e++)_.push(Number((p+e*f).toPrecision(12)));return{edges:_,counts:h,width:f,total:g}},C=(t,n={})=>{let i=n.binned??S(t,n),a=e.resolveLocale(n.locale),o=n.format??(e=>w(e,a));return{id:`histogram`,name:n.name??r(a).count,type:`bar`,color:n.color,barWidth:1,radius:1,data:i.counts.map((e,t)=>{let n=i.edges[t]??0,r=i.edges[t+1]??n;return{x:(n+r)/2,y:e,label:`${o(n)} – ${o(r)}`}})}},w=(t,n)=>e.numberFormat(n,{maximumSignificantDigits:6}).format(t),T=(e,t={})=>{let n=v(e),r=n.length;if(!r)return{low:NaN,q1:NaN,median:NaN,q3:NaN,high:NaN,outliers:[],min:NaN,max:NaN,mean:NaN,count:0};let i=y(n,.25),a=y(n,.5),o=y(n,.75),s=n[0],c=n[r-1],l=0;for(let e=0;e<r;e++)l+=n[e];let u=t.whisker??1.5,d=s,f=c,p=[];if(u!==`minmax`){let e=(o-i)*u,t=i-e,a=o+e,s=0;for(;s<r&&n[s]<t;)p.push(n[s++]);d=s<r?n[s]:i;let c=r-1,l=[];for(;c>=0&&n[c]>a;)l.push(n[c--]);f=c>=0?n[c]:o,p.push(...l.reverse())}return{low:Math.min(d,i),q1:i,median:a,q3:o,high:Math.max(f,o),outliers:p,min:s,max:c,mean:l/r,count:r}},E=(e,t={})=>e.map(e=>{let n=T(e.values,t);return{x:e.x,y:Number.isFinite(n.median)?n.median:null,low:n.low,q1:n.q1,q3:n.q3,high:n.high,outliers:n.outliers,...e.color?{color:e.color}:{}}}),D=e=>i(e,`boxplot`),O=(e,t={})=>{let n=t.upColor??`var(--success-color, #16a34a)`,i=t.downColor??`var(--danger-color, #dc2626)`,a=t.totalColor??`var(--primary-color, #4f46e5)`,o=t.start??0,s=e.map(e=>{if(e.kind===`total`||e.kind===`subtotal`)return{x:e.label,y:o,color:e.color??a};let t=e.value??0,r=o;return o+=t,{x:e.label,y0:r,y:o,color:e.color??(t>=0?n:i)}});return{id:`waterfall`,name:t.name??r(t.locale).change,type:`bar`,color:a,data:s,showLabels:t.labels??!1,format:t.format}},k=(e,t={})=>{let n=t.minSize??6,r=t.maxSize??48,i=e=>{if(typeof e!=`object`||!e)return null;if(!(`length`in e))return e.value??null;let t=e,n=new Float64Array(t.length).fill(NaN);for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`&&!Array.isArray(r)){let t=r.value;typeof t==`number`&&(n[e]=t)}}return n},a=t.maxValue??0;if(t.maxValue===void 0)for(let t of e){let e=i(t.data);if(e)for(let t=0;t<e.length;t++){let n=Math.abs(e[t]);n>a&&(a=n)}}let o=e=>Number.isFinite(e)&&a>0?Math.max(n,r*Math.sqrt(Math.min(1,Math.abs(e)/a))):n;return e.map(e=>{let t={...e,type:e.type??`scatter`,opacity:e.opacity??.68};if(t.type!==`scatter`)return t;let n=e.data;if(typeof n==`object`&&n&&!(`length`in n)){let e=n.value;if(!e)return t;let r=new Float32Array(e.length);for(let t=0;t<e.length;t++)r[t]=o(e[t]);return{...t,data:{...n,size:r}}}let r=n,i=[];for(let e=0;e<r.length;e++){let t=r[e];if(!t||typeof t!=`object`||Array.isArray(t))continue;let n=t;i.push({...n,size:n.size??o(typeof n.value==`number`?n.value:NaN)})}return i.sort((e,t)=>(t.size??0)-(e.size??0)),{...t,data:i}})},A=[`--primary-color`,`--success-color`,`--warning-color`,`--danger-color`,`--info-color`],j=[`#4f46e5`,`#10b981`,`#f59e0b`,`#ef4444`,`#0ea5e9`,`#8b5cf6`,`#14b8a6`,`#f97316`],M=e=>{let t=e%8,n=j[t]??`#4f46e5`,r=A[t];return r?`var(--chart-series-${t+1}, var(${r}, ${n}))`:`var(--chart-series-${t+1}, ${n})`},N=e=>e instanceof Date?e.getTime():e===void 0?NaN:e,P=(t,n={})=>{let i=e.resolveLocale(n.locale),a=r(i),o=n.taskName??a.tasks,s=[];for(let e of t){let t=e.group??o;!e.milestone&&!s.includes(t)&&s.push(t)}let c=e=>{let t=Math.max(0,s.indexOf(e));return n.colors?.[t]??M(t)},l=n.formatProgress??(t=>e.numberFormat(i,{style:`percent`,maximumFractionDigits:0}).format(t)),u=s.map(e=>({id:`gantt:${e}`,name:e,type:`bar`,stack:`gantt`,color:c(e),opacity:.3,barWidth:.62,radius:4,data:t.filter(t=>!t.milestone&&(t.group??o)===e).map(e=>({x:e.name,y0:N(e.start),y:N(e.end??e.start),...e.color?{color:e.color}:{}}))})),d=t.filter(e=>!e.milestone&&e.progress!==void 0&&e.progress>0);d.length&&u.push({id:`gantt:progress`,name:n.progressName??a.progress,type:`bar`,stack:`gantt`,color:`var(--text-secondary-color, #6b7280)`,radius:4,data:d.map(e=>{let t=N(e.start),n=N(e.end??e.start),r=Math.min(1,Math.max(0,e.progress??0));return{x:e.name,y0:t,y:t+(n-t)*r,label:l(r),color:e.color??c(e.group??o)}})});let f=t.filter(e=>e.milestone);f.length&&u.push({id:`gantt:milestones`,name:n.milestoneName??a.milestones,type:`scatter`,color:`var(--text-color, #1f2937)`,pointSize:13,opacity:1,data:f.map(e=>({x:e.name,y:N(e.start),...e.color?{color:e.color}:{}}))});let p=1/0,m=-1/0;for(let e of t)for(let t of[N(e.start),N(e.end??e.start)])t<p&&(p=t),t>m&&(m=t);let h=Number.isFinite(m-p)?Math.max((m-p)*.025,1):0;return{series:u,categories:t.map(e=>e.name),domain:Number.isFinite(p)?[p-h,m+h]:[0,1]}},F=(e,t)=>i(e,`area`,void 0,t).map(e=>e.type===`area`?{...e,lineWidth:e.lineWidth??1.5}:e);exports.DEFAULT_QUADRANT_COLORS=f,exports.areaSeries=o,exports.barSeries=s,exports.binValues=S,exports.boxplotData=E,exports.boxplotSeries=D,exports.boxplotStats=T,exports.bubbleSeries=k,exports.candlestickSeries=l,exports.ganttSeries=P,exports.heatmapChartOptions=u,exports.histogramSeries=C,exports.lineSeries=a,exports.paletteColor=M,exports.presetLabels=r,exports.quadrantCenter=g,exports.quadrantChartOptions=_,exports.quadrantOf=h,exports.quantiles=b,exports.rangeAreaSeries=F,exports.scatterSeries=c,exports.sparklineOptions=d,exports.waterfallSeries=O,exports.withSeriesType=i;
1
+ const e=require("./locale.cjs"),t=require("./labels.cjs"),n=require("./scale.cjs");var r={en:{value:`Value`,values:`Values`,count:`Count`,change:`Change`,tasks:`Tasks`,progress:`Progress`,milestones:`Milestones`},zh:{value:`数值`,values:`数值`,count:`数量`,change:`变化`,tasks:`任务`,progress:`进度`,milestones:`里程碑`},ja:{value:`値`,values:`値`,count:`件数`,change:`増減`,tasks:`タスク`,progress:`進捗`,milestones:`マイルストーン`},fr:{value:`Valeur`,values:`Valeurs`,count:`Effectif`,change:`Variation`,tasks:`Tâches`,progress:`Avancement`,milestones:`Jalons`}},i=t=>e.localeLabels(r,t),a=(e,t,n,r)=>e.map(e=>{let i=e.type??t;return{...e,type:i,...n!==void 0&&i===t?{stack:e.stack??n}:{},...r!==void 0&&(i===`line`||i===`area`)?{curve:e.curve??r}:{}}}),o=(e,t=!1,n={})=>a(e,t?`area`:`line`,n.stacked?`stack`:void 0,n.curve),s=(e,t={})=>o(e,!0,t),c=(e,t=!1,n=!1)=>a(e,`bar`,t?`stack`:void 0).map(e=>n&&e.type===`bar`?{...e,showLabels:e.showLabels??!0}:e),l=e=>a(e,`scatter`),u=e=>a(e,`candlestick`),d=(e,t={})=>{let n=e.data.some(e=>typeof e.x==`number`),r=e.data.some(e=>typeof e.y==`number`);return{...t,series:[{id:`heatmap`,name:e.name??i(t.locale).value,type:`heatmap`,data:e.data.map(e=>({x:e.x,y:e.y,value:e.value})),colorScale:e.colorScale,valueRange:e.valueRange,colorMidpoint:e.colorMidpoint,radius:e.radius,format:e.format}],xAxis:{...n?{}:{type:`category`,categories:e.xCategories},grid:!1,...t.xAxis},yAxis:{...r?{}:{type:`category`,categories:e.yCategories},grid:!1,...t.yAxis},legend:t.legend??!0,interaction:t.interaction??{zoom:!1},tooltip:t.tooltip??{mode:`nearest`}}},f=(e,t={})=>{let n=e.type??`line`;return{...t,series:[{id:`sparkline`,name:e.name??i(t.locale).value,type:n,data:e.data,color:e.color,curve:n===`bar`?void 0:e.curve??`smooth`,lineWidth:1.5,opacity:n===`area`?.22:void 0,radius:n===`bar`?1.5:void 0,format:e.format}],xAxis:{visible:!1,grid:!1,...t.xAxis},yAxis:{visible:!1,grid:!1,nice:!1,...t.yAxis},legend:!1,padding:t.padding??{top:4,right:4,bottom:4,left:4},interaction:t.interaction??{zoom:!1},annotations:e.reference===void 0?t.annotations:[...t.annotations??[],{type:`line`,axis:`y`,value:e.reference,dash:[2,3]}]}},p={topLeft:`var(--danger-color, #ef4444)`,topRight:`var(--primary-color, #4f46e5)`,bottomLeft:`var(--warning-color, #f59e0b)`,bottomRight:`var(--text-secondary-color, #64748b)`},m=`var(--border-strong-color, var(--border-color, #cbd5e1))`,h=e=>{let[t,n]=e.xDomain??[0,10],[r,i]=e.yDomain??[0,10];return{x0:t,x1:n,y0:r,y1:i,xs:e.xSplit??(t+n)/2,ys:e.ySplit??(r+i)/2}},g=(e,t,n)=>{let{xs:r,ys:i}=h(e),a=e.reverseX?t<r:t>=r;return n>=i?a?`topRight`:`topLeft`:a?`bottomRight`:`bottomLeft`},_=(e,t)=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=h(e),c=t.endsWith(`Right`);return{x:(e.reverseX?!c:c)?(o+r)/2:(n+o)/2,y:t.startsWith(`top`)?(s+a)/2:(i+s)/2}},v=(e,t={})=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=h(e),c=!!e.reverseX,l=t=>e.quadrants?.[t]?.color??p[t],u=[{type:`scatter`,name:e.name??``,pointSize:e.pointSize??12,showLabels:e.showLabels??!0,opacity:.9,data:e.points.map(t=>({x:t.x,y:t.y,label:t.label,size:t.size,color:t.color??l(g(e,t.x,t.y))}))}],d=c?[o,r]:[n,o],f=c?[n,o]:[o,r],_=(t,[n,r],[i,a],o)=>({type:`rect`,x0:n,x1:r,y0:i,y1:a,color:l(t),opacity:.07,label:e.quadrants?.[t]?.label,labelPosition:o}),v=e.axisLabels??{},y=c?r:n,b=c?n:r,x=[...v.top?[{type:`text`,x:o,y:a,text:v.top,anchor:`top`}]:[],...v.bottom?[{type:`text`,x:o,y:i,text:v.bottom,anchor:`bottom`}]:[],...v.left?[{type:`text`,x:y,y:s,text:v.left,anchor:`left`}]:[],...v.right?[{type:`text`,x:b,y:s,text:v.right,anchor:`right`}]:[]],S=[_(`topLeft`,d,[s,a],`top-left`),_(`topRight`,f,[s,a],`top-right`),_(`bottomLeft`,d,[i,s],`bottom-left`),_(`bottomRight`,f,[i,s],`bottom-right`),{type:`line`,axis:`x`,value:o,dash:[],color:m},{type:`line`,axis:`y`,value:s,dash:[],color:m},...x,...t.annotations??[]],C=e.showTicks??!0,w=t.interaction!==!1&&{zoom:!1,...typeof t.interaction==`object`?t.interaction:{},...e.draggable?{dragPoints:!0}:{}};return{...t,series:u,annotations:S,tooltip:t.tooltip??(C?void 0:{render:t=>{let n=t.items[0];if(!n)return null;let r=e.quadrants?.[g(e,n.x,n.y)]?.label;return[n.label??e.name??``,r??``].filter(Boolean).join(`
2
+ `)}}),xAxis:{min:n,max:r,title:e.xLabel,reverse:c,nice:!1,grid:!1,tickCount:4,visible:C||!!e.xLabel,...C?{}:{format:()=>``}},yAxis:{min:i,max:a,title:e.yLabel,nice:!1,grid:!1,tickCount:4,visible:C||!!e.yLabel,...C?{}:{format:()=>``}},legend:t.legend??!1,padding:t.padding??(C?void 0:{top:4,right:4,bottom:4,left:4}),interaction:w}},y=e=>{let t=0;for(let n=0;n<e.length;n++)Number.isFinite(e[n])&&t++;let n=new Float64Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];Number.isFinite(i)&&(n[r++]=i)}return n.sort()},b=(e,t)=>{let n=e.length;if(!n)return NaN;let r=Math.min(1,Math.max(0,t))*(n-1),i=Math.floor(r),a=Math.min(n-1,i+1);return e[i]+(e[a]-e[i])*(r-i)},x=(e,t)=>{let n=y(e);return t.map(e=>b(n,e))},S=1e5,C=(e,t={})=>{let r=0,i=1/0,a=-1/0;for(let t=0;t<e.length;t++){let n=e[t];Number.isFinite(n)&&(r++,n<i&&(i=n),n>a&&(a=n))}let[o,s]=t.domain??[i,a];if(!r||!Number.isFinite(o)||!Number.isFinite(s))return{edges:[0,1],counts:[0],width:1,total:0};o>s&&([o,s]=[s,o]),s===o&&(o-=.5,s+=.5);let c=s-o,l=t.bins??`auto`,u=Math.ceil(Math.log2(r))+1,d;if(typeof l==`number`)d=Math.round(l);else if(l===`sturges`)d=u;else{let t=Math.max(1,Math.floor(e.length/S)),n=[];for(let r=0;r<e.length;r+=t){let t=e[r];Number.isFinite(t)&&n.push(t)}let i=Float64Array.from(n).sort(),a=2*(b(i,.75)-b(i,.25))/Math.cbrt(r);d=a>0?Math.ceil(c/a):u}d=Math.max(1,Math.min(1e3,d||1));let f=c/d,p=o;(t.nice??!0)&&(f=n.tickStep(o,s,d)||f,p=Math.floor(o/f+1e-9)*f,d=Math.max(1,Math.ceil((s-p)/f-1e-9)));let m=p+d*f,h=Array(d).fill(0),g=0;for(let t=0;t<e.length;t++){let n=e[t];if(!(n>=p&&n<=m))continue;let r=Math.min(d-1,Math.floor((n-p)/f));h[r]++,g++}let _=[];for(let e=0;e<=d;e++)_.push(Number((p+e*f).toPrecision(12)));return{edges:_,counts:h,width:f,total:g}},w=(t,n={})=>{let r=n.binned??C(t,n),a=e.resolveLocale(n.locale),o=n.format??(e=>T(e,a));return{id:`histogram`,name:n.name??i(a).count,type:`bar`,color:n.color,barWidth:1,radius:1,data:r.counts.map((e,t)=>{let n=r.edges[t]??0,i=r.edges[t+1]??n;return{x:(n+i)/2,y:e,label:`${o(n)} – ${o(i)}`}})}},T=(t,n)=>e.numberFormat(n,{maximumSignificantDigits:6}).format(t),E=(e,t={})=>{let n=y(e),r=n.length;if(!r)return{low:NaN,q1:NaN,median:NaN,q3:NaN,high:NaN,outliers:[],min:NaN,max:NaN,mean:NaN,count:0};let i=b(n,.25),a=b(n,.5),o=b(n,.75),s=n[0],c=n[r-1],l=0;for(let e=0;e<r;e++)l+=n[e];let u=t.whisker??1.5,d=s,f=c,p=[];if(u!==`minmax`){let e=(o-i)*u,t=i-e,a=o+e,s=0;for(;s<r&&n[s]<t;)p.push(n[s++]);d=s<r?n[s]:i;let c=r-1,l=[];for(;c>=0&&n[c]>a;)l.push(n[c--]);f=c>=0?n[c]:o,p.push(...l.reverse())}return{low:Math.min(d,i),q1:i,median:a,q3:o,high:Math.max(f,o),outliers:p,min:s,max:c,mean:l/r,count:r}},D=(e,t={})=>e.map(e=>{let n=E(e.values,t);return{x:e.x,y:Number.isFinite(n.median)?n.median:null,low:n.low,q1:n.q1,q3:n.q3,high:n.high,outliers:n.outliers,...e.color?{color:e.color}:{}}}),O=e=>a(e,`boxplot`),k=(e,t={})=>{let n=t.upColor??`var(--success-color, #16a34a)`,r=t.downColor??`var(--danger-color, #dc2626)`,a=t.totalColor??`var(--primary-color, #4f46e5)`,o=t.start??0,s=e.map(e=>{if(e.kind===`total`||e.kind===`subtotal`)return{x:e.label,y:o,color:e.color??a};let t=e.value??0,i=o;return o+=t,{x:e.label,y0:i,y:o,color:e.color??(t>=0?n:r)}});return{id:`waterfall`,name:t.name??i(t.locale).change,type:`bar`,color:a,data:s,showLabels:t.labels??!1,format:t.format,connector:t.connector??!0}},A=(e,t={})=>{let n=t.minSize??6,r=t.maxSize??48,i=e=>{if(typeof e!=`object`||!e)return null;if(!(`length`in e))return e.value??null;let t=e,n=new Float64Array(t.length).fill(NaN);for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`&&!Array.isArray(r)){let t=r.value;typeof t==`number`&&(n[e]=t)}}return n},a=t.maxValue??0;if(t.maxValue===void 0)for(let t of e){let e=i(t.data);if(e)for(let t=0;t<e.length;t++){let n=Math.abs(e[t]);n>a&&(a=n)}}let o=e=>Number.isFinite(e)&&a>0?Math.max(n,r*Math.sqrt(Math.min(1,Math.abs(e)/a))):n;return e.map(e=>{let t={...e,type:e.type??`scatter`,opacity:e.opacity??.68};if(t.type!==`scatter`)return t;let n=e.data;if(typeof n==`object`&&n&&!(`length`in n)){let e=n.value;if(!e)return t;let r=new Float32Array(e.length);for(let t=0;t<e.length;t++)r[t]=o(e[t]);return{...t,data:{...n,size:r}}}let r=n,i=[];for(let e=0;e<r.length;e++){let t=r[e];if(!t||typeof t!=`object`||Array.isArray(t))continue;let n=t;i.push({...n,size:n.size??o(typeof n.value==`number`?n.value:NaN)})}return i.sort((e,t)=>(t.size??0)-(e.size??0)),{...t,data:i}})},j=[`--primary-color`,`--success-color`,`--warning-color`,`--danger-color`,`--info-color`],M=[`#4f46e5`,`#10b981`,`#f59e0b`,`#ef4444`,`#0ea5e9`,`#8b5cf6`,`#14b8a6`,`#f97316`],N=e=>{let t=e%8,n=M[t]??`#4f46e5`,r=j[t];return r?`var(--chart-series-${t+1}, var(${r}, ${n}))`:`var(--chart-series-${t+1}, ${n})`},P=e=>e instanceof Date?e.getTime():e===void 0?NaN:e,F=(n,r={})=>{let a=e.resolveLocale(r.locale),o=i(a),s=t.chartLabels(a),c=r.taskName??o.tasks,l=r.progressName??o.progress,u=/^(zh|ja)\b/i.test(a)?`、`:`, `,d=[];for(let e of n){let t=e.group??c;!e.milestone&&!d.includes(t)&&d.push(t)}let f=e=>{let t=Math.max(0,d.indexOf(e));return r.colors?.[t]??N(t)},p=r.formatProgress??(t=>e.numberFormat(a,{style:`percent`,maximumFractionDigits:0}).format(t)),m=d.map(e=>({id:`gantt:${e}`,name:e,type:`bar`,stack:`gantt`,color:f(e),opacity:.3,barWidth:.62,radius:4,data:n.filter(t=>!t.milestone&&(t.group??c)===e).map(e=>{let t=[];return e.progress!==void 0&&t.push({name:l,value:p(Math.min(1,Math.max(0,e.progress)))}),e.dependencies?.length&&t.push({name:r.dependenciesName??s.dependencies,value:e.dependencies.join(u)}),{x:e.name,y0:P(e.start),y:P(e.end??e.start),...e.color?{color:e.color}:{},...t.length?{details:t}:{}}})})),h=n.filter(e=>!e.milestone&&e.progress!==void 0&&e.progress>0);h.length&&m.push({id:`gantt:progress`,name:l,type:`bar`,stack:`gantt`,tooltip:!1,color:`var(--text-secondary-color, #6b7280)`,radius:4,data:h.map(e=>{let t=P(e.start),n=P(e.end??e.start),r=Math.min(1,Math.max(0,e.progress??0));return{x:e.name,y0:t,y:t+(n-t)*r,label:p(r),color:e.color??f(e.group??c)}})});let g=n.filter(e=>e.milestone);g.length&&m.push({id:`gantt:milestones`,name:r.milestoneName??o.milestones,type:`scatter`,color:`var(--text-color, #1f2937)`,pointSize:13,opacity:1,data:g.map(e=>({x:e.name,y:P(e.start),...e.color?{color:e.color}:{}}))});let _=1/0,v=-1/0;for(let e of n)for(let t of[P(e.start),P(e.end??e.start)])t<_&&(_=t),t>v&&(v=t);let y=Number.isFinite(v-_)?Math.max((v-_)*.025,1):0,b=new Set(n.map(e=>e.name)),x=[];if(r.dependencyArrows!==!1)for(let e of n)for(let t of e.dependencies??[])t!==e.name&&b.has(t)&&x.push({from:t,to:e.name,...r.dependencyColor?{color:r.dependencyColor}:{}});return{series:m,categories:n.map(e=>e.name),domain:Number.isFinite(_)?[_-y,v+y]:[0,1],dependencies:x}},I=(e,t)=>a(e,`area`,void 0,t).map(e=>e.type===`area`?{...e,lineWidth:e.lineWidth??1.5}:e);exports.DEFAULT_QUADRANT_COLORS=p,exports.areaSeries=s,exports.barSeries=c,exports.binValues=C,exports.boxplotData=D,exports.boxplotSeries=O,exports.boxplotStats=E,exports.bubbleSeries=A,exports.candlestickSeries=u,exports.ganttSeries=F,exports.heatmapChartOptions=d,exports.histogramSeries=w,exports.lineSeries=o,exports.paletteColor=N,exports.presetLabels=i,exports.quadrantCenter=_,exports.quadrantChartOptions=v,exports.quadrantOf=g,exports.quantiles=x,exports.rangeAreaSeries=I,exports.scatterSeries=l,exports.sparklineOptions=f,exports.waterfallSeries=k,exports.withSeriesType=a;
3
3
  //# sourceMappingURL=presets.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"presets.cjs","names":["localeLabels","tickStep","resolveLocale","numberFormat","require_locale","require_scale","PRESET_LABELS","presetLabels","locale","withSeriesType","series","t","s","type","stack","curve","lineSeries","area","extra","areaSeries","barSeries","stacked","labels","scatterSeries","candlestickSeries","heatmapChartOptions","numericX","config","c","numericY","base","sparklineOptions","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","y0","y1","quadrantOf","right","x","xs","y","ys","quadrantCenter","visualRight","corner","quadrantChartOptions","reverseX","color","p","left","rect","xa","xb","ya","yb","position","ends","visualLeft","texts","annotations","showTicks","interaction","item","event","region","sortedFinite","n","i","values","out","k","v","quantileOf","sorted","at","lo","hi","quantiles","ps","SPREAD_SAMPLE","binValues","min","max","options","span","rule","sturges","count","stride","sample","width","start","end","counts","total","edges","histogramSeries","bins","format","formatEdge","value","a","b","boxplotStats","q1","median","q3","sum","whisker","low","high","outliers","reach","from","to","j","upper","boxplotData","groups","g","boxplotSeries","waterfallSeries","up","down","running","data","steps","step","bubbleSeries","minSize","maxSize","valuesOf","list","top","sizeOf","size","points","d","THEMED","FALLBACK","paletteColor","fallback","themed","time","ganttSeries","names","taskName","tasks","colorOf","formatProgress","share","progress","milestones","pad","rangeAreaSeries"],"sources":["../../../../charts/src/engine/presets.ts"],"sourcesContent":["// Option presets of the chart components, shared by every platform (React,\n// mini-programs, React Native): they turn component props into engine\n// options.\n\nimport {\n localeLabels,\n numberFormat,\n resolveLocale,\n type LabelDictionary,\n} from \"./locale\";\nimport { tickStep } from \"./scale\";\nimport type {\n ChartAnnotation,\n ChartCurve,\n ChartInteractionOptions,\n ChartOptions,\n ChartPointDatum,\n ChartSeries,\n ChartSeriesType,\n ChartXValue,\n} from \"./types\";\n\n/** Default series names of the presets */\ninterface PresetLabels {\n value: string;\n values: string;\n count: string;\n change: string;\n tasks: string;\n progress: string;\n milestones: string;\n}\n\nconst PRESET_LABELS: LabelDictionary<PresetLabels> = {\n en: {\n value: \"Value\",\n values: \"Values\",\n count: \"Count\",\n change: \"Change\",\n tasks: \"Tasks\",\n progress: \"Progress\",\n milestones: \"Milestones\",\n },\n zh: {\n value: \"数值\",\n values: \"数值\",\n count: \"数量\",\n change: \"变化\",\n tasks: \"任务\",\n progress: \"进度\",\n milestones: \"里程碑\",\n },\n ja: {\n value: \"値\",\n values: \"値\",\n count: \"件数\",\n change: \"増減\",\n tasks: \"タスク\",\n progress: \"進捗\",\n milestones: \"マイルストーン\",\n },\n fr: {\n value: \"Valeur\",\n values: \"Valeurs\",\n count: \"Effectif\",\n change: \"Variation\",\n tasks: \"Tâches\",\n progress: \"Avancement\",\n milestones: \"Jalons\",\n },\n};\n\n/** Default series names of the presets in a locale (the page language by default) */\nexport const presetLabels = (locale?: string): PresetLabels =>\n localeLabels(PRESET_LABELS, locale);\n\n/** Gives the series without a `type` the type of the component */\nexport const withSeriesType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n curve?: ChartCurve,\n): ChartSeries[] =>\n series.map((s) => {\n const t = s.type ?? type;\n return {\n ...s,\n type: t,\n ...(stack !== undefined && t === type ? { stack: s.stack ?? stack } : {}),\n ...(curve !== undefined && (t === \"line\" || t === \"area\")\n ? { curve: s.curve ?? curve }\n : {}),\n };\n });\n\n/** Options of the line-like components */\nexport interface LineSeriesOptions {\n /** Stacks the series on top of each other */\n stacked?: boolean;\n /** Shape of the lines */\n curve?: ChartCurve;\n}\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (\n series: readonly ChartSeries[],\n area = false,\n extra: LineSeriesOptions = {},\n) =>\n withSeriesType(\n series,\n area ? \"area\" : \"line\",\n extra.stacked ? \"stack\" : undefined,\n extra.curve,\n );\n\n/** Series of an AreaChart */\nexport const areaSeries = (\n series: readonly ChartSeries[],\n extra: LineSeriesOptions = {},\n) => lineSeries(series, true, extra);\n\n/** Series of a BarChart (`stacked` stacks them, `labels` shows the values) */\nexport const barSeries = (\n series: readonly ChartSeries[],\n stacked = false,\n labels = false,\n) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined).map((s) =>\n labels && s.type === \"bar\" ? { ...s, showLabels: s.showLabels ?? true } : s,\n );\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\n\n/** Series of a CandlestickChart */\nexport const candlestickSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"candlestick\");\n\n/** A cell of a HeatmapChart */\nexport interface HeatmapCell {\n /** Column: a category name (or a number on a numeric axis) */\n x: string | number;\n /** Row: a category name (or a number on a numeric axis) */\n y: string | number;\n /** Value mapped to the color scale; `null` leaves the cell empty */\n value: number | null;\n}\n\n/** Settings of a heatmap (the props of HeatmapChart) */\nexport interface HeatmapConfig {\n /** Cells */\n data: readonly HeatmapCell[];\n /** Column names in order (collected from the data when omitted) */\n xCategories?: readonly string[];\n /** Row names from bottom to top (collected from the data when omitted) */\n yCategories?: readonly string[];\n /** Colors from the lowest to the highest value; a ramp of the first palette color by default */\n colorScale?: readonly string[];\n /** Values at the ends of the color scale; the data range by default */\n valueRange?: readonly [number, number];\n /** Name of the value in the tooltip */\n name?: string;\n /** Corner radius of the cells, in pixels */\n radius?: number;\n /** Formats the values in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a heatmap */\nexport const heatmapChartOptions = (\n config: HeatmapConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const numericX = config.data.some((c) => typeof c.x === \"number\");\n const numericY = config.data.some((c) => typeof c.y === \"number\");\n return {\n ...base,\n series: [\n {\n id: \"heatmap\",\n name: config.name ?? presetLabels(base.locale).value,\n type: \"heatmap\",\n data: config.data.map((c) => ({ x: c.x, y: c.y, value: c.value })),\n colorScale: config.colorScale,\n valueRange: config.valueRange,\n radius: config.radius,\n format: config.format,\n },\n ],\n xAxis: {\n ...(numericX\n ? {}\n : { type: \"category\" as const, categories: config.xCategories }),\n grid: false,\n ...base.xAxis,\n },\n yAxis: {\n ...(numericY\n ? {}\n : { type: \"category\" as const, categories: config.yCategories }),\n grid: false,\n ...base.yAxis,\n },\n legend: base.legend ?? false,\n interaction: base.interaction ?? { zoom: false },\n tooltip: base.tooltip ?? { mode: \"nearest\" },\n };\n};\n\n/** Settings of a sparkline (the props of Sparkline) */\nexport interface SparklineConfig {\n /** Values (or `[x, y]` pairs, typed arrays, ...) */\n data: ChartSeries[\"data\"];\n /**\n * How the values are drawn\n * @default \"line\"\n */\n type?: \"line\" | \"area\" | \"bar\";\n /** Color (any CSS color); the first palette color by default */\n color?: string;\n /**\n * Shape of the line\n * @default \"smooth\"\n */\n curve?: ChartCurve;\n /** Name shown in the tooltip */\n name?: string;\n /** Draws a reference line at this value (e.g. a target or the average) */\n reference?: number;\n /** Formats the value in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a sparkline: no axes, no legend, a tooltip only */\nexport const sparklineOptions = (\n config: SparklineConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const type = config.type ?? \"line\";\n return {\n ...base,\n series: [\n {\n id: \"sparkline\",\n name: config.name ?? presetLabels(base.locale).value,\n type,\n data: config.data,\n color: config.color,\n curve: type === \"bar\" ? undefined : (config.curve ?? \"smooth\"),\n lineWidth: 1.5,\n opacity: type === \"area\" ? 0.22 : undefined,\n radius: type === \"bar\" ? 1.5 : undefined,\n format: config.format,\n },\n ],\n xAxis: { visible: false, grid: false, ...base.xAxis },\n yAxis: { visible: false, grid: false, nice: false, ...base.yAxis },\n legend: false,\n padding: base.padding ?? { top: 4, right: 4, bottom: 4, left: 4 },\n interaction: base.interaction ?? { zoom: false },\n annotations:\n config.reference !== undefined\n ? [\n ...(base.annotations ?? []),\n {\n type: \"line\",\n axis: \"y\",\n value: config.reference,\n dash: [2, 3],\n },\n ]\n : base.annotations,\n };\n};\n\n/** A point of a QuadrantChart */\nexport interface QuadrantPoint {\n /** Position on the horizontal axis */\n x: number;\n /** Position on the vertical axis */\n y: number;\n /** Text drawn next to the dot and shown in the tooltip */\n label?: string;\n /** Dot color (any CSS color); the color of its quadrant by default */\n color?: string;\n /** Dot diameter in pixels */\n size?: number;\n}\n\n/** Title and color of a quadrant */\nexport interface QuadrantRegion {\n /** Title drawn in the outer corner of the quadrant */\n label?: string;\n /** Background tint and default dot color (any CSS color) */\n color?: string;\n}\n\n/** The four quadrants of a QuadrantChart */\nexport interface QuadrantRegions {\n topLeft?: QuadrantRegion;\n topRight?: QuadrantRegion;\n bottomLeft?: QuadrantRegion;\n bottomRight?: QuadrantRegion;\n}\n\n/** A quadrant, as seen on screen */\nexport type QuadrantCorner = keyof QuadrantRegions;\n\n/** Texts at the four ends of the dividers, inside the plot */\nexport interface QuadrantAxisLabels {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n}\n\n/** Settings of a quadrant matrix (the props of QuadrantChart) */\nexport interface QuadrantConfig {\n /** Points to place */\n points: readonly QuadrantPoint[];\n /**\n * Range of the horizontal axis\n * @default [0, 10]\n */\n xDomain?: [number, number];\n /**\n * Range of the vertical axis\n * @default [0, 10]\n */\n yDomain?: [number, number];\n /** X value of the vertical divider (the middle of `xDomain` by default) */\n xSplit?: number;\n /** Y value of the horizontal divider (the middle of `yDomain` by default) */\n ySplit?: number;\n /** Titles and colors of the quadrants */\n quadrants?: QuadrantRegions;\n /** Title of the horizontal axis */\n xLabel?: string;\n /** Title of the vertical axis */\n yLabel?: string;\n /** Texts at the ends of the dividers, drawn inside the plot (e.g. \"Important\" at the top) */\n axisLabels?: QuadrantAxisLabels;\n /**\n * Shows the numeric ticks of the axes; `false` keeps only the matrix\n * @default true\n */\n showTicks?: boolean;\n /** Reverses the horizontal axis (e.g. \"urgent\" on the left) */\n reverseX?: boolean;\n /**\n * Draws the labels next to the dots (overlapping labels are skipped)\n * @default true\n */\n showLabels?: boolean;\n /**\n * Dot diameter in pixels\n * @default 12\n */\n pointSize?: number;\n /** Name of the points in the tooltip */\n name?: string;\n /** Lets the user drag the dots (`drag` / `drop` events) */\n draggable?: boolean;\n}\n\nexport const DEFAULT_QUADRANT_COLORS: Required<Record<QuadrantCorner, string>> =\n {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n };\n\nconst DIVIDER = \"var(--border-strong-color, var(--border-color, #cbd5e1))\";\n\nconst splits = (config: QuadrantConfig) => {\n const [x0, x1] = config.xDomain ?? [0, 10];\n const [y0, y1] = config.yDomain ?? [0, 10];\n return {\n x0,\n x1,\n y0,\n y1,\n xs: config.xSplit ?? (x0 + x1) / 2,\n ys: config.ySplit ?? (y0 + y1) / 2,\n };\n};\n\n/** Quadrant of a data position, as seen on screen */\nexport const quadrantOf = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n x: number,\n y: number,\n): QuadrantCorner => {\n const { xs, ys } = splits(config as QuadrantConfig);\n const right = config.reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n};\n\n/** Center of a quadrant in data coordinates */\nexport const quadrantCenter = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n corner: QuadrantCorner,\n): { x: number; y: number } => {\n const { x0, x1, y0, y1, xs, ys } = splits(config as QuadrantConfig);\n const visualRight = corner.endsWith(\"Right\");\n const dataHigh = config.reverseX ? !visualRight : visualRight;\n return {\n x: dataHigh ? (xs + x1) / 2 : (x0 + xs) / 2,\n y: corner.startsWith(\"top\") ? (ys + y1) / 2 : (y0 + ys) / 2,\n };\n};\n\n/** Engine options of a quadrant matrix */\nexport const quadrantChartOptions = (\n config: QuadrantConfig,\n base: Omit<ChartOptions, \"series\"> = {},\n): ChartOptions => {\n const { x0, x1, y0, y1, xs, ys } = splits(config);\n const reverseX = !!config.reverseX;\n const color = (corner: QuadrantCorner) =>\n config.quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner];\n\n const series: ChartSeries[] = [\n {\n type: \"scatter\",\n name: config.name ?? \"\",\n pointSize: config.pointSize ?? 12,\n showLabels: config.showLabels ?? true,\n opacity: 0.9,\n data: config.points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: p.color ?? color(quadrantOf(config, p.x, p.y)),\n })),\n },\n ];\n\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: QuadrantCorner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => ({\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: color(corner),\n opacity: 0.07,\n label: config.quadrants?.[corner]?.label,\n labelPosition: position,\n });\n const ends = config.axisLabels ?? {};\n const visualLeft = reverseX ? x1 : x0;\n const visualRight = reverseX ? x0 : x1;\n const texts: ChartAnnotation[] = [\n ...(ends.top\n ? [{ type: \"text\", x: xs, y: y1, text: ends.top, anchor: \"top\" } as const]\n : []),\n ...(ends.bottom\n ? [\n {\n type: \"text\",\n x: xs,\n y: y0,\n text: ends.bottom,\n anchor: \"bottom\",\n } as const,\n ]\n : []),\n ...(ends.left\n ? [\n {\n type: \"text\",\n x: visualLeft,\n y: ys,\n text: ends.left,\n anchor: \"left\",\n } as const,\n ]\n : []),\n ...(ends.right\n ? [\n {\n type: \"text\",\n x: visualRight,\n y: ys,\n text: ends.right,\n anchor: \"right\",\n } as const,\n ]\n : []),\n ];\n\n const annotations: ChartAnnotation[] = [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n { type: \"line\", axis: \"x\", value: xs, dash: [], color: DIVIDER },\n { type: \"line\", axis: \"y\", value: ys, dash: [], color: DIVIDER },\n ...texts,\n ...(base.annotations ?? []),\n ];\n\n const showTicks = config.showTicks ?? true;\n const interaction: boolean | ChartInteractionOptions =\n base.interaction === false\n ? false\n : {\n zoom: false,\n ...(typeof base.interaction === \"object\" ? base.interaction : {}),\n ...(config.draggable ? { dragPoints: true } : {}),\n };\n\n return {\n ...base,\n series,\n annotations,\n tooltip:\n base.tooltip ??\n (showTicks\n ? undefined\n : {\n render: (event) => {\n const item = event.items[0];\n if (!item) return null;\n const region =\n config.quadrants?.[quadrantOf(config, item.x, item.y)]?.label;\n return [item.label ?? config.name ?? \"\", region ?? \"\"]\n .filter(Boolean)\n .join(\"\\n\");\n },\n }),\n xAxis: {\n min: x0,\n max: x1,\n title: config.xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.xLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n yAxis: {\n min: y0,\n max: y1,\n title: config.yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.yLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n legend: base.legend ?? false,\n padding:\n base.padding ??\n (showTicks ? undefined : { top: 4, right: 4, bottom: 4, left: 4 }),\n interaction,\n };\n};\n\n// ------------------------------------------------------------- statistics\n\n/** Finite values of a list, as a sorted typed array */\nconst sortedFinite = (values: ArrayLike<number>): Float64Array => {\n let n = 0;\n for (let i = 0; i < values.length; i++) if (Number.isFinite(values[i])) n++;\n const out = new Float64Array(n);\n let k = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (Number.isFinite(v)) out[k++] = v;\n }\n return out.sort();\n};\n\n/** Quantile `p` (0-1) of sorted values, linearly interpolated (NumPy / Excel) */\nconst quantileOf = (sorted: ArrayLike<number>, p: number): number => {\n const n = sorted.length;\n if (!n) return NaN;\n const at = Math.min(1, Math.max(0, p)) * (n - 1);\n const lo = Math.floor(at);\n const hi = Math.min(n - 1, lo + 1);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (at - lo);\n};\n\n/**\n * Quantiles of values (`[0.5, 0.95, 0.99]` gives the median, p95 and p99),\n * linearly interpolated like NumPy and Excel; non-finite values are ignored\n */\nexport const quantiles = (\n values: ArrayLike<number>,\n ps: readonly number[],\n): number[] => {\n const sorted = sortedFinite(values);\n return ps.map((p) => quantileOf(sorted, p));\n};\n\n/** How the bins of a histogram are chosen: a count, or a rule */\nexport type HistogramBinning =\n number | \"auto\" | \"sturges\" | \"freedman-diaconis\";\n\n/** Options of `binValues` */\nexport interface BinOptions {\n /**\n * Number of bins, or the rule choosing it: `sturges` (log2 n + 1, for\n * small normal-ish samples), `freedman-diaconis` (bin width from the\n * interquartile range, robust to outliers); `auto` uses Freedman-Diaconis\n * and Sturges when the spread is zero\n * @default \"auto\"\n */\n bins?: HistogramBinning;\n /** Range covered by the bins (values outside are not counted); the data range by default */\n domain?: readonly [number, number];\n /**\n * Rounds the bin width to 1, 2 or 5 × 10^k and aligns the edges on it\n * @default true\n */\n nice?: boolean;\n}\n\n/** Bins of a histogram */\nexport interface HistogramBins {\n /** Edges of the bins: one more than the bins */\n edges: number[];\n /** Number of values in every bin */\n counts: number[];\n /** Width of a bin */\n width: number;\n /** Number of values counted (finite, inside the domain) */\n total: number;\n}\n\n/** At most this many values are sorted to estimate the spread (Freedman-Diaconis) */\nconst SPREAD_SAMPLE = 100_000;\n\n/**\n * Counts values into bins of equal width: linear in the number of values\n * (a million samples take a few milliseconds; the spread of large samples\n * is estimated on an even subsample)\n */\nexport const binValues = (\n values: ArrayLike<number>,\n options: BinOptions = {},\n): HistogramBins => {\n let n = 0;\n let min = Infinity;\n let max = -Infinity;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!Number.isFinite(v)) continue;\n n++;\n if (v < min) min = v;\n if (v > max) max = v;\n }\n let [lo, hi] = options.domain ?? [min, max];\n if (!n || !Number.isFinite(lo) || !Number.isFinite(hi)) {\n return { edges: [0, 1], counts: [0], width: 1, total: 0 };\n }\n if (lo > hi) [lo, hi] = [hi, lo];\n if (hi === lo) {\n lo -= 0.5;\n hi += 0.5;\n }\n const span = hi - lo;\n const rule = options.bins ?? \"auto\";\n const sturges = Math.ceil(Math.log2(n)) + 1;\n let count: number;\n if (typeof rule === \"number\") {\n count = Math.round(rule);\n } else if (rule === \"sturges\") {\n count = sturges;\n } else {\n // Freedman-Diaconis: width = 2 IQR / n^(1/3)\n const stride = Math.max(1, Math.floor(values.length / SPREAD_SAMPLE));\n const sample: number[] = [];\n for (let i = 0; i < values.length; i += stride) {\n const v = values[i];\n if (Number.isFinite(v)) sample.push(v);\n }\n const sorted = Float64Array.from(sample).sort();\n const iqr = quantileOf(sorted, 0.75) - quantileOf(sorted, 0.25);\n const width = (2 * iqr) / Math.cbrt(n);\n count = width > 0 ? Math.ceil(span / width) : sturges;\n }\n count = Math.max(1, Math.min(1000, count || 1));\n let width = span / count;\n let start = lo;\n if (options.nice ?? true) {\n width = tickStep(lo, hi, count) || width;\n start = Math.floor(lo / width + 1e-9) * width;\n count = Math.max(1, Math.ceil((hi - start) / width - 1e-9));\n }\n const end = start + count * width;\n const counts = new Array<number>(count).fill(0);\n let total = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!(v >= start && v <= end)) continue;\n // the last bin includes its right edge\n const k = Math.min(count - 1, Math.floor((v - start) / width));\n counts[k]++;\n total++;\n }\n const edges: number[] = [];\n for (let k = 0; k <= count; k++)\n edges.push(Number((start + k * width).toPrecision(12)));\n return { edges, counts, width, total };\n};\n\n/** Options of `histogramSeries` */\nexport interface HistogramSeriesOptions extends BinOptions {\n /** Name of the series (legend, tooltip) */\n name?: string;\n /** Bar color (any CSS color) */\n color?: string;\n /** Formats the edges of the bins in the tooltip */\n format?: (value: number) => string;\n /** Bins already computed (`binValues`): `values` are then ignored */\n binned?: HistogramBins;\n /**\n * Locale of the default name and of the bin edges\n * @default the page language\n */\n locale?: string;\n}\n\n/** Bar series of a histogram: one touching bar per bin, labelled with its range */\nexport const histogramSeries = (\n values: ArrayLike<number>,\n options: HistogramSeriesOptions = {},\n): ChartSeries => {\n const bins = options.binned ?? binValues(values, options);\n const locale = resolveLocale(options.locale);\n const format =\n options.format ?? ((value: number) => formatEdge(value, locale));\n return {\n id: \"histogram\",\n name: options.name ?? presetLabels(locale).count,\n type: \"bar\",\n color: options.color,\n barWidth: 1,\n radius: 1,\n data: bins.counts.map((count, k) => {\n const a = bins.edges[k] ?? 0;\n const b = bins.edges[k + 1] ?? a;\n return {\n x: (a + b) / 2,\n y: count,\n label: `${format(a)} – ${format(b)}`,\n };\n }),\n };\n};\n\nconst formatEdge = (value: number, locale: string) =>\n numberFormat(locale, { maximumSignificantDigits: 6 }).format(value);\n\n/** Options of `boxplotStats` */\nexport interface BoxplotStatsOptions {\n /**\n * Reach of the whiskers in interquartile ranges beyond the box (Tukey:\n * 1.5); `\"minmax\"` extends them to the extremes (no outliers)\n * @default 1.5\n */\n whisker?: number | \"minmax\";\n}\n\n/** Five-number summary of a sample, with the outliers */\nexport interface BoxplotStats {\n /** Lower whisker: the smallest value within reach */\n low: number;\n /** First quartile */\n q1: number;\n median: number;\n /** Third quartile */\n q3: number;\n /** Upper whisker: the largest value within reach */\n high: number;\n /** Values beyond the whiskers */\n outliers: number[];\n min: number;\n max: number;\n mean: number;\n /** Number of finite values */\n count: number;\n}\n\n/** Quartiles, whiskers (Tukey's 1.5 IQR by default) and outliers of raw values */\nexport const boxplotStats = (\n values: ArrayLike<number>,\n options: BoxplotStatsOptions = {},\n): BoxplotStats => {\n const sorted = sortedFinite(values);\n const n = sorted.length;\n if (!n) {\n return {\n low: NaN,\n q1: NaN,\n median: NaN,\n q3: NaN,\n high: NaN,\n outliers: [],\n min: NaN,\n max: NaN,\n mean: NaN,\n count: 0,\n };\n }\n const q1 = quantileOf(sorted, 0.25);\n const median = quantileOf(sorted, 0.5);\n const q3 = quantileOf(sorted, 0.75);\n const min = sorted[0];\n const max = sorted[n - 1];\n let sum = 0;\n for (let i = 0; i < n; i++) sum += sorted[i];\n const whisker = options.whisker ?? 1.5;\n let low = min;\n let high = max;\n const outliers: number[] = [];\n if (whisker !== \"minmax\") {\n const reach = (q3 - q1) * whisker;\n const from = q1 - reach;\n const to = q3 + reach;\n let i = 0;\n while (i < n && sorted[i] < from) outliers.push(sorted[i++]);\n low = i < n ? sorted[i] : q1;\n let j = n - 1;\n const upper: number[] = [];\n while (j >= 0 && sorted[j] > to) upper.push(sorted[j--]);\n high = j >= 0 ? sorted[j] : q3;\n outliers.push(...upper.reverse());\n }\n return {\n low: Math.min(low, q1),\n q1,\n median,\n q3,\n high: Math.max(high, q3),\n outliers,\n min,\n max,\n mean: sum / n,\n count: n,\n };\n};\n\n/** A sample of a box plot */\nexport interface BoxplotGroup {\n /** Category (or position) of the box */\n x: ChartXValue;\n /** Raw values: their quartiles, whiskers and outliers are computed */\n values: ArrayLike<number>;\n /** Color of the box (any CSS color) */\n color?: string;\n}\n\n/** Box plot data of raw samples (one datum per group) */\nexport const boxplotData = (\n groups: readonly BoxplotGroup[],\n options: BoxplotStatsOptions = {},\n): ChartPointDatum[] =>\n groups.map((g) => {\n const s = boxplotStats(g.values, options);\n return {\n x: g.x,\n y: Number.isFinite(s.median) ? s.median : null,\n low: s.low,\n q1: s.q1,\n q3: s.q3,\n high: s.high,\n outliers: s.outliers,\n ...(g.color ? { color: g.color } : {}),\n };\n });\n\n/** Series of a BoxPlotChart */\nexport const boxplotSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"boxplot\");\n\n// ---------------------------------------------------------------- waterfall\n\n/** A bar of a waterfall chart */\nexport interface WaterfallStep {\n /** Category name of the bar */\n label: string;\n /** Change (positive or negative); ignored by totals */\n value?: number;\n /**\n * `subtotal` and `total` bars show the running total, from zero\n * @default \"change\"\n */\n kind?: \"change\" | \"subtotal\" | \"total\";\n /** Color of this bar (any CSS color) */\n color?: string;\n}\n\n/** Options of `waterfallSeries` */\nexport interface WaterfallOptions {\n /** Name of the series (tooltip) */\n name?: string;\n /** Color of the increases @default the success color */\n upColor?: string;\n /** Color of the decreases @default the danger color */\n downColor?: string;\n /** Color of the totals and subtotals @default the primary color */\n totalColor?: string;\n /**\n * Value the first change starts from\n * @default 0\n */\n start?: number;\n /**\n * Writes the change (or the total) at the end of every bar\n * @default false\n */\n labels?: boolean;\n /** Formats the values (labels, tooltip) */\n format?: (value: number) => string;\n /**\n * Locale of the default name\n * @default the page language\n */\n locale?: string;\n}\n\n/**\n * Floating bar series of a waterfall (bridge) chart: every change starts\n * where the previous one ended; totals and subtotals start from zero\n */\nexport const waterfallSeries = (\n steps: readonly WaterfallStep[],\n options: WaterfallOptions = {},\n): ChartSeries => {\n const up = options.upColor ?? \"var(--success-color, #16a34a)\";\n const down = options.downColor ?? \"var(--danger-color, #dc2626)\";\n const total = options.totalColor ?? \"var(--primary-color, #4f46e5)\";\n let running = options.start ?? 0;\n const data: ChartPointDatum[] = steps.map((step) => {\n if (step.kind === \"total\" || step.kind === \"subtotal\") {\n return { x: step.label, y: running, color: step.color ?? total };\n }\n const value = step.value ?? 0;\n const from = running;\n running += value;\n return {\n x: step.label,\n y0: from,\n y: running,\n color: step.color ?? (value >= 0 ? up : down),\n };\n });\n return {\n id: \"waterfall\",\n name: options.name ?? presetLabels(options.locale).change,\n type: \"bar\",\n color: total,\n data,\n showLabels: options.labels ?? false,\n format: options.format,\n };\n};\n\n// ------------------------------------------------------------------ bubbles\n\n/** Options of `bubbleSeries` */\nexport interface BubbleOptions {\n /**\n * Diameter in pixels of the smallest bubbles\n * @default 6\n */\n minSize?: number;\n /**\n * Diameter in pixels of the largest value\n * @default 48\n */\n maxSize?: number;\n /** Value drawn with `maxSize` (share a scale between charts); the largest value by default */\n maxValue?: number;\n}\n\n/**\n * Scatter series whose dots are sized by the `value` of their points: the\n * area of a bubble is proportional to its value (diameter ∝ √value), the\n * scale is shared by every series. Points are drawn from the largest to\n * the smallest, so small bubbles stay on top (hover indexes refer to that\n * order).\n */\nexport const bubbleSeries = (\n series: readonly ChartSeries[],\n options: BubbleOptions = {},\n): ChartSeries[] => {\n const minSize = options.minSize ?? 6;\n const maxSize = options.maxSize ?? 48;\n const valuesOf = (data: ChartSeries[\"data\"]): ArrayLike<number> | null => {\n if (typeof data !== \"object\" || data === null) return null;\n if (!(\"length\" in data)) {\n const v = (data as { value?: ArrayLike<number> }).value;\n return v ?? null;\n }\n const list = data as ArrayLike<unknown>;\n const out = new Float64Array(list.length).fill(NaN);\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const v = (item as { value?: unknown }).value;\n if (typeof v === \"number\") out[i] = v;\n }\n }\n return out;\n };\n let top = options.maxValue ?? 0;\n if (options.maxValue === undefined) {\n for (const s of series) {\n const values = valuesOf(s.data);\n if (!values) continue;\n for (let i = 0; i < values.length; i++) {\n const v = Math.abs(values[i]);\n if (v > top) top = v;\n }\n }\n }\n const sizeOf = (v: number) =>\n Number.isFinite(v) && top > 0\n ? Math.max(minSize, maxSize * Math.sqrt(Math.min(1, Math.abs(v) / top)))\n : minSize;\n return series.map((s) => {\n const base: ChartSeries = {\n ...s,\n type: s.type ?? \"scatter\",\n opacity: s.opacity ?? 0.68,\n };\n if (base.type !== \"scatter\") return base;\n const data = s.data;\n if (typeof data === \"object\" && data !== null && !(\"length\" in data)) {\n const values = (data as { value?: ArrayLike<number> }).value;\n if (!values) return base;\n const size = new Float32Array(values.length);\n for (let i = 0; i < values.length; i++) size[i] = sizeOf(values[i]);\n return { ...base, data: { ...data, size } };\n }\n const list = data as ArrayLike<unknown>;\n const points: ChartPointDatum[] = [];\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (!item || typeof item !== \"object\" || Array.isArray(item)) continue;\n const d = item as ChartPointDatum;\n points.push({\n ...d,\n size: d.size ?? sizeOf(typeof d.value === \"number\" ? d.value : NaN),\n });\n }\n points.sort((a, b) => (b.size ?? 0) - (a.size ?? 0));\n return { ...base, data: points };\n });\n};\n\n// -------------------------------------------------------------------- gantt\n\n/** A task (or milestone) of a Gantt chart */\nexport interface GanttTask {\n /** Row name (unique) */\n name: string;\n /** Start (a timestamp or a date) */\n start: number | Date;\n /** End; omitted for milestones */\n end?: number | Date;\n /** Share done, 0-1: drawn as a solid bar over the task */\n progress?: number;\n /** Group (phase, team): a color and a legend entry per group */\n group?: string;\n /** Color of the task (any CSS color); the color of its group by default */\n color?: string;\n /** Draws a dot at `start` instead of a bar */\n milestone?: boolean;\n}\n\n/** Options of `ganttSeries` */\nexport interface GanttOptions {\n /** Colors of the groups in order of appearance (any CSS colors); the chart palette by default */\n colors?: readonly string[];\n /**\n * Name of the tasks without a group\n * @default \"Tasks\" (in the `locale`)\n */\n taskName?: string;\n /**\n * Name of the progress bars (legend, tooltip)\n * @default \"Progress\" (in the `locale`)\n */\n progressName?: string;\n /**\n * Name of the milestones (legend, tooltip)\n * @default \"Milestones\" (in the `locale`)\n */\n milestoneName?: string;\n /** Formats the progress shares (tooltip) @default \"60%\" */\n formatProgress?: (share: number) => string;\n /**\n * Locale of the default names and of the progress shares\n * @default the page language\n */\n locale?: string;\n}\n\n/** Series of a Gantt chart and the row names in order */\nexport interface GanttSeries {\n series: ChartSeries[];\n /** Task names from top to bottom (the `categories` of the x axis) */\n categories: string[];\n /** Time range of the tasks with a small margin (the `min` / `max` of the value axis) */\n domain: [number, number];\n}\n\nconst THEMED = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n];\nconst FALLBACK = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\n/** Color `k` of the chart palette as a CSS color (theme variables first) */\nexport const paletteColor = (k: number): string => {\n const i = k % 8;\n const fallback = FALLBACK[i] ?? \"#4f46e5\";\n const themed = THEMED[i];\n return themed\n ? `var(--chart-series-${i + 1}, var(${themed}, ${fallback}))`\n : `var(--chart-series-${i + 1}, ${fallback})`;\n};\n\nconst time = (v: number | Date | undefined) =>\n v instanceof Date ? v.getTime() : v === undefined ? NaN : v;\n\n/**\n * Floating bar series of a Gantt chart (horizontal, on a time axis): a\n * translucent bar per task with its progress drawn over it, one series per\n * group, and the milestones as dots\n */\nexport const ganttSeries = (\n tasks: readonly GanttTask[],\n options: GanttOptions = {},\n): GanttSeries => {\n const locale = resolveLocale(options.locale);\n const names = presetLabels(locale);\n const taskName = options.taskName ?? names.tasks;\n const groups: string[] = [];\n for (const t of tasks) {\n const g = t.group ?? taskName;\n if (!t.milestone && !groups.includes(g)) groups.push(g);\n }\n const colorOf = (g: string) => {\n const k = Math.max(0, groups.indexOf(g));\n return options.colors?.[k] ?? paletteColor(k);\n };\n const formatProgress =\n options.formatProgress ??\n ((share: number) =>\n numberFormat(locale, {\n style: \"percent\",\n maximumFractionDigits: 0,\n }).format(share));\n const series: ChartSeries[] = groups.map((g) => ({\n id: `gantt:${g}`,\n name: g,\n type: \"bar\",\n stack: \"gantt\",\n color: colorOf(g),\n opacity: 0.3,\n barWidth: 0.62,\n radius: 4,\n data: tasks\n .filter((t) => !t.milestone && (t.group ?? taskName) === g)\n .map((t) => ({\n x: t.name,\n y0: time(t.start),\n y: time(t.end ?? t.start),\n ...(t.color ? { color: t.color } : {}),\n })),\n }));\n const progress = tasks.filter(\n (t) => !t.milestone && t.progress !== undefined && t.progress > 0,\n );\n if (progress.length) {\n series.push({\n id: \"gantt:progress\",\n name: options.progressName ?? names.progress,\n type: \"bar\",\n stack: \"gantt\",\n // every bar has the color of its task: a neutral legend swatch\n color: \"var(--text-secondary-color, #6b7280)\",\n radius: 4,\n data: progress.map((t) => {\n const start = time(t.start);\n const end = time(t.end ?? t.start);\n const share = Math.min(1, Math.max(0, t.progress ?? 0));\n return {\n x: t.name,\n y0: start,\n y: start + (end - start) * share,\n label: formatProgress(share),\n color: t.color ?? colorOf(t.group ?? taskName),\n };\n }),\n });\n }\n const milestones = tasks.filter((t) => t.milestone);\n if (milestones.length) {\n series.push({\n id: \"gantt:milestones\",\n name: options.milestoneName ?? names.milestones,\n type: \"scatter\",\n color: \"var(--text-color, #1f2937)\",\n pointSize: 13,\n opacity: 1,\n data: milestones.map((t) => ({\n x: t.name,\n y: time(t.start),\n ...(t.color ? { color: t.color } : {}),\n })),\n });\n }\n let lo = Infinity;\n let hi = -Infinity;\n for (const t of tasks) {\n for (const v of [time(t.start), time(t.end ?? t.start)]) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n }\n // room for the milestone dots at the ends\n const pad = Number.isFinite(hi - lo) ? Math.max((hi - lo) * 0.025, 1) : 0;\n return {\n series,\n categories: tasks.map((t) => t.name),\n domain: Number.isFinite(lo) ? [lo - pad, hi + pad] : [0, 1],\n };\n};\n\n// -------------------------------------------------------------- range areas\n\n/** Series of a RangeAreaChart: bands between `y0` and `y` (thin edges) */\nexport const rangeAreaSeries = (\n series: readonly ChartSeries[],\n curve?: ChartCurve,\n) =>\n withSeriesType(series, \"area\", undefined, curve).map((s) =>\n s.type === \"area\" ? { ...s, lineWidth: s.lineWidth ?? 1.5 } : s,\n );\n"],"mappings":"yDAiCA,IAAMM,EAA+C,CACnD,GAAI,CACF,MAAO,QACP,OAAQ,SACR,MAAO,QACP,OAAQ,SACR,MAAO,QACP,SAAU,WACV,WAAY,YACd,EACA,GAAI,CACF,MAAO,KACP,OAAQ,KACR,MAAO,KACP,OAAQ,KACR,MAAO,KACP,SAAU,KACV,WAAY,KACd,EACA,GAAI,CACF,MAAO,IACP,OAAQ,IACR,MAAO,KACP,OAAQ,KACR,MAAO,MACP,SAAU,KACV,WAAY,SACd,EACA,GAAI,CACF,MAAO,SACP,OAAQ,UACR,MAAO,WACP,OAAQ,YACR,MAAO,SACP,SAAU,aACV,WAAY,QACd,CACF,EAGaC,EAAgB,GAC3BP,EAAAA,aAAaM,EAAeE,CAAM,EAGvBC,GACX,EACA,EACA,EACA,IAEAC,EAAO,IAAK,GAAM,CAChB,IAAMC,EAAIC,EAAE,MAAQC,EACpB,MAAO,CACL,GAAGD,EACH,KAAMD,EACN,GAAIG,IAAU,IAAA,IAAaH,IAAME,EAAO,CAAE,MAAOD,EAAE,OAASE,CAAM,EAAI,CAAC,EACvE,GAAIC,IAAU,IAAA,KAAcJ,IAAM,QAAUA,IAAM,QAC9C,CAAE,MAAOC,EAAE,OAASG,CAAM,EAC1B,CAAC,CACP,CACF,CAAC,EAWUC,GACX,EACA,EAAO,GACP,EAA2B,CAAC,IAE5BP,EACEC,EACAO,EAAO,OAAS,OAChBC,EAAM,QAAU,QAAU,IAAA,GAC1BA,EAAM,KACR,EAGWC,GAC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Q,GAAM3I,EAAE,SAAS,EAC9CgJ,EAAW,QACbjJ,EAAO,KAAK,CACV,GAAI,mBACJ,KAAM4E,EAAQ,eAAiB8D,EAAM,WACrC,KAAM,UACN,MAAO,6BACP,UAAW,GACX,QAAS,EACT,KAAMO,EAAW,IAAK,IAAO,CAC3B,EAAGhJ,EAAE,KACL,EAAGuI,EAAKvI,EAAE,KAAK,EACf,GAAIA,EAAE,MAAQ,CAAE,MAAOA,EAAE,KAAM,EAAI,CAAC,CACtC,EAAE,CACJ,CAAC,EAEH,IAAImE,EAAK,IACLC,EAAK,KACT,IAAK,IAAMpE,KAAK2I,EACd,IAAK,IAAM5E,IAAK,CAACwE,EAAKvI,EAAE,KAAK,EAAGuI,EAAKvI,EAAE,KAAOA,EAAE,KAAK,CAAC,EAChD+D,EAAII,IAAI,EAAKJ,GACbA,EAAIK,IAAI,EAAKL,GAIrB,IAAMkF,EAAM,OAAO,SAAS7E,EAAKD,CAAE,EAAI,KAAK,KAAKC,EAAKD,GAAM,KAAO,CAAC,EAAI,EACxE,MAAO,CACL,SACA,WAAYwE,EAAM,IAAK,GAAM3I,EAAE,IAAI,EACnC,OAAQ,OAAO,SAASmE,CAAE,EAAI,CAACA,EAAK8E,EAAK7E,EAAK6E,CAAG,EAAI,CAAC,EAAG,CAAC,CAC5D,CACF,EAKaC,GACX,EACA,IAEApJ,EAAeC,EAAQ,OAAQ,IAAA,GAAWK,CAAK,CAAC,CAAC,IAAK,GACpDH,EAAE,OAAS,OAAS,CAAE,GAAGA,EAAG,UAAWA,EAAE,WAAa,GAAI,EAAIA,CAChE"}
1
+ {"version":3,"file":"presets.cjs","names":["localeLabels","tickStep","resolveLocale","numberFormat","chartLabels","require_locale","require_labels","require_scale","PRESET_LABELS","presetLabels","locale","withSeriesType","series","t","s","type","stack","curve","lineSeries","area","extra","areaSeries","barSeries","stacked","labels","scatterSeries","candlestickSeries","heatmapChartOptions","numericX","config","c","numericY","base","sparklineOptions","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","y0","y1","quadrantOf","right","x","xs","y","ys","quadrantCenter","visualRight","corner","quadrantChartOptions","reverseX","color","p","left","rect","xa","xb","ya","yb","position","ends","visualLeft","texts","annotations","showTicks","interaction","item","event","region","sortedFinite","n","i","values","out","k","v","quantileOf","sorted","at","lo","hi","quantiles","ps","SPREAD_SAMPLE","binValues","min","max","options","span","rule","sturges","count","stride","sample","width","start","end","counts","total","edges","histogramSeries","bins","format","formatEdge","value","a","b","boxplotStats","q1","median","q3","sum","whisker","low","high","outliers","reach","from","to","j","upper","boxplotData","groups","g","boxplotSeries","waterfallSeries","up","down","running","data","steps","step","bubbleSeries","minSize","maxSize","valuesOf","list","top","sizeOf","size","points","d","THEMED","FALLBACK","paletteColor","fallback","themed","time","ganttSeries","names","rows","taskName","progressName","separator","tasks","colorOf","formatProgress","share","details","progress","milestones","pad","known","dependencies","rangeAreaSeries"],"sources":["../../../../charts/src/engine/presets.ts"],"sourcesContent":["// Option presets of the chart components, shared by every platform (React,\n// mini-programs, React Native): they turn component props into engine\n// options.\n\nimport {\n localeLabels,\n numberFormat,\n resolveLocale,\n type LabelDictionary,\n} from \"./locale\";\nimport { chartLabels } from \"./labels\";\nimport { tickStep } from \"./scale\";\nimport type {\n ChartAnnotation,\n ChartColorScheme,\n ChartConnectorOptions,\n ChartCurve,\n ChartDependency,\n ChartInteractionOptions,\n ChartOptions,\n ChartPointDatum,\n ChartSeries,\n ChartSeriesType,\n ChartTooltipDetail,\n ChartXValue,\n} from \"./types\";\n\n/** Default series names of the presets */\ninterface PresetLabels {\n value: string;\n values: string;\n count: string;\n change: string;\n tasks: string;\n progress: string;\n milestones: string;\n}\n\nconst PRESET_LABELS: LabelDictionary<PresetLabels> = {\n en: {\n value: \"Value\",\n values: \"Values\",\n count: \"Count\",\n change: \"Change\",\n tasks: \"Tasks\",\n progress: \"Progress\",\n milestones: \"Milestones\",\n },\n zh: {\n value: \"数值\",\n values: \"数值\",\n count: \"数量\",\n change: \"变化\",\n tasks: \"任务\",\n progress: \"进度\",\n milestones: \"里程碑\",\n },\n ja: {\n value: \"値\",\n values: \"値\",\n count: \"件数\",\n change: \"増減\",\n tasks: \"タスク\",\n progress: \"進捗\",\n milestones: \"マイルストーン\",\n },\n fr: {\n value: \"Valeur\",\n values: \"Valeurs\",\n count: \"Effectif\",\n change: \"Variation\",\n tasks: \"Tâches\",\n progress: \"Avancement\",\n milestones: \"Jalons\",\n },\n};\n\n/** Default series names of the presets in a locale (the page language by default) */\nexport const presetLabels = (locale?: string): PresetLabels =>\n localeLabels(PRESET_LABELS, locale);\n\n/** Gives the series without a `type` the type of the component */\nexport const withSeriesType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n curve?: ChartCurve,\n): ChartSeries[] =>\n series.map((s) => {\n const t = s.type ?? type;\n return {\n ...s,\n type: t,\n ...(stack !== undefined && t === type ? { stack: s.stack ?? stack } : {}),\n ...(curve !== undefined && (t === \"line\" || t === \"area\")\n ? { curve: s.curve ?? curve }\n : {}),\n };\n });\n\n/** Options of the line-like components */\nexport interface LineSeriesOptions {\n /** Stacks the series on top of each other */\n stacked?: boolean;\n /** Shape of the lines */\n curve?: ChartCurve;\n}\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (\n series: readonly ChartSeries[],\n area = false,\n extra: LineSeriesOptions = {},\n) =>\n withSeriesType(\n series,\n area ? \"area\" : \"line\",\n extra.stacked ? \"stack\" : undefined,\n extra.curve,\n );\n\n/** Series of an AreaChart */\nexport const areaSeries = (\n series: readonly ChartSeries[],\n extra: LineSeriesOptions = {},\n) => lineSeries(series, true, extra);\n\n/** Series of a BarChart (`stacked` stacks them, `labels` shows the values) */\nexport const barSeries = (\n series: readonly ChartSeries[],\n stacked = false,\n labels = false,\n) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined).map((s) =>\n labels && s.type === \"bar\" ? { ...s, showLabels: s.showLabels ?? true } : s,\n );\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\n\n/** Series of a CandlestickChart */\nexport const candlestickSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"candlestick\");\n\n/** A cell of a HeatmapChart */\nexport interface HeatmapCell {\n /** Column: a category name (or a number on a numeric axis) */\n x: string | number;\n /** Row: a category name (or a number on a numeric axis) */\n y: string | number;\n /** Value mapped to the color scale; `null` leaves the cell empty */\n value: number | null;\n}\n\n/** Settings of a heatmap (the props of HeatmapChart) */\nexport interface HeatmapConfig {\n /** Cells */\n data: readonly HeatmapCell[];\n /** Column names in order (collected from the data when omitted) */\n xCategories?: readonly string[];\n /** Row names from bottom to top (collected from the data when omitted) */\n yCategories?: readonly string[];\n /**\n * Colors from the lowest to the highest value (interpolated in OKLab), or\n * a built-in theme-aware ramp of the first palette color\n * @default \"sequential\"\n */\n colorScale?: readonly string[] | ChartColorScheme;\n /** Values at the ends of the color scale; the data range by default */\n valueRange?: readonly [number, number];\n /**\n * Value at the middle of the color scale (diverging data)\n * @default 0 for `diverging` ramps spanning it, else the middle of the range\n */\n colorMidpoint?: number;\n /** Name of the value in the tooltip */\n name?: string;\n /** Corner radius of the cells, in pixels */\n radius?: number;\n /** Formats the values in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a heatmap */\nexport const heatmapChartOptions = (\n config: HeatmapConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const numericX = config.data.some((c) => typeof c.x === \"number\");\n const numericY = config.data.some((c) => typeof c.y === \"number\");\n return {\n ...base,\n series: [\n {\n id: \"heatmap\",\n name: config.name ?? presetLabels(base.locale).value,\n type: \"heatmap\",\n data: config.data.map((c) => ({ x: c.x, y: c.y, value: c.value })),\n colorScale: config.colorScale,\n valueRange: config.valueRange,\n colorMidpoint: config.colorMidpoint,\n radius: config.radius,\n format: config.format,\n },\n ],\n xAxis: {\n ...(numericX\n ? {}\n : { type: \"category\" as const, categories: config.xCategories }),\n grid: false,\n ...base.xAxis,\n },\n yAxis: {\n ...(numericY\n ? {}\n : { type: \"category\" as const, categories: config.yCategories }),\n grid: false,\n ...base.yAxis,\n },\n // the color legend (visual map)\n legend: base.legend ?? true,\n interaction: base.interaction ?? { zoom: false },\n tooltip: base.tooltip ?? { mode: \"nearest\" },\n };\n};\n\n/** Settings of a sparkline (the props of Sparkline) */\nexport interface SparklineConfig {\n /** Values (or `[x, y]` pairs, typed arrays, ...) */\n data: ChartSeries[\"data\"];\n /**\n * How the values are drawn\n * @default \"line\"\n */\n type?: \"line\" | \"area\" | \"bar\";\n /** Color (any CSS color); the first palette color by default */\n color?: string;\n /**\n * Shape of the line\n * @default \"smooth\"\n */\n curve?: ChartCurve;\n /** Name shown in the tooltip */\n name?: string;\n /** Draws a reference line at this value (e.g. a target or the average) */\n reference?: number;\n /** Formats the value in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a sparkline: no axes, no legend, a tooltip only */\nexport const sparklineOptions = (\n config: SparklineConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const type = config.type ?? \"line\";\n return {\n ...base,\n series: [\n {\n id: \"sparkline\",\n name: config.name ?? presetLabels(base.locale).value,\n type,\n data: config.data,\n color: config.color,\n curve: type === \"bar\" ? undefined : (config.curve ?? \"smooth\"),\n lineWidth: 1.5,\n opacity: type === \"area\" ? 0.22 : undefined,\n radius: type === \"bar\" ? 1.5 : undefined,\n format: config.format,\n },\n ],\n xAxis: { visible: false, grid: false, ...base.xAxis },\n yAxis: { visible: false, grid: false, nice: false, ...base.yAxis },\n legend: false,\n padding: base.padding ?? { top: 4, right: 4, bottom: 4, left: 4 },\n interaction: base.interaction ?? { zoom: false },\n annotations:\n config.reference !== undefined\n ? [\n ...(base.annotations ?? []),\n {\n type: \"line\",\n axis: \"y\",\n value: config.reference,\n dash: [2, 3],\n },\n ]\n : base.annotations,\n };\n};\n\n/** A point of a QuadrantChart */\nexport interface QuadrantPoint {\n /** Position on the horizontal axis */\n x: number;\n /** Position on the vertical axis */\n y: number;\n /** Text drawn next to the dot and shown in the tooltip */\n label?: string;\n /** Dot color (any CSS color); the color of its quadrant by default */\n color?: string;\n /** Dot diameter in pixels */\n size?: number;\n}\n\n/** Title and color of a quadrant */\nexport interface QuadrantRegion {\n /** Title drawn in the outer corner of the quadrant */\n label?: string;\n /** Background tint and default dot color (any CSS color) */\n color?: string;\n}\n\n/** The four quadrants of a QuadrantChart */\nexport interface QuadrantRegions {\n topLeft?: QuadrantRegion;\n topRight?: QuadrantRegion;\n bottomLeft?: QuadrantRegion;\n bottomRight?: QuadrantRegion;\n}\n\n/** A quadrant, as seen on screen */\nexport type QuadrantCorner = keyof QuadrantRegions;\n\n/** Texts at the four ends of the dividers, inside the plot */\nexport interface QuadrantAxisLabels {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n}\n\n/** Settings of a quadrant matrix (the props of QuadrantChart) */\nexport interface QuadrantConfig {\n /** Points to place */\n points: readonly QuadrantPoint[];\n /**\n * Range of the horizontal axis\n * @default [0, 10]\n */\n xDomain?: [number, number];\n /**\n * Range of the vertical axis\n * @default [0, 10]\n */\n yDomain?: [number, number];\n /** X value of the vertical divider (the middle of `xDomain` by default) */\n xSplit?: number;\n /** Y value of the horizontal divider (the middle of `yDomain` by default) */\n ySplit?: number;\n /** Titles and colors of the quadrants */\n quadrants?: QuadrantRegions;\n /** Title of the horizontal axis */\n xLabel?: string;\n /** Title of the vertical axis */\n yLabel?: string;\n /** Texts at the ends of the dividers, drawn inside the plot (e.g. \"Important\" at the top) */\n axisLabels?: QuadrantAxisLabels;\n /**\n * Shows the numeric ticks of the axes; `false` keeps only the matrix\n * @default true\n */\n showTicks?: boolean;\n /** Reverses the horizontal axis (e.g. \"urgent\" on the left) */\n reverseX?: boolean;\n /**\n * Draws the labels next to the dots (overlapping labels are skipped)\n * @default true\n */\n showLabels?: boolean;\n /**\n * Dot diameter in pixels\n * @default 12\n */\n pointSize?: number;\n /** Name of the points in the tooltip */\n name?: string;\n /** Lets the user drag the dots (`drag` / `drop` events) */\n draggable?: boolean;\n}\n\nexport const DEFAULT_QUADRANT_COLORS: Required<Record<QuadrantCorner, string>> =\n {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n };\n\nconst DIVIDER = \"var(--border-strong-color, var(--border-color, #cbd5e1))\";\n\nconst splits = (config: QuadrantConfig) => {\n const [x0, x1] = config.xDomain ?? [0, 10];\n const [y0, y1] = config.yDomain ?? [0, 10];\n return {\n x0,\n x1,\n y0,\n y1,\n xs: config.xSplit ?? (x0 + x1) / 2,\n ys: config.ySplit ?? (y0 + y1) / 2,\n };\n};\n\n/** Quadrant of a data position, as seen on screen */\nexport const quadrantOf = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n x: number,\n y: number,\n): QuadrantCorner => {\n const { xs, ys } = splits(config as QuadrantConfig);\n const right = config.reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n};\n\n/** Center of a quadrant in data coordinates */\nexport const quadrantCenter = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n corner: QuadrantCorner,\n): { x: number; y: number } => {\n const { x0, x1, y0, y1, xs, ys } = splits(config as QuadrantConfig);\n const visualRight = corner.endsWith(\"Right\");\n const dataHigh = config.reverseX ? !visualRight : visualRight;\n return {\n x: dataHigh ? (xs + x1) / 2 : (x0 + xs) / 2,\n y: corner.startsWith(\"top\") ? (ys + y1) / 2 : (y0 + ys) / 2,\n };\n};\n\n/** Engine options of a quadrant matrix */\nexport const quadrantChartOptions = (\n config: QuadrantConfig,\n base: Omit<ChartOptions, \"series\"> = {},\n): ChartOptions => {\n const { x0, x1, y0, y1, xs, ys } = splits(config);\n const reverseX = !!config.reverseX;\n const color = (corner: QuadrantCorner) =>\n config.quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner];\n\n const series: ChartSeries[] = [\n {\n type: \"scatter\",\n name: config.name ?? \"\",\n pointSize: config.pointSize ?? 12,\n showLabels: config.showLabels ?? true,\n opacity: 0.9,\n data: config.points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: p.color ?? color(quadrantOf(config, p.x, p.y)),\n })),\n },\n ];\n\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: QuadrantCorner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => ({\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: color(corner),\n opacity: 0.07,\n label: config.quadrants?.[corner]?.label,\n labelPosition: position,\n });\n const ends = config.axisLabels ?? {};\n const visualLeft = reverseX ? x1 : x0;\n const visualRight = reverseX ? x0 : x1;\n const texts: ChartAnnotation[] = [\n ...(ends.top\n ? [{ type: \"text\", x: xs, y: y1, text: ends.top, anchor: \"top\" } as const]\n : []),\n ...(ends.bottom\n ? [\n {\n type: \"text\",\n x: xs,\n y: y0,\n text: ends.bottom,\n anchor: \"bottom\",\n } as const,\n ]\n : []),\n ...(ends.left\n ? [\n {\n type: \"text\",\n x: visualLeft,\n y: ys,\n text: ends.left,\n anchor: \"left\",\n } as const,\n ]\n : []),\n ...(ends.right\n ? [\n {\n type: \"text\",\n x: visualRight,\n y: ys,\n text: ends.right,\n anchor: \"right\",\n } as const,\n ]\n : []),\n ];\n\n const annotations: ChartAnnotation[] = [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n { type: \"line\", axis: \"x\", value: xs, dash: [], color: DIVIDER },\n { type: \"line\", axis: \"y\", value: ys, dash: [], color: DIVIDER },\n ...texts,\n ...(base.annotations ?? []),\n ];\n\n const showTicks = config.showTicks ?? true;\n const interaction: boolean | ChartInteractionOptions =\n base.interaction === false\n ? false\n : {\n zoom: false,\n ...(typeof base.interaction === \"object\" ? base.interaction : {}),\n ...(config.draggable ? { dragPoints: true } : {}),\n };\n\n return {\n ...base,\n series,\n annotations,\n tooltip:\n base.tooltip ??\n (showTicks\n ? undefined\n : {\n render: (event) => {\n const item = event.items[0];\n if (!item) return null;\n const region =\n config.quadrants?.[quadrantOf(config, item.x, item.y)]?.label;\n return [item.label ?? config.name ?? \"\", region ?? \"\"]\n .filter(Boolean)\n .join(\"\\n\");\n },\n }),\n xAxis: {\n min: x0,\n max: x1,\n title: config.xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.xLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n yAxis: {\n min: y0,\n max: y1,\n title: config.yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.yLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n legend: base.legend ?? false,\n padding:\n base.padding ??\n (showTicks ? undefined : { top: 4, right: 4, bottom: 4, left: 4 }),\n interaction,\n };\n};\n\n// ------------------------------------------------------------- statistics\n\n/** Finite values of a list, as a sorted typed array */\nconst sortedFinite = (values: ArrayLike<number>): Float64Array => {\n let n = 0;\n for (let i = 0; i < values.length; i++) if (Number.isFinite(values[i])) n++;\n const out = new Float64Array(n);\n let k = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (Number.isFinite(v)) out[k++] = v;\n }\n return out.sort();\n};\n\n/** Quantile `p` (0-1) of sorted values, linearly interpolated (NumPy / Excel) */\nconst quantileOf = (sorted: ArrayLike<number>, p: number): number => {\n const n = sorted.length;\n if (!n) return NaN;\n const at = Math.min(1, Math.max(0, p)) * (n - 1);\n const lo = Math.floor(at);\n const hi = Math.min(n - 1, lo + 1);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (at - lo);\n};\n\n/**\n * Quantiles of values (`[0.5, 0.95, 0.99]` gives the median, p95 and p99),\n * linearly interpolated like NumPy and Excel; non-finite values are ignored\n */\nexport const quantiles = (\n values: ArrayLike<number>,\n ps: readonly number[],\n): number[] => {\n const sorted = sortedFinite(values);\n return ps.map((p) => quantileOf(sorted, p));\n};\n\n/** How the bins of a histogram are chosen: a count, or a rule */\nexport type HistogramBinning =\n number | \"auto\" | \"sturges\" | \"freedman-diaconis\";\n\n/** Options of `binValues` */\nexport interface BinOptions {\n /**\n * Number of bins, or the rule choosing it: `sturges` (log2 n + 1, for\n * small normal-ish samples), `freedman-diaconis` (bin width from the\n * interquartile range, robust to outliers); `auto` uses Freedman-Diaconis\n * and Sturges when the spread is zero\n * @default \"auto\"\n */\n bins?: HistogramBinning;\n /** Range covered by the bins (values outside are not counted); the data range by default */\n domain?: readonly [number, number];\n /**\n * Rounds the bin width to 1, 2 or 5 × 10^k and aligns the edges on it\n * @default true\n */\n nice?: boolean;\n}\n\n/** Bins of a histogram */\nexport interface HistogramBins {\n /** Edges of the bins: one more than the bins */\n edges: number[];\n /** Number of values in every bin */\n counts: number[];\n /** Width of a bin */\n width: number;\n /** Number of values counted (finite, inside the domain) */\n total: number;\n}\n\n/** At most this many values are sorted to estimate the spread (Freedman-Diaconis) */\nconst SPREAD_SAMPLE = 100_000;\n\n/**\n * Counts values into bins of equal width: linear in the number of values\n * (a million samples take a few milliseconds; the spread of large samples\n * is estimated on an even subsample)\n */\nexport const binValues = (\n values: ArrayLike<number>,\n options: BinOptions = {},\n): HistogramBins => {\n let n = 0;\n let min = Infinity;\n let max = -Infinity;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!Number.isFinite(v)) continue;\n n++;\n if (v < min) min = v;\n if (v > max) max = v;\n }\n let [lo, hi] = options.domain ?? [min, max];\n if (!n || !Number.isFinite(lo) || !Number.isFinite(hi)) {\n return { edges: [0, 1], counts: [0], width: 1, total: 0 };\n }\n if (lo > hi) [lo, hi] = [hi, lo];\n if (hi === lo) {\n lo -= 0.5;\n hi += 0.5;\n }\n const span = hi - lo;\n const rule = options.bins ?? \"auto\";\n const sturges = Math.ceil(Math.log2(n)) + 1;\n let count: number;\n if (typeof rule === \"number\") {\n count = Math.round(rule);\n } else if (rule === \"sturges\") {\n count = sturges;\n } else {\n // Freedman-Diaconis: width = 2 IQR / n^(1/3)\n const stride = Math.max(1, Math.floor(values.length / SPREAD_SAMPLE));\n const sample: number[] = [];\n for (let i = 0; i < values.length; i += stride) {\n const v = values[i];\n if (Number.isFinite(v)) sample.push(v);\n }\n const sorted = Float64Array.from(sample).sort();\n const iqr = quantileOf(sorted, 0.75) - quantileOf(sorted, 0.25);\n const width = (2 * iqr) / Math.cbrt(n);\n count = width > 0 ? Math.ceil(span / width) : sturges;\n }\n count = Math.max(1, Math.min(1000, count || 1));\n let width = span / count;\n let start = lo;\n if (options.nice ?? true) {\n width = tickStep(lo, hi, count) || width;\n start = Math.floor(lo / width + 1e-9) * width;\n count = Math.max(1, Math.ceil((hi - start) / width - 1e-9));\n }\n const end = start + count * width;\n const counts = new Array<number>(count).fill(0);\n let total = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!(v >= start && v <= end)) continue;\n // the last bin includes its right edge\n const k = Math.min(count - 1, Math.floor((v - start) / width));\n counts[k]++;\n total++;\n }\n const edges: number[] = [];\n for (let k = 0; k <= count; k++)\n edges.push(Number((start + k * width).toPrecision(12)));\n return { edges, counts, width, total };\n};\n\n/** Options of `histogramSeries` */\nexport interface HistogramSeriesOptions extends BinOptions {\n /** Name of the series (legend, tooltip) */\n name?: string;\n /** Bar color (any CSS color) */\n color?: string;\n /** Formats the edges of the bins in the tooltip */\n format?: (value: number) => string;\n /** Bins already computed (`binValues`): `values` are then ignored */\n binned?: HistogramBins;\n /**\n * Locale of the default name and of the bin edges\n * @default the page language\n */\n locale?: string;\n}\n\n/** Bar series of a histogram: one touching bar per bin, labelled with its range */\nexport const histogramSeries = (\n values: ArrayLike<number>,\n options: HistogramSeriesOptions = {},\n): ChartSeries => {\n const bins = options.binned ?? binValues(values, options);\n const locale = resolveLocale(options.locale);\n const format =\n options.format ?? ((value: number) => formatEdge(value, locale));\n return {\n id: \"histogram\",\n name: options.name ?? presetLabels(locale).count,\n type: \"bar\",\n color: options.color,\n barWidth: 1,\n radius: 1,\n data: bins.counts.map((count, k) => {\n const a = bins.edges[k] ?? 0;\n const b = bins.edges[k + 1] ?? a;\n return {\n x: (a + b) / 2,\n y: count,\n label: `${format(a)} – ${format(b)}`,\n };\n }),\n };\n};\n\nconst formatEdge = (value: number, locale: string) =>\n numberFormat(locale, { maximumSignificantDigits: 6 }).format(value);\n\n/** Options of `boxplotStats` */\nexport interface BoxplotStatsOptions {\n /**\n * Reach of the whiskers in interquartile ranges beyond the box (Tukey:\n * 1.5); `\"minmax\"` extends them to the extremes (no outliers)\n * @default 1.5\n */\n whisker?: number | \"minmax\";\n}\n\n/** Five-number summary of a sample, with the outliers */\nexport interface BoxplotStats {\n /** Lower whisker: the smallest value within reach */\n low: number;\n /** First quartile */\n q1: number;\n median: number;\n /** Third quartile */\n q3: number;\n /** Upper whisker: the largest value within reach */\n high: number;\n /** Values beyond the whiskers */\n outliers: number[];\n min: number;\n max: number;\n mean: number;\n /** Number of finite values */\n count: number;\n}\n\n/** Quartiles, whiskers (Tukey's 1.5 IQR by default) and outliers of raw values */\nexport const boxplotStats = (\n values: ArrayLike<number>,\n options: BoxplotStatsOptions = {},\n): BoxplotStats => {\n const sorted = sortedFinite(values);\n const n = sorted.length;\n if (!n) {\n return {\n low: NaN,\n q1: NaN,\n median: NaN,\n q3: NaN,\n high: NaN,\n outliers: [],\n min: NaN,\n max: NaN,\n mean: NaN,\n count: 0,\n };\n }\n const q1 = quantileOf(sorted, 0.25);\n const median = quantileOf(sorted, 0.5);\n const q3 = quantileOf(sorted, 0.75);\n const min = sorted[0];\n const max = sorted[n - 1];\n let sum = 0;\n for (let i = 0; i < n; i++) sum += sorted[i];\n const whisker = options.whisker ?? 1.5;\n let low = min;\n let high = max;\n const outliers: number[] = [];\n if (whisker !== \"minmax\") {\n const reach = (q3 - q1) * whisker;\n const from = q1 - reach;\n const to = q3 + reach;\n let i = 0;\n while (i < n && sorted[i] < from) outliers.push(sorted[i++]);\n low = i < n ? sorted[i] : q1;\n let j = n - 1;\n const upper: number[] = [];\n while (j >= 0 && sorted[j] > to) upper.push(sorted[j--]);\n high = j >= 0 ? sorted[j] : q3;\n outliers.push(...upper.reverse());\n }\n return {\n low: Math.min(low, q1),\n q1,\n median,\n q3,\n high: Math.max(high, q3),\n outliers,\n min,\n max,\n mean: sum / n,\n count: n,\n };\n};\n\n/** A sample of a box plot */\nexport interface BoxplotGroup {\n /** Category (or position) of the box */\n x: ChartXValue;\n /** Raw values: their quartiles, whiskers and outliers are computed */\n values: ArrayLike<number>;\n /** Color of the box (any CSS color) */\n color?: string;\n}\n\n/** Box plot data of raw samples (one datum per group) */\nexport const boxplotData = (\n groups: readonly BoxplotGroup[],\n options: BoxplotStatsOptions = {},\n): ChartPointDatum[] =>\n groups.map((g) => {\n const s = boxplotStats(g.values, options);\n return {\n x: g.x,\n y: Number.isFinite(s.median) ? s.median : null,\n low: s.low,\n q1: s.q1,\n q3: s.q3,\n high: s.high,\n outliers: s.outliers,\n ...(g.color ? { color: g.color } : {}),\n };\n });\n\n/** Series of a BoxPlotChart */\nexport const boxplotSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"boxplot\");\n\n// ---------------------------------------------------------------- waterfall\n\n/** A bar of a waterfall chart */\nexport interface WaterfallStep {\n /** Category name of the bar */\n label: string;\n /** Change (positive or negative); ignored by totals */\n value?: number;\n /**\n * `subtotal` and `total` bars show the running total, from zero\n * @default \"change\"\n */\n kind?: \"change\" | \"subtotal\" | \"total\";\n /** Color of this bar (any CSS color) */\n color?: string;\n}\n\n/** Options of `waterfallSeries` */\nexport interface WaterfallOptions {\n /** Name of the series (tooltip) */\n name?: string;\n /** Color of the increases @default the success color */\n upColor?: string;\n /** Color of the decreases @default the danger color */\n downColor?: string;\n /** Color of the totals and subtotals @default the primary color */\n totalColor?: string;\n /**\n * Value the first change starts from\n * @default 0\n */\n start?: number;\n /**\n * Writes the change (or the total) at the end of every bar\n * @default false\n */\n labels?: boolean;\n /** Formats the values (labels, tooltip) */\n format?: (value: number) => string;\n /**\n * Thin lines from the end of every bar to the next one; an object styles\n * them\n * @default true (dashed, secondary text color)\n */\n connector?: boolean | ChartConnectorOptions;\n /**\n * Locale of the default name\n * @default the page language\n */\n locale?: string;\n}\n\n/**\n * Floating bar series of a waterfall (bridge) chart: every change starts\n * where the previous one ended; totals and subtotals start from zero\n */\nexport const waterfallSeries = (\n steps: readonly WaterfallStep[],\n options: WaterfallOptions = {},\n): ChartSeries => {\n const up = options.upColor ?? \"var(--success-color, #16a34a)\";\n const down = options.downColor ?? \"var(--danger-color, #dc2626)\";\n const total = options.totalColor ?? \"var(--primary-color, #4f46e5)\";\n let running = options.start ?? 0;\n const data: ChartPointDatum[] = steps.map((step) => {\n if (step.kind === \"total\" || step.kind === \"subtotal\") {\n return { x: step.label, y: running, color: step.color ?? total };\n }\n const value = step.value ?? 0;\n const from = running;\n running += value;\n return {\n x: step.label,\n y0: from,\n y: running,\n color: step.color ?? (value >= 0 ? up : down),\n };\n });\n return {\n id: \"waterfall\",\n name: options.name ?? presetLabels(options.locale).change,\n type: \"bar\",\n color: total,\n data,\n showLabels: options.labels ?? false,\n format: options.format,\n connector: options.connector ?? true,\n };\n};\n\n// ------------------------------------------------------------------ bubbles\n\n/** Options of `bubbleSeries` */\nexport interface BubbleOptions {\n /**\n * Diameter in pixels of the smallest bubbles\n * @default 6\n */\n minSize?: number;\n /**\n * Diameter in pixels of the largest value\n * @default 48\n */\n maxSize?: number;\n /** Value drawn with `maxSize` (share a scale between charts); the largest value by default */\n maxValue?: number;\n}\n\n/**\n * Scatter series whose dots are sized by the `value` of their points: the\n * area of a bubble is proportional to its value (diameter ∝ √value), the\n * scale is shared by every series. Points are drawn from the largest to\n * the smallest, so small bubbles stay on top (hover indexes refer to that\n * order).\n */\nexport const bubbleSeries = (\n series: readonly ChartSeries[],\n options: BubbleOptions = {},\n): ChartSeries[] => {\n const minSize = options.minSize ?? 6;\n const maxSize = options.maxSize ?? 48;\n const valuesOf = (data: ChartSeries[\"data\"]): ArrayLike<number> | null => {\n if (typeof data !== \"object\" || data === null) return null;\n if (!(\"length\" in data)) {\n const v = (data as { value?: ArrayLike<number> }).value;\n return v ?? null;\n }\n const list = data as ArrayLike<unknown>;\n const out = new Float64Array(list.length).fill(NaN);\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const v = (item as { value?: unknown }).value;\n if (typeof v === \"number\") out[i] = v;\n }\n }\n return out;\n };\n let top = options.maxValue ?? 0;\n if (options.maxValue === undefined) {\n for (const s of series) {\n const values = valuesOf(s.data);\n if (!values) continue;\n for (let i = 0; i < values.length; i++) {\n const v = Math.abs(values[i]);\n if (v > top) top = v;\n }\n }\n }\n const sizeOf = (v: number) =>\n Number.isFinite(v) && top > 0\n ? Math.max(minSize, maxSize * Math.sqrt(Math.min(1, Math.abs(v) / top)))\n : minSize;\n return series.map((s) => {\n const base: ChartSeries = {\n ...s,\n type: s.type ?? \"scatter\",\n opacity: s.opacity ?? 0.68,\n };\n if (base.type !== \"scatter\") return base;\n const data = s.data;\n if (typeof data === \"object\" && data !== null && !(\"length\" in data)) {\n const values = (data as { value?: ArrayLike<number> }).value;\n if (!values) return base;\n const size = new Float32Array(values.length);\n for (let i = 0; i < values.length; i++) size[i] = sizeOf(values[i]);\n return { ...base, data: { ...data, size } };\n }\n const list = data as ArrayLike<unknown>;\n const points: ChartPointDatum[] = [];\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (!item || typeof item !== \"object\" || Array.isArray(item)) continue;\n const d = item as ChartPointDatum;\n points.push({\n ...d,\n size: d.size ?? sizeOf(typeof d.value === \"number\" ? d.value : NaN),\n });\n }\n points.sort((a, b) => (b.size ?? 0) - (a.size ?? 0));\n return { ...base, data: points };\n });\n};\n\n// -------------------------------------------------------------------- gantt\n\n/** A task (or milestone) of a Gantt chart */\nexport interface GanttTask {\n /** Row name (unique) */\n name: string;\n /** Start (a timestamp or a date) */\n start: number | Date;\n /** End; omitted for milestones */\n end?: number | Date;\n /** Share done, 0-1: drawn as a solid bar over the task */\n progress?: number;\n /** Group (phase, team): a color and a legend entry per group */\n group?: string;\n /** Color of the task (any CSS color); the color of its group by default */\n color?: string;\n /** Draws a dot at `start` instead of a bar */\n milestone?: boolean;\n /** Names of the tasks this one waits for (tooltip, and arrows from their ends) */\n dependencies?: readonly string[];\n}\n\n/** Options of `ganttSeries` */\nexport interface GanttOptions {\n /** Colors of the groups in order of appearance (any CSS colors); the chart palette by default */\n colors?: readonly string[];\n /**\n * Name of the tasks without a group\n * @default \"Tasks\" (in the `locale`)\n */\n taskName?: string;\n /**\n * Name of the progress bars (legend, tooltip)\n * @default \"Progress\" (in the `locale`)\n */\n progressName?: string;\n /**\n * Name of the milestones (legend, tooltip)\n * @default \"Milestones\" (in the `locale`)\n */\n milestoneName?: string;\n /** Formats the progress shares (tooltip) @default \"60%\" */\n formatProgress?: (share: number) => string;\n /**\n * Name of the dependencies row of the tooltip\n * @default \"Depends on\" (in the `locale`)\n */\n dependenciesName?: string;\n /**\n * Draws the dependencies as elbow arrows from the end of every\n * predecessor to the start of the task\n * @default true\n */\n dependencyArrows?: boolean;\n /** Color of the dependency arrows (any CSS color); the secondary text color by default */\n dependencyColor?: string;\n /**\n * Locale of the default names and of the progress shares\n * @default the page language\n */\n locale?: string;\n}\n\n/** Series of a Gantt chart and the row names in order */\nexport interface GanttSeries {\n series: ChartSeries[];\n /** Task names from top to bottom (the `categories` of the x axis) */\n categories: string[];\n /** Time range of the tasks with a small margin (the `min` / `max` of the value axis) */\n domain: [number, number];\n /** Arrows of the dependencies between existing tasks (the `dependencies` of the chart) */\n dependencies: ChartDependency[];\n}\n\nconst THEMED = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n];\nconst FALLBACK = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\n/** Color `k` of the chart palette as a CSS color (theme variables first) */\nexport const paletteColor = (k: number): string => {\n const i = k % 8;\n const fallback = FALLBACK[i] ?? \"#4f46e5\";\n const themed = THEMED[i];\n return themed\n ? `var(--chart-series-${i + 1}, var(${themed}, ${fallback}))`\n : `var(--chart-series-${i + 1}, ${fallback})`;\n};\n\nconst time = (v: number | Date | undefined) =>\n v instanceof Date ? v.getTime() : v === undefined ? NaN : v;\n\n/**\n * Floating bar series of a Gantt chart (horizontal, on a time axis): a\n * translucent bar per task with its progress drawn over it, one series per\n * group, and the milestones as dots\n */\nexport const ganttSeries = (\n tasks: readonly GanttTask[],\n options: GanttOptions = {},\n): GanttSeries => {\n const locale = resolveLocale(options.locale);\n const names = presetLabels(locale);\n const rows = chartLabels(locale);\n const taskName = options.taskName ?? names.tasks;\n const progressName = options.progressName ?? names.progress;\n const separator = /^(zh|ja)\\b/i.test(locale) ? \"、\" : \", \";\n const groups: string[] = [];\n for (const t of tasks) {\n const g = t.group ?? taskName;\n if (!t.milestone && !groups.includes(g)) groups.push(g);\n }\n const colorOf = (g: string) => {\n const k = Math.max(0, groups.indexOf(g));\n return options.colors?.[k] ?? paletteColor(k);\n };\n const formatProgress =\n options.formatProgress ??\n ((share: number) =>\n numberFormat(locale, {\n style: \"percent\",\n maximumFractionDigits: 0,\n }).format(share));\n const series: ChartSeries[] = groups.map((g) => ({\n id: `gantt:${g}`,\n name: g,\n type: \"bar\",\n stack: \"gantt\",\n color: colorOf(g),\n opacity: 0.3,\n barWidth: 0.62,\n radius: 4,\n data: tasks\n .filter((t) => !t.milestone && (t.group ?? taskName) === g)\n .map((t) => {\n // the tooltip of a task: its progress and what it waits for\n const details: ChartTooltipDetail[] = [];\n if (t.progress !== undefined)\n details.push({\n name: progressName,\n value: formatProgress(Math.min(1, Math.max(0, t.progress))),\n });\n if (t.dependencies?.length)\n details.push({\n name: options.dependenciesName ?? rows.dependencies,\n value: t.dependencies.join(separator),\n });\n return {\n x: t.name,\n y0: time(t.start),\n y: time(t.end ?? t.start),\n ...(t.color ? { color: t.color } : {}),\n ...(details.length ? { details } : {}),\n };\n }),\n }));\n const progress = tasks.filter(\n (t) => !t.milestone && t.progress !== undefined && t.progress > 0,\n );\n if (progress.length) {\n series.push({\n id: \"gantt:progress\",\n name: progressName,\n type: \"bar\",\n stack: \"gantt\",\n // shown in the tooltip of its task\n tooltip: false,\n // every bar has the color of its task: a neutral legend swatch\n color: \"var(--text-secondary-color, #6b7280)\",\n radius: 4,\n data: progress.map((t) => {\n const start = time(t.start);\n const end = time(t.end ?? t.start);\n const share = Math.min(1, Math.max(0, t.progress ?? 0));\n return {\n x: t.name,\n y0: start,\n y: start + (end - start) * share,\n label: formatProgress(share),\n color: t.color ?? colorOf(t.group ?? taskName),\n };\n }),\n });\n }\n const milestones = tasks.filter((t) => t.milestone);\n if (milestones.length) {\n series.push({\n id: \"gantt:milestones\",\n name: options.milestoneName ?? names.milestones,\n type: \"scatter\",\n color: \"var(--text-color, #1f2937)\",\n pointSize: 13,\n opacity: 1,\n data: milestones.map((t) => ({\n x: t.name,\n y: time(t.start),\n ...(t.color ? { color: t.color } : {}),\n })),\n });\n }\n let lo = Infinity;\n let hi = -Infinity;\n for (const t of tasks) {\n for (const v of [time(t.start), time(t.end ?? t.start)]) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n }\n // room for the milestone dots at the ends\n const pad = Number.isFinite(hi - lo) ? Math.max((hi - lo) * 0.025, 1) : 0;\n const known = new Set(tasks.map((t) => t.name));\n const dependencies: ChartDependency[] = [];\n if (options.dependencyArrows !== false) {\n for (const t of tasks) {\n for (const from of t.dependencies ?? []) {\n if (from === t.name || !known.has(from)) continue;\n dependencies.push({\n from,\n to: t.name,\n ...(options.dependencyColor\n ? { color: options.dependencyColor }\n : {}),\n });\n }\n }\n }\n return {\n series,\n categories: tasks.map((t) => t.name),\n domain: Number.isFinite(lo) ? [lo - pad, hi + pad] : [0, 1],\n dependencies,\n };\n};\n\n// -------------------------------------------------------------- range areas\n\n/** Series of a RangeAreaChart: bands between `y0` and `y` (thin edges) */\nexport const rangeAreaSeries = (\n series: readonly ChartSeries[],\n curve?: ChartCurve,\n) =>\n withSeriesType(series, \"area\", undefined, curve).map((s) =>\n s.type === \"area\" ? { ...s, lineWidth: s.lineWidth ?? 1.5 } : s,\n );\n"],"mappings":"mFAsCA,IAAMQ,EAA+C,CACnD,GAAI,CACF,MAAO,QACP,OAAQ,SACR,MAAO,QACP,OAAQ,SACR,MAAO,QACP,SAAU,WACV,WAAY,YACd,EACA,GAAI,CACF,MAAO,KACP,OAAQ,KACR,MAAO,KACP,OAAQ,KACR,MAAO,KACP,SAAU,KACV,WAAY,KACd,EACA,GAAI,CACF,MAAO,IACP,OAAQ,IACR,MAAO,KACP,OAAQ,KACR,MAAO,MACP,SAAU,KACV,WAAY,SACd,EACA,GAAI,CACF,MAAO,SACP,OAAQ,UACR,MAAO,WACP,OAAQ,YACR,MAAO,SACP,SAAU,aACV,WAAY,QACd,CACF,EAGaC,EAAgB,GAC3BT,EAAAA,aAAaQ,EAAeE,CAAM,EAGvBC,GACX,EACA,EACA,EACA,IAEAC,EAAO,IAAK,GAAM,CAChB,IAAMC,EAAIC,EAAE,MAAQC,EACpB,MAAO,CACL,GAAGD,EACH,KAAMD,EACN,GAAIG,IAAU,IAAA,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