@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
@@ -31,13 +31,15 @@ const canvas_1 = require("../util/canvas");
31
31
  const dom_1 = require("../util/dom");
32
32
  const layout_1 = require("../util/layout");
33
33
  const shape_1 = require("../util/shape");
34
+ const data_1 = require("../util/data");
35
+ const bbox_1 = require("../util/bbox");
34
36
  const controller_1 = require("./controller");
35
- const plugin_1 = require("./controller/plugin");
36
37
  const hooks_1 = __importDefault(require("./hooks"));
37
- const data_1 = require("../util/data");
38
38
  class Graph extends event_emitter_1.default {
39
39
  constructor(spec) {
40
40
  super();
41
+ // the tag to indicate whether the graph instance is destroyed
42
+ this.destroyed = false;
41
43
  this.defaultSpecification = {
42
44
  theme: {
43
45
  type: 'spec',
@@ -68,7 +70,9 @@ class Graph extends event_emitter_1.default {
68
70
  canvases: {
69
71
  background: this.backgroundCanvas,
70
72
  main: this.canvas,
73
+ label: this.labelCanvas,
71
74
  transient: this.transientCanvas,
75
+ transientLabel: this.transientLabelCanvas,
72
76
  },
73
77
  });
74
78
  const { data } = spec;
@@ -85,13 +89,12 @@ class Graph extends event_emitter_1.default {
85
89
  this.interactionController = new controller_1.InteractionController(this);
86
90
  this.layoutController = new controller_1.LayoutController(this);
87
91
  this.themeController = new controller_1.ThemeController(this);
88
- this.itemController = new controller_1.ItemController(this);
89
92
  this.viewportController = new controller_1.ViewportController(this);
90
- this.extensionController = new controller_1.ExtensionController(this);
91
- this.pluginController = new plugin_1.PluginController(this);
93
+ this.itemController = new controller_1.ItemController(this);
94
+ this.pluginController = new controller_1.PluginController(this);
92
95
  }
93
96
  initCanvas() {
94
- const { renderer, container, canvas, backgroundCanvas, transientCanvas, width, height, } = this.specification;
97
+ const { renderer, container, width, height } = this.specification;
95
98
  let pixelRatio;
96
99
  if (renderer && !(0, util_1.isString)(renderer)) {
97
100
  // @ts-ignore
@@ -103,13 +106,7 @@ class Graph extends event_emitter_1.default {
103
106
  // @ts-ignore
104
107
  this.rendererType = renderer || 'canvas';
105
108
  }
106
- /**
107
- * These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
108
- */
109
- if (canvas) {
110
- this.canvas = canvas;
111
- this.backgroundCanvas = backgroundCanvas;
112
- this.transientCanvas = transientCanvas;
109
+ if (container) {
113
110
  this.container = container;
114
111
  }
115
112
  else {
@@ -122,19 +119,36 @@ class Graph extends event_emitter_1.default {
122
119
  return;
123
120
  }
124
121
  this.container = containerDOM;
125
- const size = [width, height];
126
- if (size[0] === undefined) {
127
- size[0] = containerDOM.scrollWidth;
128
- }
129
- if (size[1] === undefined) {
130
- size[1] = containerDOM.scrollHeight;
131
- }
132
- this.backgroundCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
133
- this.canvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
134
- this.transientCanvas = (0, canvas_1.createCanvas)(this.rendererType, containerDOM, size[0], size[1], pixelRatio);
135
122
  }
136
- Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready)).then(() => {
137
- [this.backgroundCanvas, this.canvas, this.transientCanvas].forEach((canvas, i) => {
123
+ [
124
+ 'backgroundCanvas',
125
+ 'canvas',
126
+ 'labelCanvas',
127
+ 'transientCanvas',
128
+ 'transientLabelCanvas',
129
+ ].forEach((name) => {
130
+ this[name] =
131
+ this.specification[name] ||
132
+ (0, canvas_1.createCanvas)(['labelCanvas', 'transientLabelCanvas'].includes(name)
133
+ ? 'canvas'
134
+ : this.rendererType, this.container, width !== null && width !== void 0 ? width : this.container.scrollWidth, height !== null && height !== void 0 ? height : this.container.scrollHeight, pixelRatio, undefined,
135
+ // enable dom interaction only for main canvas
136
+ name === 'canvas' ? [] : ['dom-interaction']);
137
+ });
138
+ Promise.all([
139
+ this.backgroundCanvas,
140
+ this.canvas,
141
+ this.labelCanvas,
142
+ this.transientCanvas,
143
+ this.transientLabelCanvas,
144
+ ].map((canvas) => canvas.ready)).then(() => {
145
+ [
146
+ this.backgroundCanvas,
147
+ this.canvas,
148
+ this.labelCanvas,
149
+ this.transientCanvas,
150
+ this.transientLabelCanvas,
151
+ ].forEach((canvas, i) => {
138
152
  const $domElement = canvas
139
153
  .getContextService()
140
154
  .getDomElement();
@@ -196,6 +210,9 @@ class Graph extends event_emitter_1.default {
196
210
  itemstatechange: new hooks_1.default({
197
211
  name: 'itemstatechange',
198
212
  }),
213
+ itemstateconfigchange: new hooks_1.default({
214
+ name: 'itemstateconfigchange',
215
+ }),
199
216
  itemvisibilitychange: new hooks_1.default({
200
217
  name: 'itemvisibilitychange',
201
218
  }),
@@ -218,8 +235,22 @@ class Graph extends event_emitter_1.default {
218
235
  * Update the specs(configurations).
219
236
  */
220
237
  updateSpecification(spec) {
221
- const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
222
- // TODO: update something
238
+ const { node, edge, combo, theme, nodeState, edgeState, comboState } = spec, others = __rest(spec, ["node", "edge", "combo", "theme", "nodeState", "edgeState", "comboState"]);
239
+ if (node)
240
+ this.updateMapper('node', node);
241
+ if (edge)
242
+ this.updateMapper('edge', edge);
243
+ if (combo)
244
+ this.updateMapper('combo', combo);
245
+ if (theme)
246
+ this.updateTheme(theme);
247
+ if (nodeState)
248
+ this.updateStateConfig('node', nodeState, 'replace');
249
+ if (edgeState)
250
+ this.updateStateConfig('edge', edgeState, 'replace');
251
+ if (comboState)
252
+ this.updateStateConfig('combo', comboState, 'replace');
253
+ const newSpec = Object.assign(this.specification, this.formatSpecification(others));
223
254
  return newSpec;
224
255
  }
225
256
  /**
@@ -263,6 +294,26 @@ class Graph extends event_emitter_1.default {
263
294
  mapper,
264
295
  });
265
296
  }
297
+ /**
298
+ * Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
299
+ * @param {string} itemType - The type of item (node, edge, or combo).
300
+ * @param {object} stateConfig - The state configuration to update.
301
+ * @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
302
+ **/
303
+ updateStateConfig(itemType, stateConfig, updateType = 'mergeReplace') {
304
+ if ((0, util_1.isEmpty)(stateConfig))
305
+ return;
306
+ const stateField = `${itemType}State`;
307
+ if (updateType === 'mergeReplace') {
308
+ const config = Object.assign(Object.assign({}, this.specification[stateField]), stateConfig);
309
+ this.specification[itemType] = config;
310
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
311
+ }
312
+ else {
313
+ this.specification[itemType] = stateConfig;
314
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
315
+ }
316
+ }
266
317
  /**
267
318
  * Get the copy of specs(configurations).
268
319
  * @returns graph specs
@@ -286,6 +337,7 @@ class Graph extends event_emitter_1.default {
286
337
  graphCore: this.dataController.graphCore,
287
338
  theme: this.themeController.specification,
288
339
  transientCanvas: this.transientCanvas,
340
+ transientLabelCanvas: this.transientLabelCanvas,
289
341
  tileOptimize: {
290
342
  tileFirstRender,
291
343
  tileFirstRenderSize,
@@ -326,7 +378,13 @@ class Graph extends event_emitter_1.default {
326
378
  yield emitRender();
327
379
  }
328
380
  else {
329
- yield Promise.all([this.backgroundCanvas, this.canvas, this.transientCanvas].map((canvas) => canvas.ready));
381
+ yield Promise.all([
382
+ this.backgroundCanvas,
383
+ this.canvas,
384
+ this.labelCanvas,
385
+ this.transientCanvas,
386
+ this.transientLabelCanvas,
387
+ ].map((canvas) => canvas.ready));
330
388
  yield emitRender();
331
389
  }
332
390
  });
@@ -335,10 +393,11 @@ class Graph extends event_emitter_1.default {
335
393
  * Change graph data.
336
394
  * @param data new data
337
395
  * @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)
396
+ * @param relayout whether relayout the nodes after data changing
338
397
  * @returns
339
398
  * @group Data
340
399
  */
341
- changeData(data, type = 'mergeReplace') {
400
+ changeData(data, type = 'mergeReplace', relayout = true) {
342
401
  return __awaiter(this, void 0, void 0, function* () {
343
402
  const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
344
403
  this.hooks.datachange.emit({ data, type });
@@ -346,13 +405,16 @@ class Graph extends event_emitter_1.default {
346
405
  graphCore: this.dataController.graphCore,
347
406
  theme: this.themeController.specification,
348
407
  transientCanvas: this.transientCanvas,
408
+ transientLabelCanvas: this.transientLabelCanvas,
349
409
  tileOptimize: {
350
410
  tileFirstRender,
351
411
  tileFirstRenderSize,
352
412
  },
353
413
  });
354
414
  this.emit('afterrender');
355
- yield this.layout();
415
+ if (relayout) {
416
+ yield this.layout();
417
+ }
356
418
  });
357
419
  }
358
420
  /**
@@ -505,8 +567,8 @@ class Graph extends event_emitter_1.default {
505
567
  const { direction = 'both', ratioRule = 'min', boundsType = 'render', onlyOutOfViewport = false, onlyZoomAtLargerThanViewport = false, } = rules || {};
506
568
  const { min, max, center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
507
569
  ? // Get the bounds of the whole graph content.
508
- this.canvas.document.documentElement.getBounds()
509
- : // Get the bounds of the nodes positions while the graph content is not ready.
570
+ (0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
571
+ : // Get the b ounds of the nodes positions while the graph content is not ready.
510
572
  (0, layout_1.getLayoutBounds)(this);
511
573
  const origin = this.canvas.canvas2Viewport({
512
574
  x: graphCenterX,
@@ -566,7 +628,7 @@ class Graph extends event_emitter_1.default {
566
628
  return __awaiter(this, void 0, void 0, function* () {
567
629
  const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
568
630
  ? // Get the bounds of the whole graph content.
569
- this.canvas.document.documentElement.getBounds()
631
+ (0, bbox_1.getCombinedCanvasesBounds)([this.canvas, this.labelCanvas])
570
632
  : // Get the bounds of the nodes positions while the graph content is not ready.
571
633
  (0, layout_1.getLayoutBounds)(this);
572
634
  yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
@@ -629,9 +691,15 @@ class Graph extends event_emitter_1.default {
629
691
  this.emit('beforesetsize', { oldSize, size: size });
630
692
  this.specification.width = size[0];
631
693
  this.specification.height = size[1];
632
- this.canvas.resize(size[0], size[1]);
633
- this.transientCanvas.resize(size[0], size[1]);
634
- this.backgroundCanvas.resize(size[0], size[1]);
694
+ [
695
+ this.canvas,
696
+ this.labelCanvas,
697
+ this.transientCanvas,
698
+ this.transientLabelCanvas,
699
+ this.backgroundCanvas,
700
+ ].forEach((canvas) => {
701
+ canvas.resize(size[0], size[1]);
702
+ });
635
703
  this.emit('aftersetsize', { oldSize, size: size });
636
704
  }
637
705
  getCanvasRange() {
@@ -760,6 +828,16 @@ class Graph extends event_emitter_1.default {
760
828
  getRelatedEdgesData(nodeId, direction = 'both') {
761
829
  return this.dataController.findRelatedEdges(nodeId, direction);
762
830
  }
831
+ /**
832
+ * Get nearby edges from a start node using quad-tree collision detection.
833
+ * @param nodeId id of the start node
834
+ * @returns nearby edges' data array
835
+ */
836
+ getNearEdgesData(nodeId, shouldBegin) {
837
+ const transientItem = this.itemController.getTransientItem(nodeId);
838
+ const itemMap = this.itemController.getItemMap();
839
+ return this.dataController.findNearEdges(nodeId, itemMap, transientItem, shouldBegin);
840
+ }
763
841
  /**
764
842
  * Get one-hop node ids from a start node.
765
843
  * @param nodeId id of the start node
@@ -797,15 +875,6 @@ class Graph extends event_emitter_1.default {
797
875
  getDisplayModel(id) {
798
876
  return this.itemController.findDisplayModel(id);
799
877
  }
800
- /**
801
- * Retrieve the nearby edges for a given node using quadtree collision detection.
802
- * @param nodeId node id
803
- * @group Data
804
- */
805
- getNearEdgesForNode(nodeId) {
806
- const { graphCore } = this.dataController;
807
- return this.itemController.findNearEdgesByNode(nodeId, graphCore);
808
- }
809
878
  /**
810
879
  * Find items which has the state.
811
880
  * @param itemType item type
@@ -837,6 +906,7 @@ class Graph extends event_emitter_1.default {
837
906
  // data controller and item controller subscribe additem in order
838
907
  const { graphCore } = this.dataController;
839
908
  const { specification } = this.themeController;
909
+ const modelArr = (0, util_1.isArray)(models) ? models : [models];
840
910
  graphCore.once('changed', (event) => {
841
911
  if (!event.changes.length)
842
912
  return;
@@ -844,7 +914,7 @@ class Graph extends event_emitter_1.default {
844
914
  const timingParameters = {
845
915
  type: itemType,
846
916
  action: 'add',
847
- models,
917
+ models: modelArr,
848
918
  apiName: 'addData',
849
919
  changes,
850
920
  };
@@ -857,7 +927,6 @@ class Graph extends event_emitter_1.default {
857
927
  });
858
928
  this.emit('afteritemchange', timingParameters);
859
929
  });
860
- const modelArr = (0, util_1.isArray)(models) ? models : [models];
861
930
  const data = { nodes: [], edges: [], combos: [] };
862
931
  data[`${itemType}s`] = modelArr;
863
932
  this.hooks.datachange.emit({
@@ -869,7 +938,8 @@ class Graph extends event_emitter_1.default {
869
938
  }
870
939
  /**
871
940
  * Remove one or more node/edge/combo data from the graph.
872
- * @param item the item to be removed
941
+ * @param itemType the type the item(s) to be removed.
942
+ * @param id the id or the ids' array of the items to be removed.
873
943
  * @returns whether success
874
944
  * @group Data
875
945
  */
@@ -963,8 +1033,8 @@ class Graph extends event_emitter_1.default {
963
1033
  }
964
1034
  /**
965
1035
  * Update one or more node/edge/combo data on the graph.
966
- * @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
967
- * @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
1036
+ * @param {ITEM_TYPE} itemType the type the item(s) to be udated.
1037
+ * @param models update configs.
968
1038
  * @group Data
969
1039
  */
970
1040
  updateData(itemType, models) {
@@ -974,11 +1044,11 @@ class Graph extends event_emitter_1.default {
974
1044
  const { graphCore } = this.dataController;
975
1045
  const { specification } = this.themeController;
976
1046
  graphCore.once('changed', (event) => {
977
- const changes = this.extendChanges((0, util_1.clone)(event.changes));
1047
+ const changes = this.extendChanges((0, data_1.cloneJSON)(event.changes));
978
1048
  const timingParameters = {
979
1049
  type: itemType,
980
1050
  action: 'update',
981
- models,
1051
+ models: modelArr,
982
1052
  apiName: 'updateData',
983
1053
  changes,
984
1054
  };
@@ -1001,21 +1071,27 @@ class Graph extends event_emitter_1.default {
1001
1071
  /**
1002
1072
  * Update one or more nodes' positions,
1003
1073
  * do not update other styles which leads to better performance than updating positions by updateData.
1004
- * @param models new configurations with x and y for every node, which has id field to indicate the specific item
1074
+ * @param models new configurations with x and y for every node, which has id field to indicate the specific item.
1075
+ * @param upsertAncestors whether update the ancestors in combo tree.
1076
+ * @param disableAnimate whether disable the animation for this call.
1077
+ * @param callback callback function after update nodes done.
1005
1078
  * @group Data
1006
1079
  */
1007
- updateNodePosition(models, upsertAncestors, disableAnimate = false, callback, stack) {
1008
- return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback, stack);
1080
+ updateNodePosition(models, upsertAncestors, disableAnimate = false, callback) {
1081
+ return this.updatePosition('node', models, upsertAncestors, disableAnimate, callback);
1009
1082
  }
1010
1083
  /**
1011
1084
  * Update one or more combos' positions,
1012
1085
  * do not update other styles which leads to better performance than updating positions by updateData.
1013
1086
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1014
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1087
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
1088
+ * @param upsertAncestors whether update the ancestors in combo tree.
1089
+ * @param disableAnimate whether disable the animation for this call.
1090
+ * @param callback callback function after update combos done.
1015
1091
  * @group Data
1016
1092
  */
1017
- updateComboPosition(models, upsertAncestors, disableAnimate = false, callback, stack) {
1018
- return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback, stack);
1093
+ updateComboPosition(models, upsertAncestors, disableAnimate = false, callback) {
1094
+ return this.updatePosition('combo', models, upsertAncestors, disableAnimate, callback);
1019
1095
  }
1020
1096
  /**
1021
1097
  * Get history plugin instance
@@ -1028,7 +1104,7 @@ class Graph extends event_emitter_1.default {
1028
1104
  }
1029
1105
  return this.pluginController.getPlugin('history');
1030
1106
  }
1031
- updatePosition(type, models, upsertAncestors, disableAnimate = false, callback, stack) {
1107
+ updatePosition(type, models, upsertAncestors, disableAnimate = false, callback) {
1032
1108
  const modelArr = (0, util_1.isArray)(models) ? models : [models];
1033
1109
  const { graphCore } = this.dataController;
1034
1110
  const { specification } = this.themeController;
@@ -1040,7 +1116,7 @@ class Graph extends event_emitter_1.default {
1040
1116
  type,
1041
1117
  action: 'updatePosition',
1042
1118
  upsertAncestors,
1043
- models,
1119
+ models: modelArr,
1044
1120
  apiName: 'updatePosition',
1045
1121
  changes,
1046
1122
  };
@@ -1063,7 +1139,7 @@ class Graph extends event_emitter_1.default {
1063
1139
  edges: [],
1064
1140
  combos: type === 'combo' ? modelArr : [],
1065
1141
  },
1066
- type: 'update',
1142
+ type: 'updatePosition',
1067
1143
  });
1068
1144
  const dataList = this.dataController.findData(type, modelArr.map((model) => model.id));
1069
1145
  return (0, util_1.isArray)(models) ? dataList : dataList[0];
@@ -1086,22 +1162,40 @@ class Graph extends event_emitter_1.default {
1086
1162
  * @returns
1087
1163
  * @group Item
1088
1164
  */
1089
- showItem(ids, disableAnimate = false) {
1165
+ showItem(ids, options) {
1166
+ const { disableAnimate = false, shapeIds } = options || {};
1090
1167
  const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
1091
1168
  if ((0, util_1.isEmpty)(idArr))
1092
1169
  return;
1093
- const changes = {
1094
- newValue: [{ ids: idArr, visible: true }],
1095
- oldValue: this.getItemPreviousVisibility(idArr),
1096
- };
1097
- this.hooks.itemvisibilitychange.emit({
1098
- ids: idArr,
1099
- value: true,
1100
- graphCore: this.dataController.graphCore,
1101
- animate: !disableAnimate,
1102
- });
1170
+ let changes;
1171
+ if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
1172
+ const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
1173
+ changes = {
1174
+ newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
1175
+ oldValue: this.getItemPreviousVisibility(idArr),
1176
+ };
1177
+ this.hooks.itemvisibilitychange.emit({
1178
+ ids: idArr,
1179
+ value: true,
1180
+ graphCore: this.dataController.graphCore,
1181
+ animate: !disableAnimate,
1182
+ shapeIds: shapeIdsArr,
1183
+ });
1184
+ }
1185
+ else {
1186
+ changes = {
1187
+ newValue: [{ ids: idArr, visible: true }],
1188
+ oldValue: this.getItemPreviousVisibility(idArr),
1189
+ };
1190
+ this.hooks.itemvisibilitychange.emit({
1191
+ ids: idArr,
1192
+ value: true,
1193
+ graphCore: this.dataController.graphCore,
1194
+ animate: !disableAnimate,
1195
+ });
1196
+ }
1103
1197
  this.emit('afteritemvisibilitychange', {
1104
- ids,
1198
+ ids: idArr,
1105
1199
  value: true,
1106
1200
  animate: !disableAnimate,
1107
1201
  action: 'updateVisibility',
@@ -1111,27 +1205,49 @@ class Graph extends event_emitter_1.default {
1111
1205
  }
1112
1206
  /**
1113
1207
  * Hide the item(s).
1114
- * @param item the item to be hidden
1208
+ * @param id the id for the item to be hidden.
1209
+ * @param disableAnimate whether disable the hidden animations.
1210
+ * @param keepKeyShape whether keep the keyShape.
1211
+ * @param keepRelated whether keep the related nodes for edge.
1115
1212
  * @returns
1116
1213
  * @group Item
1117
1214
  */
1118
- hideItem(ids, disableAnimate = false, keepKeyShape = false) {
1215
+ hideItem(ids, options) {
1216
+ const { disableAnimate = false, keepKeyShape = false, keepRelated = false, shapeIds, } = options || {};
1119
1217
  const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
1120
1218
  if ((0, util_1.isEmpty)(idArr))
1121
1219
  return;
1122
- const changes = {
1123
- newValue: [{ ids: idArr, visible: false }],
1124
- oldValue: this.getItemPreviousVisibility(idArr),
1125
- };
1126
- this.hooks.itemvisibilitychange.emit({
1127
- ids: idArr,
1128
- value: false,
1129
- graphCore: this.dataController.graphCore,
1130
- animate: !disableAnimate,
1131
- keepKeyShape,
1132
- });
1220
+ let changes;
1221
+ if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
1222
+ const shapeIdsArr = (0, util_1.isArray)(shapeIds) ? shapeIds : [shapeIds];
1223
+ changes = {
1224
+ newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
1225
+ oldValue: this.getItemPreviousVisibility(idArr),
1226
+ };
1227
+ this.hooks.itemvisibilitychange.emit({
1228
+ ids: idArr,
1229
+ value: false,
1230
+ graphCore: this.dataController.graphCore,
1231
+ animate: !disableAnimate,
1232
+ shapeIds: shapeIdsArr,
1233
+ });
1234
+ }
1235
+ else {
1236
+ changes = {
1237
+ newValue: [{ ids: idArr, visible: false }],
1238
+ oldValue: this.getItemPreviousVisibility(idArr),
1239
+ };
1240
+ this.hooks.itemvisibilitychange.emit({
1241
+ ids: idArr,
1242
+ value: false,
1243
+ graphCore: this.dataController.graphCore,
1244
+ animate: !disableAnimate,
1245
+ keepKeyShape,
1246
+ keepRelated,
1247
+ });
1248
+ }
1133
1249
  this.emit('afteritemvisibilitychange', {
1134
- ids,
1250
+ ids: idArr,
1135
1251
  value: false,
1136
1252
  animate: !disableAnimate,
1137
1253
  action: 'updateVisibility',
@@ -1292,11 +1408,20 @@ class Graph extends event_emitter_1.default {
1292
1408
  getItemVisible(id) {
1293
1409
  return this.itemController.getItemVisible(id);
1294
1410
  }
1411
+ /**
1412
+ * Get the visible shape ids in a node / edge / combo.
1413
+ * @param id the id for the node / edge / combo
1414
+ * @returns ids of the visible shapes
1415
+ */
1416
+ getItemVisibleShapeIds(id) {
1417
+ return this.itemController.getItemVisibleShapeIds(id);
1418
+ }
1295
1419
  // ===== combo operations =====
1296
1420
  /**
1297
1421
  * 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.
1298
- * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
1299
- * @param model combo user data
1422
+ * Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
1423
+ * @param model combo user data.
1424
+ * @param childrenIds the ids of the children nodes / combos to move into the new combo.
1300
1425
  * @returns whether success
1301
1426
  * @group Combo
1302
1427
  */
@@ -1338,7 +1463,7 @@ class Graph extends event_emitter_1.default {
1338
1463
  }
1339
1464
  /**
1340
1465
  * Collapse a combo.
1341
- * @param comboId combo ids
1466
+ * @param comboId combo id or ids' array.
1342
1467
  * @group Combo
1343
1468
  */
1344
1469
  collapseCombo(comboIds) {
@@ -1355,7 +1480,7 @@ class Graph extends event_emitter_1.default {
1355
1480
  }
1356
1481
  /**
1357
1482
  * Expand a combo.
1358
- * @param combo combo ids
1483
+ * @param comboId combo id or ids' array.
1359
1484
  * @group Combo
1360
1485
  */
1361
1486
  expandCombo(comboIds) {
@@ -1374,7 +1499,11 @@ class Graph extends event_emitter_1.default {
1374
1499
  * Move one or more combos a distance (dx, dy) relatively,
1375
1500
  * do not update other styles which leads to better performance than updating positions by updateData.
1376
1501
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1377
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1502
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
1503
+ * @param dx the distance alone x-axis to move the combo.
1504
+ * @param dy the distance alone y-axis to move the combo.
1505
+ * @param upsertAncestors whether update the ancestors in the combo tree.
1506
+ * @param callback callback function after move combo done.
1378
1507
  * @group Combo
1379
1508
  */
1380
1509
  moveCombo(ids, dx, dy, upsertAncestors, callback) {
@@ -1496,7 +1625,9 @@ class Graph extends event_emitter_1.default {
1496
1625
  */
1497
1626
  setCursor(cursor) {
1498
1627
  this.canvas.setCursor(cursor);
1628
+ this.labelCanvas.setCursor(cursor);
1499
1629
  this.transientCanvas.setCursor(cursor);
1630
+ this.transientLabelCanvas.setCursor(cursor);
1500
1631
  }
1501
1632
  /**
1502
1633
  * Add behavior(s) to mode(s).
@@ -1628,10 +1759,9 @@ class Graph extends event_emitter_1.default {
1628
1759
  */
1629
1760
  updatePlugin(plugin) {
1630
1761
  const { plugins } = this.specification;
1631
- const { key } = plugin;
1762
+ const { key, type } = plugin;
1632
1763
  if (!key) {
1633
- console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
1634
- return;
1764
+ console.warn(`The key for the plugin is not found. G6 will update the first plugin with type ${type}`);
1635
1765
  }
1636
1766
  if (!plugins) {
1637
1767
  console.warn('Update plugin failed, the plugin to be updated does not exist.');
@@ -1639,11 +1769,12 @@ class Graph extends event_emitter_1.default {
1639
1769
  }
1640
1770
  const oldPlugin = plugins === null || plugins === void 0 ? void 0 : plugins.find((p) => {
1641
1771
  if (typeof p === 'string')
1642
- return p === key;
1643
- return p.key === key;
1772
+ return p === key || p === type;
1773
+ return (p.key === key ||
1774
+ p.type === type);
1644
1775
  });
1645
1776
  if (!oldPlugin) {
1646
- console.warn('Update plugin failed, the key for the plugin to be updated should be assign.');
1777
+ console.warn(`Update plugin failed, the plugin with key ${key} or type ${type} is not found.`);
1647
1778
  return;
1648
1779
  }
1649
1780
  const idx = plugins.indexOf(oldPlugin);
@@ -1656,7 +1787,7 @@ class Graph extends event_emitter_1.default {
1656
1787
  /**
1657
1788
  * Draw or update a G shape or group to the transient canvas.
1658
1789
  * @param type shape type or item type
1659
- * @param id new shape id or updated shape id for a interation shape, node/edge/combo id for item interaction group drawing
1790
+ * @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
1660
1791
  * @returns upserted shape or group
1661
1792
  * @group Interaction
1662
1793
  */
@@ -1679,45 +1810,62 @@ class Graph extends event_emitter_1.default {
1679
1810
  */
1680
1811
  toDataURL(type) {
1681
1812
  return __awaiter(this, void 0, void 0, function* () {
1682
- const backgroundCanvas = this.backgroundCanvas;
1683
- const canvas = this.canvas;
1684
- const transientCanvas = this.transientCanvas;
1685
- const rendererType = this.rendererType;
1813
+ const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
1686
1814
  const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1687
- const width = this.getSize()[0];
1688
- const height = this.getSize()[1];
1815
+ const [width, height] = this.getSize();
1689
1816
  const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
1817
+ const camera = canvas.getCamera();
1690
1818
  const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, width, height, pixelRatio);
1819
+ yield vCanvas.ready;
1820
+ const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1821
+ const clonedGroup = canvas.getRoot().cloneNode(true);
1822
+ const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1823
+ const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
1824
+ const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
1825
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1826
+ labelClonedGroup.translate([
1827
+ currentViewportLTCanvas.x - originViewportLTCanvas.x,
1828
+ currentViewportLTCanvas.y - originViewportLTCanvas.y,
1829
+ ]);
1830
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
1831
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
1832
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
1833
+ childGroup.children.forEach((shape) => {
1834
+ if (shape.getAttribute('data-is-label-background') &&
1835
+ shape.style.transform)
1836
+ shape.remove();
1837
+ });
1838
+ });
1839
+ vCanvas.appendChild(backgroundClonedGroup);
1840
+ vCanvas.appendChild(clonedGroup);
1841
+ vCanvas.appendChild(labelClonedGroup);
1842
+ vCanvas.appendChild(transientClonedGroup);
1843
+ const vCamera = vCanvas.getCamera();
1844
+ vCamera.setZoom(camera.getZoom());
1845
+ vCamera.setPosition(camera.getPosition());
1846
+ vCamera.setFocalPoint(camera.getFocalPoint());
1691
1847
  const vCanvasContextService = vCanvas.getContextService();
1692
1848
  let bgRect;
1693
1849
  if (rendererType !== 'svg') {
1850
+ const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1694
1851
  bgRect = new g_1.Rect({
1695
- style: {
1696
- x: 0,
1697
- y: 0,
1698
- z: -1,
1699
- width: vCanvasContextService.getDomElement().width,
1700
- height: vCanvasContextService.getDomElement().height,
1852
+ style: Object.assign(Object.assign({}, backPositionCanvas), { z: -1, width: vCanvasContextService.getDomElement().width, height: vCanvasContextService.getDomElement().height,
1701
1853
  //@ts-ignore
1702
- fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1703
- },
1854
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'], zIndex: -10 }),
1704
1855
  });
1705
1856
  vCanvas.appendChild(bgRect);
1706
1857
  }
1707
- const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1708
- const clonedGroup = canvas.getRoot().cloneNode(true);
1709
- const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1710
- vCanvas.appendChild(backgroundClonedGroup);
1711
- vCanvas.appendChild(clonedGroup);
1712
- vCanvas.appendChild(transientClonedGroup);
1713
- vCanvas.render();
1714
1858
  if (!type)
1715
1859
  type = 'image/png';
1716
1860
  let dataURL = '';
1717
- yield vCanvasContextService.toDataURL({ type }).then((url) => {
1718
- dataURL = url;
1861
+ return new Promise((resolve) => {
1862
+ setTimeout(() => {
1863
+ vCanvasContextService.toDataURL({ type }).then((url) => {
1864
+ dataURL = url;
1865
+ resolve(dataURL);
1866
+ });
1867
+ }, 50);
1719
1868
  });
1720
- return dataURL;
1721
1869
  });
1722
1870
  }
1723
1871
  /**
@@ -1729,16 +1877,15 @@ class Graph extends event_emitter_1.default {
1729
1877
  */
1730
1878
  toFullDataURL(type, imageConfig) {
1731
1879
  return __awaiter(this, void 0, void 0, function* () {
1732
- const backgroundCanvas = this.backgroundCanvas;
1733
- const canvas = this.canvas;
1734
- const transientCanvas = this.transientCanvas;
1735
- const backgroundRoot = canvas.getRoot();
1880
+ const { backgroundCanvas, canvas, transientCanvas, labelCanvas, rendererType, } = this;
1881
+ const backgroundRoot = backgroundCanvas.getRoot();
1736
1882
  const root = canvas.getRoot();
1737
1883
  const transientRoot = transientCanvas.getRoot();
1738
- const rendererType = this.rendererType;
1739
- const backgroundBBox = backgroundRoot.getBBox();
1740
- const BBox = root.getBBox();
1741
- const transientBBox = transientRoot.getBBox();
1884
+ const labelRoot = labelCanvas.getRoot();
1885
+ const backgroundBBox = backgroundRoot.getRenderBounds();
1886
+ const BBox = root.getRenderBounds();
1887
+ const transientBBox = transientRoot.getRenderBounds();
1888
+ const labelBBox = labelRoot.getRenderBounds();
1742
1889
  let padding = imageConfig ? imageConfig.padding : undefined;
1743
1890
  if (!padding) {
1744
1891
  padding = [0, 0, 0, 0];
@@ -1746,26 +1893,10 @@ class Graph extends event_emitter_1.default {
1746
1893
  else if ((0, util_1.isNumber)(padding)) {
1747
1894
  padding = [padding, padding, padding, padding];
1748
1895
  }
1749
- const left = (transientBBox.left
1750
- ? backgroundBBox.left
1751
- ? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
1752
- : Math.min(BBox.left, transientBBox.left)
1753
- : BBox.left) - padding[3];
1754
- const right = (transientBBox.right
1755
- ? backgroundBBox.right
1756
- ? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
1757
- : Math.max(BBox.right, transientBBox.right)
1758
- : BBox.right) + padding[1];
1759
- const top = (transientBBox.top
1760
- ? backgroundBBox.top
1761
- ? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
1762
- : Math.min(BBox.top, transientBBox.top)
1763
- : BBox.top) - padding[0];
1764
- const bottom = (transientBBox.bottom
1765
- ? backgroundBBox.bottom
1766
- ? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
1767
- : Math.max(BBox.bottom, transientBBox.bottom)
1768
- : BBox.bottom) + padding[2];
1896
+ const left = Math.min(backgroundBBox.min[0] || Infinity, BBox.min[0] || Infinity, transientBBox.min[0] || Infinity, labelBBox.min[0] || Infinity) - padding[3];
1897
+ const right = Math.max(backgroundBBox.max[0] || -Infinity, BBox.max[0] || -Infinity, transientBBox.max[0] || -Infinity, labelBBox.max[0] || -Infinity) - padding[1];
1898
+ const top = Math.min(backgroundBBox.min[1] || Infinity, BBox.min[1] || Infinity, transientBBox.min[1] || Infinity, labelBBox.min[1] || Infinity) - padding[0];
1899
+ const bottom = Math.max(backgroundBBox.max[1] || -Infinity, BBox.max[1] || -Infinity, transientBBox.max[1] || -Infinity, labelBBox.max[1] || -Infinity) - padding[2];
1769
1900
  const graphCenterX = (left + right) / 2;
1770
1901
  const graphCenterY = (top + bottom) / 2;
1771
1902
  const halfX = (right - left) / 2;
@@ -1775,6 +1906,7 @@ class Graph extends event_emitter_1.default {
1775
1906
  const vHeight = halfY * 2;
1776
1907
  const vContainerDOM = (0, dom_1.createDOM)('<div id="virtual-image"></div>');
1777
1908
  const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
1909
+ yield vCanvas.ready;
1778
1910
  const vCanvasContextService = vCanvas.getContextService();
1779
1911
  if (rendererType !== 'svg') {
1780
1912
  const bgRect = new g_1.Rect({
@@ -1793,6 +1925,7 @@ class Graph extends event_emitter_1.default {
1793
1925
  const backgroundClonedGroup = backgroundRoot.cloneNode(true);
1794
1926
  const clonedGroup = root.cloneNode(true);
1795
1927
  const transientClonedGroup = transientRoot.cloneNode(true);
1928
+ const labelClonedGroup = labelRoot.cloneNode(true);
1796
1929
  const transPosition = [
1797
1930
  -graphCenterX + halfX,
1798
1931
  -graphCenterY + halfY,
@@ -1800,17 +1933,36 @@ class Graph extends event_emitter_1.default {
1800
1933
  backgroundClonedGroup.setPosition(transPosition);
1801
1934
  clonedGroup.setPosition(transPosition);
1802
1935
  transientClonedGroup.setPosition(transPosition);
1936
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
1937
+ const labelTransPosition = [
1938
+ transPosition[0] + currentViewportLTCanvas.x,
1939
+ transPosition[1] + currentViewportLTCanvas.y,
1940
+ ];
1941
+ labelClonedGroup.setPosition(labelTransPosition);
1942
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
1943
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
1944
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
1945
+ childGroup.children.forEach((shape) => {
1946
+ if (shape.getAttribute('data-is-label-background') &&
1947
+ shape.style.transform)
1948
+ shape.remove();
1949
+ });
1950
+ });
1803
1951
  vCanvas.appendChild(backgroundClonedGroup);
1804
1952
  vCanvas.appendChild(clonedGroup);
1953
+ vCanvas.appendChild(labelClonedGroup);
1805
1954
  vCanvas.appendChild(transientClonedGroup);
1806
- vCanvas.render();
1807
1955
  if (!type)
1808
1956
  type = 'image/png';
1809
1957
  let dataURL = '';
1810
- yield vCanvasContextService.toDataURL({ type }).then((url) => {
1811
- dataURL = url;
1958
+ return new Promise((resolve) => {
1959
+ setTimeout(() => {
1960
+ vCanvasContextService.toDataURL({ type }).then((url) => {
1961
+ dataURL = url;
1962
+ resolve(dataURL);
1963
+ });
1964
+ }, 50);
1812
1965
  });
1813
- return dataURL;
1814
1966
  });
1815
1967
  }
1816
1968
  /**
@@ -2072,7 +2224,7 @@ class Graph extends event_emitter_1.default {
2072
2224
  * @returns
2073
2225
  * @group Tree
2074
2226
  */
2075
- collapse(ids, disableAnimate = false, stack) {
2227
+ collapse(ids, disableAnimate = false) {
2076
2228
  this.hooks.treecollapseexpand.emit({
2077
2229
  ids: (0, util_1.isArray)(ids) ? ids : [ids],
2078
2230
  action: 'collapse',
@@ -2088,7 +2240,7 @@ class Graph extends event_emitter_1.default {
2088
2240
  * @returns
2089
2241
  * @group Tree
2090
2242
  */
2091
- expand(ids, disableAnimate = false, stack) {
2243
+ expand(ids, disableAnimate = false) {
2092
2244
  this.hooks.treecollapseexpand.emit({
2093
2245
  ids: (0, util_1.isArray)(ids) ? ids : [ids],
2094
2246
  action: 'expand',
@@ -2102,15 +2254,23 @@ class Graph extends event_emitter_1.default {
2102
2254
  * @group Graph Instance
2103
2255
  */
2104
2256
  destroy(callback) {
2105
- // TODO: call the destroy functions after items' buildOut animations finished
2106
- // setTimeout(() => {
2257
+ var _a;
2258
+ const camera = this.canvas.getCamera();
2259
+ const transientCamera = this.transientCanvas.getCamera();
2260
+ // @ts-ignore
2261
+ if ((_a = camera.landmarks) === null || _a === void 0 ? void 0 : _a.length) {
2262
+ camera.cancelLandmarkAnimation();
2263
+ transientCamera.cancelLandmarkAnimation();
2264
+ this.emit('cancelviewportanimation');
2265
+ }
2107
2266
  this.canvas.destroy();
2267
+ this.labelCanvas.destroy();
2108
2268
  this.backgroundCanvas.destroy();
2109
2269
  this.transientCanvas.destroy();
2270
+ this.transientLabelCanvas.destroy();
2110
2271
  // clear history stack
2111
2272
  this.cleanHistory();
2112
2273
  callback === null || callback === void 0 ? void 0 : callback();
2113
- // }, 500);
2114
2274
  this.hooks.destroy.emit({});
2115
2275
  // TODO: destroy controllers and off the listeners
2116
2276
  // this.dataController.destroy();
@@ -2118,7 +2278,6 @@ class Graph extends event_emitter_1.default {
2118
2278
  // this.layoutController.destroy();
2119
2279
  // this.themeController.destroy();
2120
2280
  // this.itemController.destroy();
2121
- // this.extensionController.destroy();
2122
2281
  this.destroyed = true;
2123
2282
  }
2124
2283
  }