@antv/g6 5.0.0-beta.26 → 5.0.0-beta.28

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 (592) hide show
  1. package/LICENSE +21 -0
  2. package/dist/g6.min.js +2 -2
  3. package/esm/constant/shape.d.ts +2 -2
  4. package/esm/index.d.ts +6 -2
  5. package/esm/index.js +1 -1
  6. package/esm/index.js.map +1 -1
  7. package/esm/item/combo.d.ts +6 -4
  8. package/esm/item/combo.js +13 -4
  9. package/esm/item/combo.js.map +1 -1
  10. package/esm/item/edge.d.ts +12 -4
  11. package/esm/item/edge.js +106 -18
  12. package/esm/item/edge.js.map +1 -1
  13. package/esm/item/item.d.ts +20 -10
  14. package/esm/item/item.js +114 -63
  15. package/esm/item/item.js.map +1 -1
  16. package/esm/item/node.d.ts +11 -4
  17. package/esm/item/node.js +102 -8
  18. package/esm/item/node.js.map +1 -1
  19. package/esm/runtime/controller/data.d.ts +5 -1
  20. package/esm/runtime/controller/data.js +53 -11
  21. package/esm/runtime/controller/data.js.map +1 -1
  22. package/esm/runtime/controller/index.d.ts +1 -1
  23. package/esm/runtime/controller/index.js +1 -1
  24. package/esm/runtime/controller/index.js.map +1 -1
  25. package/esm/runtime/controller/interaction.js +4 -3
  26. package/esm/runtime/controller/interaction.js.map +1 -1
  27. package/esm/runtime/controller/item.d.ts +25 -13
  28. package/esm/runtime/controller/item.js +284 -116
  29. package/esm/runtime/controller/item.js.map +1 -1
  30. package/esm/runtime/controller/layout.d.ts +3 -0
  31. package/esm/runtime/controller/layout.js +176 -99
  32. package/esm/runtime/controller/layout.js.map +1 -1
  33. package/esm/runtime/controller/plugin.d.ts +3 -0
  34. package/esm/runtime/controller/plugin.js +66 -24
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/controller/viewport.js +9 -2
  37. package/esm/runtime/controller/viewport.js.map +1 -1
  38. package/esm/runtime/graph.d.ts +75 -31
  39. package/esm/runtime/graph.js +320 -161
  40. package/esm/runtime/graph.js.map +1 -1
  41. package/esm/runtime/hooks.d.ts +2 -2
  42. package/esm/runtime/hooks.js +2 -2
  43. package/esm/stdlib/behavior/click-select.js +9 -3
  44. package/esm/stdlib/behavior/click-select.js.map +1 -1
  45. package/esm/stdlib/behavior/create-edge.d.ts +1 -1
  46. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
  47. package/esm/stdlib/behavior/drag-canvas.js +6 -3
  48. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  49. package/esm/stdlib/behavior/drag-combo.js +8 -8
  50. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  51. package/esm/stdlib/behavior/drag-node.d.ts +5 -1
  52. package/esm/stdlib/behavior/drag-node.js +122 -28
  53. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  54. package/esm/stdlib/behavior/hover-activate.d.ts +1 -1
  55. package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
  56. package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
  57. package/esm/stdlib/behavior/scroll-canvas.js +8 -8
  58. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
  59. package/esm/stdlib/behavior/track-canvas-3d.d.ts +1 -1
  60. package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
  61. package/esm/stdlib/behavior/zoom-canvas.d.ts +16 -0
  62. package/esm/stdlib/behavior/zoom-canvas.js +110 -8
  63. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  64. package/esm/stdlib/data/mapNodeSize.js +2 -2
  65. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  66. package/esm/stdlib/data/transformV4Data.js +12 -6
  67. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  68. package/esm/stdlib/data/validateData.js +2 -2
  69. package/esm/stdlib/data/validateData.js.map +1 -1
  70. package/esm/stdlib/index.d.ts +8 -4
  71. package/esm/stdlib/index.js +10 -6
  72. package/esm/stdlib/index.js.map +1 -1
  73. package/esm/stdlib/item/combo/circle.js +12 -7
  74. package/esm/stdlib/item/combo/circle.js.map +1 -1
  75. package/esm/stdlib/item/combo/rect.js +12 -7
  76. package/esm/stdlib/item/combo/rect.js.map +1 -1
  77. package/esm/stdlib/item/edge/base.d.ts +24 -16
  78. package/esm/stdlib/item/edge/base.js +60 -121
  79. package/esm/stdlib/item/edge/base.js.map +1 -1
  80. package/esm/stdlib/item/edge/cubic.js +11 -6
  81. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  82. package/esm/stdlib/item/edge/line.js +12 -7
  83. package/esm/stdlib/item/edge/line.js.map +1 -1
  84. package/esm/stdlib/item/edge/loop.js +6 -1
  85. package/esm/stdlib/item/edge/loop.js.map +1 -1
  86. package/esm/stdlib/item/edge/polyline.js +11 -6
  87. package/esm/stdlib/item/edge/polyline.js.map +1 -1
  88. package/esm/stdlib/item/edge/quadratic.js +11 -6
  89. package/esm/stdlib/item/edge/quadratic.js.map +1 -1
  90. package/esm/stdlib/item/node/base.d.ts +26 -33
  91. package/esm/stdlib/item/node/base.js +98 -196
  92. package/esm/stdlib/item/node/base.js.map +1 -1
  93. package/esm/stdlib/item/node/base3d.d.ts +11 -2
  94. package/esm/stdlib/item/node/base3d.js +14 -3
  95. package/esm/stdlib/item/node/base3d.js.map +1 -1
  96. package/esm/stdlib/item/node/circle.js +13 -7
  97. package/esm/stdlib/item/node/circle.js.map +1 -1
  98. package/esm/stdlib/item/node/cube.d.ts +0 -2
  99. package/esm/stdlib/item/node/cube.js +12 -9
  100. package/esm/stdlib/item/node/cube.js.map +1 -1
  101. package/esm/stdlib/item/node/diamond.js +20 -11
  102. package/esm/stdlib/item/node/diamond.js.map +1 -1
  103. package/esm/stdlib/item/node/donut.js +18 -8
  104. package/esm/stdlib/item/node/donut.js.map +1 -1
  105. package/esm/stdlib/item/node/ellipse.js +11 -6
  106. package/esm/stdlib/item/node/ellipse.js.map +1 -1
  107. package/esm/stdlib/item/node/hexagon.js +12 -7
  108. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  109. package/esm/stdlib/item/node/image.js +13 -3
  110. package/esm/stdlib/item/node/image.js.map +1 -1
  111. package/esm/stdlib/item/node/index.d.ts +1 -0
  112. package/esm/stdlib/item/node/index.js +1 -0
  113. package/esm/stdlib/item/node/index.js.map +1 -1
  114. package/esm/stdlib/item/node/modelRect.d.ts +33 -1
  115. package/esm/stdlib/item/node/modelRect.js +135 -78
  116. package/esm/stdlib/item/node/modelRect.js.map +1 -1
  117. package/esm/stdlib/item/node/plane.d.ts +38 -0
  118. package/esm/stdlib/item/node/plane.js +62 -0
  119. package/esm/stdlib/item/node/plane.js.map +1 -0
  120. package/esm/stdlib/item/node/rect.js +12 -7
  121. package/esm/stdlib/item/node/rect.js.map +1 -1
  122. package/esm/stdlib/item/node/sphere.js +12 -7
  123. package/esm/stdlib/item/node/sphere.js.map +1 -1
  124. package/esm/stdlib/item/node/star.d.ts +1 -3
  125. package/esm/stdlib/item/node/star.js +16 -10
  126. package/esm/stdlib/item/node/star.js.map +1 -1
  127. package/esm/stdlib/item/node/triangle.js +17 -7
  128. package/esm/stdlib/item/node/triangle.js.map +1 -1
  129. package/esm/stdlib/plugin/edgeBundling/index.d.ts +75 -0
  130. package/esm/stdlib/plugin/edgeBundling/index.js +364 -0
  131. package/esm/stdlib/plugin/edgeBundling/index.js.map +1 -0
  132. package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
  133. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  134. package/esm/stdlib/plugin/fisheye/index.js +3 -2
  135. package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
  136. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  137. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  138. package/esm/stdlib/plugin/hull/bubbleset.d.ts +1 -1
  139. package/esm/stdlib/plugin/hull/bubbleset.js +13 -13
  140. package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -1
  141. package/esm/stdlib/plugin/hull/index.d.ts +1 -1
  142. package/esm/stdlib/plugin/hull/index.js +4 -4
  143. package/esm/stdlib/plugin/hull/util.js +1 -1
  144. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  145. package/esm/stdlib/plugin/index.d.ts +2 -0
  146. package/esm/stdlib/plugin/index.js +2 -0
  147. package/esm/stdlib/plugin/index.js.map +1 -1
  148. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  149. package/esm/stdlib/plugin/legend/index.js +10 -10
  150. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  151. package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
  152. package/esm/stdlib/plugin/lodController/index.js +558 -0
  153. package/esm/stdlib/plugin/lodController/index.js.map +1 -0
  154. package/esm/stdlib/plugin/menu/index.js +1 -1
  155. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  156. package/esm/stdlib/plugin/minimap/index.js +12 -14
  157. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  158. package/esm/stdlib/plugin/snapline/index.d.ts +2 -2
  159. package/esm/stdlib/plugin/snapline/index.js +2 -2
  160. package/esm/stdlib/plugin/snapline/index.js.map +1 -1
  161. package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
  162. package/esm/stdlib/plugin/toolbar/index.js +27 -29
  163. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/tooltip/index.d.ts +1 -1
  165. package/esm/stdlib/plugin/tooltip/index.js +3 -3
  166. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  167. package/{lib/stdlib/plugin/watermaker → esm/stdlib/plugin/watermarker}/index.d.ts +1 -1
  168. package/esm/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
  169. package/esm/stdlib/plugin/watermarker/index.js.map +1 -0
  170. package/esm/stdlib/selector/lasso.js +3 -3
  171. package/esm/stdlib/selector/lasso.js.map +1 -1
  172. package/esm/stdlib/theme/dark.js +31 -34
  173. package/esm/stdlib/theme/dark.js.map +1 -1
  174. package/esm/stdlib/theme/light.js +29 -29
  175. package/esm/stdlib/theme/light.js.map +1 -1
  176. package/esm/stdlib/themeSolver/spec.js +5 -5
  177. package/esm/stdlib/themeSolver/spec.js.map +1 -1
  178. package/esm/stdlib/themeSolver/subject.d.ts +1 -1
  179. package/esm/stdlib/themeSolver/subject.js +1 -1
  180. package/esm/types/animate.d.ts +2 -2
  181. package/esm/types/combo.d.ts +2 -2
  182. package/esm/types/data.d.ts +3 -1
  183. package/esm/types/edge.d.ts +2 -2
  184. package/esm/types/graph.d.ts +113 -51
  185. package/esm/types/hook.d.ts +18 -3
  186. package/esm/types/index.d.ts +2 -1
  187. package/esm/types/index.js +1 -0
  188. package/esm/types/index.js.map +1 -1
  189. package/esm/types/item.d.ts +17 -25
  190. package/esm/types/item.js.map +1 -1
  191. package/esm/types/layout.d.ts +8 -3
  192. package/esm/types/layout.js.map +1 -1
  193. package/esm/types/node.d.ts +4 -33
  194. package/esm/types/plugin.d.ts +2 -1
  195. package/esm/types/plugin.js +2 -1
  196. package/esm/types/plugin.js.map +1 -1
  197. package/esm/types/spec.d.ts +6 -5
  198. package/esm/types/theme.d.ts +8 -8
  199. package/esm/types/view.d.ts +1 -1
  200. package/esm/util/animate.d.ts +7 -2
  201. package/esm/util/animate.js +38 -24
  202. package/esm/util/animate.js.map +1 -1
  203. package/esm/util/bbox.d.ts +7 -1
  204. package/esm/util/bbox.js +16 -0
  205. package/esm/util/bbox.js.map +1 -1
  206. package/esm/util/canvas.d.ts +1 -1
  207. package/esm/util/canvas.js +7 -1
  208. package/esm/util/canvas.js.map +1 -1
  209. package/esm/util/data.d.ts +16 -10
  210. package/esm/util/data.js +27 -14
  211. package/esm/util/data.js.map +1 -1
  212. package/esm/util/dom.js +5 -5
  213. package/esm/util/dom.js.map +1 -1
  214. package/esm/util/extend.js +1 -1
  215. package/esm/util/extend.js.map +1 -1
  216. package/esm/util/item.d.ts +1 -1
  217. package/esm/util/item.js +9 -9
  218. package/esm/util/item.js.map +1 -1
  219. package/esm/util/mapper.js +1 -1
  220. package/esm/util/mapper.js.map +1 -1
  221. package/esm/util/math.d.ts +1 -1
  222. package/esm/util/math.js +1 -1
  223. package/esm/util/path.d.ts +7 -2
  224. package/esm/util/path.js +73 -2
  225. package/esm/util/path.js.map +1 -1
  226. package/esm/util/polyline.d.ts +12 -2
  227. package/esm/util/polyline.js +25 -20
  228. package/esm/util/polyline.js.map +1 -1
  229. package/esm/util/router.d.ts +1 -1
  230. package/esm/util/router.js +26 -25
  231. package/esm/util/router.js.map +1 -1
  232. package/esm/util/shape.d.ts +26 -14
  233. package/esm/util/shape.js +56 -32
  234. package/esm/util/shape.js.map +1 -1
  235. package/esm/util/shape3d.d.ts +2 -2
  236. package/esm/util/shape3d.js +9 -12
  237. package/esm/util/shape3d.js.map +1 -1
  238. package/esm/util/zoom.d.ts +5 -8
  239. package/esm/util/zoom.js +15 -20
  240. package/esm/util/zoom.js.map +1 -1
  241. package/lib/constant/shape.d.ts +2 -2
  242. package/lib/index.d.ts +6 -2
  243. package/lib/index.js +1 -1
  244. package/lib/index.js.map +1 -1
  245. package/lib/item/combo.d.ts +6 -4
  246. package/lib/item/combo.js +13 -4
  247. package/lib/item/combo.js.map +1 -1
  248. package/lib/item/edge.d.ts +12 -4
  249. package/lib/item/edge.js +105 -17
  250. package/lib/item/edge.js.map +1 -1
  251. package/lib/item/item.d.ts +20 -10
  252. package/lib/item/item.js +112 -61
  253. package/lib/item/item.js.map +1 -1
  254. package/lib/item/node.d.ts +11 -4
  255. package/lib/item/node.js +102 -8
  256. package/lib/item/node.js.map +1 -1
  257. package/lib/runtime/controller/data.d.ts +5 -1
  258. package/lib/runtime/controller/data.js +52 -10
  259. package/lib/runtime/controller/data.js.map +1 -1
  260. package/lib/runtime/controller/index.d.ts +1 -1
  261. package/lib/runtime/controller/index.js +1 -1
  262. package/lib/runtime/controller/index.js.map +1 -1
  263. package/lib/runtime/controller/interaction.js +3 -2
  264. package/lib/runtime/controller/interaction.js.map +1 -1
  265. package/lib/runtime/controller/item.d.ts +25 -13
  266. package/lib/runtime/controller/item.js +281 -113
  267. package/lib/runtime/controller/item.js.map +1 -1
  268. package/lib/runtime/controller/layout.d.ts +3 -0
  269. package/lib/runtime/controller/layout.js +176 -122
  270. package/lib/runtime/controller/layout.js.map +1 -1
  271. package/lib/runtime/controller/plugin.d.ts +3 -0
  272. package/lib/runtime/controller/plugin.js +66 -24
  273. package/lib/runtime/controller/plugin.js.map +1 -1
  274. package/lib/runtime/controller/viewport.js +9 -2
  275. package/lib/runtime/controller/viewport.js.map +1 -1
  276. package/lib/runtime/graph.d.ts +75 -31
  277. package/lib/runtime/graph.js +320 -161
  278. package/lib/runtime/graph.js.map +1 -1
  279. package/lib/runtime/hooks.d.ts +2 -2
  280. package/lib/runtime/hooks.js +2 -2
  281. package/lib/stdlib/behavior/click-select.js +9 -3
  282. package/lib/stdlib/behavior/click-select.js.map +1 -1
  283. package/lib/stdlib/behavior/create-edge.d.ts +1 -1
  284. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
  285. package/lib/stdlib/behavior/drag-canvas.js +6 -3
  286. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  287. package/lib/stdlib/behavior/drag-combo.js +8 -8
  288. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  289. package/lib/stdlib/behavior/drag-node.d.ts +5 -1
  290. package/lib/stdlib/behavior/drag-node.js +122 -28
  291. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  292. package/lib/stdlib/behavior/hover-activate.d.ts +1 -1
  293. package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
  294. package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
  295. package/lib/stdlib/behavior/scroll-canvas.js +8 -8
  296. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
  297. package/lib/stdlib/behavior/track-canvas-3d.d.ts +1 -1
  298. package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
  299. package/lib/stdlib/behavior/zoom-canvas.d.ts +16 -0
  300. package/lib/stdlib/behavior/zoom-canvas.js +109 -7
  301. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  302. package/lib/stdlib/data/mapNodeSize.js +2 -2
  303. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  304. package/lib/stdlib/data/transformV4Data.js +12 -6
  305. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  306. package/lib/stdlib/data/validateData.js +2 -2
  307. package/lib/stdlib/data/validateData.js.map +1 -1
  308. package/lib/stdlib/index.d.ts +8 -4
  309. package/lib/stdlib/index.js +12 -8
  310. package/lib/stdlib/index.js.map +1 -1
  311. package/lib/stdlib/item/combo/circle.js +12 -7
  312. package/lib/stdlib/item/combo/circle.js.map +1 -1
  313. package/lib/stdlib/item/combo/rect.js +12 -7
  314. package/lib/stdlib/item/combo/rect.js.map +1 -1
  315. package/lib/stdlib/item/edge/base.d.ts +24 -16
  316. package/lib/stdlib/item/edge/base.js +60 -121
  317. package/lib/stdlib/item/edge/base.js.map +1 -1
  318. package/lib/stdlib/item/edge/cubic.js +11 -6
  319. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  320. package/lib/stdlib/item/edge/line.js +12 -7
  321. package/lib/stdlib/item/edge/line.js.map +1 -1
  322. package/lib/stdlib/item/edge/loop.js +6 -1
  323. package/lib/stdlib/item/edge/loop.js.map +1 -1
  324. package/lib/stdlib/item/edge/polyline.js +11 -6
  325. package/lib/stdlib/item/edge/polyline.js.map +1 -1
  326. package/lib/stdlib/item/edge/quadratic.js +11 -6
  327. package/lib/stdlib/item/edge/quadratic.js.map +1 -1
  328. package/lib/stdlib/item/node/base.d.ts +26 -33
  329. package/lib/stdlib/item/node/base.js +98 -196
  330. package/lib/stdlib/item/node/base.js.map +1 -1
  331. package/lib/stdlib/item/node/base3d.d.ts +11 -2
  332. package/lib/stdlib/item/node/base3d.js +14 -3
  333. package/lib/stdlib/item/node/base3d.js.map +1 -1
  334. package/lib/stdlib/item/node/circle.js +13 -7
  335. package/lib/stdlib/item/node/circle.js.map +1 -1
  336. package/lib/stdlib/item/node/cube.d.ts +0 -2
  337. package/lib/stdlib/item/node/cube.js +12 -9
  338. package/lib/stdlib/item/node/cube.js.map +1 -1
  339. package/lib/stdlib/item/node/diamond.js +20 -11
  340. package/lib/stdlib/item/node/diamond.js.map +1 -1
  341. package/lib/stdlib/item/node/donut.js +18 -8
  342. package/lib/stdlib/item/node/donut.js.map +1 -1
  343. package/lib/stdlib/item/node/ellipse.js +11 -6
  344. package/lib/stdlib/item/node/ellipse.js.map +1 -1
  345. package/lib/stdlib/item/node/hexagon.js +12 -7
  346. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  347. package/lib/stdlib/item/node/image.js +13 -3
  348. package/lib/stdlib/item/node/image.js.map +1 -1
  349. package/lib/stdlib/item/node/index.d.ts +1 -0
  350. package/lib/stdlib/item/node/index.js +1 -0
  351. package/lib/stdlib/item/node/index.js.map +1 -1
  352. package/lib/stdlib/item/node/modelRect.d.ts +33 -1
  353. package/lib/stdlib/item/node/modelRect.js +135 -78
  354. package/lib/stdlib/item/node/modelRect.js.map +1 -1
  355. package/lib/stdlib/item/node/plane.d.ts +38 -0
  356. package/lib/stdlib/item/node/plane.js +66 -0
  357. package/lib/stdlib/item/node/plane.js.map +1 -0
  358. package/lib/stdlib/item/node/rect.js +12 -7
  359. package/lib/stdlib/item/node/rect.js.map +1 -1
  360. package/lib/stdlib/item/node/sphere.js +12 -7
  361. package/lib/stdlib/item/node/sphere.js.map +1 -1
  362. package/lib/stdlib/item/node/star.d.ts +1 -3
  363. package/lib/stdlib/item/node/star.js +16 -10
  364. package/lib/stdlib/item/node/star.js.map +1 -1
  365. package/lib/stdlib/item/node/triangle.js +17 -7
  366. package/lib/stdlib/item/node/triangle.js.map +1 -1
  367. package/lib/stdlib/plugin/edgeBundling/index.d.ts +75 -0
  368. package/lib/stdlib/plugin/edgeBundling/index.js +368 -0
  369. package/lib/stdlib/plugin/edgeBundling/index.js.map +1 -0
  370. package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
  371. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  372. package/lib/stdlib/plugin/fisheye/index.js +2 -1
  373. package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
  374. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  375. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  376. package/lib/stdlib/plugin/hull/bubbleset.d.ts +1 -1
  377. package/lib/stdlib/plugin/hull/bubbleset.js +13 -13
  378. package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -1
  379. package/lib/stdlib/plugin/hull/index.d.ts +1 -1
  380. package/lib/stdlib/plugin/hull/index.js +4 -4
  381. package/lib/stdlib/plugin/hull/util.js +1 -1
  382. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  383. package/lib/stdlib/plugin/index.d.ts +2 -0
  384. package/lib/stdlib/plugin/index.js +2 -0
  385. package/lib/stdlib/plugin/index.js.map +1 -1
  386. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  387. package/lib/stdlib/plugin/legend/index.js +10 -10
  388. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  389. package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
  390. package/lib/stdlib/plugin/lodController/index.js +562 -0
  391. package/lib/stdlib/plugin/lodController/index.js.map +1 -0
  392. package/lib/stdlib/plugin/menu/index.js +1 -1
  393. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  394. package/lib/stdlib/plugin/minimap/index.js +12 -14
  395. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  396. package/lib/stdlib/plugin/snapline/index.d.ts +2 -2
  397. package/lib/stdlib/plugin/snapline/index.js +2 -2
  398. package/lib/stdlib/plugin/snapline/index.js.map +1 -1
  399. package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
  400. package/lib/stdlib/plugin/toolbar/index.js +27 -29
  401. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  402. package/lib/stdlib/plugin/tooltip/index.d.ts +1 -1
  403. package/lib/stdlib/plugin/tooltip/index.js +3 -3
  404. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  405. package/{esm/stdlib/plugin/watermaker → lib/stdlib/plugin/watermarker}/index.d.ts +1 -1
  406. package/lib/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
  407. package/lib/stdlib/plugin/watermarker/index.js.map +1 -0
  408. package/lib/stdlib/selector/lasso.js +3 -3
  409. package/lib/stdlib/selector/lasso.js.map +1 -1
  410. package/lib/stdlib/theme/dark.js +31 -34
  411. package/lib/stdlib/theme/dark.js.map +1 -1
  412. package/lib/stdlib/theme/light.js +29 -29
  413. package/lib/stdlib/theme/light.js.map +1 -1
  414. package/lib/stdlib/themeSolver/spec.js +5 -5
  415. package/lib/stdlib/themeSolver/spec.js.map +1 -1
  416. package/lib/stdlib/themeSolver/subject.d.ts +1 -1
  417. package/lib/stdlib/themeSolver/subject.js +1 -1
  418. package/lib/types/animate.d.ts +2 -2
  419. package/lib/types/combo.d.ts +2 -2
  420. package/lib/types/data.d.ts +3 -1
  421. package/lib/types/edge.d.ts +2 -2
  422. package/lib/types/graph.d.ts +113 -51
  423. package/lib/types/hook.d.ts +18 -3
  424. package/lib/types/index.d.ts +2 -1
  425. package/lib/types/index.js +3 -1
  426. package/lib/types/index.js.map +1 -1
  427. package/lib/types/item.d.ts +17 -25
  428. package/lib/types/item.js.map +1 -1
  429. package/lib/types/layout.d.ts +8 -3
  430. package/lib/types/layout.js.map +1 -1
  431. package/lib/types/node.d.ts +4 -33
  432. package/lib/types/plugin.d.ts +2 -1
  433. package/lib/types/plugin.js +2 -1
  434. package/lib/types/plugin.js.map +1 -1
  435. package/lib/types/spec.d.ts +6 -5
  436. package/lib/types/theme.d.ts +8 -8
  437. package/lib/types/view.d.ts +1 -1
  438. package/lib/util/animate.d.ts +7 -2
  439. package/lib/util/animate.js +38 -24
  440. package/lib/util/animate.js.map +1 -1
  441. package/lib/util/bbox.d.ts +7 -1
  442. package/lib/util/bbox.js +18 -1
  443. package/lib/util/bbox.js.map +1 -1
  444. package/lib/util/canvas.d.ts +1 -1
  445. package/lib/util/canvas.js +7 -1
  446. package/lib/util/canvas.js.map +1 -1
  447. package/lib/util/data.d.ts +16 -10
  448. package/lib/util/data.js +30 -16
  449. package/lib/util/data.js.map +1 -1
  450. package/lib/util/dom.js +5 -5
  451. package/lib/util/dom.js.map +1 -1
  452. package/lib/util/extend.js +4 -7
  453. package/lib/util/extend.js.map +1 -1
  454. package/lib/util/item.d.ts +1 -1
  455. package/lib/util/item.js +9 -9
  456. package/lib/util/item.js.map +1 -1
  457. package/lib/util/mapper.js +1 -1
  458. package/lib/util/mapper.js.map +1 -1
  459. package/lib/util/math.d.ts +1 -1
  460. package/lib/util/math.js +1 -1
  461. package/lib/util/path.d.ts +7 -2
  462. package/lib/util/path.js +73 -2
  463. package/lib/util/path.js.map +1 -1
  464. package/lib/util/polyline.d.ts +12 -2
  465. package/lib/util/polyline.js +28 -21
  466. package/lib/util/polyline.js.map +1 -1
  467. package/lib/util/router.d.ts +1 -1
  468. package/lib/util/router.js +26 -25
  469. package/lib/util/router.js.map +1 -1
  470. package/lib/util/shape.d.ts +26 -14
  471. package/lib/util/shape.js +54 -30
  472. package/lib/util/shape.js.map +1 -1
  473. package/lib/util/shape3d.d.ts +2 -2
  474. package/lib/util/shape3d.js +9 -12
  475. package/lib/util/shape3d.js.map +1 -1
  476. package/lib/util/zoom.d.ts +5 -8
  477. package/lib/util/zoom.js +17 -22
  478. package/lib/util/zoom.js.map +1 -1
  479. package/package.json +37 -53
  480. package/src/index.ts +1 -1
  481. package/src/item/combo.ts +15 -6
  482. package/src/item/edge.ts +135 -19
  483. package/src/item/item.ts +139 -66
  484. package/src/item/node.ts +125 -12
  485. package/src/runtime/controller/data.ts +80 -17
  486. package/src/runtime/controller/index.ts +1 -1
  487. package/src/runtime/controller/interaction.ts +5 -4
  488. package/src/runtime/controller/item.ts +398 -170
  489. package/src/runtime/controller/layout.ts +252 -113
  490. package/src/runtime/controller/plugin.ts +86 -33
  491. package/src/runtime/controller/viewport.ts +8 -2
  492. package/src/runtime/graph.ts +494 -212
  493. package/src/runtime/hooks.ts +2 -2
  494. package/src/stdlib/behavior/click-select.ts +8 -3
  495. package/src/stdlib/behavior/create-edge.ts +1 -1
  496. package/src/stdlib/behavior/drag-canvas.ts +7 -4
  497. package/src/stdlib/behavior/drag-combo.ts +8 -8
  498. package/src/stdlib/behavior/drag-node.ts +166 -51
  499. package/src/stdlib/behavior/hover-activate.ts +1 -1
  500. package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
  501. package/src/stdlib/behavior/rotate-canvas-3d.ts +2 -2
  502. package/src/stdlib/behavior/scroll-canvas.ts +8 -8
  503. package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
  504. package/src/stdlib/behavior/zoom-canvas-3d.ts +1 -1
  505. package/src/stdlib/behavior/zoom-canvas.ts +137 -16
  506. package/src/stdlib/data/mapNodeSize.ts +2 -2
  507. package/src/stdlib/data/transformV4Data.ts +27 -3
  508. package/src/stdlib/data/validateData.ts +2 -2
  509. package/src/stdlib/index.ts +11 -4
  510. package/src/stdlib/item/combo/circle.ts +26 -11
  511. package/src/stdlib/item/combo/rect.ts +26 -11
  512. package/src/stdlib/item/edge/base.ts +60 -163
  513. package/src/stdlib/item/edge/cubic.ts +26 -4
  514. package/src/stdlib/item/edge/line.ts +27 -5
  515. package/src/stdlib/item/edge/loop.ts +6 -1
  516. package/src/stdlib/item/edge/polyline.ts +26 -4
  517. package/src/stdlib/item/edge/quadratic.ts +26 -4
  518. package/src/stdlib/item/node/base.ts +91 -260
  519. package/src/stdlib/item/node/base3d.ts +19 -3
  520. package/src/stdlib/item/node/circle.ts +29 -8
  521. package/src/stdlib/item/node/cube.ts +26 -12
  522. package/src/stdlib/item/node/diamond.ts +35 -11
  523. package/src/stdlib/item/node/donut.ts +32 -18
  524. package/src/stdlib/item/node/ellipse.ts +25 -11
  525. package/src/stdlib/item/node/hexagon.ts +27 -7
  526. package/src/stdlib/item/node/image.ts +13 -5
  527. package/src/stdlib/item/node/index.ts +1 -0
  528. package/src/stdlib/item/node/modelRect.ts +230 -136
  529. package/src/stdlib/item/node/plane.ts +121 -0
  530. package/src/stdlib/item/node/rect.ts +27 -7
  531. package/src/stdlib/item/node/sphere.ts +26 -10
  532. package/src/stdlib/item/node/star.ts +32 -11
  533. package/src/stdlib/item/node/triangle.ts +32 -9
  534. package/src/stdlib/plugin/edgeBundling/index.ts +529 -0
  535. package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
  536. package/src/stdlib/plugin/fisheye/index.ts +3 -2
  537. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  538. package/src/stdlib/plugin/hull/bubbleset.ts +14 -14
  539. package/src/stdlib/plugin/hull/index.ts +4 -4
  540. package/src/stdlib/plugin/hull/util.ts +1 -1
  541. package/src/stdlib/plugin/index.ts +2 -0
  542. package/src/stdlib/plugin/legend/index.ts +11 -12
  543. package/src/stdlib/plugin/lodController/index.ts +603 -0
  544. package/src/stdlib/plugin/menu/index.ts +1 -1
  545. package/src/stdlib/plugin/minimap/index.ts +12 -14
  546. package/src/stdlib/plugin/snapline/index.ts +3 -3
  547. package/src/stdlib/plugin/toolbar/index.ts +29 -31
  548. package/src/stdlib/plugin/tooltip/index.ts +4 -4
  549. package/src/stdlib/plugin/{watermaker → watermarker}/index.ts +8 -8
  550. package/src/stdlib/selector/lasso.ts +3 -3
  551. package/src/stdlib/theme/dark.ts +31 -34
  552. package/src/stdlib/theme/light.ts +29 -29
  553. package/src/stdlib/themeSolver/spec.ts +5 -5
  554. package/src/stdlib/themeSolver/subject.ts +1 -1
  555. package/src/types/animate.ts +3 -3
  556. package/src/types/combo.ts +2 -2
  557. package/src/types/data.ts +5 -1
  558. package/src/types/edge.ts +2 -2
  559. package/src/types/graph.ts +144 -61
  560. package/src/types/hook.ts +37 -3
  561. package/src/types/index.ts +2 -1
  562. package/src/types/item.ts +23 -30
  563. package/src/types/layout.ts +21 -16
  564. package/src/types/node.ts +4 -33
  565. package/src/types/plugin.ts +3 -1
  566. package/src/types/spec.ts +6 -5
  567. package/src/types/theme.ts +8 -8
  568. package/src/types/view.ts +1 -1
  569. package/src/util/animate.ts +105 -79
  570. package/src/util/bbox.ts +26 -1
  571. package/src/util/canvas.ts +8 -0
  572. package/src/util/data.ts +26 -15
  573. package/src/util/dom.ts +6 -6
  574. package/src/util/extend.ts +1 -1
  575. package/src/util/item.ts +16 -2
  576. package/src/util/mapper.ts +1 -1
  577. package/src/util/math.ts +1 -1
  578. package/src/util/path.ts +73 -3
  579. package/src/util/polyline.ts +33 -26
  580. package/src/util/router.ts +28 -26
  581. package/src/util/shape.ts +96 -44
  582. package/src/util/shape3d.ts +16 -10
  583. package/src/util/zoom.ts +19 -25
  584. package/esm/runtime/controller/extension.d.ts +0 -9
  585. package/esm/runtime/controller/extension.js +0 -11
  586. package/esm/runtime/controller/extension.js.map +0 -1
  587. package/esm/stdlib/plugin/watermaker/index.js.map +0 -1
  588. package/lib/runtime/controller/extension.d.ts +0 -9
  589. package/lib/runtime/controller/extension.js +0 -15
  590. package/lib/runtime/controller/extension.js.map +0 -1
  591. package/lib/stdlib/plugin/watermaker/index.js.map +0 -1
  592. package/src/runtime/controller/extension.ts +0 -14
@@ -25,13 +25,15 @@ import { changeRenderer, createCanvas } from '../util/canvas';
25
25
  import { createDOM } from '../util/dom';
26
26
  import { getLayoutBounds } from '../util/layout';
27
27
  import { formatPadding } from '../util/shape';
28
- import { DataController, ExtensionController, InteractionController, ItemController, LayoutController, ThemeController, ViewportController, } from './controller';
29
- import { PluginController } from './controller/plugin';
28
+ import { cloneJSON, isEmptyGraph } from '../util/data';
29
+ import { getCombinedCanvasesBounds } from '../util/bbox';
30
+ import { DataController, InteractionController, ItemController, LayoutController, ThemeController, ViewportController, PluginController, } from './controller';
30
31
  import Hook from './hooks';
31
- import { isEmptyGraph } from '../util/data';
32
32
  export class Graph extends EventEmitter {
33
33
  constructor(spec) {
34
34
  super();
35
+ // the tag to indicate whether the graph instance is destroyed
36
+ this.destroyed = false;
35
37
  this.defaultSpecification = {
36
38
  theme: {
37
39
  type: 'spec',
@@ -62,7 +64,9 @@ export class Graph extends EventEmitter {
62
64
  canvases: {
63
65
  background: this.backgroundCanvas,
64
66
  main: this.canvas,
67
+ label: this.labelCanvas,
65
68
  transient: this.transientCanvas,
69
+ transientLabel: this.transientLabelCanvas,
66
70
  },
67
71
  });
68
72
  const { data } = spec;
@@ -79,13 +83,12 @@ export class Graph extends EventEmitter {
79
83
  this.interactionController = new InteractionController(this);
80
84
  this.layoutController = new LayoutController(this);
81
85
  this.themeController = new ThemeController(this);
82
- this.itemController = new ItemController(this);
83
86
  this.viewportController = new ViewportController(this);
84
- this.extensionController = new ExtensionController(this);
87
+ this.itemController = new ItemController(this);
85
88
  this.pluginController = new PluginController(this);
86
89
  }
87
90
  initCanvas() {
88
- const { renderer, container, canvas, backgroundCanvas, transientCanvas, width, height, } = this.specification;
91
+ const { renderer, container, width, height } = this.specification;
89
92
  let pixelRatio;
90
93
  if (renderer && !isString(renderer)) {
91
94
  // @ts-ignore
@@ -97,13 +100,7 @@ export class Graph extends EventEmitter {
97
100
  // @ts-ignore
98
101
  this.rendererType = renderer || 'canvas';
99
102
  }
100
- /**
101
- * These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
102
- */
103
- if (canvas) {
104
- this.canvas = canvas;
105
- this.backgroundCanvas = backgroundCanvas;
106
- this.transientCanvas = transientCanvas;
103
+ if (container) {
107
104
  this.container = container;
108
105
  }
109
106
  else {
@@ -116,19 +113,36 @@ export class Graph extends EventEmitter {
116
113
  return;
117
114
  }
118
115
  this.container = containerDOM;
119
- const size = [width, height];
120
- if (size[0] === undefined) {
121
- size[0] = containerDOM.scrollWidth;
122
- }
123
- if (size[1] === undefined) {
124
- size[1] = containerDOM.scrollHeight;
125
- }
126
- this.backgroundCanvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
127
- this.canvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
128
- this.transientCanvas = createCanvas(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
129
116
  }
130
- Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready)).then(() => {
131
- [this.backgroundCanvas, this.canvas, this.transientCanvas].forEach((canvas, i) => {
117
+ [
118
+ 'backgroundCanvas',
119
+ 'canvas',
120
+ 'labelCanvas',
121
+ 'transientCanvas',
122
+ 'transientLabelCanvas',
123
+ ].forEach((name) => {
124
+ this[name] =
125
+ this.specification[name] ||
126
+ createCanvas(['labelCanvas', 'transientLabelCanvas'].includes(name)
127
+ ? 'canvas'
128
+ : this.rendererType, this.container, width !== null && width !== void 0 ? width : this.container.scrollWidth, height !== null && height !== void 0 ? height : this.container.scrollHeight, pixelRatio, undefined,
129
+ // enable dom interaction only for main canvas
130
+ name === 'canvas' ? [] : ['dom-interaction']);
131
+ });
132
+ Promise.all([
133
+ this.backgroundCanvas,
134
+ this.canvas,
135
+ this.labelCanvas,
136
+ this.transientCanvas,
137
+ this.transientLabelCanvas,
138
+ ].map((canvas) => canvas.ready)).then(() => {
139
+ [
140
+ this.backgroundCanvas,
141
+ this.canvas,
142
+ this.labelCanvas,
143
+ this.transientCanvas,
144
+ this.transientLabelCanvas,
145
+ ].forEach((canvas, i) => {
132
146
  const $domElement = canvas
133
147
  .getContextService()
134
148
  .getDomElement();
@@ -190,6 +204,9 @@ export class Graph extends EventEmitter {
190
204
  itemstatechange: new Hook({
191
205
  name: 'itemstatechange',
192
206
  }),
207
+ itemstateconfigchange: new Hook({
208
+ name: 'itemstateconfigchange',
209
+ }),
193
210
  itemvisibilitychange: new Hook({
194
211
  name: 'itemvisibilitychange',
195
212
  }),
@@ -212,8 +229,22 @@ export class Graph extends EventEmitter {
212
229
  * Update the specs(configurations).
213
230
  */
214
231
  updateSpecification(spec) {
215
- const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
216
- // TODO: update something
232
+ const { node, edge, combo, theme, nodeState, edgeState, comboState } = spec, others = __rest(spec, ["node", "edge", "combo", "theme", "nodeState", "edgeState", "comboState"]);
233
+ if (node)
234
+ this.updateMapper('node', node);
235
+ if (edge)
236
+ this.updateMapper('edge', edge);
237
+ if (combo)
238
+ this.updateMapper('combo', combo);
239
+ if (theme)
240
+ this.updateTheme(theme);
241
+ if (nodeState)
242
+ this.updateStateConfig('node', nodeState, 'replace');
243
+ if (edgeState)
244
+ this.updateStateConfig('edge', edgeState, 'replace');
245
+ if (comboState)
246
+ this.updateStateConfig('combo', comboState, 'replace');
247
+ const newSpec = Object.assign(this.specification, this.formatSpecification(others));
217
248
  return newSpec;
218
249
  }
219
250
  /**
@@ -257,6 +288,26 @@ export class Graph extends EventEmitter {
257
288
  mapper,
258
289
  });
259
290
  }
291
+ /**
292
+ * Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
293
+ * @param {string} itemType - The type of item (node, edge, or combo).
294
+ * @param {object} stateConfig - The state configuration to update.
295
+ * @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
296
+ **/
297
+ updateStateConfig(itemType, stateConfig, updateType = 'mergeReplace') {
298
+ if (isEmpty(stateConfig))
299
+ return;
300
+ const stateField = `${itemType}State`;
301
+ if (updateType === 'mergeReplace') {
302
+ const config = Object.assign(Object.assign({}, this.specification[stateField]), stateConfig);
303
+ this.specification[itemType] = config;
304
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
305
+ }
306
+ else {
307
+ this.specification[itemType] = stateConfig;
308
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
309
+ }
310
+ }
260
311
  /**
261
312
  * Get the copy of specs(configurations).
262
313
  * @returns graph specs
@@ -280,6 +331,7 @@ export class Graph extends EventEmitter {
280
331
  graphCore: this.dataController.graphCore,
281
332
  theme: this.themeController.specification,
282
333
  transientCanvas: this.transientCanvas,
334
+ transientLabelCanvas: this.transientLabelCanvas,
283
335
  tileOptimize: {
284
336
  tileFirstRender,
285
337
  tileFirstRenderSize,
@@ -320,7 +372,13 @@ export class Graph extends EventEmitter {
320
372
  yield emitRender();
321
373
  }
322
374
  else {
323
- yield Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready));
375
+ yield Promise.all([
376
+ this.backgroundCanvas,
377
+ this.canvas,
378
+ this.labelCanvas,
379
+ this.transientCanvas,
380
+ this.transientLabelCanvas,
381
+ ].map((canvas) => canvas.ready));
324
382
  yield emitRender();
325
383
  }
326
384
  });
@@ -329,10 +387,11 @@ export class Graph extends EventEmitter {
329
387
  * Change graph data.
330
388
  * @param data new data
331
389
  * @param type the way to change data, 'replace' means discard the old data and use the new one; 'mergeReplace' means merge the common part, remove (old - new), add (new - old)
390
+ * @param relayout whether relayout the nodes after data changing
332
391
  * @returns
333
392
  * @group Data
334
393
  */
335
- changeData(data, type = 'mergeReplace') {
394
+ changeData(data, type = 'mergeReplace', relayout = true) {
336
395
  return __awaiter(this, void 0, void 0, function* () {
337
396
  const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
338
397
  this.hooks.datachange.emit({ data, type });
@@ -340,13 +399,16 @@ export class Graph extends EventEmitter {
340
399
  graphCore: this.dataController.graphCore,
341
400
  theme: this.themeController.specification,
342
401
  transientCanvas: this.transientCanvas,
402
+ transientLabelCanvas: this.transientLabelCanvas,
343
403
  tileOptimize: {
344
404
  tileFirstRender,
345
405
  tileFirstRenderSize,
346
406
  },
347
407
  });
348
408
  this.emit('afterrender');
349
- yield this.layout();
409
+ if (relayout) {
410
+ yield this.layout();
411
+ }
350
412
  });
351
413
  }
352
414
  /**
@@ -499,8 +561,8 @@ export class Graph extends EventEmitter {
499
561
  const { direction = 'both', ratioRule = 'min', boundsType = 'render', onlyOutOfViewport = false, onlyZoomAtLargerThanViewport = false, } = rules || {};
500
562
  const { min, max, center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
501
563
  ? // Get the bounds of the whole graph content.
502
- this.canvas.document.documentElement.getBounds()
503
- : // Get the bounds of the nodes positions while the graph content is not ready.
564
+ getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
565
+ : // Get the b ounds of the nodes positions while the graph content is not ready.
504
566
  getLayoutBounds(this);
505
567
  const origin = this.canvas.canvas2Viewport({
506
568
  x: graphCenterX,
@@ -560,7 +622,7 @@ export class Graph extends EventEmitter {
560
622
  return __awaiter(this, void 0, void 0, function* () {
561
623
  const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
562
624
  ? // Get the bounds of the whole graph content.
563
- this.canvas.document.documentElement.getBounds()
625
+ getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
564
626
  : // Get the bounds of the nodes positions while the graph content is not ready.
565
627
  getLayoutBounds(this);
566
628
  yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
@@ -623,9 +685,15 @@ export class Graph extends EventEmitter {
623
685
  this.emit('beforesetsize', { oldSize, size: size });
624
686
  this.specification.width = size[0];
625
687
  this.specification.height = size[1];
626
- this.canvas.resize(size[0], size[1]);
627
- this.transientCanvas.resize(size[0], size[1]);
628
- this.backgroundCanvas.resize(size[0], size[1]);
688
+ [
689
+ this.canvas,
690
+ this.labelCanvas,
691
+ this.transientCanvas,
692
+ this.transientLabelCanvas,
693
+ this.backgroundCanvas,
694
+ ].forEach((canvas) => {
695
+ canvas.resize(size[0], size[1]);
696
+ });
629
697
  this.emit('aftersetsize', { oldSize, size: size });
630
698
  }
631
699
  getCanvasRange() {
@@ -754,6 +822,16 @@ export class Graph extends EventEmitter {
754
822
  getRelatedEdgesData(nodeId, direction = 'both') {
755
823
  return this.dataController.findRelatedEdges(nodeId, direction);
756
824
  }
825
+ /**
826
+ * Get nearby edges from a start node using quad-tree collision detection.
827
+ * @param nodeId id of the start node
828
+ * @returns nearby edges' data array
829
+ */
830
+ getNearEdgesData(nodeId, shouldBegin) {
831
+ const transientItem = this.itemController.getTransientItem(nodeId);
832
+ const itemMap = this.itemController.getItemMap();
833
+ return this.dataController.findNearEdges(nodeId, itemMap, transientItem, shouldBegin);
834
+ }
757
835
  /**
758
836
  * Get one-hop node ids from a start node.
759
837
  * @param nodeId id of the start node
@@ -791,15 +869,6 @@ export class Graph extends EventEmitter {
791
869
  getDisplayModel(id) {
792
870
  return this.itemController.findDisplayModel(id);
793
871
  }
794
- /**
795
- * Retrieve the nearby edges for a given node using quadtree collision detection.
796
- * @param nodeId node id
797
- * @group Data
798
- */
799
- getNearEdgesForNode(nodeId) {
800
- const { graphCore } = this.dataController;
801
- return this.itemController.findNearEdgesByNode(nodeId, graphCore);
802
- }
803
872
  /**
804
873
  * Find items which has the state.
805
874
  * @param itemType item type
@@ -831,6 +900,7 @@ export class Graph extends EventEmitter {
831
900
  // data controller and item controller subscribe additem in order
832
901
  const { graphCore } = this.dataController;
833
902
  const { specification } = this.themeController;
903
+ const modelArr = isArray(models) ? models : [models];
834
904
  graphCore.once('changed', (event) => {
835
905
  if (!event.changes.length)
836
906
  return;
@@ -838,7 +908,7 @@ export class Graph extends EventEmitter {
838
908
  const timingParameters = {
839
909
  type: itemType,
840
910
  action: 'add',
841
- models,
911
+ models: modelArr,
842
912
  apiName: 'addData',
843
913
  changes,
844
914
  };
@@ -851,7 +921,6 @@ export class Graph extends EventEmitter {
851
921
  });
852
922
  this.emit('afteritemchange', timingParameters);
853
923
  });
854
- const modelArr = isArray(models) ? models : [models];
855
924
  const data = { nodes: [], edges: [], combos: [] };
856
925
  data[`${itemType}s`] = modelArr;
857
926
  this.hooks.datachange.emit({
@@ -863,7 +932,8 @@ export class Graph extends EventEmitter {
863
932
  }
864
933
  /**
865
934
  * Remove one or more node/edge/combo data from the graph.
866
- * @param item the item to be removed
935
+ * @param itemType the type the item(s) to be removed.
936
+ * @param id the id or the ids' array of the items to be removed.
867
937
  * @returns whether success
868
938
  * @group Data
869
939
  */
@@ -957,8 +1027,8 @@ export class Graph extends EventEmitter {
957
1027
  }
958
1028
  /**
959
1029
  * Update one or more node/edge/combo data on the graph.
960
- * @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
961
- * @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
1030
+ * @param {ITEM_TYPE} itemType the type the item(s) to be udated.
1031
+ * @param models update configs.
962
1032
  * @group Data
963
1033
  */
964
1034
  updateData(itemType, models) {
@@ -968,11 +1038,11 @@ export class Graph extends EventEmitter {
968
1038
  const { graphCore } = this.dataController;
969
1039
  const { specification } = this.themeController;
970
1040
  graphCore.once('changed', (event) => {
971
- const changes = this.extendChanges(clone(event.changes));
1041
+ const changes = this.extendChanges(cloneJSON(event.changes));
972
1042
  const timingParameters = {
973
1043
  type: itemType,
974
1044
  action: 'update',
975
- models,
1045
+ models: modelArr,
976
1046
  apiName: 'updateData',
977
1047
  changes,
978
1048
  };
@@ -995,21 +1065,27 @@ export class Graph extends EventEmitter {
995
1065
  /**
996
1066
  * Update one or more nodes' positions,
997
1067
  * do not update other styles which leads to better performance than updating positions by updateData.
998
- * @param models new configurations with x and y for every node, which has id field to indicate the specific item
1068
+ * @param models new configurations with x and y for every node, which has id field to indicate the specific item.
1069
+ * @param upsertAncestors whether update the ancestors in combo tree.
1070
+ * @param disableAnimate whether disable the animation for this call.
1071
+ * @param callback callback function after update nodes done.
999
1072
  * @group Data
1000
1073
  */
1001
- updateNodePosition(models, upsertAncestors, disableAnimate = false, callback, stack) {
1002
- return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback, stack);
1074
+ updateNodePosition(models, upsertAncestors, disableAnimate = false, callback) {
1075
+ return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback);
1003
1076
  }
1004
1077
  /**
1005
1078
  * Update one or more combos' positions,
1006
1079
  * do not update other styles which leads to better performance than updating positions by updateData.
1007
1080
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1008
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1081
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
1082
+ * @param upsertAncestors whether update the ancestors in combo tree.
1083
+ * @param disableAnimate whether disable the animation for this call.
1084
+ * @param callback callback function after update combos done.
1009
1085
  * @group Data
1010
1086
  */
1011
- updateComboPosition(models, upsertAncestors, disableAnimate = false, callback, stack) {
1012
- return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback, stack);
1087
+ updateComboPosition(models, upsertAncestors, disableAnimate = false, callback) {
1088
+ return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback);
1013
1089
  }
1014
1090
  /**
1015
1091
  * Get history plugin instance
@@ -1022,7 +1098,7 @@ export class Graph extends EventEmitter {
1022
1098
  }
1023
1099
  return this.pluginController.getPlugin('history');
1024
1100
  }
1025
- updatePosition(type, models, upsertAncestors, disableAnimate = false, callback, stack) {
1101
+ updatePosition(type, models, upsertAncestors, disableAnimate = false, callback) {
1026
1102
  const modelArr = isArray(models) ? models : [models];
1027
1103
  const { graphCore } = this.dataController;
1028
1104
  const { specification } = this.themeController;
@@ -1034,7 +1110,7 @@ export class Graph extends EventEmitter {
1034
1110
  type,
1035
1111
  action: 'updatePosition',
1036
1112
  upsertAncestors,
1037
- models,
1113
+ models: modelArr,
1038
1114
  apiName: 'updatePosition',
1039
1115
  changes,
1040
1116
  };
@@ -1057,7 +1133,7 @@ export class Graph extends EventEmitter {
1057
1133
  edges: [],
1058
1134
  combos: type === 'combo' ? modelArr : [],
1059
1135
  },
1060
- type: 'update',
1136
+ type: 'updatePosition',
1061
1137
  });
1062
1138
  const dataList = this.dataController.findData(type, modelArr.map((model) => model.id));
1063
1139
  return isArray(models) ? dataList : dataList[0];
@@ -1080,22 +1156,40 @@ export class Graph extends EventEmitter {
1080
1156
  * @returns
1081
1157
  * @group Item
1082
1158
  */
1083
- showItem(ids, disableAnimate = false) {
1159
+ showItem(ids, options) {
1160
+ const { disableAnimate = false, shapeIds } = options || {};
1084
1161
  const idArr = isArray(ids) ? ids : [ids];
1085
1162
  if (isEmpty(idArr))
1086
1163
  return;
1087
- const changes = {
1088
- newValue: [{ ids: idArr, visible: true }],
1089
- oldValue: this.getItemPreviousVisibility(idArr),
1090
- };
1091
- this.hooks.itemvisibilitychange.emit({
1092
- ids: idArr,
1093
- value: true,
1094
- graphCore: this.dataController.graphCore,
1095
- animate: !disableAnimate,
1096
- });
1164
+ let changes;
1165
+ if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
1166
+ const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
1167
+ changes = {
1168
+ newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
1169
+ oldValue: this.getItemPreviousVisibility(idArr),
1170
+ };
1171
+ this.hooks.itemvisibilitychange.emit({
1172
+ ids: idArr,
1173
+ value: true,
1174
+ graphCore: this.dataController.graphCore,
1175
+ animate: !disableAnimate,
1176
+ shapeIds: shapeIdsArr,
1177
+ });
1178
+ }
1179
+ else {
1180
+ changes = {
1181
+ newValue: [{ ids: idArr, visible: true }],
1182
+ oldValue: this.getItemPreviousVisibility(idArr),
1183
+ };
1184
+ this.hooks.itemvisibilitychange.emit({
1185
+ ids: idArr,
1186
+ value: true,
1187
+ graphCore: this.dataController.graphCore,
1188
+ animate: !disableAnimate,
1189
+ });
1190
+ }
1097
1191
  this.emit('afteritemvisibilitychange', {
1098
- ids,
1192
+ ids: idArr,
1099
1193
  value: true,
1100
1194
  animate: !disableAnimate,
1101
1195
  action: 'updateVisibility',
@@ -1105,27 +1199,49 @@ export class Graph extends EventEmitter {
1105
1199
  }
1106
1200
  /**
1107
1201
  * Hide the item(s).
1108
- * @param item the item to be hidden
1202
+ * @param id the id for the item to be hidden.
1203
+ * @param disableAnimate whether disable the hidden animations.
1204
+ * @param keepKeyShape whether keep the keyShape.
1205
+ * @param keepRelated whether keep the related nodes for edge.
1109
1206
  * @returns
1110
1207
  * @group Item
1111
1208
  */
1112
- hideItem(ids, disableAnimate = false, keepKeyShape = false) {
1209
+ hideItem(ids, options) {
1210
+ const { disableAnimate = false, keepKeyShape = false, keepRelated = false, shapeIds, } = options || {};
1113
1211
  const idArr = isArray(ids) ? ids : [ids];
1114
1212
  if (isEmpty(idArr))
1115
1213
  return;
1116
- const changes = {
1117
- newValue: [{ ids: idArr, visible: false }],
1118
- oldValue: this.getItemPreviousVisibility(idArr),
1119
- };
1120
- this.hooks.itemvisibilitychange.emit({
1121
- ids: idArr,
1122
- value: false,
1123
- graphCore: this.dataController.graphCore,
1124
- animate: !disableAnimate,
1125
- keepKeyShape,
1126
- });
1214
+ let changes;
1215
+ if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
1216
+ const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
1217
+ changes = {
1218
+ newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
1219
+ oldValue: this.getItemPreviousVisibility(idArr),
1220
+ };
1221
+ this.hooks.itemvisibilitychange.emit({
1222
+ ids: idArr,
1223
+ value: false,
1224
+ graphCore: this.dataController.graphCore,
1225
+ animate: !disableAnimate,
1226
+ shapeIds: shapeIdsArr,
1227
+ });
1228
+ }
1229
+ else {
1230
+ changes = {
1231
+ newValue: [{ ids: idArr, visible: false }],
1232
+ oldValue: this.getItemPreviousVisibility(idArr),
1233
+ };
1234
+ this.hooks.itemvisibilitychange.emit({
1235
+ ids: idArr,
1236
+ value: false,
1237
+ graphCore: this.dataController.graphCore,
1238
+ animate: !disableAnimate,
1239
+ keepKeyShape,
1240
+ keepRelated,
1241
+ });
1242
+ }
1127
1243
  this.emit('afteritemvisibilitychange', {
1128
- ids,
1244
+ ids: idArr,
1129
1245
  value: false,
1130
1246
  animate: !disableAnimate,
1131
1247
  action: 'updateVisibility',
@@ -1286,11 +1402,20 @@ export class Graph extends EventEmitter {
1286
1402
  getItemVisible(id) {
1287
1403
  return this.itemController.getItemVisible(id);
1288
1404
  }
1405
+ /**
1406
+ * Get the visible shape ids in a node / edge / combo.
1407
+ * @param id the id for the node / edge / combo
1408
+ * @returns ids of the visible shapes
1409
+ */
1410
+ getItemVisibleShapeIds(id) {
1411
+ return this.itemController.getItemVisibleShapeIds(id);
1412
+ }
1289
1413
  // ===== combo operations =====
1290
1414
  /**
1291
1415
  * Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
1292
- * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
1293
- * @param model combo user data
1416
+ * Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
1417
+ * @param model combo user data.
1418
+ * @param childrenIds the ids of the children nodes / combos to move into the new combo.
1294
1419
  * @returns whether success
1295
1420
  * @group Combo
1296
1421
  */
@@ -1332,7 +1457,7 @@ export class Graph extends EventEmitter {
1332
1457
  }
1333
1458
  /**
1334
1459
  * Collapse a combo.
1335
- * @param comboId combo ids
1460
+ * @param comboId combo id or ids' array.
1336
1461
  * @group Combo
1337
1462
  */
1338
1463
  collapseCombo(comboIds) {
@@ -1349,7 +1474,7 @@ export class Graph extends EventEmitter {
1349
1474
  }
1350
1475
  /**
1351
1476
  * Expand a combo.
1352
- * @param combo combo ids
1477
+ * @param comboId combo id or ids' array.
1353
1478
  * @group Combo
1354
1479
  */
1355
1480
  expandCombo(comboIds) {
@@ -1368,7 +1493,11 @@ export class Graph extends EventEmitter {
1368
1493
  * Move one or more combos a distance (dx, dy) relatively,
1369
1494
  * do not update other styles which leads to better performance than updating positions by updateData.
1370
1495
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1371
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1496
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
1497
+ * @param dx the distance alone x-axis to move the combo.
1498
+ * @param dy the distance alone y-axis to move the combo.
1499
+ * @param upsertAncestors whether update the ancestors in the combo tree.
1500
+ * @param callback callback function after move combo done.
1372
1501
  * @group Combo
1373
1502
  */
1374
1503
  moveCombo(ids, dx, dy, upsertAncestors, callback) {
@@ -1490,7 +1619,9 @@ export class Graph extends EventEmitter {
1490
1619
  */
1491
1620
  setCursor(cursor) {
1492
1621
  this.canvas.setCursor(cursor);
1622
+ this.labelCanvas.setCursor(cursor);
1493
1623
  this.transientCanvas.setCursor(cursor);
1624
+ this.transientLabelCanvas.setCursor(cursor);
1494
1625
  }
1495
1626
  /**
1496
1627
  * Add behavior(s) to mode(s).
@@ -1622,10 +1753,9 @@ export class Graph extends EventEmitter {
1622
1753
  */
1623
1754
  updatePlugin(plugin) {
1624
1755
  const { plugins } = this.specification;
1625
- const { key } = plugin;
1756
+ const { key, type } = plugin;
1626
1757
  if (!key) {
1627
- console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
1628
- return;
1758
+ console.warn(`The key for the plugin is not found. G6 will update the first plugin with type ${type}`);
1629
1759
  }
1630
1760
  if (!plugins) {
1631
1761
  console.warn('Update plugin failed, the plugin to be updated does not exist.');
@@ -1633,11 +1763,12 @@ export class Graph extends EventEmitter {
1633
1763
  }
1634
1764
  const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
1635
1765
  if (typeof p === 'string')
1636
- return p === key;
1637
- return p.key === key;
1766
+ return p === key || p === type;
1767
+ return (p.key === key ||
1768
+ p.type === type);
1638
1769
  });
1639
1770
  if (!oldPlugin) {
1640
- console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
1771
+ console.warn(`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`);
1641
1772
  return;
1642
1773
  }
1643
1774
  const idx = plugins.indexOf(oldPlugin);
@@ -1650,7 +1781,7 @@ export class Graph extends EventEmitter {
1650
1781
  /**
1651
1782
  * Draw or update a G shape or group to the transient canvas.
1652
1783
  * @param type shape type or item type
1653
- * @param id new shape id or updated shape id for a interation shape, node/edge/combo id for item interaction group drawing
1784
+ * @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
1654
1785
  * @returns upserted shape or group
1655
1786
  * @group Interaction
1656
1787
  */
@@ -1673,45 +1804,62 @@ export class Graph extends EventEmitter {
1673
1804
  */
1674
1805
  toDataURL(type) {
1675
1806
  return __awaiter(this, void 0, void 0, function* () {
1676
- const backgroundCanvas = this.backgroundCanvas;
1677
- const canvas = this.canvas;
1678
- const transientCanvas = this.transientCanvas;
1679
- const rendererType = this.rendererType;
1807
+ const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
1680
1808
  const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1681
- const width = this.getSize()[0];
1682
- const height = this.getSize()[1];
1809
+ const [width, height] = this.getSize();
1683
1810
  const vContainerDOM = createDOM('<div id="virtual-image"></div>');
1811
+ const camera = canvas.getCamera();
1684
1812
  const vCanvas = createCanvas(rendererType, vContainerDOM, width, height, pixelRatio);
1813
+ yield vCanvas.ready;
1814
+ const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1815
+ const clonedGroup = canvas.getRoot().cloneNode(true);
1816
+ const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1817
+ const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
1818
+ const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
1819
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1820
+ labelClonedGroup.translate([
1821
+ currentViewportLTCanvas.x - originViewportLTCanvas.x,
1822
+ currentViewportLTCanvas.y - originViewportLTCanvas.y,
1823
+ ]);
1824
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
1825
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
1826
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
1827
+ childGroup.children.forEach((shape) => {
1828
+ if (shape.getAttribute('data-is-label-background') &&
1829
+ shape.style.transform)
1830
+ shape.remove();
1831
+ });
1832
+ });
1833
+ vCanvas.appendChild(backgroundClonedGroup);
1834
+ vCanvas.appendChild(clonedGroup);
1835
+ vCanvas.appendChild(labelClonedGroup);
1836
+ vCanvas.appendChild(transientClonedGroup);
1837
+ const vCamera = vCanvas.getCamera();
1838
+ vCamera.setZoom(camera.getZoom());
1839
+ vCamera.setPosition(camera.getPosition());
1840
+ vCamera.setFocalPoint(camera.getFocalPoint());
1685
1841
  const vCanvasContextService = vCanvas.getContextService();
1686
1842
  let bgRect;
1687
1843
  if (rendererType !== 'svg') {
1844
+ const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1688
1845
  bgRect = new Rect({
1689
- style: {
1690
- x: 0,
1691
- y: 0,
1692
- z: -1,
1693
- width: vCanvasContextService.getDomElement().width,
1694
- height: vCanvasContextService.getDomElement().height,
1846
+ style: Object.assign(Object.assign({}, backPositionCanvas), { z: -1, width: vCanvasContextService.getDomElement().width, height: vCanvasContextService.getDomElement().height,
1695
1847
  //@ts-ignore
1696
- fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1697
- },
1848
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'], zIndex: -10 }),
1698
1849
  });
1699
1850
  vCanvas.appendChild(bgRect);
1700
1851
  }
1701
- const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1702
- const clonedGroup = canvas.getRoot().cloneNode(true);
1703
- const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1704
- vCanvas.appendChild(backgroundClonedGroup);
1705
- vCanvas.appendChild(clonedGroup);
1706
- vCanvas.appendChild(transientClonedGroup);
1707
- vCanvas.render();
1708
1852
  if (!type)
1709
1853
  type = 'image/png';
1710
1854
  let dataURL = '';
1711
- yield vCanvasContextService.toDataURL({ type }).then((url) => {
1712
- dataURL = url;
1855
+ return new Promise((resolve) => {
1856
+ setTimeout(() => {
1857
+ vCanvasContextService.toDataURL({ type }).then((url) => {
1858
+ dataURL = url;
1859
+ resolve(dataURL);
1860
+ });
1861
+ }, 50);
1713
1862
  });
1714
- return dataURL;
1715
1863
  });
1716
1864
  }
1717
1865
  /**
@@ -1723,16 +1871,15 @@ export class Graph extends EventEmitter {
1723
1871
  */
1724
1872
  toFullDataURL(type, imageConfig) {
1725
1873
  return __awaiter(this, void 0, void 0, function* () {
1726
- const backgroundCanvas = this.backgroundCanvas;
1727
- const canvas = this.canvas;
1728
- const transientCanvas = this.transientCanvas;
1729
- const backgroundRoot = canvas.getRoot();
1874
+ const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
1875
+ const backgroundRoot = backgroundCanvas.getRoot();
1730
1876
  const root = canvas.getRoot();
1731
1877
  const transientRoot = transientCanvas.getRoot();
1732
- const rendererType = this.rendererType;
1733
- const backgroundBBox = backgroundRoot.getBBox();
1734
- const BBox = root.getBBox();
1735
- const transientBBox = transientRoot.getBBox();
1878
+ const labelRoot = labelCanvas.getRoot();
1879
+ const backgroundBBox = backgroundRoot.getRenderBounds();
1880
+ const BBox = root.getRenderBounds();
1881
+ const transientBBox = transientRoot.getRenderBounds();
1882
+ const labelBBox = labelRoot.getRenderBounds();
1736
1883
  let padding = imageConfig ? imageConfig.padding : undefined;
1737
1884
  if (!padding) {
1738
1885
  padding = [0, 0, 0, 0];
@@ -1740,26 +1887,10 @@ export class Graph extends EventEmitter {
1740
1887
  else if (isNumber(padding)) {
1741
1888
  padding = [padding, padding, padding, padding];
1742
1889
  }
1743
- const left = (transientBBox.left
1744
- ? backgroundBBox.left
1745
- ? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
1746
- : Math.min(BBox.left, transientBBox.left)
1747
- : BBox.left) - padding[3];
1748
- const right = (transientBBox.right
1749
- ? backgroundBBox.right
1750
- ? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
1751
- : Math.max(BBox.right, transientBBox.right)
1752
- : BBox.right) + padding[1];
1753
- const top = (transientBBox.top
1754
- ? backgroundBBox.top
1755
- ? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
1756
- : Math.min(BBox.top, transientBBox.top)
1757
- : BBox.top) - padding[0];
1758
- const bottom = (transientBBox.bottom
1759
- ? backgroundBBox.bottom
1760
- ? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
1761
- : Math.max(BBox.bottom, transientBBox.bottom)
1762
- : BBox.bottom) + padding[2];
1890
+ const left = Math.min(backgroundBBox.min[0] || Infinity, BBox.min[0] || Infinity, transientBBox.min[0] || Infinity, labelBBox.min[0] || Infinity) - padding[3];
1891
+ const right = Math.max(backgroundBBox.max[0] || -Infinity, BBox.max[0] || -Infinity, transientBBox.max[0] || -Infinity, labelBBox.max[0] || -Infinity) - padding[1];
1892
+ const top = Math.min(backgroundBBox.min[1] || Infinity, BBox.min[1] || Infinity, transientBBox.min[1] || Infinity, labelBBox.min[1] || Infinity) - padding[0];
1893
+ const bottom = Math.max(backgroundBBox.max[1] || -Infinity, BBox.max[1] || -Infinity, transientBBox.max[1] || -Infinity, labelBBox.max[1] || -Infinity) - padding[2];
1763
1894
  const graphCenterX = (left + right) / 2;
1764
1895
  const graphCenterY = (top + bottom) / 2;
1765
1896
  const halfX = (right - left) / 2;
@@ -1769,6 +1900,7 @@ export class Graph extends EventEmitter {
1769
1900
  const vHeight = halfY * 2;
1770
1901
  const vContainerDOM = createDOM('<div id="virtual-image"></div>');
1771
1902
  const vCanvas = createCanvas(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
1903
+ yield vCanvas.ready;
1772
1904
  const vCanvasContextService = vCanvas.getContextService();
1773
1905
  if (rendererType !== 'svg') {
1774
1906
  const bgRect = new Rect({
@@ -1787,6 +1919,7 @@ export class Graph extends EventEmitter {
1787
1919
  const backgroundClonedGroup = backgroundRoot.cloneNode(true);
1788
1920
  const clonedGroup = root.cloneNode(true);
1789
1921
  const transientClonedGroup = transientRoot.cloneNode(true);
1922
+ const labelClonedGroup = labelRoot.cloneNode(true);
1790
1923
  const transPosition = [
1791
1924
  -graphCenterX + halfX,
1792
1925
  -graphCenterY + halfY,
@@ -1794,17 +1927,36 @@ export class Graph extends EventEmitter {
1794
1927
  backgroundClonedGroup.setPosition(transPosition);
1795
1928
  clonedGroup.setPosition(transPosition);
1796
1929
  transientClonedGroup.setPosition(transPosition);
1930
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1931
+ const labelTransPosition = [
1932
+ transPosition[0] + currentViewportLTCanvas.x,
1933
+ transPosition[1] + currentViewportLTCanvas.y,
1934
+ ];
1935
+ labelClonedGroup.setPosition(labelTransPosition);
1936
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
1937
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
1938
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
1939
+ childGroup.children.forEach((shape) => {
1940
+ if (shape.getAttribute('data-is-label-background') &&
1941
+ shape.style.transform)
1942
+ shape.remove();
1943
+ });
1944
+ });
1797
1945
  vCanvas.appendChild(backgroundClonedGroup);
1798
1946
  vCanvas.appendChild(clonedGroup);
1947
+ vCanvas.appendChild(labelClonedGroup);
1799
1948
  vCanvas.appendChild(transientClonedGroup);
1800
- vCanvas.render();
1801
1949
  if (!type)
1802
1950
  type = 'image/png';
1803
1951
  let dataURL = '';
1804
- yield vCanvasContextService.toDataURL({ type }).then((url) => {
1805
- dataURL = url;
1952
+ return new Promise((resolve) => {
1953
+ setTimeout(() => {
1954
+ vCanvasContextService.toDataURL({ type }).then((url) => {
1955
+ dataURL = url;
1956
+ resolve(dataURL);
1957
+ });
1958
+ }, 50);
1806
1959
  });
1807
- return dataURL;
1808
1960
  });
1809
1961
  }
1810
1962
  /**
@@ -2066,7 +2218,7 @@ export class Graph extends EventEmitter {
2066
2218
  * @returns
2067
2219
  * @group Tree
2068
2220
  */
2069
- collapse(ids, disableAnimate = false, stack) {
2221
+ collapse(ids, disableAnimate = false) {
2070
2222
  this.hooks.treecollapseexpand.emit({
2071
2223
  ids: isArray(ids) ? ids : [ids],
2072
2224
  action: 'collapse',
@@ -2082,7 +2234,7 @@ export class Graph extends EventEmitter {
2082
2234
  * @returns
2083
2235
  * @group Tree
2084
2236
  */
2085
- expand(ids, disableAnimate = false, stack) {
2237
+ expand(ids, disableAnimate = false) {
2086
2238
  this.hooks.treecollapseexpand.emit({
2087
2239
  ids: isArray(ids) ? ids : [ids],
2088
2240
  action: 'expand',
@@ -2096,15 +2248,23 @@ export class Graph extends EventEmitter {
2096
2248
  * @group Graph Instance
2097
2249
  */
2098
2250
  destroy(callback) {
2099
- // TODO: call the destroy functions after items' buildOut animations finished
2100
- // setTimeout(() => {
2251
+ var _a;
2252
+ const camera = this.canvas.getCamera();
2253
+ const transientCamera = this.transientCanvas.getCamera();
2254
+ // @ts-ignore
2255
+ if ((_a = camera.landmarks) === null || _a === void 0 ? void 0 : _a.length) {
2256
+ camera.cancelLandmarkAnimation();
2257
+ transientCamera.cancelLandmarkAnimation();
2258
+ this.emit('cancelviewportanimation');
2259
+ }
2101
2260
  this.canvas.destroy();
2261
+ this.labelCanvas.destroy();
2102
2262
  this.backgroundCanvas.destroy();
2103
2263
  this.transientCanvas.destroy();
2264
+ this.transientLabelCanvas.destroy();
2104
2265
  // clear history stack
2105
2266
  this.cleanHistory();
2106
2267
  callback === null || callback === void 0 ? void 0 : callback();
2107
- // }, 500);
2108
2268
  this.hooks.destroy.emit({});
2109
2269
  // TODO: destroy controllers and off the listeners
2110
2270
  // this.dataController.destroy();
@@ -2112,7 +2272,6 @@ export class Graph extends EventEmitter {
2112
2272
  // this.layoutController.destroy();
2113
2273
  // this.themeController.destroy();
2114
2274
  // this.itemController.destroy();
2115
- // this.extensionController.destroy();
2116
2275
  this.destroyed = true;
2117
2276
  }
2118
2277
  }