minerva-design 1.5.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 (457) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/custom-elements.json +122 -5
  3. package/dist/angular/fesm2022/minerva-angular.mjs +55 -0
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +23 -2
  6. package/dist/charts/canvas.d.cts +2 -1
  7. package/dist/charts/canvas.d.ts +2 -1
  8. package/dist/charts/core.d.cts +1 -1
  9. package/dist/charts/core.d.ts +1 -1
  10. package/dist/charts/engine/canvas.cjs +1 -1
  11. package/dist/charts/engine/canvas.cjs.map +1 -1
  12. package/dist/charts/engine/canvas.js +2 -1
  13. package/dist/charts/engine/canvas.js.map +1 -1
  14. package/dist/charts/engine/chart.cjs +1 -1
  15. package/dist/charts/engine/chart.cjs.map +1 -1
  16. package/dist/charts/engine/chart.js +144 -143
  17. package/dist/charts/engine/chart.js.map +1 -1
  18. package/dist/charts/engine/controller.cjs +2 -2
  19. package/dist/charts/engine/controller.cjs.map +1 -1
  20. package/dist/charts/engine/controller.d.cts +3 -1
  21. package/dist/charts/engine/controller.d.ts +3 -1
  22. package/dist/charts/engine/controller.js +130 -132
  23. package/dist/charts/engine/controller.js.map +1 -1
  24. package/dist/charts/engine/defaults.cjs.map +1 -1
  25. package/dist/charts/engine/defaults.d.cts +4 -4
  26. package/dist/charts/engine/defaults.d.ts +4 -4
  27. package/dist/charts/engine/defaults.js.map +1 -1
  28. package/dist/charts/engine/graph/chart.cjs +1 -1
  29. package/dist/charts/engine/graph/chart.cjs.map +1 -1
  30. package/dist/charts/engine/graph/chart.js +740 -597
  31. package/dist/charts/engine/graph/chart.js.map +1 -1
  32. package/dist/charts/engine/graph/dag.cjs +1 -1
  33. package/dist/charts/engine/graph/dag.cjs.map +1 -1
  34. package/dist/charts/engine/graph/dag.js +191 -166
  35. package/dist/charts/engine/graph/dag.js.map +1 -1
  36. package/dist/charts/engine/graph/force.cjs +1 -1
  37. package/dist/charts/engine/graph/force.cjs.map +1 -1
  38. package/dist/charts/engine/graph/force.d.cts +9 -0
  39. package/dist/charts/engine/graph/force.d.ts +9 -0
  40. package/dist/charts/engine/graph/force.js +279 -181
  41. package/dist/charts/engine/graph/force.js.map +1 -1
  42. package/dist/charts/engine/graph/geometry.cjs +1 -1
  43. package/dist/charts/engine/graph/geometry.cjs.map +1 -1
  44. package/dist/charts/engine/graph/geometry.d.cts +14 -1
  45. package/dist/charts/engine/graph/geometry.d.ts +14 -1
  46. package/dist/charts/engine/graph/geometry.js +77 -24
  47. package/dist/charts/engine/graph/geometry.js.map +1 -1
  48. package/dist/charts/engine/graph/model.cjs +1 -1
  49. package/dist/charts/engine/graph/model.cjs.map +1 -1
  50. package/dist/charts/engine/graph/model.d.cts +9 -0
  51. package/dist/charts/engine/graph/model.d.ts +9 -0
  52. package/dist/charts/engine/graph/model.js +63 -43
  53. package/dist/charts/engine/graph/model.js.map +1 -1
  54. package/dist/charts/engine/graph/types.d.cts +14 -0
  55. package/dist/charts/engine/graph/types.d.ts +14 -0
  56. package/dist/charts/engine/graph/worker.cjs +12 -6
  57. package/dist/charts/engine/graph/worker.cjs.map +1 -1
  58. package/dist/charts/engine/graph/worker.js +12 -6
  59. package/dist/charts/engine/graph/worker.js.map +1 -1
  60. package/dist/charts/engine/labels.cjs.map +1 -1
  61. package/dist/charts/engine/labels.d.cts +17 -0
  62. package/dist/charts/engine/labels.d.ts +17 -0
  63. package/dist/charts/engine/labels.js.map +1 -1
  64. package/dist/charts/engine/model.cjs +1 -1
  65. package/dist/charts/engine/model.cjs.map +1 -1
  66. package/dist/charts/engine/model.d.cts +33 -0
  67. package/dist/charts/engine/model.d.ts +33 -0
  68. package/dist/charts/engine/model.js +149 -126
  69. package/dist/charts/engine/model.js.map +1 -1
  70. package/dist/charts/engine/orderbook/field.cjs +37 -0
  71. package/dist/charts/engine/orderbook/field.cjs.map +1 -0
  72. package/dist/charts/engine/orderbook/field.d.cts +92 -0
  73. package/dist/charts/engine/orderbook/field.d.ts +92 -0
  74. package/dist/charts/engine/orderbook/field.js +297 -0
  75. package/dist/charts/engine/orderbook/field.js.map +1 -0
  76. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  77. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  78. package/dist/charts/engine/orderbook/heatmap.js +413 -441
  79. package/dist/charts/engine/orderbook/heatmap.js.map +1 -1
  80. package/dist/charts/engine/orderbook/host.cjs +1 -1
  81. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  82. package/dist/charts/engine/orderbook/host.d.cts +8 -1
  83. package/dist/charts/engine/orderbook/host.d.ts +8 -1
  84. package/dist/charts/engine/orderbook/host.js +27 -5
  85. package/dist/charts/engine/orderbook/host.js.map +1 -1
  86. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  87. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  88. package/dist/charts/engine/orderbook/ladder.js +1 -1
  89. package/dist/charts/engine/orderbook/ladder.js.map +1 -1
  90. package/dist/charts/engine/orderbook/layout.cjs +1 -1
  91. package/dist/charts/engine/orderbook/layout.cjs.map +1 -1
  92. package/dist/charts/engine/orderbook/layout.d.cts +5 -0
  93. package/dist/charts/engine/orderbook/layout.d.ts +5 -0
  94. package/dist/charts/engine/orderbook/layout.js +8 -2
  95. package/dist/charts/engine/orderbook/layout.js.map +1 -1
  96. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  97. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  98. package/dist/charts/engine/orderbook/tape.js +3 -3
  99. package/dist/charts/engine/orderbook/tape.js.map +1 -1
  100. package/dist/charts/engine/orderbook/types.d.cts +12 -4
  101. package/dist/charts/engine/orderbook/types.d.ts +12 -4
  102. package/dist/charts/engine/overlay.cjs +1 -1
  103. package/dist/charts/engine/overlay.cjs.map +1 -1
  104. package/dist/charts/engine/overlay.d.cts +17 -0
  105. package/dist/charts/engine/overlay.d.ts +17 -0
  106. package/dist/charts/engine/overlay.js +29 -13
  107. package/dist/charts/engine/overlay.js.map +1 -1
  108. package/dist/charts/engine/presets.cjs +1 -1
  109. package/dist/charts/engine/presets.cjs.map +1 -1
  110. package/dist/charts/engine/presets.d.cts +12 -2
  111. package/dist/charts/engine/presets.d.ts +12 -2
  112. package/dist/charts/engine/presets.js +8 -2
  113. package/dist/charts/engine/presets.js.map +1 -1
  114. package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
  115. package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
  116. package/dist/charts/engine/renderers/canvas2d.js +13 -9
  117. package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
  118. package/dist/charts/engine/renderers/follow.cjs +2 -0
  119. package/dist/charts/engine/renderers/follow.cjs.map +1 -0
  120. package/dist/charts/engine/renderers/follow.d.cts +8 -0
  121. package/dist/charts/engine/renderers/follow.d.ts +8 -0
  122. package/dist/charts/engine/renderers/follow.js +10 -0
  123. package/dist/charts/engine/renderers/follow.js.map +1 -0
  124. package/dist/charts/engine/renderers/gl-budget.cjs +2 -0
  125. package/dist/charts/engine/renderers/gl-budget.cjs.map +1 -0
  126. package/dist/charts/engine/renderers/gl-budget.d.cts +32 -0
  127. package/dist/charts/engine/renderers/gl-budget.d.ts +32 -0
  128. package/dist/charts/engine/renderers/gl-budget.js +95 -0
  129. package/dist/charts/engine/renderers/gl-budget.js.map +1 -0
  130. package/dist/charts/engine/renderers/gl.cjs +1 -1
  131. package/dist/charts/engine/renderers/gl.cjs.map +1 -1
  132. package/dist/charts/engine/renderers/gl.js +1 -1
  133. package/dist/charts/engine/renderers/gl.js.map +1 -1
  134. package/dist/charts/engine/renderers/shaders.cjs +9 -6
  135. package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
  136. package/dist/charts/engine/renderers/shaders.d.cts +1 -1
  137. package/dist/charts/engine/renderers/shaders.d.ts +1 -1
  138. package/dist/charts/engine/renderers/shaders.js +9 -6
  139. package/dist/charts/engine/renderers/shaders.js.map +1 -1
  140. package/dist/charts/engine/renderers/types.cjs.map +1 -1
  141. package/dist/charts/engine/renderers/types.d.cts +2 -0
  142. package/dist/charts/engine/renderers/types.d.ts +2 -0
  143. package/dist/charts/engine/renderers/types.js.map +1 -1
  144. package/dist/charts/engine/renderers/webgl.cjs +1 -1
  145. package/dist/charts/engine/renderers/webgl.cjs.map +1 -1
  146. package/dist/charts/engine/renderers/webgl.js +85 -64
  147. package/dist/charts/engine/renderers/webgl.js.map +1 -1
  148. package/dist/charts/engine/renderers/webgl2.cjs +1 -1
  149. package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
  150. package/dist/charts/engine/renderers/webgl2.js +72 -58
  151. package/dist/charts/engine/renderers/webgl2.js.map +1 -1
  152. package/dist/charts/engine/renderers/webgpu.cjs +1 -1
  153. package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
  154. package/dist/charts/engine/renderers/webgpu.js +1 -1
  155. package/dist/charts/engine/renderers/webgpu.js.map +1 -1
  156. package/dist/charts/engine/scene.cjs +1 -1
  157. package/dist/charts/engine/scene.cjs.map +1 -1
  158. package/dist/charts/engine/scene.d.cts +51 -4
  159. package/dist/charts/engine/scene.d.ts +51 -4
  160. package/dist/charts/engine/scene.js +188 -122
  161. package/dist/charts/engine/scene.js.map +1 -1
  162. package/dist/charts/engine/shapes/chord.cjs +1 -1
  163. package/dist/charts/engine/shapes/chord.cjs.map +1 -1
  164. package/dist/charts/engine/shapes/chord.js +108 -103
  165. package/dist/charts/engine/shapes/chord.js.map +1 -1
  166. package/dist/charts/engine/shapes/types.d.cts +5 -3
  167. package/dist/charts/engine/shapes/types.d.ts +5 -3
  168. package/dist/charts/engine/three-d/canvas2d.cjs +1 -1
  169. package/dist/charts/engine/three-d/canvas2d.cjs.map +1 -1
  170. package/dist/charts/engine/three-d/canvas2d.d.cts +36 -1
  171. package/dist/charts/engine/three-d/canvas2d.d.ts +36 -1
  172. package/dist/charts/engine/three-d/canvas2d.js +155 -80
  173. package/dist/charts/engine/three-d/canvas2d.js.map +1 -1
  174. package/dist/charts/engine/three-d/chart.cjs +1 -1
  175. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  176. package/dist/charts/engine/three-d/chart.js +219 -215
  177. package/dist/charts/engine/three-d/chart.js.map +1 -1
  178. package/dist/charts/engine/three-d/oit.cjs +109 -0
  179. package/dist/charts/engine/three-d/oit.cjs.map +1 -0
  180. package/dist/charts/engine/three-d/oit.d.cts +34 -0
  181. package/dist/charts/engine/three-d/oit.d.ts +34 -0
  182. package/dist/charts/engine/three-d/oit.js +111 -0
  183. package/dist/charts/engine/three-d/oit.js.map +1 -0
  184. package/dist/charts/engine/three-d/render-types.cjs +1 -1
  185. package/dist/charts/engine/three-d/render-types.cjs.map +1 -1
  186. package/dist/charts/engine/three-d/render-types.d.cts +16 -3
  187. package/dist/charts/engine/three-d/render-types.d.ts +16 -3
  188. package/dist/charts/engine/three-d/render-types.js +6 -9
  189. package/dist/charts/engine/three-d/render-types.js.map +1 -1
  190. package/dist/charts/engine/three-d/shaders.cjs +52 -26
  191. package/dist/charts/engine/three-d/shaders.cjs.map +1 -1
  192. package/dist/charts/engine/three-d/shaders.d.cts +11 -3
  193. package/dist/charts/engine/three-d/shaders.d.ts +11 -3
  194. package/dist/charts/engine/three-d/shaders.js +84 -40
  195. package/dist/charts/engine/three-d/shaders.js.map +1 -1
  196. package/dist/charts/engine/three-d/sort.cjs +1 -1
  197. package/dist/charts/engine/three-d/sort.cjs.map +1 -1
  198. package/dist/charts/engine/three-d/sort.d.cts +6 -4
  199. package/dist/charts/engine/three-d/sort.d.ts +6 -4
  200. package/dist/charts/engine/three-d/sort.js +51 -39
  201. package/dist/charts/engine/three-d/sort.js.map +1 -1
  202. package/dist/charts/engine/three-d/types.d.cts +9 -0
  203. package/dist/charts/engine/three-d/types.d.ts +9 -0
  204. package/dist/charts/engine/three-d/webgl.cjs +1 -1
  205. package/dist/charts/engine/three-d/webgl.cjs.map +1 -1
  206. package/dist/charts/engine/three-d/webgl.d.cts +9 -0
  207. package/dist/charts/engine/three-d/webgl.d.ts +9 -0
  208. package/dist/charts/engine/three-d/webgl.js +199 -76
  209. package/dist/charts/engine/three-d/webgl.js.map +1 -1
  210. package/dist/charts/engine/three-d/webgpu.cjs +1 -1
  211. package/dist/charts/engine/three-d/webgpu.cjs.map +1 -1
  212. package/dist/charts/engine/three-d/webgpu.js +225 -99
  213. package/dist/charts/engine/three-d/webgpu.js.map +1 -1
  214. package/dist/charts/engine/trading/chart.cjs +1 -1
  215. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  216. package/dist/charts/engine/trading/chart.d.cts +0 -1
  217. package/dist/charts/engine/trading/chart.d.ts +0 -1
  218. package/dist/charts/engine/trading/chart.js +1048 -883
  219. package/dist/charts/engine/trading/chart.js.map +1 -1
  220. package/dist/charts/engine/trading/drawings.cjs +2 -2
  221. package/dist/charts/engine/trading/drawings.cjs.map +1 -1
  222. package/dist/charts/engine/trading/drawings.d.cts +6 -0
  223. package/dist/charts/engine/trading/drawings.d.ts +6 -0
  224. package/dist/charts/engine/trading/drawings.js +100 -88
  225. package/dist/charts/engine/trading/drawings.js.map +1 -1
  226. package/dist/charts/engine/trading/format.cjs +1 -1
  227. package/dist/charts/engine/trading/format.cjs.map +1 -1
  228. package/dist/charts/engine/trading/format.d.cts +6 -0
  229. package/dist/charts/engine/trading/format.d.ts +6 -0
  230. package/dist/charts/engine/trading/format.js +42 -30
  231. package/dist/charts/engine/trading/format.js.map +1 -1
  232. package/dist/charts/engine/trading/geometry.cjs +1 -1
  233. package/dist/charts/engine/trading/geometry.cjs.map +1 -1
  234. package/dist/charts/engine/trading/geometry.d.cts +16 -0
  235. package/dist/charts/engine/trading/geometry.d.ts +16 -0
  236. package/dist/charts/engine/trading/geometry.js +19 -4
  237. package/dist/charts/engine/trading/geometry.js.map +1 -1
  238. package/dist/charts/engine/trading/labels.cjs +1 -1
  239. package/dist/charts/engine/trading/labels.cjs.map +1 -1
  240. package/dist/charts/engine/trading/labels.js +24 -4
  241. package/dist/charts/engine/trading/labels.js.map +1 -1
  242. package/dist/charts/engine/trading/studies.cjs +1 -1
  243. package/dist/charts/engine/trading/studies.cjs.map +1 -1
  244. package/dist/charts/engine/trading/studies.d.cts +8 -0
  245. package/dist/charts/engine/trading/studies.d.ts +8 -0
  246. package/dist/charts/engine/trading/studies.js +4 -1
  247. package/dist/charts/engine/trading/studies.js.map +1 -1
  248. package/dist/charts/engine/trading/types.d.cts +34 -11
  249. package/dist/charts/engine/trading/types.d.ts +34 -11
  250. package/dist/charts/engine/types.d.cts +25 -4
  251. package/dist/charts/engine/types.d.ts +25 -4
  252. package/dist/charts/react/charts.cjs +1 -1
  253. package/dist/charts/react/charts.cjs.map +1 -1
  254. package/dist/charts/react/charts.js +20 -15
  255. package/dist/charts/react/charts.js.map +1 -1
  256. package/dist/charts/react/graph.cjs +1 -1
  257. package/dist/charts/react/graph.cjs.map +1 -1
  258. package/dist/charts/react/graph.d.cts +6 -0
  259. package/dist/charts/react/graph.d.ts +6 -0
  260. package/dist/charts/react/graph.js +28 -27
  261. package/dist/charts/react/graph.js.map +1 -1
  262. package/dist/charts/react/orderbook.cjs +1 -1
  263. package/dist/charts/react/orderbook.cjs.map +1 -1
  264. package/dist/charts/react/orderbook.d.cts +3 -1
  265. package/dist/charts/react/orderbook.d.ts +3 -1
  266. package/dist/charts/react/orderbook.js +1 -0
  267. package/dist/charts/react/orderbook.js.map +1 -1
  268. package/dist/charts/react/shapes.cjs.map +1 -1
  269. package/dist/charts/react/shapes.d.cts +4 -3
  270. package/dist/charts/react/shapes.d.ts +4 -3
  271. package/dist/charts/react/shapes.js.map +1 -1
  272. package/dist/charts/react/three-d.cjs +1 -1
  273. package/dist/charts/react/three-d.cjs.map +1 -1
  274. package/dist/charts/react/three-d.d.cts +7 -0
  275. package/dist/charts/react/three-d.d.ts +7 -0
  276. package/dist/charts/react/three-d.js +14 -13
  277. package/dist/charts/react/three-d.js.map +1 -1
  278. package/dist/charts/react/trading.cjs.map +1 -1
  279. package/dist/charts/react/trading.d.cts +3 -3
  280. package/dist/charts/react/trading.d.ts +3 -3
  281. package/dist/charts/react/trading.js.map +1 -1
  282. package/dist/core/contracts.cjs +1 -1
  283. package/dist/core/contracts.cjs.map +1 -1
  284. package/dist/core/contracts.js +1 -1
  285. package/dist/core/contracts.js.map +1 -1
  286. package/dist/native/charts/src/canvas.cjs +1 -1
  287. package/dist/native/charts/src/canvas.js +4 -3
  288. package/dist/native/charts/src/engine/controller.cjs +2 -2
  289. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  290. package/dist/native/charts/src/engine/controller.js +102 -104
  291. package/dist/native/charts/src/engine/controller.js.map +1 -1
  292. package/dist/native/charts/src/engine/labels.cjs +1 -1
  293. package/dist/native/charts/src/engine/labels.cjs.map +1 -1
  294. package/dist/native/charts/src/engine/labels.js +14 -1
  295. package/dist/native/charts/src/engine/labels.js.map +1 -1
  296. package/dist/native/charts/src/engine/model.cjs +1 -1
  297. package/dist/native/charts/src/engine/model.cjs.map +1 -1
  298. package/dist/native/charts/src/engine/model.js +180 -157
  299. package/dist/native/charts/src/engine/model.js.map +1 -1
  300. package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
  301. package/dist/native/charts/src/engine/overlay.js.map +1 -1
  302. package/dist/native/charts/src/engine/presets.cjs +1 -1
  303. package/dist/native/charts/src/engine/presets.cjs.map +1 -1
  304. package/dist/native/charts/src/engine/presets.js +8 -2
  305. package/dist/native/charts/src/engine/presets.js.map +1 -1
  306. package/dist/native/charts/src/engine/scene.cjs +1 -1
  307. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  308. package/dist/native/charts/src/engine/scene.js +188 -122
  309. package/dist/native/charts/src/engine/scene.js.map +1 -1
  310. package/dist/native/charts/src/engine/shapes/chord.cjs +1 -1
  311. package/dist/native/charts/src/engine/shapes/chord.cjs.map +1 -1
  312. package/dist/native/charts/src/engine/shapes/chord.js +108 -103
  313. package/dist/native/charts/src/engine/shapes/chord.js.map +1 -1
  314. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  315. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  316. package/dist/native/charts/src/engine/shapes/layout.js +88 -73
  317. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  318. package/dist/native/components/Chart/ChartBase.cjs +1 -1
  319. package/dist/native/components/Chart/ChartBase.cjs.map +1 -1
  320. package/dist/native/components/Chart/ChartBase.js +127 -115
  321. package/dist/native/components/Chart/ChartBase.js.map +1 -1
  322. package/dist/native/components/Chart/charts.cjs +1 -1
  323. package/dist/native/components/Chart/charts.cjs.map +1 -1
  324. package/dist/native/components/Chart/charts.js +8 -5
  325. package/dist/native/components/Chart/charts.js.map +1 -1
  326. package/dist/native/components/Chart/scene.cjs +1 -1
  327. package/dist/native/components/Chart/scene.cjs.map +1 -1
  328. package/dist/native/components/Chart/scene.d.cts +6 -1
  329. package/dist/native/components/Chart/scene.d.ts +6 -1
  330. package/dist/native/components/Chart/scene.js +99 -50
  331. package/dist/native/components/Chart/scene.js.map +1 -1
  332. package/dist/native/components/Chart/types.d.cts +7 -1
  333. package/dist/native/components/Chart/types.d.ts +7 -1
  334. package/dist/native/components/Charts/charts.cjs +1 -1
  335. package/dist/native/components/Charts/charts.cjs.map +1 -1
  336. package/dist/native/components/Charts/charts.js +23 -18
  337. package/dist/native/components/Charts/charts.js.map +1 -1
  338. package/dist/native/components/ShapeChart/ShapeChartBase.cjs +1 -1
  339. package/dist/native/components/ShapeChart/ShapeChartBase.cjs.map +1 -1
  340. package/dist/native/components/ShapeChart/ShapeChartBase.d.cts +1 -1
  341. package/dist/native/components/ShapeChart/ShapeChartBase.d.ts +1 -1
  342. package/dist/native/components/ShapeChart/ShapeChartBase.js +97 -107
  343. package/dist/native/components/ShapeChart/ShapeChartBase.js.map +1 -1
  344. package/dist/native/components/ShapeChart/geometry.cjs +1 -1
  345. package/dist/native/components/ShapeChart/geometry.cjs.map +1 -1
  346. package/dist/native/components/ShapeChart/geometry.js +120 -36
  347. package/dist/native/components/ShapeChart/geometry.js.map +1 -1
  348. package/dist/native/components/ShapeChart/types.d.cts +6 -4
  349. package/dist/native/components/ShapeChart/types.d.ts +6 -4
  350. package/dist/native/source/components/Chart/ChartBase.tsx +19 -6
  351. package/dist/native/source/components/Chart/charts.tsx +10 -3
  352. package/dist/native/source/components/Chart/scene.tsx +85 -0
  353. package/dist/native/source/components/Chart/types.ts +7 -0
  354. package/dist/native/source/components/Charts/charts.tsx +7 -0
  355. package/dist/native/source/components/ShapeChart/ShapeChartBase.tsx +10 -36
  356. package/dist/native/source/components/ShapeChart/geometry.ts +188 -18
  357. package/dist/native/source/components/ShapeChart/types.ts +6 -4
  358. package/dist/taro/chart-a11y.d.ts +7 -0
  359. package/dist/taro/charts.d.ts +4 -1
  360. package/dist/taro/index.js +3212 -3049
  361. package/dist/taro/shape-charts.d.ts +6 -4
  362. package/dist/uni/AreaChart.vue +2 -1
  363. package/dist/uni/AreaChart.vue.d.ts +1 -1
  364. package/dist/uni/BarChart.vue +2 -1
  365. package/dist/uni/BarChart.vue.d.ts +1 -1
  366. package/dist/uni/BoxPlotChart.vue +2 -1
  367. package/dist/uni/BubbleChart.vue +2 -1
  368. package/dist/uni/CandlestickChart.vue +2 -1
  369. package/dist/uni/Chart.vue +2 -1
  370. package/dist/uni/Divider.vue.d.ts +1 -1
  371. package/dist/uni/DonutChart.vue.d.ts +1 -1
  372. package/dist/uni/GanttChart.vue +2 -1
  373. package/dist/uni/GanttChart.vue.d.ts +11 -0
  374. package/dist/uni/GaugeChart.vue.d.ts +1 -1
  375. package/dist/uni/HeatmapChart.vue +2 -1
  376. package/dist/uni/HistogramChart.vue +2 -1
  377. package/dist/uni/HorizontalBarChart.vue +2 -1
  378. package/dist/uni/HorizontalBarChart.vue.d.ts +1 -1
  379. package/dist/uni/LineChart.vue +2 -1
  380. package/dist/uni/MixedChart.vue +2 -1
  381. package/dist/uni/PieChart.vue.d.ts +1 -1
  382. package/dist/uni/QuadrantChart.vue +2 -1
  383. package/dist/uni/RangeAreaChart.vue +2 -1
  384. package/dist/uni/ScatterChart.vue +2 -1
  385. package/dist/uni/Sparkline.vue +2 -1
  386. package/dist/uni/WaterfallChart.vue +2 -1
  387. package/dist/uni/chart-a11y.d.ts +7 -0
  388. package/dist/uni/chart-a11y.js +29 -0
  389. package/dist/uni/chart-canvas.d.ts +9 -0
  390. package/dist/uni/chart-canvas.js +11 -1
  391. package/dist/uni/chart-types.d.ts +8 -1
  392. package/dist/uni/chart-types.js +5 -1
  393. package/dist/uni/charts-canvas.js +2 -1
  394. package/dist/uni/named-chart-options.d.ts +2 -0
  395. package/dist/uni/named-chart-options.js +3 -0
  396. package/dist/uni/shape-chart-canvas.d.ts +0 -2
  397. package/dist/uni/shape-chart-canvas.js +4 -36
  398. package/dist/uni/shape-chart-types.d.ts +2 -2
  399. package/dist/uni/shape-chart-types.js +2 -2
  400. package/dist/vue/components/Chart/Bar3DChart.vue.d.ts +2 -0
  401. package/dist/vue/components/Chart/DependencyGraph.vue.d.ts +2 -0
  402. package/dist/vue/components/Chart/GanttChart.vue.d.ts +15 -0
  403. package/dist/vue/components/Chart/GanttChart.vue.js.map +1 -1
  404. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js +8 -0
  405. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  406. package/dist/vue/components/Chart/GraphChart.vue.d.ts +2 -0
  407. package/dist/vue/components/Chart/Line3DChart.vue.d.ts +2 -0
  408. package/dist/vue/components/Chart/Scatter3DChart.vue.d.ts +2 -0
  409. package/dist/vue/components/Chart/Surface3DChart.vue.d.ts +2 -0
  410. package/dist/vue/components/Chart/TradingChart.vue.d.ts +9 -0
  411. package/dist/vue/components/Chart/TreeChart.vue.d.ts +2 -0
  412. package/dist/vue/components/Chart/graph.d.ts +3 -0
  413. package/dist/vue/components/Chart/graph.js +2 -0
  414. package/dist/vue/components/Chart/graph.js.map +1 -1
  415. package/dist/vue/components/Chart/three-d.d.ts +3 -0
  416. package/dist/vue/components/Chart/three-d.js +2 -0
  417. package/dist/vue/components/Chart/three-d.js.map +1 -1
  418. package/dist/vue/components/Chart/trading.d.ts +7 -2
  419. package/dist/vue/components/Chart/trading.js +1 -0
  420. package/dist/vue/components/Chart/trading.js.map +1 -1
  421. package/dist/weapp/area-chart/index.wxml +1 -1
  422. package/dist/weapp/bar-chart/index.wxml +1 -1
  423. package/dist/weapp/box-plot-chart/index.wxml +1 -1
  424. package/dist/weapp/bubble-chart/index.wxml +1 -1
  425. package/dist/weapp/candlestick-chart/index.wxml +1 -1
  426. package/dist/weapp/chart/index.wxml +1 -1
  427. package/dist/weapp/charts/canvas.js +326 -54
  428. package/dist/weapp/charts/core.js +2 -0
  429. package/dist/weapp/controls.js +58 -27
  430. package/dist/weapp/gantt-chart/index.wxml +1 -1
  431. package/dist/weapp/heatmap-chart/index.wxml +1 -1
  432. package/dist/weapp/histogram-chart/index.wxml +1 -1
  433. package/dist/weapp/horizontal-bar-chart/index.wxml +1 -1
  434. package/dist/weapp/line-chart/index.wxml +1 -1
  435. package/dist/weapp/mixed-chart/index.wxml +1 -1
  436. package/dist/weapp/quadrant-chart/index.wxml +1 -1
  437. package/dist/weapp/range-area-chart/index.wxml +1 -1
  438. package/dist/weapp/scatter-chart/index.wxml +1 -1
  439. package/dist/weapp/sparkline/index.wxml +1 -1
  440. package/dist/weapp/types.d.ts +11 -2
  441. package/dist/weapp/waterfall-chart/index.wxml +1 -1
  442. package/dist/web-components/components/chart/extended.d.ts +4 -0
  443. package/dist/web-components/components/chart/extended.js +8 -2
  444. package/dist/web-components/components/chart/extended.js.map +1 -1
  445. package/dist/web-components/components/chart-3d/chart-3d.d.ts +1 -1
  446. package/dist/web-components/components/chart-3d/chart-3d.js.map +1 -1
  447. package/dist/web-components/components/graph/graph.d.ts +2 -0
  448. package/dist/web-components/components/graph/graph.js +3 -2
  449. package/dist/web-components/components/graph/graph.js.map +1 -1
  450. package/dist/web-components/components/trading-chart/trading-chart.d.ts +1 -1
  451. package/dist/web-components/components/trading-chart/trading-chart.js.map +1 -1
  452. package/dist/web-components/html-custom-data.json +45 -0
  453. package/dist/web-components/types/react.d.ts +4 -4
  454. package/dist/web-components/types/solid.d.ts +8 -8
  455. package/dist/web-components/types/svelte.d.ts +8 -8
  456. package/dist/web-components/types/vue.d.ts +4 -4
  457. package/package.json +1 -1
@@ -8824,6 +8824,10 @@ export declare class MnGanttChart extends MnSeriesChartBase {
8824
8824
  readonly formatProgress: import("@angular/core").InputSignal<((share: number) => string) | undefined>;
8825
8825
  /** Name of the dependencies row of the tooltip (default "Depends on", in the `locale`) */
8826
8826
  readonly dependenciesName: import("@angular/core").InputSignal<string | undefined>;
8827
+ /** Draws the `dependencies` of the tasks as elbow arrows from the end of every predecessor to the start of the task */
8828
+ readonly dependencyArrows: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
8829
+ /** Color of the dependency arrows (any CSS color); the secondary text color by default */
8830
+ readonly dependencyColor: import("@angular/core").InputSignal<string | undefined>;
8827
8831
  /** Draws a line at this date (`true`: now) */
8828
8832
  readonly today: import("@angular/core").InputSignal<number | boolean | Date>;
8829
8833
  /** Label of the today line */
@@ -8867,6 +8871,16 @@ export declare class MnGanttChart extends MnSeriesChartBase {
8867
8871
  "required": false;
8868
8872
  "isSignal": true;
8869
8873
  };
8874
+ "dependencyArrows": {
8875
+ "alias": "dependencyArrows";
8876
+ "required": false;
8877
+ "isSignal": true;
8878
+ };
8879
+ "dependencyColor": {
8880
+ "alias": "dependencyColor";
8881
+ "required": false;
8882
+ "isSignal": true;
8883
+ };
8870
8884
  "today": {
8871
8885
  "alias": "today";
8872
8886
  "required": false;
@@ -9315,7 +9329,7 @@ export declare class MnTradingChart extends MnChartEngine<TradingChartOptions, T
9315
9329
  readonly indicators: import("@angular/core").InputSignal<readonly TradingIndicator[] | undefined>;
9316
9330
  /** Locale of the texts, numbers and dates (`"zh-CN"`); the page language by default */
9317
9331
  readonly locale: import("@angular/core").InputSignal<string | undefined>;
9318
- /** Other engine options (`TradingChartOptions`: markers, priceLines, drawings, colorConvention, timeZone, sessionBreaks, orderEntry, volumeProfile, labels...) */
9332
+ /** Other engine options (`TradingChartOptions`: markers, priceLines, drawings, colorConvention, timeZone, sessionBreaks, orderEntry, volumeProfile, autoscaleIncludesDrawings, labels...) */
9319
9333
  readonly options: import("@angular/core").InputSignal<Partial<TradingChartOptions> | undefined>;
9320
9334
  /** The crosshair moved (`null` when it left the chart) */
9321
9335
  readonly crosshairMove: import("@angular/core").OutputEmitterRef<TradingCrosshairEvent | null>;
@@ -9696,7 +9710,7 @@ export declare abstract class MnChart3DBase<S extends Chart3DSeries> extends MnC
9696
9710
  readonly tooltip: import("@angular/core").InputSignal<boolean | Chart3DTooltipOptions | undefined>;
9697
9711
  /** BCP 47 locale of the texts and numbers the engine writes; the runtime's default locale by default */
9698
9712
  readonly locale: import("@angular/core").InputSignal<string | undefined>;
9699
- /** Other engine options (`Chart3DOptions`: aspect, box, valueRange, interaction, lighting, renderer, palette...) */
9713
+ /** Other engine options (`Chart3DOptions`: aspect, box, valueRange, interaction, lighting, exposure, renderer, palette...) */
9700
9714
  readonly options: import("@angular/core").InputSignal<Partial<Omit<Chart3DOptions, "series">> | undefined>;
9701
9715
  /** The hovered point, cell or bar changed (`null`: none) */
9702
9716
  readonly hover: import("@angular/core").OutputEmitterRef<Chart3DHoverEvent | null>;
@@ -9877,6 +9891,8 @@ export declare abstract class MnGraphChartBase extends MnChartEngine<GraphChartO
9877
9891
  readonly edgeColor: import("@angular/core").InputSignal<"source" | "neutral" | "target" | undefined>;
9878
9892
  /** Arrowheads on the edges without `directed` (on for DAGs) */
9879
9893
  readonly arrows: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
9894
+ /** Shape of the arrowheads: `open` (a slim outlined head) or `filled` (a solid head in the edge color; default `open`) */
9895
+ readonly arrowStyle: import("@angular/core").InputSignal<"filled" | "open" | undefined>;
9880
9896
  /** Node labels; `auto` hides minor and overlapping labels when zoomed out (default `auto`) */
9881
9897
  readonly nodeLabels: import("@angular/core").InputSignal<boolean | "auto" | undefined>;
9882
9898
  /** Edge labels: always, `auto` (zoomed in or highlighted), only `hover`, or never (default `auto`) */
@@ -10000,6 +10016,11 @@ export declare abstract class MnGraphChartBase extends MnChartEngine<GraphChartO
10000
10016
  "required": false;
10001
10017
  "isSignal": true;
10002
10018
  };
10019
+ "arrowStyle": {
10020
+ "alias": "arrowStyle";
10021
+ "required": false;
10022
+ "isSignal": true;
10023
+ };
10003
10024
  "nodeLabels": {
10004
10025
  "alias": "nodeLabels";
10005
10026
  "required": false;
@@ -1,7 +1,7 @@
1
1
  export { createCanvasChart, drawScene, type CanvasChartConfig, type CanvasChartInstance, type ChartCanvas, type ChartTouch, } from './engine/canvas.cjs';
2
2
  export { createChartController, scenePrimitives, type ChartAreaPrimitive, type ChartBarPrimitive, type ChartColorLegendLayout, type ChartController, type ChartControllerConfig, type ChartControllerEventMap, type ChartDotPrimitive, type ChartHoverLayout, type ChartLegendEntry, type ChartLegendLayout, type ChartLinePrimitive, type ChartPointerOptions, type ChartPrimitive, type ChartPrimitiveOptions, type ChartScene, type ChartTooltipLayout, } from './engine/controller.cjs';
3
3
  export { formatCompact, formatDuration, formatValue } from './engine/format.cjs';
4
- export { chartAriaLabel } from './engine/labels.cjs';
4
+ export { chartAriaLabel, describeChart } from './engine/labels.cjs';
5
5
  export { drawPrimitives } from './engine/canvas.cjs';
6
6
  export { lineOf as annotationLine, rectOf as annotationRect, textBox as annotationTextBox, } from './engine/overlay.cjs';
7
7
  export { toData, toScreen } from './engine/layout.cjs';
@@ -12,4 +12,5 @@ export type * from './engine/types.cjs';
12
12
  export { createCanvasShapeChart, type CanvasShapeChartConfig, type CanvasShapeChartInstance, } from './engine/shapes/canvas.cjs';
13
13
  export { drawShapeScene } from './engine/shapes/draw.cjs';
14
14
  export { calendarStrips } from './engine/shapes/calendar.cjs';
15
+ export { describeChart as describeShapeChart } from './engine/shapes/layout.cjs';
15
16
  export type * from './engine/shapes/types.cjs';
@@ -1,7 +1,7 @@
1
1
  export { createCanvasChart, drawScene, type CanvasChartConfig, type CanvasChartInstance, type ChartCanvas, type ChartTouch, } from './engine/canvas.js';
2
2
  export { createChartController, scenePrimitives, type ChartAreaPrimitive, type ChartBarPrimitive, type ChartColorLegendLayout, type ChartController, type ChartControllerConfig, type ChartControllerEventMap, type ChartDotPrimitive, type ChartHoverLayout, type ChartLegendEntry, type ChartLegendLayout, type ChartLinePrimitive, type ChartPointerOptions, type ChartPrimitive, type ChartPrimitiveOptions, type ChartScene, type ChartTooltipLayout, } from './engine/controller.js';
3
3
  export { formatCompact, formatDuration, formatValue } from './engine/format.js';
4
- export { chartAriaLabel } from './engine/labels.js';
4
+ export { chartAriaLabel, describeChart } from './engine/labels.js';
5
5
  export { drawPrimitives } from './engine/canvas.js';
6
6
  export { lineOf as annotationLine, rectOf as annotationRect, textBox as annotationTextBox, } from './engine/overlay.js';
7
7
  export { toData, toScreen } from './engine/layout.js';
@@ -12,4 +12,5 @@ export type * from './engine/types.js';
12
12
  export { createCanvasShapeChart, type CanvasShapeChartConfig, type CanvasShapeChartInstance, } from './engine/shapes/canvas.js';
13
13
  export { drawShapeScene } from './engine/shapes/draw.js';
14
14
  export { calendarStrips } from './engine/shapes/calendar.js';
15
+ export { describeChart as describeShapeChart } from './engine/shapes/layout.js';
15
16
  export type * from './engine/shapes/types.js';
@@ -12,4 +12,4 @@ export * from './engine/three-d/index.cjs';
12
12
  export * from './engine/graph/index.cjs';
13
13
  export { areaSeries, barSeries, binValues, boxplotData, boxplotSeries, boxplotStats, bubbleSeries, candlestickSeries, ganttSeries, histogramSeries, lineSeries, quantiles, rangeAreaSeries, scatterSeries, waterfallSeries, withSeriesType, type LineSeriesOptions, type BinOptions, type BoxplotGroup, type BoxplotStats, type BoxplotStatsOptions, type BubbleOptions, type GanttOptions, type GanttSeries, type GanttTask, type HistogramBinning, type HistogramBins, type HistogramSeriesOptions, type WaterfallOptions, type WaterfallStep, heatmapChartOptions, quadrantCenter, quadrantChartOptions, quadrantOf, sparklineOptions, type HeatmapCell, type HeatmapConfig, type QuadrantAxisLabels, type QuadrantConfig, type QuadrantCorner, type QuadrantPoint, type QuadrantRegion, type QuadrantRegions, type SparklineConfig, } from './engine/presets.cjs';
14
14
  export type { ChartThemeInput } from './engine/theme.cjs';
15
- export type { ChartAnnotation, ChartAxisOptions, ChartAxisType, ChartColorScheme, ChartColumnData, ChartConnectorOptions, ChartCurve, ChartDragEvent, ChartEventMap, ChartHoverEvent, ChartHoverItem, ChartInstance, ChartInteractionOptions, ChartLabelPosition, ChartLabels, ChartLegendOptions, ChartLineAnnotation, ChartOptions, ChartOrientation, ChartPadding, ChartPlotClickEvent, ChartPointDatum, ChartRect, ChartRectAnnotation, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartSeriesData, ChartSeriesType, ChartTextAnnotation, ChartTimeZone, ChartTooltipDetail, ChartTooltipLabels, ChartTooltipOptions, ChartView, ChartXValue, } from './engine/types.cjs';
15
+ export type { ChartAnnotation, ChartAxisOptions, ChartAxisType, ChartColorScheme, ChartColumnData, ChartConnectorOptions, ChartCurve, ChartDependency, ChartDragEvent, ChartEventMap, ChartHoverEvent, ChartHoverItem, ChartInstance, ChartInteractionOptions, ChartLabelPosition, ChartLabels, ChartLegendOptions, ChartLineAnnotation, ChartOptions, ChartOrientation, ChartPadding, ChartPlotClickEvent, ChartPointDatum, ChartRect, ChartRectAnnotation, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartSeriesData, ChartSeriesType, ChartTextAnnotation, ChartTimeZone, ChartTooltipDetail, ChartTooltipLabels, ChartTooltipOptions, ChartView, ChartXValue, } from './engine/types.cjs';
@@ -12,4 +12,4 @@ export * from './engine/three-d/index.js';
12
12
  export * from './engine/graph/index.js';
13
13
  export { areaSeries, barSeries, binValues, boxplotData, boxplotSeries, boxplotStats, bubbleSeries, candlestickSeries, ganttSeries, histogramSeries, lineSeries, quantiles, rangeAreaSeries, scatterSeries, waterfallSeries, withSeriesType, type LineSeriesOptions, type BinOptions, type BoxplotGroup, type BoxplotStats, type BoxplotStatsOptions, type BubbleOptions, type GanttOptions, type GanttSeries, type GanttTask, type HistogramBinning, type HistogramBins, type HistogramSeriesOptions, type WaterfallOptions, type WaterfallStep, heatmapChartOptions, quadrantCenter, quadrantChartOptions, quadrantOf, sparklineOptions, type HeatmapCell, type HeatmapConfig, type QuadrantAxisLabels, type QuadrantConfig, type QuadrantCorner, type QuadrantPoint, type QuadrantRegion, type QuadrantRegions, type SparklineConfig, } from './engine/presets.js';
14
14
  export type { ChartThemeInput } from './engine/theme.js';
15
- export type { ChartAnnotation, ChartAxisOptions, ChartAxisType, ChartColorScheme, ChartColumnData, ChartConnectorOptions, ChartCurve, ChartDragEvent, ChartEventMap, ChartHoverEvent, ChartHoverItem, ChartInstance, ChartInteractionOptions, ChartLabelPosition, ChartLabels, ChartLegendOptions, ChartLineAnnotation, ChartOptions, ChartOrientation, ChartPadding, ChartPlotClickEvent, ChartPointDatum, ChartRect, ChartRectAnnotation, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartSeriesData, ChartSeriesType, ChartTextAnnotation, ChartTimeZone, ChartTooltipDetail, ChartTooltipLabels, ChartTooltipOptions, ChartView, ChartXValue, } from './engine/types.js';
15
+ export type { ChartAnnotation, ChartAxisOptions, ChartAxisType, ChartColorScheme, ChartColumnData, ChartConnectorOptions, ChartCurve, ChartDependency, ChartDragEvent, ChartEventMap, ChartHoverEvent, ChartHoverItem, ChartInstance, ChartInteractionOptions, ChartLabelPosition, ChartLabels, ChartLegendOptions, ChartLineAnnotation, ChartOptions, ChartOrientation, ChartPadding, ChartPlotClickEvent, ChartPointDatum, ChartRect, ChartRectAnnotation, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartSeriesData, ChartSeriesType, ChartTextAnnotation, ChartTimeZone, ChartTooltipDetail, ChartTooltipLabels, ChartTooltipOptions, ChartView, ChartXValue, } from './engine/types.js';
@@ -1,2 +1,2 @@
1
- const e=require("./color.cjs"),t=require("./items.cjs"),n=require("./overlay.cjs"),r=require("./renderers/canvas2d.cjs"),i=require("./signature.cjs"),a=require("./controller.cjs");var o=e=>(e[0]+e[1])/2,s=(e,t,n,r,i,a)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()},c=(e,t,n)=>{e.save(),e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip(),e.lineJoin=`round`,e.lineCap=`round`;for(let n of t)if(n.kind===`area`)e.globalAlpha=n.opacity,e.fillStyle=n.color,n.segments.forEach((t,r)=>{let i=n.bottoms?.[r],a=t.length/2;if(!(a<2)){e.beginPath();for(let n=0;n<a;n++)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n*2],t[n*2+1]);for(let r=a-1;r>=0;r--){let a=i?i[r]:n.baseline;n.horizontal?e.lineTo(a,t[r*2+1]):e.lineTo(t[r*2],a)}e.closePath(),e.fill()}}),e.globalAlpha=1;else if(n.kind===`line`){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath();for(let t of n.segments)for(let n=0;n<t.length;n+=2)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n],t[n+1]);e.stroke()}else if(n.kind===`bars`){e.globalAlpha=n.opacity??1;let t=n.radius??0;for(let r=0;r<n.rects.length;r+=4){let[i,a,o,c]=[n.rects[r],n.rects[r+1],n.rects[r+2],n.rects[r+3]];e.fillStyle=n.colors?.[r/4]??n.color;let l=Math.min(t,o/2,c/2);l>.5?(s(e,i,a,o,c,l),e.fill()):e.fillRect(i,a,o,c)}e.globalAlpha=1}else{let t=n.stroke??0;for(let r=0;r<n.dots.length;r+=3){let i=n.colors[r/3]??`#888`,a=n.dots[r+2]/2;e.beginPath(),e.arc(n.dots[r],n.dots[r+1],Math.max(0,a-t/2),0,Math.PI*2),n.opacity>0&&(e.globalAlpha=n.opacity,e.fillStyle=i,e.fill()),t>0&&(e.globalAlpha=1,e.lineWidth=t,e.strokeStyle=i,e.stroke())}e.globalAlpha=1}e.restore()},l=(t,r,i)=>{let{theme:a}=i,{bar:o,stops:c}=r,l=c.length;if(typeof t.createLinearGradient==`function`){let e=t.createLinearGradient(o.x,0,o.x+o.width,0);c.forEach((t,n)=>e.addColorStop(n/Math.max(1,l-1),t)),t.fillStyle=e,s(t,o.x,o.y,o.width,o.height,o.height/2),t.fill()}else{let e=o.width/l;c.forEach((n,r)=>{t.fillStyle=n,t.fillRect(o.x+r*e,o.y,e+.5,o.height)})}t.fillStyle=e.toCss(a.text,.35);for(let e of r.ticks)t.fillRect(Math.round(e),o.y-2,1,o.height+4);t.font=n.font(a,11),t.textBaseline=`middle`,t.fillStyle=e.toCss(a.textMuted);for(let e of r.labels)t.textAlign=e.align,t.fillText(e.text,e.x,e.y);r.caret!==null&&(s(t,r.caret-2,o.y-3,4,o.height+6,2),t.fillStyle=e.toCss(a.text),t.fill(),t.lineWidth=1.5,t.strokeStyle=e.toCss(a.background),t.stroke())},u=(t,i,o,u,d,f=r.createCanvas2dPainter(t))=>{let{width:p,height:m,theme:h,model:g,view:_,layout:v}=i,{plot:y,scales:b}=v,x=d;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,Math.ceil(p*x),Math.ceil(m*x)),t.setTransform(x,0,0,x,0,0),n.drawBackground(t,{width:p,height:m,scales:b,x:g.x,y:g.y,xTicks:v.xTicks,yTicks:v.yTicks,y2:g.y2,y2Ticks:v.y2Ticks,theme:h,annotations:i.annotations});let S=i.legend?.colors;if(S&&l(t,S,i),i.legend){t.font=n.font(h,12),t.textBaseline=`middle`,t.textAlign=`left`;for(let n of i.legend.entries){let r=n.box.y+n.box.height/2;if(t.globalAlpha=n.hidden?.45:1,t.fillStyle=n.color,n.shape===`dot`?(t.beginPath(),t.arc(n.box.x+5,r,4,0,Math.PI*2),t.fill()):n.shape===`line`?t.fillRect(n.box.x,r-1,10,2):t.fillRect(n.box.x+1,r-4,8,8),t.fillStyle=e.toCss(h.textMuted),t.fillText(n.name,n.box.x+14,r),n.hidden){let e=n.box.width-22;t.fillRect(n.box.x+14,r,e,1)}}t.globalAlpha=1}for(let n of i.hover?.marks??[])n.kind===`band`&&(s(t,n.x,n.y,n.width,n.height,6),t.fillStyle=e.toCss(h.text,.06),t.fill());b.horizontal?c(t,a.scenePrimitives(i),y):C();function C(){let e=(e,t,n)=>{let r=2/(e[1]-e[0]),i=(t-e[0])*r-1;return n?[-r,-i]:[r,i]},[t,n]=e(_.x,u.x,g.x.reverse),[r,i]=e(_.y,u.y,g.y.reverse);f.paint(o,{transform:{xScale:t,xOffset:n,yScale:r,yOffset:i},width:Math.max(1,Math.round(y.width*x)),height:Math.max(1,Math.round(y.height*x)),dpr:x},Math.round(y.x*x),Math.round(y.y*x))}t.setTransform(x,0,0,x,0,0);for(let n of i.hover?.marks??[])n.kind===`guide`&&(t.fillStyle=e.toCss(h.text,.06),t.fillRect(n.x,n.y,n.width,n.height));if(n.drawForeground(t,{width:p,height:m,scales:b,theme:h,annotations:i.annotations,pointLabels:[],clear:!1,connectors:i.connectors}),i.pointLabels.length){t.save(),t.font=n.font(h),t.textAlign=`left`,t.textBaseline=`middle`,t.lineWidth=3,t.lineJoin=`round`,t.strokeStyle=e.toCss(h.background,.9),t.fillStyle=e.toCss(h.text,.85);for(let{label:e,box:n}of i.pointLabels)t.strokeText(e.text,n.x,n.y+n.height/2),t.fillText(e.text,n.x,n.y+n.height/2);t.restore()}let w=i.hover;if(w){if(w.crosshairX!==null){t.save(),t.strokeStyle=e.toCss(h.textMuted,.55),t.lineWidth=1,t.setLineDash([3,3]),t.beginPath();let n=Math.round(w.crosshairX)+.5;t.moveTo(n,y.y),t.lineTo(n,y.y+y.height),t.stroke(),t.restore()}if(w.crosshairY!==null){t.save(),t.strokeStyle=e.toCss(h.textMuted,.55),t.lineWidth=1,t.setLineDash([3,3]),t.beginPath();let n=Math.round(w.crosshairY)+.5;t.moveTo(y.x,n),t.lineTo(y.x+y.width,n),t.stroke(),t.restore()}for(let n of w.marks)if(n.kind!==`band`&&n.kind!==`guide`){if(n.kind===`cell`){let e=Math.min(3,n.width*.06,n.height*.06),r=Math.max(2,n.radius);t.save(),t.shadowColor=`rgba(15, 23, 42, 0.4)`,t.shadowBlur=12,t.shadowOffsetY=4,s(t,n.x-e,n.y-e,n.width+e*2,n.height+e*2,r),t.fillStyle=n.color,t.fill(),t.restore();let i=Math.min(2.75,n.width/5,n.height/5);n.width>8&&n.height>8&&(s(t,n.x+i,n.y+i,n.width-i*2,n.height-i*2,Math.max(1,r-i/2)),t.lineWidth=1.5,t.strokeStyle=n.ring,t.stroke());continue}t.beginPath(),t.arc(n.x,n.y,n.size/2+4,0,Math.PI*2),t.fillStyle=n.halo,t.fill(),t.beginPath(),t.arc(n.x,n.y,n.size/2-1,0,Math.PI*2),t.fillStyle=n.color,t.fill(),t.lineWidth=2,t.strokeStyle=e.toCss(h.background),t.stroke()}}if(i.dragging){let n=i.dragging;t.beginPath(),t.arc(n.x,n.y,n.size/2,0,Math.PI*2),t.fillStyle=n.color,t.globalAlpha=.85,t.fill(),t.globalAlpha=1,t.lineWidth=2,t.strokeStyle=e.toCss(h.background),t.stroke()}let T=w?.tooltip;if(T){let{box:r,lineHeight:i,padding:a}=T;t.save(),t.shadowColor=`rgba(15, 23, 42, 0.18)`,t.shadowBlur=16,t.shadowOffsetY=6,s(t,r.x,r.y,r.width,r.height,8),t.fillStyle=e.toCss(h.background),t.fill(),t.restore(),s(t,r.x+.5,r.y+.5,r.width-1,r.height-1,8),t.strokeStyle=e.toCss(h.axis,.6),t.lineWidth=1,t.stroke(),t.textBaseline=`middle`;let o=r.y+a+i/2,c=r.x+a+2,l=r.x+r.width-a-2;if(T.text){t.font=n.font(h,12),t.fillStyle=e.toCss(h.text),t.textAlign=`left`;for(let e of T.text)t.fillText(e,c,o),o+=i}else{let{content:r}=T,a=c;r.titleColor&&(t.fillStyle=r.titleColor,t.beginPath(),t.arc(a+4,o,4,0,Math.PI*2),t.fill(),a+=14),t.font=n.font(h,12,600),t.fillStyle=e.toCss(h.text),t.textAlign=`left`,t.fillText(r.title,a,o),o+=i,r.subtitle&&(t.font=n.font(h,11),t.fillStyle=e.toCss(h.textMuted),t.fillText(r.subtitle,a,o-2),o+=i);for(let s of r.rows)a=c,s.color&&(t.fillStyle=s.color,t.beginPath(),t.arc(a+4,o,4,0,Math.PI*2),t.fill()),a+=T.swatchWidth,t.font=n.font(h,12),t.textAlign=`left`,t.fillStyle=e.toCss(h.textMuted),t.fillText(s.name,a,o),t.font=n.font(h,12,600),t.textAlign=`right`,t.fillStyle=e.toCss(h.text),t.fillText(s.value,l,o),o+=i}}},d=e=>{let{canvas:n}=e,s=n.getContext(`2d`),c=e.width,l=e.height,d=e.pixelRatio??1,f=!1,p=null,m=[],h=null,g=``,_=``,v=e.options,y=new WeakMap,b=0,x=e=>{let t=y.get(e);return t===void 0&&y.set(e,t=++b),t},S={x:0,y:0},C=0,w=``,T=(e,t)=>s?(t!==w&&(s.font=t,w=t),s.measureText(e).width):e.length*6.5,E=s?r.createCanvas2dPainter(s):null,D=globalThis,O=()=>{if(p=null,f||!s||!E)return;let e=A.getScene();if(!e)return;let r=Math.max(1,Math.round(c*d)),a=Math.max(1,Math.round(l*d));n.width!==r&&(n.width=r),n.height!==a&&(n.height=a),w=``,h!==e.model&&(h=e.model,g=i.itemsSignature(e.model,x(e.theme),e=>v.series[e]?.stack));let y=e.layout.scales,b={x:1/Math.abs(y.xPerPx),y:1/Math.abs(y.yPerPx)},T=`${g}|${t.cellStyleKey(e.model,b)}`;T!==_&&(_=T,S={x:o(e.model.base.x),y:o(e.model.base.y)},m=t.buildItems(e.model,S,++C,b)),u(s,e,m,S,d,E),w=``},k=()=>{f||p!==null||(p=n.requestAnimationFrame?n.requestAnimationFrame(O):D.requestAnimationFrame?D.requestAnimationFrame(O):setTimeout(O,16))},A=a.createChartController({options:e.options,theme:e.theme,measureText:T,onInvalidate:k});A.setSize(c,l);let j=(e,t)=>({id:e.identifier??t,touch:!0});return{setOptions:e=>{v=e,A.setOptions(e)},setTheme:e=>A.setTheme(e),resize(e,t,n){c=e,l=t,n&&(d=n),A.setSize(e,t),k()},render(){p!==null&&(n.cancelAnimationFrame?n.cancelAnimationFrame(p):D.cancelAnimationFrame?D.cancelAnimationFrame(p):clearTimeout(p)),O()},touchStart(e){e.forEach((e,t)=>A.pointerDown(e.x,e.y,j(e,t)))},touchMove(e){e.forEach((e,t)=>A.pointerMove(e.x,e.y,j(e,t)))},touchEnd(e){e.forEach((e,t)=>A.pointerUp(e.x,e.y,j(e,t)))},touchCancel(e=[{x:0,y:0}]){e.forEach((e,t)=>A.pointerCancel(j(e,t)))},pointerDown:(e,t,n)=>A.pointerDown(e,t,n),pointerMove:(e,t,n)=>A.pointerMove(e,t,n),pointerUp:(e,t,n)=>A.pointerUp(e,t,n),pointerLeave:()=>A.pointerLeave(),zoomAt:(e,t,n)=>A.zoomAt(e,t,n),resetZoom:()=>A.resetZoom(),getView:()=>A.getView(),setView:e=>A.setView(e),toggleSeries:e=>A.toggleSeries(e),clearHover:()=>A.clearHover(),getPlotRect:()=>A.getPlotRect(),toPixel:(e,t)=>A.toPixel(e,t),fromPixel:(e,t)=>A.fromPixel(e,t),getController:()=>A,on:(e,t)=>A.on(e,t),destroy(){f||(f=!0,p!==null&&(n.cancelAnimationFrame?n.cancelAnimationFrame(p):D.cancelAnimationFrame?D.cancelAnimationFrame(p):clearTimeout(p)),E?.destroy(),A.destroy())}}};exports.createCanvasChart=d,exports.drawPrimitives=c,exports.drawScene=u;
1
+ const e=require("./color.cjs"),t=require("./items.cjs"),n=require("./overlay.cjs"),r=require("./renderers/canvas2d.cjs"),i=require("./signature.cjs"),a=require("./controller.cjs");var o=e=>(e[0]+e[1])/2,s=(e,t,n,r,i,a)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()},c=(e,t,n)=>{e.save(),e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip(),e.lineJoin=`round`,e.lineCap=`round`;for(let n of t)if(n.kind===`area`)e.globalAlpha=n.opacity,e.fillStyle=n.color,n.segments.forEach((t,r)=>{let i=n.bottoms?.[r],a=t.length/2;if(!(a<2)){e.beginPath();for(let n=0;n<a;n++)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n*2],t[n*2+1]);for(let r=a-1;r>=0;r--){let a=i?i[r]:n.baseline;n.horizontal?e.lineTo(a,t[r*2+1]):e.lineTo(t[r*2],a)}e.closePath(),e.fill()}}),e.globalAlpha=1;else if(n.kind===`line`){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath();for(let t of n.segments)for(let n=0;n<t.length;n+=2)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n],t[n+1]);e.stroke()}else if(n.kind===`bars`){e.globalAlpha=n.opacity??1;let t=n.radius??0;for(let r=0;r<n.rects.length;r+=4){let[i,a,o,c]=[n.rects[r],n.rects[r+1],n.rects[r+2],n.rects[r+3]];e.fillStyle=n.colors?.[r/4]??n.color;let l=Math.min(t,o/2,c/2);l>.5?(s(e,i,a,o,c,l),e.fill()):e.fillRect(i,a,o,c)}e.globalAlpha=1}else{let t=n.stroke??0;for(let r=0;r<n.dots.length;r+=3){let i=n.colors[r/3]??`#888`,a=n.dots[r+2]/2;e.beginPath(),e.arc(n.dots[r],n.dots[r+1],Math.max(0,a-t/2),0,Math.PI*2),n.opacity>0&&(e.globalAlpha=n.opacity,e.fillStyle=i,e.fill()),t>0&&(e.globalAlpha=1,e.lineWidth=t,e.strokeStyle=i,e.stroke())}e.globalAlpha=1}e.restore()},l=(t,r,i)=>{let{theme:a}=i,{bar:o,stops:c}=r,l=c.length;if(typeof t.createLinearGradient==`function`){let e=t.createLinearGradient(o.x,0,o.x+o.width,0);c.forEach((t,n)=>e.addColorStop(n/Math.max(1,l-1),t)),t.fillStyle=e,s(t,o.x,o.y,o.width,o.height,o.height/2),t.fill()}else{let e=o.width/l;c.forEach((n,r)=>{t.fillStyle=n,t.fillRect(o.x+r*e,o.y,e+.5,o.height)})}t.fillStyle=e.toCss(a.text,.35);for(let e of r.ticks)t.fillRect(Math.round(e),o.y-2,1,o.height+4);t.font=n.font(a,11),t.textBaseline=`middle`,t.fillStyle=e.toCss(a.textMuted);for(let e of r.labels)t.textAlign=e.align,t.fillText(e.text,e.x,e.y);r.caret!==null&&(s(t,r.caret-2,o.y-3,4,o.height+6,2),t.fillStyle=e.toCss(a.text),t.fill(),t.lineWidth=1.5,t.strokeStyle=e.toCss(a.background),t.stroke())},u=(t,i,o,u,d,f=r.createCanvas2dPainter(t))=>{let{width:p,height:m,theme:h,model:g,view:_,layout:v}=i,{plot:y,scales:b}=v,x=d;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,Math.ceil(p*x),Math.ceil(m*x)),t.setTransform(x,0,0,x,0,0),n.drawBackground(t,{width:p,height:m,scales:b,x:g.x,y:g.y,xTicks:v.xTicks,yTicks:v.yTicks,y2:g.y2,y2Ticks:v.y2Ticks,theme:h,annotations:i.annotations});let S=i.legend?.colors;if(S&&l(t,S,i),i.legend){t.font=n.font(h,12),t.textBaseline=`middle`,t.textAlign=`left`;for(let n of i.legend.entries){let r=n.box.y+n.box.height/2;if(t.globalAlpha=n.hidden?.45:1,t.fillStyle=n.color,n.shape===`dot`?(t.beginPath(),t.arc(n.box.x+5,r,4,0,Math.PI*2),t.fill()):n.shape===`line`?t.fillRect(n.box.x,r-1,10,2):t.fillRect(n.box.x+1,r-4,8,8),t.fillStyle=e.toCss(h.textMuted),t.fillText(n.name,n.box.x+14,r),n.hidden){let e=n.box.width-22;t.fillRect(n.box.x+14,r,e,1)}}t.globalAlpha=1}for(let n of i.hover?.marks??[])n.kind===`band`&&(s(t,n.x,n.y,n.width,n.height,6),t.fillStyle=e.toCss(h.text,.06),t.fill());b.horizontal?c(t,a.scenePrimitives(i),y):C();function C(){let e=(e,t,n)=>{let r=2/(e[1]-e[0]),i=(t-e[0])*r-1;return n?[-r,-i]:[r,i]},[t,n]=e(_.x,u.x,g.x.reverse),[r,i]=e(_.y,u.y,g.y.reverse);f.paint(o,{transform:{xScale:t,xOffset:n,yScale:r,yOffset:i},width:Math.max(1,Math.round(y.width*x)),height:Math.max(1,Math.round(y.height*x)),dpr:x},Math.round(y.x*x),Math.round(y.y*x))}t.setTransform(x,0,0,x,0,0);for(let n of i.hover?.marks??[])n.kind===`guide`&&(t.fillStyle=e.toCss(h.text,.06),t.fillRect(n.x,n.y,n.width,n.height));if(n.drawForeground(t,{width:p,height:m,scales:b,theme:h,annotations:i.annotations,pointLabels:[],clear:!1,connectors:i.connectors,arrows:i.arrows}),i.pointLabels.length){t.save(),t.font=n.font(h),t.textAlign=`left`,t.textBaseline=`middle`,t.lineWidth=3,t.lineJoin=`round`,t.strokeStyle=e.toCss(h.background,.9),t.fillStyle=e.toCss(h.text,.85);for(let{label:e,box:n}of i.pointLabels)t.strokeText(e.text,n.x,n.y+n.height/2),t.fillText(e.text,n.x,n.y+n.height/2);t.restore()}let w=i.hover;if(w){if(w.crosshairX!==null){t.save(),t.strokeStyle=e.toCss(h.textMuted,.55),t.lineWidth=1,t.setLineDash([3,3]),t.beginPath();let n=Math.round(w.crosshairX)+.5;t.moveTo(n,y.y),t.lineTo(n,y.y+y.height),t.stroke(),t.restore()}if(w.crosshairY!==null){t.save(),t.strokeStyle=e.toCss(h.textMuted,.55),t.lineWidth=1,t.setLineDash([3,3]),t.beginPath();let n=Math.round(w.crosshairY)+.5;t.moveTo(y.x,n),t.lineTo(y.x+y.width,n),t.stroke(),t.restore()}for(let n of w.marks)if(n.kind!==`band`&&n.kind!==`guide`){if(n.kind===`cell`){let e=Math.min(3,n.width*.06,n.height*.06),r=Math.max(2,n.radius);t.save(),t.shadowColor=`rgba(15, 23, 42, 0.4)`,t.shadowBlur=12,t.shadowOffsetY=4,s(t,n.x-e,n.y-e,n.width+e*2,n.height+e*2,r),t.fillStyle=n.color,t.fill(),t.restore();let i=Math.min(2.75,n.width/5,n.height/5);n.width>8&&n.height>8&&(s(t,n.x+i,n.y+i,n.width-i*2,n.height-i*2,Math.max(1,r-i/2)),t.lineWidth=1.5,t.strokeStyle=n.ring,t.stroke());continue}t.beginPath(),t.arc(n.x,n.y,n.size/2+4,0,Math.PI*2),t.fillStyle=n.halo,t.fill(),t.beginPath(),t.arc(n.x,n.y,n.size/2-1,0,Math.PI*2),t.fillStyle=n.color,t.fill(),t.lineWidth=2,t.strokeStyle=e.toCss(h.background),t.stroke()}}if(i.dragging){let n=i.dragging;t.beginPath(),t.arc(n.x,n.y,n.size/2,0,Math.PI*2),t.fillStyle=n.color,t.globalAlpha=.85,t.fill(),t.globalAlpha=1,t.lineWidth=2,t.strokeStyle=e.toCss(h.background),t.stroke()}let T=w?.tooltip;if(T){let{box:r,lineHeight:i,padding:a}=T;t.save(),t.shadowColor=`rgba(15, 23, 42, 0.18)`,t.shadowBlur=16,t.shadowOffsetY=6,s(t,r.x,r.y,r.width,r.height,8),t.fillStyle=e.toCss(h.background),t.fill(),t.restore(),s(t,r.x+.5,r.y+.5,r.width-1,r.height-1,8),t.strokeStyle=e.toCss(h.axis,.6),t.lineWidth=1,t.stroke(),t.textBaseline=`middle`;let o=r.y+a+i/2,c=r.x+a+2,l=r.x+r.width-a-2;if(T.text){t.font=n.font(h,12),t.fillStyle=e.toCss(h.text),t.textAlign=`left`;for(let e of T.text)t.fillText(e,c,o),o+=i}else{let{content:r}=T,a=c;r.titleColor&&(t.fillStyle=r.titleColor,t.beginPath(),t.arc(a+4,o,4,0,Math.PI*2),t.fill(),a+=14),t.font=n.font(h,12,600),t.fillStyle=e.toCss(h.text),t.textAlign=`left`,t.fillText(r.title,a,o),o+=i,r.subtitle&&(t.font=n.font(h,11),t.fillStyle=e.toCss(h.textMuted),t.fillText(r.subtitle,a,o-2),o+=i);for(let s of r.rows)a=c,s.color&&(t.fillStyle=s.color,t.beginPath(),t.arc(a+4,o,4,0,Math.PI*2),t.fill()),a+=T.swatchWidth,t.font=n.font(h,12),t.textAlign=`left`,t.fillStyle=e.toCss(h.textMuted),t.fillText(s.name,a,o),t.font=n.font(h,12,600),t.textAlign=`right`,t.fillStyle=e.toCss(h.text),t.fillText(s.value,l,o),o+=i}}},d=e=>{let{canvas:n}=e,s=n.getContext(`2d`),c=e.width,l=e.height,d=e.pixelRatio??1,f=!1,p=null,m=[],h=null,g=``,_=``,v=e.options,y=new WeakMap,b=0,x=e=>{let t=y.get(e);return t===void 0&&y.set(e,t=++b),t},S={x:0,y:0},C=0,w=``,T=(e,t)=>s?(t!==w&&(s.font=t,w=t),s.measureText(e).width):e.length*6.5,E=s?r.createCanvas2dPainter(s):null,D=globalThis,O=()=>{if(p=null,f||!s||!E)return;let e=A.getScene();if(!e)return;let r=Math.max(1,Math.round(c*d)),a=Math.max(1,Math.round(l*d));n.width!==r&&(n.width=r),n.height!==a&&(n.height=a),w=``,h!==e.model&&(h=e.model,g=i.itemsSignature(e.model,x(e.theme),e=>v.series[e]?.stack));let y=e.layout.scales,b={x:1/Math.abs(y.xPerPx),y:1/Math.abs(y.yPerPx)},T=`${g}|${t.cellStyleKey(e.model,b)}`;T!==_&&(_=T,S={x:o(e.model.base.x),y:o(e.model.base.y)},m=t.buildItems(e.model,S,++C,b)),u(s,e,m,S,d,E),w=``},k=()=>{f||p!==null||(p=n.requestAnimationFrame?n.requestAnimationFrame(O):D.requestAnimationFrame?D.requestAnimationFrame(O):setTimeout(O,16))},A=a.createChartController({options:e.options,theme:e.theme,measureText:T,onInvalidate:k});A.setSize(c,l);let j=(e,t)=>({id:e.identifier??t,touch:!0});return{setOptions:e=>{v=e,A.setOptions(e)},setTheme:e=>A.setTheme(e),resize(e,t,n){c=e,l=t,n&&(d=n),A.setSize(e,t),k()},render(){p!==null&&(n.cancelAnimationFrame?n.cancelAnimationFrame(p):D.cancelAnimationFrame?D.cancelAnimationFrame(p):clearTimeout(p)),O()},touchStart(e){e.forEach((e,t)=>A.pointerDown(e.x,e.y,j(e,t)))},touchMove(e){e.forEach((e,t)=>A.pointerMove(e.x,e.y,j(e,t)))},touchEnd(e){e.forEach((e,t)=>A.pointerUp(e.x,e.y,j(e,t)))},touchCancel(e=[{x:0,y:0}]){e.forEach((e,t)=>A.pointerCancel(j(e,t)))},pointerDown:(e,t,n)=>A.pointerDown(e,t,n),pointerMove:(e,t,n)=>A.pointerMove(e,t,n),pointerUp:(e,t,n)=>A.pointerUp(e,t,n),pointerLeave:()=>A.pointerLeave(),zoomAt:(e,t,n)=>A.zoomAt(e,t,n),resetZoom:()=>A.resetZoom(),getView:()=>A.getView(),setView:e=>A.setView(e),toggleSeries:e=>A.toggleSeries(e),clearHover:()=>A.clearHover(),getPlotRect:()=>A.getPlotRect(),toPixel:(e,t)=>A.toPixel(e,t),fromPixel:(e,t)=>A.fromPixel(e,t),getController:()=>A,on:(e,t)=>A.on(e,t),destroy(){f||(f=!0,p!==null&&(n.cancelAnimationFrame?n.cancelAnimationFrame(p):D.cancelAnimationFrame?D.cancelAnimationFrame(p):clearTimeout(p)),E?.destroy(),A.destroy())}}};exports.createCanvasChart=d,exports.drawPrimitives=c,exports.drawScene=u;
2
2
  //# sourceMappingURL=canvas.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.cjs","names":["toCss","font","createCanvas2dPainter","scenePrimitives","itemsSignature","cellStyleKey","buildItems","createChartController","require_color","require_items","require_overlay","require_canvas2d","require_signature","require_controller","mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","theme","t","l","drawScene","layout","dpr","pixelRatio","width","height","model","e","cy","mark","scales","paintData","scale","s","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","painter","items","label","box","hover","cx","grow","inset","d","tip","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","g","render","controller","pw","ph","index","sc","density","key","schedule","touchOptions","ratio","touches","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartThemeInput } from \"./theme\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\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\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fill();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n ctx.strokeText(label.text, box.x, box.y + box.height / 2);\n ctx.fillText(label.text, box.x, box.y + box.height / 2);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (mark.kind === \"band\" || mark.kind === \"guide\") continue;\n if (mark.kind === \"cell\") {\n // lifted: a little larger, with a soft shadow and an inner ring\n const grow = Math.min(3, mark.width * 0.06, mark.height * 0.06);\n const r = Math.max(2, mark.radius);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 12;\n ctx.shadowOffsetY = 4;\n roundedRect(\n ctx,\n mark.x - grow,\n mark.y - grow,\n mark.width + grow * 2,\n mark.height + grow * 2,\n r,\n );\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.restore();\n const inset = Math.min(2.75, mark.width / 5, mark.height / 5);\n if (mark.width > 8 && mark.height > 8) {\n roundedRect(\n ctx,\n mark.x + inset,\n mark.y + inset,\n mark.width - inset * 2,\n mark.height - inset * 2,\n Math.max(1, r - inset / 2),\n );\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = mark.ring;\n ctx.stroke();\n }\n continue;\n }\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) {\n const d = scene.dragging;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.globalAlpha = 0.85;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundedRect(\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, 0.6);\n ctx.lineWidth = 1;\n ctx.stroke();\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 (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\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 if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(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 }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render() {\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n render();\n },\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":"oLA+FA,IAAMc,EAAO,IAAyBC,EAAE,GAAKA,EAAE,I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MC,CAAQ,EACpD,SAAU,CACJ9B,IACJ,EAAY,GACRC,IAAY,OACVF,EAAO,qBAAsBA,EAAO,qBAAqBE,CAAO,EAC3Dc,EAAE,qBAAsBA,EAAE,qBAAqBd,CAAO,EAC1D,aAAaA,CAAO,GAE3BrB,GAAS,QAAQ,EACjBqC,EAAW,QAAQ,EACrB,CACF,CACF"}
1
+ {"version":3,"file":"canvas.cjs","names":["toCss","font","createCanvas2dPainter","scenePrimitives","itemsSignature","cellStyleKey","buildItems","createChartController","require_color","require_items","require_overlay","require_canvas2d","require_signature","require_controller","mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","theme","t","l","drawScene","layout","dpr","pixelRatio","width","height","model","e","cy","mark","scales","paintData","scale","s","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","painter","items","label","box","hover","cx","grow","inset","d","tip","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","g","render","controller","pw","ph","index","sc","density","key","schedule","touchOptions","ratio","touches","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartThemeInput } from \"./theme\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\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\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fill();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n arrows: scene.arrows,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n ctx.strokeText(label.text, box.x, box.y + box.height / 2);\n ctx.fillText(label.text, box.x, box.y + box.height / 2);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (mark.kind === \"band\" || mark.kind === \"guide\") continue;\n if (mark.kind === \"cell\") {\n // lifted: a little larger, with a soft shadow and an inner ring\n const grow = Math.min(3, mark.width * 0.06, mark.height * 0.06);\n const r = Math.max(2, mark.radius);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 12;\n ctx.shadowOffsetY = 4;\n roundedRect(\n ctx,\n mark.x - grow,\n mark.y - grow,\n mark.width + grow * 2,\n mark.height + grow * 2,\n r,\n );\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.restore();\n const inset = Math.min(2.75, mark.width / 5, mark.height / 5);\n if (mark.width > 8 && mark.height > 8) {\n roundedRect(\n ctx,\n mark.x + inset,\n mark.y + inset,\n mark.width - inset * 2,\n mark.height - inset * 2,\n Math.max(1, r - inset / 2),\n );\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = mark.ring;\n ctx.stroke();\n }\n continue;\n }\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) {\n const d = scene.dragging;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.globalAlpha = 0.85;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundedRect(\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, 0.6);\n ctx.lineWidth = 1;\n ctx.stroke();\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 (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\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 if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(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 }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render() {\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n render();\n },\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":"oLA+FA,IAAMc,EAAO,IAAyBC,EAAE,GAAKA,EAAE,IAAM,EAE/CC,GACJ,EACA,EACA,EACA,EACA,EACA,IACG,CACHC,EAAI,UAAU,EACdA,EAAI,OAAOC,EAAIH,EAAGI,CAAC,EACnBF,EAAI,OAAOC,EAAIE,EAAIL,EAAGI,CAAC,EACvBF,EAAI,MAAMC,EAAIE,EAAGD,EAAGD,EAAIE,EAAGD,EAAIJ,EAAGA,CAAC,EACnCE,EAAI,OAAOC,EAAIE,EAAGD,EAAIE,EAAIN,CAAC,EAC3BE,EAAI,MAAMC,EAAIE,EAAGD,EAAIE,EAAGH,EAAIE,EAAIL,EAAGI,EAAIE,EAAGN,CAAC,EAC3CE,EAAI,OAAOC,EAAIH,EAAGI,EAAIE,CAAC,EACvBJ,EAAI,MAAMC,EAAGC,EAAIE,EAAGH,EAAGC,EAAIE,EAAIN,EAAGA,CAAC,EACnCE,EAAI,OAAOC,EAAGC,EAAIJ,CAAC,EACnBE,EAAI,MAAMC,EAAGC,EAAGD,EAAIH,EAAGI,EAAGJ,CAAC,EAC3BE,EAAI,UAAU,CAChB,EAMaK,GACX,EACA,EACA,IACG,CACHL,EAAI,KAAK,EACTA,EAAI,UAAU,EACdA,EAAI,KAAKM,EAAK,EAAGA,EAAK,EAAGA,EAAK,MAAOA,EAAK,MAAM,EAChDN,EAAI,KAAK,EACT,EAAI,SAAW,QACf,EAAI,QAAU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EAC5C,QAAS,EAAG,EAAG,IAAMA,EAAW,OAAOxF,EAAGC,EAAGmF,CAAC,EAC9C,cAAiBI,EAAW,UAAU,EACtC,YAAeA,EAAW,QAAQ,EAClC,QAAU,GAAMA,EAAW,QAAQW,CAAC,EACpC,aAAe,GAAOX,EAAW,aAAaR,CAAE,EAChD,eAAkBQ,EAAW,WAAW,EACxC,gBAAmBA,EAAW,YAAY,EAC1C,SAAU,EAAG,IAAMA,EAAW,QAAQxF,EAAGC,CAAC,EAC1C,WAAY,EAAG,IAAMuF,EAAW,UAAUxF,EAAGC,CAAC,EAC9C,kBAAqBuF,EACrB,IAAK,EAAM,IAAaA,EAAW,GAAGY,EAAMC,CAAQ,EACpD,SAAU,CACJ9B,IACJ,EAAY,GACRC,IAAY,OACVF,EAAO,qBAAsBA,EAAO,qBAAqBE,CAAO,EAC3Dc,EAAE,qBAAsBA,EAAE,qBAAqBd,CAAO,EAC1D,aAAaA,CAAO,GAE3BrB,GAAS,QAAQ,EACjBqC,EAAW,QAAQ,EACrB,CACF,CACF"}
@@ -121,7 +121,8 @@ var u = (e) => (e[0] + e[1]) / 2, d = (e, t, n, r, i, a) => {
121
121
  annotations: n.annotations,
122
122
  pointLabels: [],
123
123
  clear: !1,
124
- connectors: n.connectors
124
+ connectors: n.connectors,
125
+ arrows: n.arrows
125
126
  }), n.pointLabels.length) {
126
127
  t.save(), t.font = a(_), t.textAlign = "left", t.textBaseline = "middle", t.lineWidth = 3, t.lineJoin = "round", t.strokeStyle = e(_.background, .9), t.fillStyle = e(_.text, .85);
127
128
  for (let { label: e, box: r } of n.pointLabels) t.strokeText(e.text, r.x, r.y + r.height / 2), t.fillText(e.text, r.x, r.y + r.height / 2);
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.js","names":["mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","toCss","theme","t","font","l","drawScene","createCanvas2dPainter","layout","dpr","pixelRatio","width","height","drawBackground","model","e","cy","mark","scales","scenePrimitives","paintData","scale","s","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","items","drawForeground","label","box","hover","cx","grow","inset","d","tip","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","painter","g","render","controller","pw","ph","itemsSignature","index","sc","density","key","cellStyleKey","buildItems","schedule","createChartController","touchOptions","ratio","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartThemeInput } from \"./theme\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\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\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fill();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n ctx.strokeText(label.text, box.x, box.y + box.height / 2);\n ctx.fillText(label.text, box.x, box.y + box.height / 2);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (mark.kind === \"band\" || mark.kind === \"guide\") continue;\n if (mark.kind === \"cell\") {\n // lifted: a little larger, with a soft shadow and an inner ring\n const grow = Math.min(3, mark.width * 0.06, mark.height * 0.06);\n const r = Math.max(2, mark.radius);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 12;\n ctx.shadowOffsetY = 4;\n roundedRect(\n ctx,\n mark.x - grow,\n mark.y - grow,\n mark.width + grow * 2,\n mark.height + grow * 2,\n r,\n );\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.restore();\n const inset = Math.min(2.75, mark.width / 5, mark.height / 5);\n if (mark.width > 8 && mark.height > 8) {\n roundedRect(\n ctx,\n mark.x + inset,\n mark.y + inset,\n mark.width - inset * 2,\n mark.height - inset * 2,\n Math.max(1, r - inset / 2),\n );\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = mark.ring;\n ctx.stroke();\n }\n continue;\n }\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) {\n const d = scene.dragging;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.globalAlpha = 0.85;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundedRect(\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, 0.6);\n ctx.lineWidth = 1;\n ctx.stroke();\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 (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\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 if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(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 }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render() {\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n render();\n },\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":";;;;;;;AA+FA,IAAMA,KAAO,OAAyBC,EAAE,KAAKA,EAAE,MAAM,GAE/CC,KACJ,GACA,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,uBAAsBA,EAAO,qBAAqBE,CAAO,IAC3De,EAAE,uBAAsBA,EAAE,qBAAqBf,CAAO,IAC1D,aAAaA,CAAO,IAE3Bc,GAAS,QAAQ,GACjBG,EAAW,QAAQ;EACrB;CACF;AACF"}
1
+ {"version":3,"file":"canvas.js","names":["mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","toCss","theme","t","font","l","drawScene","createCanvas2dPainter","layout","dpr","pixelRatio","width","height","drawBackground","model","e","cy","mark","scales","scenePrimitives","paintData","scale","s","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","items","drawForeground","label","box","hover","cx","grow","inset","d","tip","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","painter","g","render","controller","pw","ph","itemsSignature","index","sc","density","key","cellStyleKey","buildItems","schedule","createChartController","touchOptions","ratio","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartThemeInput } from \"./theme\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\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\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fill();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n arrows: scene.arrows,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n ctx.strokeText(label.text, box.x, box.y + box.height / 2);\n ctx.fillText(label.text, box.x, box.y + box.height / 2);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (mark.kind === \"band\" || mark.kind === \"guide\") continue;\n if (mark.kind === \"cell\") {\n // lifted: a little larger, with a soft shadow and an inner ring\n const grow = Math.min(3, mark.width * 0.06, mark.height * 0.06);\n const r = Math.max(2, mark.radius);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 12;\n ctx.shadowOffsetY = 4;\n roundedRect(\n ctx,\n mark.x - grow,\n mark.y - grow,\n mark.width + grow * 2,\n mark.height + grow * 2,\n r,\n );\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.restore();\n const inset = Math.min(2.75, mark.width / 5, mark.height / 5);\n if (mark.width > 8 && mark.height > 8) {\n roundedRect(\n ctx,\n mark.x + inset,\n mark.y + inset,\n mark.width - inset * 2,\n mark.height - inset * 2,\n Math.max(1, r - inset / 2),\n );\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = mark.ring;\n ctx.stroke();\n }\n continue;\n }\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) {\n const d = scene.dragging;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.globalAlpha = 0.85;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundedRect(\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, 0.6);\n ctx.lineWidth = 1;\n ctx.stroke();\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 (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\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 if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(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 }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render() {\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n render();\n },\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":";;;;;;;AA+FA,IAAMA,KAAO,OAAyBC,EAAE,KAAKA,EAAE,MAAM,GAE/CC,KACJ,GACA,GACA,GACA,GACA,GACA,MACG;CAWH,AAVAC,EAAI,UAAU,GACdA,EAAI,OAAOC,IAAIH,GAAGI,CAAC,GACnBF,EAAI,OAAOC,IAAIE,IAAIL,GAAGI,CAAC,GACvBF,EAAI,MAAMC,IAAIE,GAAGD,GAAGD,IAAIE,GAAGD,IAAIJ,GAAGA,CAAC,GACnCE,EAAI,OAAOC,IAAIE,GAAGD,IAAIE,IAAIN,CAAC,GAC3BE,EAAI,MAAMC,IAAIE,GAAGD,IAAIE,GAAGH,IAAIE,IAAIL,GAAGI,IAAIE,GAAGN,CAAC,GAC3CE,EAAI,OAAOC,IAAIH,GAAGI,IAAIE,CAAC,GACvBJ,EAAI,MAAMC,GAAGC,IAAIE,GAAGH,GAAGC,IAAIE,IAAIN,GAAGA,CAAC,GACnCE,EAAI,OAAOC,GAAGC,IAAIJ,CAAC,GACnBE,EAAI,MAAMC,GAAGC,GAAGD,IAAIH,GAAGI,GAAGJ,CAAC,GAC3BE,EAAI,UAAU;AAChB,GAMaK,KACX,GACA,GACA,MACG;CAMH,AALAL,EAAI,KAAK,GACTA,EAAI,UAAU,GACdA,EAAI,KAAKM,EAAK,GAAGA,EAAK,GAAGA,EAAK,OAAOA,EAAK,MAAM,GAChDN,EAAI,KAAK,GACT,EAAI,WAAW,SACf,EAAI,UAAU;CACd,KAAK,IAAMO,KAAKC,GACd,IAAID,EAAE,SAAS,QAqBb,AApBA,EAAI,cAAcA,EAAE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