@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
@@ -33,10 +33,19 @@ import type {
33
33
  } from '../types';
34
34
  import type { CameraAnimationOptions } from '../types/animate';
35
35
  import type { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
36
- import type { ComboDisplayModel, ComboModel } from '../types/combo';
36
+ import type {
37
+ ComboDisplayModel,
38
+ ComboModel,
39
+ ComboShapesEncode,
40
+ } from '../types/combo';
37
41
  import type { Bounds, Padding, Point } from '../types/common';
38
42
  import type { DataChangeType, DataConfig, GraphCore } from '../types/data';
39
- import type { EdgeDisplayModel, EdgeModel, EdgeModelData } from '../types/edge';
43
+ import type {
44
+ EdgeDisplayModel,
45
+ EdgeModel,
46
+ EdgeModelData,
47
+ EdgeShapesEncode,
48
+ } from '../types/edge';
40
49
  import type { StackType } from '../types/history';
41
50
  import type { Hooks, ViewportChangeHookParams } from '../types/hook';
42
51
  import type { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from '../types/item';
@@ -45,7 +54,12 @@ import type {
45
54
  LayoutOptions,
46
55
  StandardLayoutOptions,
47
56
  } from '../types/layout';
48
- import type { NodeDisplayModel, NodeModel, NodeModelData } from '../types/node';
57
+ import type {
58
+ NodeDisplayModel,
59
+ NodeModel,
60
+ NodeModelData,
61
+ NodeShapesEncode,
62
+ } from '../types/node';
49
63
  import { Plugin as PluginBase } from '../types/plugin';
50
64
  import type { RendererName } from '../types/render';
51
65
  import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
@@ -59,34 +73,39 @@ import { changeRenderer, createCanvas } from '../util/canvas';
59
73
  import { createDOM } from '../util/dom';
60
74
  import { getLayoutBounds } from '../util/layout';
61
75
  import { formatPadding } from '../util/shape';
76
+ import Node from '../item/node';
77
+ import { cloneJSON, isEmptyGraph } from '../util/data';
78
+ import { getCombinedCanvasesBounds } from '../util/bbox';
62
79
  import {
63
80
  DataController,
64
- ExtensionController,
65
81
  InteractionController,
66
82
  ItemController,
67
83
  LayoutController,
68
84
  ThemeController,
69
85
  ViewportController,
86
+ PluginController,
70
87
  } from './controller';
71
- import { PluginController } from './controller/plugin';
72
88
  import Hook from './hooks';
73
- import { isEmptyGraph } from '../util/data';
74
89
 
75
90
  export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
76
91
  extends EventEmitter
77
92
  implements IGraph<B, T>
78
93
  {
79
94
  public hooks: Hooks;
80
- // for nodes and edges, which will be separate into groups
95
+ // for nodes and edges excluding their labels, which will be separate into groups
81
96
  public canvas: Canvas;
97
+ // for nodes' and edges' labels
98
+ public labelCanvas: Canvas;
82
99
  // the container dom for the graph canvas
83
100
  public container: HTMLElement;
84
101
  // the tag to indicate whether the graph instance is destroyed
85
- public destroyed: boolean;
102
+ public destroyed: boolean = false;
86
103
  // the renderer type of current graph
87
104
  public rendererType: RendererName;
88
105
  // for transient shapes for interactions, e.g. transient node and related edges while draging, delegates
89
106
  public transientCanvas: Canvas;
107
+ // for transient items' label shapes
108
+ public transientLabelCanvas: Canvas;
90
109
  // for background shapes, e.g. grid, pipe indices
91
110
  public backgroundCanvas: Canvas;
92
111
  // the tag indicates all the three canvases are all ready
@@ -98,7 +117,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
98
117
  private layoutController: LayoutController;
99
118
  private viewportController: ViewportController;
100
119
  private itemController: ItemController;
101
- private extensionController: ExtensionController;
102
120
  private themeController: ThemeController;
103
121
  private pluginController: PluginController;
104
122
 
@@ -127,7 +145,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
127
145
  canvases: {
128
146
  background: this.backgroundCanvas,
129
147
  main: this.canvas,
148
+ label: this.labelCanvas,
130
149
  transient: this.transientCanvas,
150
+ transientLabel: this.transientLabelCanvas,
131
151
  },
132
152
  });
133
153
 
@@ -146,22 +166,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
146
166
  this.interactionController = new InteractionController(this);
147
167
  this.layoutController = new LayoutController(this);
148
168
  this.themeController = new ThemeController(this);
149
- this.itemController = new ItemController(this);
150
169
  this.viewportController = new ViewportController(this);
151
- this.extensionController = new ExtensionController(this);
170
+ this.itemController = new ItemController(this);
152
171
  this.pluginController = new PluginController(this);
153
172
  }
154
173
 
155
174
  private initCanvas() {
156
- const {
157
- renderer,
158
- container,
159
- canvas,
160
- backgroundCanvas,
161
- transientCanvas,
162
- width,
163
- height,
164
- } = this.specification;
175
+ const { renderer, container, width, height } = this.specification;
165
176
 
166
177
  let pixelRatio: number;
167
178
  if (renderer && !isString(renderer)) {
@@ -174,13 +185,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
174
185
  this.rendererType = renderer || 'canvas';
175
186
  }
176
187
 
177
- /**
178
- * These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
179
- */
180
- if (canvas) {
181
- this.canvas = canvas;
182
- this.backgroundCanvas = backgroundCanvas;
183
- this.transientCanvas = transientCanvas;
188
+ if (container) {
184
189
  this.container = container as HTMLElement;
185
190
  } else {
186
191
  const containerDOM = isString(container)
@@ -194,60 +199,62 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
194
199
  this.destroy();
195
200
  return;
196
201
  }
197
-
198
202
  this.container = containerDOM;
199
- const size = [width, height];
200
- if (size[0] === undefined) {
201
- size[0] = containerDOM.scrollWidth;
202
- }
203
- if (size[1] === undefined) {
204
- size[1] = containerDOM.scrollHeight;
205
- }
206
- this.backgroundCanvas = createCanvas(
207
- this.rendererType,
208
- containerDOM,
209
- size[0],
210
- size[1],
211
- pixelRatio,
212
- );
213
- this.canvas = createCanvas(
214
- this.rendererType,
215
- containerDOM,
216
- size[0],
217
- size[1],
218
- pixelRatio,
219
- );
220
- this.transientCanvas = createCanvas(
221
- this.rendererType,
222
- containerDOM,
223
- size[0],
224
- size[1],
225
- pixelRatio,
226
- );
227
203
  }
228
204
 
205
+ [
206
+ 'backgroundCanvas',
207
+ 'canvas',
208
+ 'labelCanvas',
209
+ 'transientCanvas',
210
+ 'transientLabelCanvas',
211
+ ].forEach((name) => {
212
+ this[name] =
213
+ this.specification[name] ||
214
+ createCanvas(
215
+ ['labelCanvas', 'transientLabelCanvas'].includes(name)
216
+ ? 'canvas'
217
+ : this.rendererType,
218
+ this.container,
219
+ width ?? this.container.scrollWidth,
220
+ height ?? this.container.scrollHeight,
221
+ pixelRatio,
222
+ undefined,
223
+ // enable dom interaction only for main canvas
224
+ name === 'canvas' ? [] : ['dom-interaction'],
225
+ );
226
+ });
227
+
229
228
  Promise.all(
230
- [this.backgroundCanvas, this.canvas, this.transientCanvas].map(
231
- (canvas) => canvas.ready,
232
- ),
229
+ [
230
+ this.backgroundCanvas,
231
+ this.canvas,
232
+ this.labelCanvas,
233
+ this.transientCanvas,
234
+ this.transientLabelCanvas,
235
+ ].map((canvas) => canvas.ready),
233
236
  ).then(() => {
234
- [this.backgroundCanvas, this.canvas, this.transientCanvas].forEach(
235
- (canvas, i) => {
236
- const $domElement = canvas
237
- .getContextService()
238
- .getDomElement() as unknown as HTMLElement;
239
- if ($domElement && $domElement.style) {
240
- // Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
241
- $domElement.style.position = 'absolute';
242
- $domElement.style.outline = 'none';
243
- $domElement.tabIndex = 1; // Enable keyboard events
244
- // Transient canvas should let interactive events go through.
245
- if (i !== 1) {
246
- $domElement.style.pointerEvents = 'none';
247
- }
237
+ [
238
+ this.backgroundCanvas,
239
+ this.canvas,
240
+ this.labelCanvas,
241
+ this.transientCanvas,
242
+ this.transientLabelCanvas,
243
+ ].forEach((canvas, i) => {
244
+ const $domElement = canvas
245
+ .getContextService()
246
+ .getDomElement() as unknown as HTMLElement;
247
+ if ($domElement && $domElement.style) {
248
+ // Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
249
+ $domElement.style.position = 'absolute';
250
+ $domElement.style.outline = 'none';
251
+ $domElement.tabIndex = 1; // Enable keyboard events
252
+ // Transient canvas should let interactive events go through.
253
+ if (i !== 1) {
254
+ $domElement.style.pointerEvents = 'none';
248
255
  }
249
- },
250
- );
256
+ }
257
+ });
251
258
 
252
259
  this.canvasReady = true;
253
260
  });
@@ -287,8 +294,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
287
294
  init: new Hook<{
288
295
  canvases: {
289
296
  background: Canvas;
297
+ label: Canvas;
290
298
  main: Canvas;
291
299
  transient: Canvas;
300
+ transientLabel: Canvas;
292
301
  };
293
302
  }>({ name: 'init' }),
294
303
  datachange: new Hook<{ data: GraphData; type: DataChangeType }>({
@@ -306,6 +315,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
306
315
  graphCore: GraphCore;
307
316
  theme: ThemeSpecification;
308
317
  transientCanvas: Canvas;
318
+ transientLabelCanvas: Canvas;
309
319
  }>({
310
320
  name: 'render',
311
321
  }),
@@ -328,6 +338,27 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
328
338
  }>({
329
339
  name: 'itemstatechange',
330
340
  }),
341
+ itemstateconfigchange: new Hook<{
342
+ itemType: ITEM_TYPE;
343
+ stateConfig:
344
+ | {
345
+ [stateName: string]:
346
+ | ((data: NodeModel) => NodeDisplayModel)
347
+ | NodeShapesEncode;
348
+ }
349
+ | {
350
+ [stateName: string]:
351
+ | ((data: EdgeModel) => EdgeDisplayModel)
352
+ | EdgeShapesEncode;
353
+ }
354
+ | {
355
+ [stateName: string]:
356
+ | ((data: ComboModel) => ComboDisplayModel)
357
+ | ComboShapesEncode;
358
+ };
359
+ }>({
360
+ name: 'itemstateconfigchange',
361
+ }),
331
362
  itemvisibilitychange: new Hook<{ ids: ID[]; value: boolean }>({
332
363
  name: 'itemvisibilitychange',
333
364
  }),
@@ -396,11 +427,28 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
396
427
  * Update the specs(configurations).
397
428
  */
398
429
  public updateSpecification(spec: Specification<B, T>): Specification<B, T> {
430
+ const {
431
+ node,
432
+ edge,
433
+ combo,
434
+ theme,
435
+ nodeState,
436
+ edgeState,
437
+ comboState,
438
+ ...others
439
+ } = spec;
440
+ if (node) this.updateMapper('node', node);
441
+ if (edge) this.updateMapper('edge', edge);
442
+ if (combo) this.updateMapper('combo', combo);
443
+ if (theme) this.updateTheme(theme);
444
+ if (nodeState) this.updateStateConfig('node', nodeState, 'replace');
445
+ if (edgeState) this.updateStateConfig('edge', edgeState, 'replace');
446
+ if (comboState) this.updateStateConfig('combo', comboState, 'replace');
447
+
399
448
  const newSpec = Object.assign(
400
449
  this.specification,
401
- this.formatSpecification(spec),
450
+ this.formatSpecification(others),
402
451
  );
403
- // TODO: update something
404
452
  return newSpec;
405
453
  }
406
454
  /**
@@ -449,6 +497,47 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
449
497
  });
450
498
  }
451
499
 
500
+ /**
501
+ * Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
502
+ * @param {string} itemType - The type of item (node, edge, or combo).
503
+ * @param {object} stateConfig - The state configuration to update.
504
+ * @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
505
+ **/
506
+ public updateStateConfig(
507
+ itemType: ITEM_TYPE,
508
+ stateConfig:
509
+ | {
510
+ [stateName: string]:
511
+ | ((data: NodeModel) => NodeDisplayModel)
512
+ | NodeShapesEncode;
513
+ }
514
+ | {
515
+ [stateName: string]:
516
+ | ((data: EdgeModel) => EdgeDisplayModel)
517
+ | EdgeShapesEncode;
518
+ }
519
+ | {
520
+ [stateName: string]:
521
+ | ((data: ComboModel) => ComboDisplayModel)
522
+ | ComboShapesEncode;
523
+ },
524
+ updateType: 'mergeReplace' | 'replace' = 'mergeReplace',
525
+ ) {
526
+ if (isEmpty(stateConfig)) return;
527
+ const stateField = `${itemType}State`;
528
+ if (updateType === 'mergeReplace') {
529
+ const config = {
530
+ ...this.specification[stateField],
531
+ ...stateConfig,
532
+ };
533
+ this.specification[itemType] = config;
534
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
535
+ } else {
536
+ this.specification[itemType] = stateConfig;
537
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
538
+ }
539
+ }
540
+
452
541
  /**
453
542
  * Get the copy of specs(configurations).
454
543
  * @returns graph specs
@@ -473,6 +562,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
473
562
  graphCore: this.dataController.graphCore,
474
563
  theme: this.themeController.specification,
475
564
  transientCanvas: this.transientCanvas,
565
+ transientLabelCanvas: this.transientLabelCanvas,
476
566
  tileOptimize: {
477
567
  tileFirstRender,
478
568
  tileFirstRenderSize,
@@ -518,9 +608,13 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
518
608
  await emitRender();
519
609
  } else {
520
610
  await Promise.all(
521
- [this.backgroundCanvas, this.canvas, this.transientCanvas].map(
522
- (canvas) => canvas.ready,
523
- ),
611
+ [
612
+ this.backgroundCanvas,
613
+ this.canvas,
614
+ this.labelCanvas,
615
+ this.transientCanvas,
616
+ this.transientLabelCanvas,
617
+ ].map((canvas) => canvas.ready),
524
618
  );
525
619
  await emitRender();
526
620
  }
@@ -530,12 +624,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
530
624
  * Change graph data.
531
625
  * @param data new data
532
626
  * @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)
627
+ * @param relayout whether relayout the nodes after data changing
533
628
  * @returns
534
629
  * @group Data
535
630
  */
536
631
  public async changeData(
537
632
  data: DataConfig,
538
633
  type: 'replace' | 'mergeReplace' = 'mergeReplace',
634
+ relayout: boolean = true,
539
635
  ) {
540
636
  const { tileFirstRender, tileFirstRenderSize } =
541
637
  this.specification.optimize || {};
@@ -544,6 +640,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
544
640
  graphCore: this.dataController.graphCore,
545
641
  theme: this.themeController.specification,
546
642
  transientCanvas: this.transientCanvas,
643
+ transientLabelCanvas: this.transientLabelCanvas,
547
644
  tileOptimize: {
548
645
  tileFirstRender,
549
646
  tileFirstRenderSize,
@@ -551,7 +648,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
551
648
  });
552
649
  this.emit('afterrender');
553
650
 
554
- await this.layout();
651
+ if (relayout) {
652
+ await this.layout();
653
+ }
555
654
  }
556
655
 
557
656
  /**
@@ -775,10 +874,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
775
874
  halfExtents,
776
875
  } = boundsType === 'render'
777
876
  ? // Get the bounds of the whole graph content.
778
- this.canvas.document.documentElement.getBounds()
779
- : // Get the bounds of the nodes positions while the graph content is not ready.
877
+ getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
878
+ : // Get the b ounds of the nodes positions while the graph content is not ready.
780
879
  getLayoutBounds(this);
781
-
782
880
  const origin = this.canvas.canvas2Viewport({
783
881
  x: graphCenterX,
784
882
  y: graphCenterY,
@@ -849,7 +947,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
849
947
  } =
850
948
  boundsType === 'render'
851
949
  ? // Get the bounds of the whole graph content.
852
- this.canvas.document.documentElement.getBounds()
950
+ getCombinedCanvasesBounds([this.canvas, this.labelCanvas])
853
951
  : // Get the bounds of the nodes positions while the graph content is not ready.
854
952
  getLayoutBounds(this);
855
953
  await this.translateTo(
@@ -922,9 +1020,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
922
1020
  this.emit('beforesetsize', { oldSize, size: size });
923
1021
  this.specification.width = size[0];
924
1022
  this.specification.height = size[1];
925
- this.canvas.resize(size[0], size[1]);
926
- this.transientCanvas.resize(size[0], size[1]);
927
- this.backgroundCanvas.resize(size[0], size[1]);
1023
+ [
1024
+ this.canvas,
1025
+ this.labelCanvas,
1026
+ this.transientCanvas,
1027
+ this.transientLabelCanvas,
1028
+ this.backgroundCanvas,
1029
+ ].forEach((canvas) => {
1030
+ canvas.resize(size[0], size[1]);
1031
+ });
928
1032
  this.emit('aftersetsize', { oldSize, size: size });
929
1033
  }
930
1034
 
@@ -1062,6 +1166,26 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1062
1166
  ): EdgeModel[] {
1063
1167
  return this.dataController.findRelatedEdges(nodeId, direction);
1064
1168
  }
1169
+ /**
1170
+ * Get nearby edges from a start node using quad-tree collision detection.
1171
+ * @param nodeId id of the start node
1172
+ * @returns nearby edges' data array
1173
+ */
1174
+ public getNearEdgesData(
1175
+ nodeId: ID,
1176
+ shouldBegin?: (edge: EdgeDisplayModel) => boolean,
1177
+ ): EdgeModel[] {
1178
+ const transientItem = this.itemController.getTransientItem(
1179
+ nodeId,
1180
+ ) as unknown as Node;
1181
+ const itemMap = this.itemController.getItemMap();
1182
+ return this.dataController.findNearEdges(
1183
+ nodeId,
1184
+ itemMap,
1185
+ transientItem,
1186
+ shouldBegin,
1187
+ );
1188
+ }
1065
1189
  /**
1066
1190
  * Get one-hop node ids from a start node.
1067
1191
  * @param nodeId id of the start node
@@ -1106,16 +1230,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1106
1230
  return this.itemController.findDisplayModel(id);
1107
1231
  }
1108
1232
 
1109
- /**
1110
- * Retrieve the nearby edges for a given node using quadtree collision detection.
1111
- * @param nodeId node id
1112
- * @group Data
1113
- */
1114
- public getNearEdgesForNode(nodeId: ID): EdgeModel[] {
1115
- const { graphCore } = this.dataController;
1116
- return this.itemController.findNearEdgesByNode(nodeId, graphCore);
1117
- }
1118
-
1119
1233
  /**
1120
1234
  * Find items which has the state.
1121
1235
  * @param itemType item type
@@ -1166,13 +1280,14 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1166
1280
 
1167
1281
  const { graphCore } = this.dataController;
1168
1282
  const { specification } = this.themeController;
1283
+ const modelArr = isArray(models) ? models : [models];
1169
1284
  graphCore.once('changed', (event) => {
1170
1285
  if (!event.changes.length) return;
1171
1286
  const changes = event.changes;
1172
1287
  const timingParameters = {
1173
1288
  type: itemType,
1174
1289
  action: 'add',
1175
- models,
1290
+ models: modelArr,
1176
1291
  apiName: 'addData',
1177
1292
  changes,
1178
1293
  };
@@ -1186,7 +1301,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1186
1301
  this.emit('afteritemchange', timingParameters);
1187
1302
  });
1188
1303
 
1189
- const modelArr = isArray(models) ? models : [models];
1190
1304
  const data = { nodes: [], edges: [], combos: [] };
1191
1305
  data[`${itemType}s`] = modelArr;
1192
1306
  this.hooks.datachange.emit({
@@ -1201,7 +1315,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1201
1315
  }
1202
1316
  /**
1203
1317
  * Remove one or more node/edge/combo data from the graph.
1204
- * @param item the item to be removed
1318
+ * @param itemType the type the item(s) to be removed.
1319
+ * @param id the id or the ids' array of the items to be removed.
1205
1320
  * @returns whether success
1206
1321
  * @group Data
1207
1322
  */
@@ -1303,8 +1418,8 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1303
1418
  }
1304
1419
  /**
1305
1420
  * Update one or more node/edge/combo data on the graph.
1306
- * @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
1307
- * @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
1421
+ * @param {ITEM_TYPE} itemType the type the item(s) to be udated.
1422
+ * @param models update configs.
1308
1423
  * @group Data
1309
1424
  */
1310
1425
  public updateData(
@@ -1332,11 +1447,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1332
1447
  const { graphCore } = this.dataController;
1333
1448
  const { specification } = this.themeController;
1334
1449
  graphCore.once('changed', (event) => {
1335
- const changes = this.extendChanges(clone(event.changes));
1450
+ const changes = this.extendChanges(cloneJSON(event.changes));
1336
1451
  const timingParameters = {
1337
1452
  type: itemType,
1338
1453
  action: 'update',
1339
- models,
1454
+ models: modelArr,
1340
1455
  apiName: 'updateData',
1341
1456
  changes,
1342
1457
  };
@@ -1364,7 +1479,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1364
1479
  /**
1365
1480
  * Update one or more nodes' positions,
1366
1481
  * do not update other styles which leads to better performance than updating positions by updateData.
1367
- * @param models new configurations with x and y for every node, which has id field to indicate the specific item
1482
+ * @param models new configurations with x and y for every node, which has id field to indicate the specific item.
1483
+ * @param upsertAncestors whether update the ancestors in combo tree.
1484
+ * @param disableAnimate whether disable the animation for this call.
1485
+ * @param callback callback function after update nodes done.
1368
1486
  * @group Data
1369
1487
  */
1370
1488
  public updateNodePosition(
@@ -1379,7 +1497,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1379
1497
  model: NodeModel | EdgeModel | ComboModel,
1380
1498
  canceled?: boolean,
1381
1499
  ) => void,
1382
- stack?: boolean,
1383
1500
  ) {
1384
1501
  return this.updatePosition(
1385
1502
  'node',
@@ -1387,7 +1504,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1387
1504
  upsertAncestors,
1388
1505
  disableAnimate,
1389
1506
  callback,
1390
- stack,
1391
1507
  );
1392
1508
  }
1393
1509
 
@@ -1395,7 +1511,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1395
1511
  * Update one or more combos' positions,
1396
1512
  * do not update other styles which leads to better performance than updating positions by updateData.
1397
1513
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1398
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1514
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
1515
+ * @param upsertAncestors whether update the ancestors in combo tree.
1516
+ * @param disableAnimate whether disable the animation for this call.
1517
+ * @param callback callback function after update combos done.
1399
1518
  * @group Data
1400
1519
  */
1401
1520
  public updateComboPosition(
@@ -1407,7 +1526,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1407
1526
  upsertAncestors?: boolean,
1408
1527
  disableAnimate = false,
1409
1528
  callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
1410
- stack?: boolean,
1411
1529
  ) {
1412
1530
  return this.updatePosition(
1413
1531
  'combo',
@@ -1415,7 +1533,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1415
1533
  upsertAncestors,
1416
1534
  disableAnimate,
1417
1535
  callback,
1418
- stack,
1419
1536
  );
1420
1537
  }
1421
1538
 
@@ -1446,7 +1563,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1446
1563
  model: NodeModel | EdgeModel | ComboModel,
1447
1564
  canceled?: boolean,
1448
1565
  ) => void,
1449
- stack?: boolean,
1450
1566
  ) {
1451
1567
  const modelArr = isArray(models) ? models : [models];
1452
1568
  const { graphCore } = this.dataController;
@@ -1460,7 +1576,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1460
1576
  type,
1461
1577
  action: 'updatePosition',
1462
1578
  upsertAncestors,
1463
- models,
1579
+ models: modelArr,
1464
1580
  apiName: 'updatePosition',
1465
1581
  changes,
1466
1582
  };
@@ -1484,7 +1600,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1484
1600
  edges: [],
1485
1601
  combos: type === 'combo' ? (modelArr as ComboUserModel[]) : [],
1486
1602
  },
1487
- type: 'update',
1603
+ type: 'updatePosition',
1488
1604
  });
1489
1605
  const dataList = this.dataController.findData(
1490
1606
  type,
@@ -1513,21 +1629,46 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1513
1629
  * @returns
1514
1630
  * @group Item
1515
1631
  */
1516
- public showItem(ids: ID | ID[], disableAnimate = false) {
1632
+ public showItem(
1633
+ ids: ID | ID[],
1634
+ options?: {
1635
+ disableAnimate?: boolean;
1636
+ shapeIds?: string | string[];
1637
+ },
1638
+ ) {
1639
+ const { disableAnimate = false, shapeIds } = options || {};
1517
1640
  const idArr = isArray(ids) ? ids : [ids];
1518
1641
  if (isEmpty(idArr)) return;
1519
- const changes = {
1520
- newValue: [{ ids: idArr, visible: true }],
1521
- oldValue: this.getItemPreviousVisibility(idArr),
1522
- };
1523
- this.hooks.itemvisibilitychange.emit({
1524
- ids: idArr as ID[],
1525
- value: true,
1526
- graphCore: this.dataController.graphCore,
1527
- animate: !disableAnimate,
1528
- });
1642
+
1643
+ let changes;
1644
+ if (shapeIds?.length) {
1645
+ const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
1646
+ changes = {
1647
+ newValue: [{ ids: idArr, visible: true, shapeIds: shapeIdsArr }],
1648
+ oldValue: this.getItemPreviousVisibility(idArr),
1649
+ };
1650
+ this.hooks.itemvisibilitychange.emit({
1651
+ ids: idArr as ID[],
1652
+ value: true,
1653
+ graphCore: this.dataController.graphCore,
1654
+ animate: !disableAnimate,
1655
+ shapeIds: shapeIdsArr,
1656
+ });
1657
+ } else {
1658
+ changes = {
1659
+ newValue: [{ ids: idArr, visible: true }],
1660
+ oldValue: this.getItemPreviousVisibility(idArr),
1661
+ };
1662
+ this.hooks.itemvisibilitychange.emit({
1663
+ ids: idArr as ID[],
1664
+ value: true,
1665
+ graphCore: this.dataController.graphCore,
1666
+ animate: !disableAnimate,
1667
+ });
1668
+ }
1669
+
1529
1670
  this.emit('afteritemvisibilitychange', {
1530
- ids,
1671
+ ids: idArr as ID[],
1531
1672
  value: true,
1532
1673
  animate: !disableAnimate,
1533
1674
  action: 'updateVisibility',
@@ -1537,30 +1678,62 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1537
1678
  }
1538
1679
  /**
1539
1680
  * Hide the item(s).
1540
- * @param item the item to be hidden
1681
+ * @param id the id for the item to be hidden.
1682
+ * @param disableAnimate whether disable the hidden animations.
1683
+ * @param keepKeyShape whether keep the keyShape.
1684
+ * @param keepRelated whether keep the related nodes for edge.
1541
1685
  * @returns
1542
1686
  * @group Item
1543
1687
  */
1544
1688
  public hideItem(
1545
1689
  ids: ID | ID[],
1546
- disableAnimate = false,
1547
- keepKeyShape = false,
1690
+ options?: {
1691
+ disableAnimate?: boolean;
1692
+ keepKeyShape?: boolean;
1693
+ keepRelated?: boolean;
1694
+ shapeIds?: string[];
1695
+ },
1548
1696
  ) {
1549
- const idArr = isArray(ids) ? ids : [ids];
1697
+ const {
1698
+ disableAnimate = false,
1699
+ keepKeyShape = false,
1700
+ keepRelated = false,
1701
+ shapeIds,
1702
+ } = options || {};
1703
+ const idArr: ID[] = isArray(ids) ? ids : [ids];
1550
1704
  if (isEmpty(idArr)) return;
1551
- const changes = {
1552
- newValue: [{ ids: idArr, visible: false }],
1553
- oldValue: this.getItemPreviousVisibility(idArr),
1554
- };
1555
- this.hooks.itemvisibilitychange.emit({
1556
- ids: idArr as ID[],
1557
- value: false,
1558
- graphCore: this.dataController.graphCore,
1559
- animate: !disableAnimate,
1560
- keepKeyShape,
1561
- });
1705
+
1706
+ let changes;
1707
+ if (shapeIds?.length) {
1708
+ const shapeIdsArr = isArray(shapeIds) ? shapeIds : [shapeIds];
1709
+ changes = {
1710
+ newValue: [{ ids: idArr, visible: false, shapeIds: shapeIdsArr }],
1711
+ oldValue: this.getItemPreviousVisibility(idArr),
1712
+ };
1713
+ this.hooks.itemvisibilitychange.emit({
1714
+ ids: idArr,
1715
+ value: false,
1716
+ graphCore: this.dataController.graphCore,
1717
+ animate: !disableAnimate,
1718
+ shapeIds: shapeIdsArr,
1719
+ });
1720
+ } else {
1721
+ changes = {
1722
+ newValue: [{ ids: idArr, visible: false }],
1723
+ oldValue: this.getItemPreviousVisibility(idArr),
1724
+ };
1725
+ this.hooks.itemvisibilitychange.emit({
1726
+ ids: idArr,
1727
+ value: false,
1728
+ graphCore: this.dataController.graphCore,
1729
+ animate: !disableAnimate,
1730
+ keepKeyShape,
1731
+ keepRelated,
1732
+ });
1733
+ }
1734
+
1562
1735
  this.emit('afteritemvisibilitychange', {
1563
- ids,
1736
+ ids: idArr,
1564
1737
  value: false,
1565
1738
  animate: !disableAnimate,
1566
1739
  action: 'updateVisibility',
@@ -1737,12 +1910,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1737
1910
  return this.itemController.getItemVisible(id);
1738
1911
  }
1739
1912
 
1913
+ /**
1914
+ * Get the visible shape ids in a node / edge / combo.
1915
+ * @param id the id for the node / edge / combo
1916
+ * @returns ids of the visible shapes
1917
+ */
1918
+ public getItemVisibleShapeIds(id: ID) {
1919
+ return this.itemController.getItemVisibleShapeIds(id);
1920
+ }
1921
+
1740
1922
  // ===== combo operations =====
1741
1923
 
1742
1924
  /**
1743
1925
  * 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.
1744
- * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
1745
- * @param model combo user data
1926
+ * Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
1927
+ * @param model combo user data.
1928
+ * @param childrenIds the ids of the children nodes / combos to move into the new combo.
1746
1929
  * @returns whether success
1747
1930
  * @group Combo
1748
1931
  */
@@ -1790,7 +1973,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1790
1973
  }
1791
1974
  /**
1792
1975
  * Collapse a combo.
1793
- * @param comboId combo ids
1976
+ * @param comboId combo id or ids' array.
1794
1977
  * @group Combo
1795
1978
  */
1796
1979
  public collapseCombo(comboIds: ID | ID[]) {
@@ -1810,7 +1993,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1810
1993
  }
1811
1994
  /**
1812
1995
  * Expand a combo.
1813
- * @param combo combo ids
1996
+ * @param comboId combo id or ids' array.
1814
1997
  * @group Combo
1815
1998
  */
1816
1999
  public expandCombo(comboIds: ID | ID[]) {
@@ -1833,7 +2016,11 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1833
2016
  * Move one or more combos a distance (dx, dy) relatively,
1834
2017
  * do not update other styles which leads to better performance than updating positions by updateData.
1835
2018
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1836
- * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
2019
+ * @param models new configurations with x and y for every combo, which has id field to indicate the specific item.
2020
+ * @param dx the distance alone x-axis to move the combo.
2021
+ * @param dy the distance alone y-axis to move the combo.
2022
+ * @param upsertAncestors whether update the ancestors in the combo tree.
2023
+ * @param callback callback function after move combo done.
1837
2024
  * @group Combo
1838
2025
  */
1839
2026
  public moveCombo(
@@ -1890,7 +2077,10 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1890
2077
  /**
1891
2078
  * Layout the graph (with current configurations if cfg is not assigned).
1892
2079
  */
1893
- public async layout(options?: LayoutOptions, disableAnimate = false) {
2080
+ public async layout(
2081
+ options?: Partial<LayoutOptions>,
2082
+ disableAnimate = false,
2083
+ ) {
1894
2084
  this.emit('beforelayout');
1895
2085
  const { graphCore } = this.dataController;
1896
2086
  const formattedOptions = {
@@ -1977,7 +2167,9 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1977
2167
  */
1978
2168
  public setCursor(cursor: Cursor) {
1979
2169
  this.canvas.setCursor(cursor);
2170
+ this.labelCanvas.setCursor(cursor);
1980
2171
  this.transientCanvas.setCursor(cursor);
2172
+ this.transientLabelCanvas.setCursor(cursor);
1981
2173
  }
1982
2174
 
1983
2175
  /**
@@ -2153,12 +2345,15 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2153
2345
  | PluginBase,
2154
2346
  ) {
2155
2347
  const { plugins } = this.specification;
2156
- const { key } = plugin;
2348
+ const { key, type } = plugin as {
2349
+ key: string;
2350
+ type: string;
2351
+ [cfg: string]: unknown;
2352
+ };
2157
2353
  if (!key) {
2158
2354
  console.warn(
2159
- 'Update plugin failed, the key for the plugin to be updated should be assign.',
2355
+ `The key for the plugin is not found. G6 will update the first plugin with type ${type}`,
2160
2356
  );
2161
- return;
2162
2357
  }
2163
2358
  if (!plugins) {
2164
2359
  console.warn(
@@ -2167,12 +2362,21 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2167
2362
  return;
2168
2363
  }
2169
2364
  const oldPlugin = plugins?.find((p) => {
2170
- if (typeof p === 'string') return p === key;
2171
- return p.key === key;
2365
+ if (typeof p === 'string') return p === key || p === type;
2366
+ return (
2367
+ p.key === key ||
2368
+ (
2369
+ p as {
2370
+ key: string;
2371
+ type: string;
2372
+ [cfg: string]: unknown;
2373
+ }
2374
+ ).type === type
2375
+ );
2172
2376
  });
2173
2377
  if (!oldPlugin) {
2174
2378
  console.warn(
2175
- 'Update plugin failed, the key for the plugin to be updated should be assign.',
2379
+ `Update plugin failed, the plugin with key ${key} or type ${type} is not found.`,
2176
2380
  );
2177
2381
  return;
2178
2382
  }
@@ -2193,7 +2397,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2193
2397
  /**
2194
2398
  * Draw or update a G shape or group to the transient canvas.
2195
2399
  * @param type shape type or item type
2196
- * @param id new shape id or updated shape id for a interation shape, node/edge/combo id for item interaction group drawing
2400
+ * @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
2197
2401
  * @returns upserted shape or group
2198
2402
  * @group Interaction
2199
2403
  */
@@ -2236,19 +2440,23 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2236
2440
  * @returns A Promise that resolves to the Data URL string.
2237
2441
  */
2238
2442
  public async toDataURL(type?: DataURLType): Promise<string> {
2239
- const backgroundCanvas = this.backgroundCanvas;
2240
- const canvas = this.canvas;
2241
- const transientCanvas = this.transientCanvas;
2242
- const rendererType = this.rendererType;
2443
+ const {
2444
+ backgroundCanvas,
2445
+ canvas,
2446
+ transientCanvas,
2447
+ labelCanvas,
2448
+ rendererType,
2449
+ } = this;
2243
2450
 
2244
2451
  const pixelRatio =
2245
2452
  typeof window !== 'undefined' ? window.devicePixelRatio : 1;
2246
- const width = this.getSize()[0];
2247
- const height = this.getSize()[1];
2453
+ const [width, height] = this.getSize();
2248
2454
 
2249
2455
  const vContainerDOM: HTMLElement = createDOM(
2250
2456
  '<div id="virtual-image"></div>',
2251
2457
  );
2458
+
2459
+ const camera = canvas.getCamera();
2252
2460
  const vCanvas = createCanvas(
2253
2461
  rendererType,
2254
2462
  vContainerDOM,
@@ -2256,13 +2464,48 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2256
2464
  height,
2257
2465
  pixelRatio,
2258
2466
  );
2467
+ await vCanvas.ready;
2468
+
2469
+ const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
2470
+ const clonedGroup = canvas.getRoot().cloneNode(true);
2471
+ const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
2472
+ const labelClonedGroup = labelCanvas.getRoot().cloneNode(true);
2473
+
2474
+ const originViewportLTCanvas = vCanvas.viewport2Canvas({ x: 0, y: 0 });
2475
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
2476
+ labelClonedGroup.translate([
2477
+ currentViewportLTCanvas.x - originViewportLTCanvas.x,
2478
+ currentViewportLTCanvas.y - originViewportLTCanvas.y,
2479
+ ]);
2480
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
2481
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
2482
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
2483
+ childGroup.children.forEach((shape) => {
2484
+ if (
2485
+ shape.getAttribute('data-is-label-background') &&
2486
+ shape.style.transform
2487
+ )
2488
+ shape.remove();
2489
+ });
2490
+ });
2491
+
2492
+ vCanvas.appendChild(backgroundClonedGroup);
2493
+ vCanvas.appendChild(clonedGroup);
2494
+ vCanvas.appendChild(labelClonedGroup);
2495
+ vCanvas.appendChild(transientClonedGroup);
2496
+
2497
+ const vCamera = vCanvas.getCamera();
2498
+ vCamera.setZoom(camera.getZoom());
2499
+ vCamera.setPosition(camera.getPosition());
2500
+ vCamera.setFocalPoint(camera.getFocalPoint());
2501
+
2259
2502
  const vCanvasContextService = vCanvas.getContextService();
2260
2503
  let bgRect;
2261
2504
  if (rendererType !== 'svg') {
2505
+ const backPositionCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
2262
2506
  bgRect = new Rect({
2263
2507
  style: {
2264
- x: 0,
2265
- y: 0,
2508
+ ...backPositionCanvas,
2266
2509
  z: -1,
2267
2510
  width: vCanvasContextService.getDomElement().width,
2268
2511
  height: vCanvasContextService.getDomElement().height,
@@ -2270,24 +2513,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2270
2513
  fill: backgroundCanvas.getContextService().getDomElement().style[
2271
2514
  'background-color'
2272
2515
  ],
2516
+ zIndex: -10,
2273
2517
  },
2274
2518
  });
2275
2519
  vCanvas.appendChild(bgRect);
2276
2520
  }
2277
- const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
2278
- const clonedGroup = canvas.getRoot().cloneNode(true);
2279
- const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
2280
- vCanvas.appendChild(backgroundClonedGroup);
2281
- vCanvas.appendChild(clonedGroup);
2282
- vCanvas.appendChild(transientClonedGroup);
2283
- vCanvas.render();
2284
2521
 
2285
2522
  if (!type) type = 'image/png';
2286
2523
  let dataURL = '';
2287
- await vCanvasContextService.toDataURL({ type }).then((url) => {
2288
- dataURL = url;
2524
+ return new Promise((resolve) => {
2525
+ setTimeout(() => {
2526
+ vCanvasContextService.toDataURL({ type }).then((url) => {
2527
+ dataURL = url;
2528
+ resolve(dataURL);
2529
+ });
2530
+ }, 50);
2289
2531
  });
2290
- return dataURL;
2291
2532
  }
2292
2533
 
2293
2534
  /**
@@ -2301,17 +2542,22 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2301
2542
  type?: DataURLType,
2302
2543
  imageConfig?: { padding?: number | number[] },
2303
2544
  ) {
2304
- const backgroundCanvas = this.backgroundCanvas;
2305
- const canvas = this.canvas;
2306
- const transientCanvas = this.transientCanvas;
2307
- const backgroundRoot = canvas.getRoot();
2545
+ const {
2546
+ backgroundCanvas,
2547
+ canvas,
2548
+ transientCanvas,
2549
+ labelCanvas,
2550
+ rendererType,
2551
+ } = this;
2552
+ const backgroundRoot = backgroundCanvas.getRoot();
2308
2553
  const root = canvas.getRoot();
2309
2554
  const transientRoot = transientCanvas.getRoot();
2310
- const rendererType = this.rendererType;
2555
+ const labelRoot = labelCanvas.getRoot();
2311
2556
 
2312
- const backgroundBBox = backgroundRoot.getBBox();
2313
- const BBox = root.getBBox();
2314
- const transientBBox = transientRoot.getBBox();
2557
+ const backgroundBBox = backgroundRoot.getRenderBounds();
2558
+ const BBox = root.getRenderBounds();
2559
+ const transientBBox = transientRoot.getRenderBounds();
2560
+ const labelBBox = labelRoot.getRenderBounds();
2315
2561
 
2316
2562
  let padding = imageConfig ? imageConfig.padding : undefined;
2317
2563
  if (!padding) {
@@ -2321,29 +2567,33 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2321
2567
  }
2322
2568
 
2323
2569
  const left =
2324
- (transientBBox.left
2325
- ? backgroundBBox.left
2326
- ? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
2327
- : Math.min(BBox.left, transientBBox.left)
2328
- : BBox.left) - padding[3];
2570
+ Math.min(
2571
+ backgroundBBox.min[0] || Infinity,
2572
+ BBox.min[0] || Infinity,
2573
+ transientBBox.min[0] || Infinity,
2574
+ labelBBox.min[0] || Infinity,
2575
+ ) - padding[3];
2329
2576
  const right =
2330
- (transientBBox.right
2331
- ? backgroundBBox.right
2332
- ? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
2333
- : Math.max(BBox.right, transientBBox.right)
2334
- : BBox.right) + padding[1];
2577
+ Math.max(
2578
+ backgroundBBox.max[0] || -Infinity,
2579
+ BBox.max[0] || -Infinity,
2580
+ transientBBox.max[0] || -Infinity,
2581
+ labelBBox.max[0] || -Infinity,
2582
+ ) - padding[1];
2335
2583
  const top =
2336
- (transientBBox.top
2337
- ? backgroundBBox.top
2338
- ? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
2339
- : Math.min(BBox.top, transientBBox.top)
2340
- : BBox.top) - padding[0];
2584
+ Math.min(
2585
+ backgroundBBox.min[1] || Infinity,
2586
+ BBox.min[1] || Infinity,
2587
+ transientBBox.min[1] || Infinity,
2588
+ labelBBox.min[1] || Infinity,
2589
+ ) - padding[0];
2341
2590
  const bottom =
2342
- (transientBBox.bottom
2343
- ? backgroundBBox.bottom
2344
- ? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
2345
- : Math.max(BBox.bottom, transientBBox.bottom)
2346
- : BBox.bottom) + padding[2];
2591
+ Math.max(
2592
+ backgroundBBox.max[1] || -Infinity,
2593
+ BBox.max[1] || -Infinity,
2594
+ transientBBox.max[1] || -Infinity,
2595
+ labelBBox.max[1] || -Infinity,
2596
+ ) - padding[2];
2347
2597
 
2348
2598
  const graphCenterX = (left + right) / 2;
2349
2599
  const graphCenterY = (top + bottom) / 2;
@@ -2364,6 +2614,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2364
2614
  vHeight,
2365
2615
  pixelRatio,
2366
2616
  );
2617
+ await vCanvas.ready;
2367
2618
  const vCanvasContextService = vCanvas.getContextService();
2368
2619
  if (rendererType !== 'svg') {
2369
2620
  const bgRect = new Rect({
@@ -2384,6 +2635,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2384
2635
  const backgroundClonedGroup = backgroundRoot.cloneNode(true);
2385
2636
  const clonedGroup = root.cloneNode(true);
2386
2637
  const transientClonedGroup = transientRoot.cloneNode(true);
2638
+ const labelClonedGroup = labelRoot.cloneNode(true);
2387
2639
  const transPosition: [number, number] = [
2388
2640
  -graphCenterX + halfX,
2389
2641
  -graphCenterY + halfY,
@@ -2391,17 +2643,40 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2391
2643
  backgroundClonedGroup.setPosition(transPosition);
2392
2644
  clonedGroup.setPosition(transPosition);
2393
2645
  transientClonedGroup.setPosition(transPosition);
2646
+
2647
+ const currentViewportLTCanvas = canvas.viewport2Canvas({ x: 0, y: 0 });
2648
+ const labelTransPosition: [number, number] = [
2649
+ transPosition[0] + currentViewportLTCanvas.x,
2650
+ transPosition[1] + currentViewportLTCanvas.y,
2651
+ ];
2652
+ labelClonedGroup.setPosition(labelTransPosition);
2653
+ labelClonedGroup.scale(1 / canvas.getCamera().getZoom());
2654
+ // TODO: after cloning, label background with rotation take a wrong place, remove it to temporary solve.
2655
+ labelClonedGroup.children[0].children.forEach((childGroup) => {
2656
+ childGroup.children.forEach((shape) => {
2657
+ if (
2658
+ shape.getAttribute('data-is-label-background') &&
2659
+ shape.style.transform
2660
+ )
2661
+ shape.remove();
2662
+ });
2663
+ });
2664
+
2394
2665
  vCanvas.appendChild(backgroundClonedGroup);
2395
2666
  vCanvas.appendChild(clonedGroup);
2667
+ vCanvas.appendChild(labelClonedGroup);
2396
2668
  vCanvas.appendChild(transientClonedGroup);
2397
- vCanvas.render();
2398
2669
 
2399
2670
  if (!type) type = 'image/png';
2400
2671
  let dataURL = '';
2401
- await vCanvasContextService.toDataURL({ type }).then((url) => {
2402
- dataURL = url;
2672
+ return new Promise((resolve) => {
2673
+ setTimeout(() => {
2674
+ vCanvasContextService.toDataURL({ type }).then((url) => {
2675
+ dataURL = url;
2676
+ resolve(dataURL);
2677
+ });
2678
+ }, 50);
2403
2679
  });
2404
- return dataURL;
2405
2680
  }
2406
2681
 
2407
2682
  /**
@@ -2544,7 +2819,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2544
2819
 
2545
2820
  setTimeout(async () => {
2546
2821
  await this.toFullDataURL(type, imageConfig).then((url) => {
2547
- dataURL = url;
2822
+ dataURL = url as string;
2548
2823
  });
2549
2824
  if (callback) callback(dataURL);
2550
2825
  }, 16);
@@ -2713,7 +2988,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2713
2988
  * @returns
2714
2989
  * @group Tree
2715
2990
  */
2716
- public collapse(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
2991
+ public collapse(ids: ID | ID[], disableAnimate = false) {
2717
2992
  this.hooks.treecollapseexpand.emit({
2718
2993
  ids: isArray(ids) ? ids : [ids],
2719
2994
  action: 'collapse',
@@ -2729,7 +3004,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2729
3004
  * @returns
2730
3005
  * @group Tree
2731
3006
  */
2732
- public expand(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
3007
+ public expand(ids: ID | ID[], disableAnimate = false) {
2733
3008
  this.hooks.treecollapseexpand.emit({
2734
3009
  ids: isArray(ids) ? ids : [ids],
2735
3010
  action: 'expand',
@@ -2744,17 +3019,25 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2744
3019
  * @group Graph Instance
2745
3020
  */
2746
3021
  public destroy(callback?: Function) {
2747
- // TODO: call the destroy functions after items' buildOut animations finished
2748
- // setTimeout(() => {
3022
+ const camera = this.canvas.getCamera();
3023
+ const transientCamera = this.transientCanvas.getCamera();
3024
+ // @ts-ignore
3025
+ if (camera.landmarks?.length) {
3026
+ camera.cancelLandmarkAnimation();
3027
+ transientCamera.cancelLandmarkAnimation();
3028
+ this.emit('cancelviewportanimation');
3029
+ }
3030
+
2749
3031
  this.canvas.destroy();
3032
+ this.labelCanvas.destroy();
2750
3033
  this.backgroundCanvas.destroy();
2751
3034
  this.transientCanvas.destroy();
3035
+ this.transientLabelCanvas.destroy();
2752
3036
 
2753
3037
  // clear history stack
2754
3038
  this.cleanHistory();
2755
3039
 
2756
3040
  callback?.();
2757
- // }, 500);
2758
3041
 
2759
3042
  this.hooks.destroy.emit({});
2760
3043
 
@@ -2764,7 +3047,6 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2764
3047
  // this.layoutController.destroy();
2765
3048
  // this.themeController.destroy();
2766
3049
  // this.itemController.destroy();
2767
- // this.extensionController.destroy();
2768
3050
 
2769
3051
  this.destroyed = true;
2770
3052
  }