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
@@ -1 +1 @@
1
- {"version":3,"file":"draw.cjs","names":["TAU","font","toCss","require_color","require_overlay","require_scene","SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","theme","box","boxes","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.fillText(content.title, x, y);\n y += lineHeight;\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":"qFAmBA,IAAMM,EAAS,yBACTC,EAAW,4BAGJC,EAAa,GACxB,KAAK,IAAI,EAAG,KAAK,IAAIC,EAAK,IAAMA,EAAK,IAAMA,EAAK,GAAKA,EAAK,IAAO,CAAC,CAAC,EAGxDC,GAAc,EAAc,IACvCC,EAAI,EAAI,KAAK,KAAK,KAAK,IAAI,EAAGC,EAAOD,CAAC,CAAC,EAAI,KAAK,GAAK,EAG1CE,GACX,EACA,EACA,EAAK,EACL,EAAK,IACF,CACH,IAAMC,EAAKL,EAAK,GAAKM,EACfC,EAAKP,EAAK,GAAKQ,EACf,CAAE,KAAI,KAAI,KAAI,MAAOR,EACrBS,EAAOC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C,EAAI,KAAK,EACT,GAAK,IAEP,EAAI,KAAOpB,EAAAA,KAAKoF,EAAO,GAAIU,EAAI,OAAS,IAAM,GAAG,EACjD,EAAI,UAAY,OAChB,EAAI,UAAY7F,EAAAA,MAAM6F,EAAI,OAASV,EAAM,KAAOA,EAAM,SAAS,EAC/DhE,EAAI,SAAS0E,EAAI,KAAMnC,EAAGC,CAAC,EAC3B,EAAI,KAAO5D,EAAAA,KAAKoF,EAAO,GAAI,GAAG,EAC9B,EAAI,UAAY,QAChB,EAAI,UAAYnF,EAAAA,MAAMmF,EAAM,IAAI,EAChChE,EAAI,SAAS0E,EAAI,MAAOH,EAAO/B,CAAC,EAChC,GAAK6B,CAET,CACArE,EAAI,QAAQ,CACd"}
1
+ {"version":3,"file":"draw.cjs","names":["TAU","font","toCss","require_color","require_overlay","require_scene","SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","theme","box","boxes","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":"qFAoBA,IAAMM,EAAS,yBACTC,EAAW,4BAGJC,EAAa,GACxB,KAAK,IAAI,EAAG,KAAK,IAAIC,EAAK,IAAMA,EAAK,IAAMA,EAAK,GAAKA,EAAK,IAAO,CAAC,CAAC,EAGxDC,GAAc,EAAc,IACvCC,EAAI,EAAI,KAAK,KAAK,KAAK,IAAI,EAAGC,EAAOD,CAAC,CAAC,EAAI,KAAK,GAAK,EAG1CE,GACX,EACA,EACA,EAAK,EACL,EAAK,IACF,CACH,IAAMC,EAAKL,EAAK,GAAKM,EACfC,EAAKP,EAAK,GAAKQ,EACf,CAAE,KAAI,KAAI,KAAI,MAAOR,EACrBS,EAAOC,EAAKC,EAElB,GADAC,EAAI,UAAU,EACVH,GAAQ,GAAKI,GAAMC,EAAI,OAC3B,GAAIL,GAAQlB,EAAAA,IAAM,KAAM,CACtBqB,EAAI,OAAOP,EAAKQ,EAAIN,CAAE,EACtBK,EAAI,IAAIP,EAAIE,EAAIM,EAAI,EAAGtB,EAAAA,GAAG,EACtBuB,EAAK,IACPF,EAAI,OAAOP,EAAKS,EAAIP,CAAE,EACtBK,EAAI,IAAIP,EAAIE,EAAIO,EAAIvB,EAAAA,IAAK,EAAG,EAAI,GAElCqB,EAAI,UAAU,EACd,MACF,CACA,IAAMT,EAAOJ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O5D,EAAAA,KAAKoG,EAAO,GAAI,GAAG,EAC9B,EAAI,UAAY,QAChB,EAAI,UAAYnG,EAAAA,MAAMmG,EAAM,IAAI,EAChChF,EAAI,SAAS0F,EAAI,MAAOH,EAAO/C,CAAC,EAChC,GAAK6C,CAET,CACArF,EAAI,QAAQ,CACd"}
@@ -1,6 +1,6 @@
1
1
  import { ChartTheme } from '../theme.cjs';
2
2
  import { ShapeLegendBox, ShapeTooltipBox } from './layout.cjs';
3
- import { SectorNode, ShapeHover, ShapeNode, ShapeScene } from './scene.cjs';
3
+ import { RibbonNode, SectorNode, ShapeHover, ShapeNode, ShapeScene } from './scene.cjs';
4
4
  /** Gap of a sector, reduced so thin slices keep most of their arc */
5
5
  export declare const sectorPad: (node: SectorNode) => number;
6
6
  /** Angle offset of a point at distance `r` from a radial edge moved by `half` px */
@@ -11,6 +11,10 @@ export declare const sectorPath: (ctx: CanvasRenderingContext2D, node: SectorNod
11
11
  export declare const roundRectPath: (ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, radius: number) => void;
12
12
  /** Whether a node is emphasized by the hovered item (its own or an `also` one) */
13
13
  export declare const nodeActive: (node: ShapeNode, hover: ShapeHover | null) => boolean;
14
+ /** Whether a chord ribbon joins an arc to itself (a self flow) */
15
+ export declare const ribbonIsLoop: (node: RibbonNode) => boolean;
16
+ /** Control point of the inward bulge of a self-flow ribbon */
17
+ export declare const loopControl: (node: RibbonNode) => [number, number];
14
18
  /**
15
19
  * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and
16
20
  * clears the canvas). `hover` emphasizes an item and dims the others.
@@ -1,6 +1,6 @@
1
1
  import { ChartTheme } from '../theme.js';
2
2
  import { ShapeLegendBox, ShapeTooltipBox } from './layout.js';
3
- import { SectorNode, ShapeHover, ShapeNode, ShapeScene } from './scene.js';
3
+ import { RibbonNode, SectorNode, ShapeHover, ShapeNode, ShapeScene } from './scene.js';
4
4
  /** Gap of a sector, reduced so thin slices keep most of their arc */
5
5
  export declare const sectorPad: (node: SectorNode) => number;
6
6
  /** Angle offset of a point at distance `r` from a radial edge moved by `half` px */
@@ -11,6 +11,10 @@ export declare const sectorPath: (ctx: CanvasRenderingContext2D, node: SectorNod
11
11
  export declare const roundRectPath: (ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, radius: number) => void;
12
12
  /** Whether a node is emphasized by the hovered item (its own or an `also` one) */
13
13
  export declare const nodeActive: (node: ShapeNode, hover: ShapeHover | null) => boolean;
14
+ /** Whether a chord ribbon joins an arc to itself (a self flow) */
15
+ export declare const ribbonIsLoop: (node: RibbonNode) => boolean;
16
+ /** Control point of the inward bulge of a self-flow ribbon */
17
+ export declare const loopControl: (node: RibbonNode) => [number, number];
14
18
  /**
15
19
  * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and
16
20
  * clears the canvas). `hover` emphasizes an item and dims the others.
@@ -78,50 +78,76 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
78
78
  if (t.color0 === t.color1 || typeof e.createLinearGradient != "function" || Math.abs(t.x1 - t.x0) < 1) return t.color0;
79
79
  let n = e.createLinearGradient(t.x0, 0, t.x1, 0);
80
80
  return n.addColorStop(0, t.color0), n.addColorStop(1, t.color1), n;
81
- }, g = (e, t, n) => {
81
+ }, g = (e) => Math.abs(e.s0 - e.t0) < 1e-9 && Math.abs(e.s1 - e.t1) < 1e-9, _ = (e) => {
82
+ let t = (e.s0 + e.s1) / 2;
83
+ return [e.cx + e.r * .4 * Math.cos(t), e.cy + e.r * .4 * Math.sin(t)];
84
+ }, v = (e, t) => {
85
+ let { cx: n, cy: r, r: i } = t, a = (e, t = i) => [n + t * Math.cos(e), r + t * Math.sin(e)];
86
+ e.beginPath();
87
+ let o = a(t.s0);
88
+ if (e.moveTo(o[0], o[1]), t.s1 > t.s0 && e.arc(n, r, i, t.s0, t.s1), g(t)) {
89
+ let [n, r] = _(t);
90
+ e.quadraticCurveTo(n, r, o[0], o[1]), e.closePath();
91
+ return;
92
+ }
93
+ if (t.head > 0) {
94
+ let o = a(t.t0, i - t.head), s = a((t.t0 + t.t1) / 2), c = a(t.t1, i - t.head);
95
+ e.quadraticCurveTo(n, r, o[0], o[1]), e.lineTo(s[0], s[1]), e.lineTo(c[0], c[1]);
96
+ } else {
97
+ let o = a(t.t0);
98
+ e.quadraticCurveTo(n, r, o[0], o[1]), t.t1 > t.t0 && e.arc(n, r, i, t.t0, t.t1);
99
+ }
100
+ e.quadraticCurveTo(n, r, o[0], o[1]), e.closePath();
101
+ }, y = (e, t) => {
102
+ if (t.color0 === t.color1 || typeof e.createLinearGradient != "function") return t.color0;
103
+ let n = (t.s0 + t.s1) / 2, r = (t.t0 + t.t1) / 2, i = t.cx + t.r * Math.cos(n), a = t.cy + t.r * Math.sin(n), o = t.cx + t.r * Math.cos(r), s = t.cy + t.r * Math.sin(r);
104
+ if (Math.hypot(o - i, s - a) < 1) return t.color0;
105
+ let c = e.createLinearGradient(i, a, o, s);
106
+ return c.addColorStop(0, t.color0), c.addColorStop(1, t.color1), c;
107
+ }, b = (e, t, n) => {
82
108
  e.save();
83
109
  let a = t.enter, o = a ? Math.max(0, Math.min(1, a.alpha)) : 1;
84
110
  a && a.scale !== 1 && (e.translate(a.cx, a.cy), e.scale(a.scale, a.scale), e.translate(-a.cx, -a.cy)), e.lineJoin = "round", e.lineCap = "round";
85
111
  for (let a of t.nodes) {
86
- let c = a.hit !== void 0, g = p(a, n), _ = g && a.hit === n?.index, v = o * (a.alpha ?? 1);
87
- if (n && c && !g && (v *= t.dim), v <= .002) continue;
88
- e.globalAlpha = v;
89
- let y = _ && a.shift ? a.shift[0] : 0, b = _ && a.shift ? a.shift[1] : 0;
112
+ let c = a.hit !== void 0, g = p(a, n), _ = g && a.hit === n?.index, b = o * (a.alpha ?? 1);
113
+ if (n && c && !g && (b *= t.dim), b <= .002) continue;
114
+ e.globalAlpha = b;
115
+ let x = _ && a.shift ? a.shift[0] : 0, S = _ && a.shift ? a.shift[1] : 0;
90
116
  switch (a.kind) {
91
117
  case "sector":
92
- s(e, a, y, b), e.fillStyle = a.fill, _ ? (e.save(), e.shadowColor = r, e.shadowBlur = 14, e.shadowOffsetY = 4, e.fill(), e.restore()) : e.fill();
118
+ s(e, a, x, S), e.fillStyle = a.fill, _ ? (e.save(), e.shadowColor = r, e.shadowBlur = 14, e.shadowOffsetY = 4, e.fill(), e.restore()) : e.fill();
93
119
  break;
94
120
  case "polygon": {
95
- l(e, a, y, b);
121
+ l(e, a, x, S);
96
122
  let t = g && a.hoverFill ? a.hoverFill : a.fill;
97
123
  t && (e.fillStyle = t, e.fill(), g && a.brighten && (e.fillStyle = i, e.fill())), a.stroke && (e.strokeStyle = a.stroke, e.lineWidth = g && a.hoverLineWidth ? a.hoverLineWidth : a.lineWidth ?? 1, e.stroke());
98
124
  break;
99
125
  }
100
126
  case "rect":
101
- u(e, a.x + y, a.y + b, a.width, a.height, a.radius), e.fillStyle = a.fill, e.fill(), g && a.brighten && (e.fillStyle = i, e.fill()), _ && a.hoverStroke && a.width > 3 && a.height > 3 && (u(e, a.x + y + .75, a.y + b + .75, a.width - 1.5, a.height - 1.5, Math.max(0, a.radius - .75)), e.strokeStyle = a.hoverStroke, e.lineWidth = 1.5, e.stroke());
127
+ u(e, a.x + x, a.y + S, a.width, a.height, a.radius), e.fillStyle = a.fill, e.fill(), g && a.brighten && (e.fillStyle = i, e.fill()), _ && a.hoverStroke && a.width > 3 && a.height > 3 && (u(e, a.x + x + .75, a.y + S + .75, a.width - 1.5, a.height - 1.5, Math.max(0, a.radius - .75)), e.strokeStyle = a.hoverStroke, e.lineWidth = 1.5, e.stroke());
102
128
  break;
103
129
  case "arc":
104
130
  if (a.a1 - a.a0 <= 1e-6 || a.width <= 0) break;
105
- e.beginPath(), e.arc(a.cx + y, a.cy + b, a.r, a.a0, a.a1), e.lineCap = a.cap, e.lineWidth = a.width, e.strokeStyle = a.color, e.stroke(), e.lineCap = "round";
131
+ e.beginPath(), e.arc(a.cx + x, a.cy + S, a.r, a.a0, a.a1), e.lineCap = a.cap, e.lineWidth = a.width, e.strokeStyle = a.color, e.stroke(), e.lineCap = "round";
106
132
  break;
107
133
  case "circle": {
108
134
  if (!a.fill && !a.stroke) break;
109
- let t = g && (a.indicator === void 0 || a.indicator === n?.indicator), r = t && a.hoverR ? a.hoverR : a.r, i = a.cx + y, o = a.cy + b;
135
+ let t = g && (a.indicator === void 0 || a.indicator === n?.indicator), r = t && a.hoverR ? a.hoverR : a.r, i = a.cx + x, o = a.cy + S;
110
136
  t && a.halo && (f(e, i, o, r + 5), e.fillStyle = a.halo, e.fill()), f(e, i, o, r), a.fill && (e.fillStyle = a.fill, e.fill()), a.stroke && (e.strokeStyle = a.stroke, e.lineWidth = a.lineWidth ?? 1, e.stroke());
111
137
  break;
112
138
  }
113
139
  case "line": {
114
140
  let t = a.points;
115
141
  if (t.length < 4) break;
116
- e.beginPath(), e.moveTo(t[0] + y, t[1] + b);
117
- for (let n = 2; n < t.length; n += 2) e.lineTo(t[n] + (n === t.length - 2 ? 0 : y), t[n + 1] + (n === t.length - 2 ? 0 : b));
142
+ e.beginPath(), e.moveTo(t[0] + x, t[1] + S);
143
+ for (let n = 2; n < t.length; n += 2) e.lineTo(t[n] + (n === t.length - 2 ? 0 : x), t[n + 1] + (n === t.length - 2 ? 0 : S));
118
144
  e.strokeStyle = a.color, e.lineWidth = a.width, a.dash && d(e, a.dash), e.stroke(), a.dash && d(e, []);
119
145
  break;
120
146
  }
121
147
  case "text": {
122
148
  let t = a.indicator !== void 0 && n?.indicator === a.indicator;
123
149
  e.font = t && a.hoverFont ? a.hoverFont : a.font, e.textAlign = a.align, e.textBaseline = a.baseline;
124
- let r = !!a.rotate, i = a.x + y, o = a.y + b;
150
+ let r = !!a.rotate, i = a.x + x, o = a.y + S;
125
151
  r && (e.save(), e.translate(i, o), e.rotate(a.rotate ?? 0), i = 0, o = 0), a.halo && (e.strokeStyle = a.halo, e.lineWidth = 3, e.strokeText(a.text, i, o)), e.fillStyle = t && a.hoverColor ? a.hoverColor : a.color, e.fillText(a.text, i, o), r && e.restore();
126
152
  break;
127
153
  }
@@ -129,6 +155,9 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
129
155
  if (a.width <= 0) break;
130
156
  g && a.activeAlpha !== void 0 && (e.globalAlpha = o * a.activeAlpha), m(e, a), e.lineCap = "butt", e.lineWidth = Math.max(1, a.width), e.strokeStyle = h(e, a), e.stroke(), e.lineCap = "round";
131
157
  break;
158
+ case "ribbon":
159
+ g && a.activeAlpha !== void 0 && (e.globalAlpha = o * a.activeAlpha), v(e, a), e.fillStyle = y(e, a), e.fill(), _ && (e.strokeStyle = a.color0, e.lineWidth = 1, e.stroke());
160
+ break;
132
161
  case "guide": {
133
162
  let t = n?.indicator;
134
163
  if (t === void 0 || !a.ends[t]) break;
@@ -138,14 +167,14 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
138
167
  }
139
168
  }
140
169
  e.restore();
141
- }, _ = (n, r, i) => {
170
+ }, x = (n, r, i) => {
142
171
  n.save(), n.font = t(r, 12), n.textBaseline = "middle", n.textAlign = "left";
143
172
  for (let t of i) {
144
173
  let i = t.y + t.height / 2;
145
174
  n.globalAlpha = t.hidden ? .45 : 1, n.fillStyle = t.color, f(n, t.x + 4.5, i, 4.5), n.fill(), n.fillStyle = e(r.textMuted), n.fillText(t.name, t.x + 15, i, Math.max(1, t.width - 15)), t.hidden && n.fillRect(t.x + 15, i, t.width - 15, 1);
146
175
  }
147
176
  n.restore();
148
- }, v = (n, i, a) => {
177
+ }, S = (n, i, a) => {
149
178
  let { padding: o, lineHeight: s } = a;
150
179
  n.save(), n.globalAlpha = 1, n.save(), n.shadowColor = r, n.shadowBlur = 16, n.shadowOffsetY = 6, u(n, a.x, a.y, a.width, a.height, 8), n.fillStyle = e(i.background), n.fill(), n.restore(), u(n, a.x + .5, a.y + .5, a.width - 1, a.height - 1, 8), n.strokeStyle = e(i.axis), n.lineWidth = 1, n.stroke(), n.textBaseline = "middle";
151
180
  let c = a.y + o + s / 2, l = a.x + o + 2, d = a.x + a.width - o - 2;
@@ -154,12 +183,13 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
154
183
  for (let e of a.text) n.fillText(e, l, c), c += s;
155
184
  } else if (a.content) {
156
185
  let { content: r } = a, o = l;
157
- r.color && (n.fillStyle = r.color, f(n, o + 4, c, 4), n.fill(), o += 14), n.font = t(i, 12, 600), n.fillStyle = e(i.text), n.textAlign = "left", n.fillText(r.title, o, c), c += s;
186
+ r.color && (n.fillStyle = r.color, f(n, o + 4, c, 4), n.fill(), o += 14), n.font = t(i, 12, 600), n.fillStyle = e(i.text), n.textAlign = "left";
187
+ for (let e of a.titleLines ?? [r.title]) n.fillText(e, o, c), c += s;
158
188
  for (let a of r.rows) o = l, a.color && (n.fillStyle = a.color, f(n, o + 4, c, 4), n.fill(), o += 14), n.font = t(i, 12, a.strong ? 600 : 400), n.textAlign = "left", n.fillStyle = e(a.strong ? i.text : i.textMuted), n.fillText(a.name, o, c), n.font = t(i, 12, 600), n.textAlign = "right", n.fillStyle = e(i.text), n.fillText(a.value, d, c), c += s;
159
189
  }
160
190
  n.restore();
161
191
  };
162
192
  //#endregion
163
- export { _ as drawShapeLegend, g as drawShapeScene, v as drawShapeTooltip, p as nodeActive, o as padAngleAt, u as roundRectPath, a as sectorPad, s as sectorPath };
193
+ export { x as drawShapeLegend, b as drawShapeScene, S as drawShapeTooltip, _ as loopControl, p as nodeActive, o as padAngleAt, g as ribbonIsLoop, u as roundRectPath, a as sectorPad, s as sectorPath };
164
194
 
165
195
  //# sourceMappingURL=draw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"draw.js","names":["SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","TAU","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","font","theme","box","boxes","toCss","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.fillText(content.title, x, y);\n y += lineHeight;\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;;AAmBA,IAAMA,IAAS,0BACTC,IAAW,6BAGJC,KAAa,MACxB,KAAK,IAAI,GAAG,KAAK,IAAIC,EAAK,KAAMA,EAAK,MAAMA,EAAK,KAAKA,EAAK,MAAO,CAAC,CAAC,GAGxDC,KAAc,GAAc,MACvCC,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,GAAGC,IAAOD,CAAC,CAAC,IAAI,KAAK,KAAK,GAG1CE,KACX,GACA,GACA,IAAK,GACL,IAAK,MACF;CACH,IAAMC,IAAKL,EAAK,KAAKM,GACfC,IAAKP,EAAK,KAAKQ,GACf,EAAE,OAAI,OAAI,OAAI,UAAOR,GACrBS,IAAOC,IAAKC;CAElB,IADAC,EAAI,UAAU,GACVH,KAAQ,KAAKI,KAAMC,GAAI;CAC3B,IAAIL,KAAQM,IAAM,MAAM;EAOtB,AANAH,EAAI,OAAOP,IAAKQ,GAAIN,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAIM,GAAI,GAAGE,CAAG,GACtBD,IAAK,MACPF,EAAI,OAAOP,IAAKS,GAAIP,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAI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AC3B,EAAI,OAAOwB,EAAKC,GAAO,IAAI,GAAG,GAC9B,EAAI,YAAY,SAChB,EAAI,YAAYG,EAAMH,EAAM,IAAI,GAChClE,EAAI,SAAS6E,EAAI,OAAOH,GAAOjC,CAAC,GAChC,KAAK+B;CAET;CACA,EAAI,QAAQ;AACd"}
1
+ {"version":3,"file":"draw.js","names":["SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","TAU","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","font","theme","box","boxes","toCss","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;;AAoBA,IAAMA,IAAS,0BACTC,IAAW,6BAGJC,KAAa,MACxB,KAAK,IAAI,GAAG,KAAK,IAAIC,EAAK,KAAMA,EAAK,MAAMA,EAAK,KAAKA,EAAK,MAAO,CAAC,CAAC,GAGxDC,KAAc,GAAc,MACvCC,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,GAAGC,IAAOD,CAAC,CAAC,IAAI,KAAK,KAAK,GAG1CE,KACX,GACA,GACA,IAAK,GACL,IAAK,MACF;CACH,IAAMC,IAAKL,EAAK,KAAKM,GACfC,IAAKP,EAAK,KAAKQ,GACf,EAAE,OAAI,OAAI,OAAI,UAAOR,GACrBS,IAAOC,IAAKC;CAElB,IADAC,EAAI,UAAU,GACVH,KAAQ,KAAKI,KAAMC,GAAI;CAC3B,IAAIL,KAAQM,IAAM,MAAM;EAOtB,AANAH,EAAI,OAAOP,IAAKQ,GAAIN,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAIM,GAAI,GAAGE,CAAG,GACtBD,IAAK,MACPF,EAAI,OAAOP,IAAKS,GAAIP,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAIO,GAAIC,GAAK,GAAG,EAAI,IAElCH,EAAI,UAAU;EACd;CACF;CACA,IAAMT,IAAOJ,EAAUC,CAAI,IAAI,GAEzBgB,KAAQ,GAAW,GAAc,MAAgC;EACrE,IAAMC,IAAIC,IAAIC,IAAOlB,EAAWE,GAAMD,CAAC;EACvC,OAAO,CAACG,IAAKH,IAAI,KAAK,IAAIe,CAAC,GAAGV,IAAKL,IAAI,KAAK,IAAIe,CAAC,CAAC;CACpD,GACMG,KAAS,GAAW,MAAgC,CACxDf,IAAKH,IAAI,KAAK,IAAIgB,CAAC,GACnBX,IAAKL,IAAI,K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const e=require("./scene.cjs"),t=require("./draw.cjs");var n=12,r=(t,n)=>{let r=(t-n)%e.TAU;return r<0&&(r+=e.TAU),n+r},i=(n,i,a)=>{let o=n-a.cx,s=i-a.cy,c=Math.hypot(o,s);if(c>a.r1||c<a.r0)return!1;let l=a.a1-a.a0;if(l>=e.TAU-1e-6)return!0;if(l<=0)return!1;let u=r(Math.atan2(s,o),a.a0),d=(a.pad??0)/2,f=d>0?t.padAngleAt(d,c):0;return u>=a.a0+f&&u<=a.a1-f},a=(e,t,n)=>{let r=n.length>>1,i=!1;for(let a=0,o=r-1;a<r;o=a++){let r=n[a*2],s=n[a*2+1],c=n[o*2],l=n[o*2+1];s>t!=l>t&&e<(c-r)*(t-s)/(l-s)+r&&(i=!i)}return i},o=e=>{let t=e.length>>1,n=0;for(let r=0,i=t-1;r<t;i=r++)n+=e[i*2]*e[r*2+1]-e[r*2]*e[i*2+1];return Math.abs(n)/2},s=(n,o,s)=>{switch(n.kind){case`sector`:return i(o,s,{...n,pad:t.sectorPad(n)});case`polygon`:return a(o,s,n.points)&&!(n.hole&&a(o,s,n.hole));case`rect`:{let e=n.hitPad??0;return o>=n.x-e&&o<=n.x+n.width+e&&s>=n.y-e&&s<=n.y+n.height+e}case`circle`:return Math.hypot(o-n.cx,s-n.cy)<=n.r;case`arc`:{let t=Math.hypot(o-n.cx,s-n.cy);return Math.abs(t-n.r)>n.width/2+(n.hitPad??4)?!1:n.a1-n.a0>=e.TAU-1e-6||r(Math.atan2(s-n.cy,o-n.cx),n.a0)<=n.a1}case`link`:return l(o,s,n);default:return!1}},c=24,l=(e,t,n)=>{let r=Math.max(1,n.width)/2+2,i=Math.min(n.x0,n.x1),a=Math.max(n.x0,n.x1);if(e<i-r||e>a+r||t<Math.min(n.y0,n.y1)-r||t>Math.max(n.y0,n.y1)+r)return!1;let o=(n.x0+n.x1)/2,s=e=>{let t=1-e,r=t*t*t,i=3*t*t*e,a=3*t*e*e,s=e*e*e;return[r*n.x0+(i+a)*o+s*n.x1,(r+i)*n.y0+(a+s)*n.y1]},[l,d]=s(0);for(let n=1;n<=c;n++){let[i,a]=s(n/c),o=i-l,f=a-d,p=o*o+f*f,m=p>0?u(((e-l)*o+(t-d)*f)/p):0;if(Math.hypot(e-(l+m*o),t-(d+m*f))<=r)return!0;l=i,d=a}return!1},u=e=>e<0?0:e>1?1:e,d=(e,t,i)=>{let s=e.radar;if(!s||!s.series.length)return null;let c=null,l=n;for(let e of s.series)for(let n=0;n<e.points.length>>1;n++){let r=Math.hypot(t-e.points[n*2],i-e.points[n*2+1]);r<=l&&(l=r,c={index:e.index,indicator:n})}if(c)return c;let u=1/0,d=-1;for(let e of s.series){if(e.points.length<6||!a(t,i,e.points))continue;let n=o(e.points);n<u&&(u=n,d=e.index)}if(d<0)return null;let f=Math.atan2(i-s.cy,t-s.cx),p=0,m=1/0;return s.angles.forEach((e,t)=>{let n=Math.abs(r(f-e+Math.PI,0)-Math.PI);n<m&&(m=n,p=t)}),{index:d,indicator:p}},f=(e,t,n,r=null)=>{if(e.empty)return null;if(e.type===`radar`)return d(e,t,n);let i=e.enter;i&&i.scale>0&&i.scale!==1&&(t=i.cx+(t-i.cx)/i.scale,n=i.cy+(n-i.cy)/i.scale);let a=new Set(e.items.map(e=>e.index));for(let i=e.nodes.length-1;i>=0;i--){let o=e.nodes[i];if(o.hit!==void 0&&a.has(o.hit)&&o.kind!==`text`&&o.kind!==`line`){if(s(o,t,n))return{index:o.hit};if(r?.index===o.hit&&o.shift){let[e,r]=o.shift;if(s(o,t-e,n-r))return{index:o.hit}}}}return null},p=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return null;let r=t.indicator===void 0?null:n.indicators?.[t.indicator];return r?{x:r.x,y:r.y}:{x:n.x,y:n.y}},m=(e,t,n)=>{let r=e.items;if(!r.length)return null;let i=t?r.findIndex(e=>e.index===t.index):-1,a=e.type===`radar`;if(i<0){let e=n===`prev`||n===`up`?r.length-1:0;return a?{index:r[e].index,indicator:0}:{index:r[e].index}}let o=n===`next`||n===`down`;if(e.steps){let t=n===`next`||n===`prev`?e.steps.next:e.steps.down;return{index:(r[i+(o?t:-t)]??r[i]).index}}if(a&&(n===`next`||n===`prev`)){let e=r[i].indicators?.length??1,n=t?.indicator??0;return{index:r[i].index,indicator:(n+(o?1:-1)+e)%e}}let s=r[(i+(o?1:-1)+r.length)%r.length];return a?{index:s.index,indicator:t?.indicator??0}:{index:s.index}};exports.hitTestShapes=f,exports.hoverAnchor=p,exports.pointInPolygon=a,exports.pointInSector=i,exports.pointNearLink=l,exports.stepHover=m;
1
+ const e=require("./scene.cjs"),t=require("./draw.cjs");var n=12,r=(t,n)=>{let r=(t-n)%e.TAU;return r<0&&(r+=e.TAU),n+r},i=(n,i,a)=>{let o=n-a.cx,s=i-a.cy,c=Math.hypot(o,s);if(c>a.r1||c<a.r0)return!1;let l=a.a1-a.a0;if(l>=e.TAU-1e-6)return!0;if(l<=0)return!1;let u=r(Math.atan2(s,o),a.a0),d=(a.pad??0)/2,f=d>0?t.padAngleAt(d,c):0;return u>=a.a0+f&&u<=a.a1-f},a=(e,t,n)=>{let r=n.length>>1,i=!1;for(let a=0,o=r-1;a<r;o=a++){let r=n[a*2],s=n[a*2+1],c=n[o*2],l=n[o*2+1];s>t!=l>t&&e<(c-r)*(t-s)/(l-s)+r&&(i=!i)}return i},o=e=>{let t=e.length>>1,n=0;for(let r=0,i=t-1;r<t;i=r++)n+=e[i*2]*e[r*2+1]-e[r*2]*e[i*2+1];return Math.abs(n)/2},s=(n,o,s)=>{switch(n.kind){case`sector`:return i(o,s,{...n,pad:t.sectorPad(n)});case`polygon`:return a(o,s,n.points)&&!(n.hole&&a(o,s,n.hole));case`rect`:{let e=n.hitPad??0;return o>=n.x-e&&o<=n.x+n.width+e&&s>=n.y-e&&s<=n.y+n.height+e}case`circle`:return Math.hypot(o-n.cx,s-n.cy)<=n.r;case`arc`:{let t=Math.hypot(o-n.cx,s-n.cy);return Math.abs(t-n.r)>n.width/2+(n.hitPad??4)?!1:n.a1-n.a0>=e.TAU-1e-6||r(Math.atan2(s-n.cy,o-n.cx),n.a0)<=n.a1}case`link`:return l(o,s,n);case`ribbon`:return Math.hypot(o-n.cx,s-n.cy)<=n.r+1&&a(o,s,d(n));default:return!1}},c=24,l=(e,t,n)=>{let r=Math.max(1,n.width)/2+2,i=Math.min(n.x0,n.x1),a=Math.max(n.x0,n.x1);if(e<i-r||e>a+r||t<Math.min(n.y0,n.y1)-r||t>Math.max(n.y0,n.y1)+r)return!1;let o=(n.x0+n.x1)/2,s=e=>{let t=1-e,r=t*t*t,i=3*t*t*e,a=3*t*e*e,s=e*e*e;return[r*n.x0+(i+a)*o+s*n.x1,(r+i)*n.y0+(a+s)*n.y1]},[l,d]=s(0);for(let n=1;n<=c;n++){let[i,a]=s(n/c),o=i-l,f=a-d,p=o*o+f*f,m=p>0?u(((e-l)*o+(t-d)*f)/p):0;if(Math.hypot(e-(l+m*o),t-(d+m*f))<=r)return!0;l=i,d=a}return!1},u=e=>e<0?0:e>1?1:e,d=e=>{let{cx:n,cy:r,r:i}=e,a=[],o=(e,t,o=i)=>{let s=Math.max(1,Math.ceil((t-e)/.06));for(let i=0;i<=s;i++){let c=e+(t-e)*i/s;a.push(n+o*Math.cos(c),r+o*Math.sin(c))}},s=(e,t,n,r)=>{let i=a[a.length-2],o=a[a.length-1];for(let s=1;s<=16;s++){let c=s/16,l=1-c;a.push(l*l*i+2*l*c*e+c*c*n,l*l*o+2*l*c*t+c*c*r)}},c=(e,t=i)=>[n+t*Math.cos(e),r+t*Math.sin(e)];o(e.s0,Math.max(e.s0,e.s1));let l=c(e.s0);if(t.ribbonIsLoop(e)){let[n,r]=t.loopControl(e);return s(n,r,l[0],l[1]),a}if(e.head>0){let t=c(e.t0,i-e.head);s(n,r,t[0],t[1]),a.push(...c((e.t0+e.t1)/2),...c(e.t1,i-e.head))}else{let t=c(e.t0);s(n,r,t[0],t[1]),o(e.t0,Math.max(e.t0,e.t1))}return s(n,r,l[0],l[1]),a},f=(e,t,i)=>{let s=e.radar;if(!s||!s.series.length)return null;let c=null,l=n;for(let e of s.series)for(let n=0;n<e.points.length>>1;n++){let r=Math.hypot(t-e.points[n*2],i-e.points[n*2+1]);r<=l&&(l=r,c={index:e.index,indicator:n})}if(c)return c;let u=1/0,d=-1;for(let e of s.series){if(e.points.length<6||!a(t,i,e.points))continue;let n=o(e.points);n<u&&(u=n,d=e.index)}if(d<0)return null;let f=Math.atan2(i-s.cy,t-s.cx),p=0,m=1/0;return s.angles.forEach((e,t)=>{let n=Math.abs(r(f-e+Math.PI,0)-Math.PI);n<m&&(m=n,p=t)}),{index:d,indicator:p}},p=(e,t,n,r=null)=>{if(e.empty)return null;if(e.type===`radar`)return f(e,t,n);let i=e.enter;i&&i.scale>0&&i.scale!==1&&(t=i.cx+(t-i.cx)/i.scale,n=i.cy+(n-i.cy)/i.scale);let a=new Set(e.items.map(e=>e.index));for(let i=e.nodes.length-1;i>=0;i--){let o=e.nodes[i];if(o.hit!==void 0&&a.has(o.hit)&&o.kind!==`text`&&o.kind!==`line`){if(s(o,t,n))return{index:o.hit};if(r?.index===o.hit&&o.shift){let[e,r]=o.shift;if(s(o,t-e,n-r))return{index:o.hit}}}}return null},m=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return null;let r=t.indicator===void 0?null:n.indicators?.[t.indicator];return r?{x:r.x,y:r.y}:{x:n.x,y:n.y}},h=(e,t,n)=>{let r=e.items;if(!r.length)return null;let i=t?r.findIndex(e=>e.index===t.index):-1,a=e.type===`radar`;if(i<0){let e=n===`prev`||n===`up`?r.length-1:0;return a?{index:r[e].index,indicator:0}:{index:r[e].index}}let o=n===`next`||n===`down`;if(e.steps){let t=n===`next`||n===`prev`?e.steps.next:e.steps.down;return{index:(r[i+(o?t:-t)]??r[i]).index}}if(a&&(n===`next`||n===`prev`)){let e=r[i].indicators?.length??1,n=t?.indicator??0;return{index:r[i].index,indicator:(n+(o?1:-1)+e)%e}}let s=r[(i+(o?1:-1)+r.length)%r.length];return a?{index:s.index,indicator:t?.indicator??0}:{index:s.index}};exports.hitTestShapes=p,exports.hoverAnchor=m,exports.pointInPolygon=a,exports.pointInSector=i,exports.pointNearLink=l,exports.ribbonOutline=d,exports.stepHover=h;
2
2
  //# sourceMappingURL=hit.cjs.map