@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
package/src/util/bbox.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AABB } from '@antv/g';
1
+ import { AABB, Canvas } from '@antv/g';
2
2
  import { Point, PolyPoint } from 'types/common';
3
3
 
4
4
  /**
@@ -332,3 +332,28 @@ export const isBBoxInBBox = (subBBox: AABB, bbox: AABB, scale?: number) => {
332
332
  subBBox.max[1] < bbox.max[1]
333
333
  );
334
334
  };
335
+
336
+ export const getCombinedCanvasesBounds = (canvases: Canvas[]) => {
337
+ const combinedBounds = {
338
+ min: [Infinity, Infinity, Infinity],
339
+ max: [-Infinity, -Infinity, -Infinity],
340
+ center: [0, 0, 0],
341
+ halfExtents: [0, 0, 0],
342
+ };
343
+ canvases.forEach((canvas) => {
344
+ const bounds = canvas.document.documentElement.getBounds();
345
+ combinedBounds.min = combinedBounds.min.map((val, i) =>
346
+ Math.min(val || Infinity, bounds.min[i]),
347
+ );
348
+ combinedBounds.max = combinedBounds.max.map((val, i) =>
349
+ Math.max(val || -Infinity, bounds.max[i]),
350
+ );
351
+ });
352
+ combinedBounds.center = combinedBounds.center.map(
353
+ (_, i) => (combinedBounds.max[i] + combinedBounds.min[i]) / 2,
354
+ );
355
+ combinedBounds.halfExtents = combinedBounds.halfExtents.map(
356
+ (_, i) => (combinedBounds.max[i] - combinedBounds.min[i]) / 2,
357
+ );
358
+ return combinedBounds;
359
+ };
@@ -22,6 +22,7 @@ export const createCanvas = (
22
22
  height: number,
23
23
  pixelRatio?: number,
24
24
  canvasConfig: Partial<CanvasConfig> = {},
25
+ unregisterPlugins: string[] = [],
25
26
  ): Canvas => {
26
27
  let renderer: any;
27
28
  switch (rendererType.toLowerCase()) {
@@ -46,6 +47,13 @@ export const createCanvas = (
46
47
  }),
47
48
  );
48
49
 
50
+ if (unregisterPlugins.length) {
51
+ unregisterPlugins.forEach((name) => {
52
+ const plugin = renderer.getPlugin(name);
53
+ renderer.unregisterPlugin(plugin);
54
+ });
55
+ }
56
+
49
57
  return new Canvas({
50
58
  container,
51
59
  width,
package/src/util/data.ts CHANGED
@@ -3,6 +3,7 @@ import { isArray } from '@antv/util';
3
3
  import { depthFirstSearch, connectedComponent } from '@antv/algorithm';
4
4
  import {
5
5
  DataChangeType,
6
+ DataLifecycleType,
6
7
  GraphCore,
7
8
  GraphData,
8
9
  GraphDataChanges,
@@ -93,10 +94,10 @@ export const graphComboTreeDfs = (
93
94
  };
94
95
 
95
96
  /**
96
- * Depth first search begin from nodes in g6 graph data, and then search the ancestirs from begin nodes.
97
+ * Depth first search begin from nodes in g6 graph data, and then search the ancestors from begin nodes.
97
98
  * @param graph G6 graph instance
98
99
  * @param graphCore graphlib data structure
99
- * @param nodes begin ndoes
100
+ * @param nodes begin nodes
100
101
  * @param fn will be called while visiting each node
101
102
  * @param mode 'TB' - visit from top to bottom; 'BT' - visit from bottom to top;
102
103
  * @returns
@@ -134,7 +135,7 @@ export const traverseGraphAncestors = (
134
135
  /**
135
136
  * Traverse the ancestors from the begin nodes.
136
137
  * @param graphCore graphlib data structure
137
- * @param nodes begin ndoes
138
+ * @param nodes begin nodes
138
139
  * @param fn will be called while visiting each node
139
140
  */
140
141
  export const traverseAncestors = (graphCore, nodes, fn) => {
@@ -171,7 +172,7 @@ export const isSucceed = (graph, testParent, testSucceed): boolean => {
171
172
  * @param toBeAncestorId id of the new parent to check if it is valid to be a parent of the node with id toBeSucceedId
172
173
  * @returns
173
174
  */
174
- export const validateComboStrucutre = (
175
+ export const validateComboStructure = (
175
176
  graph,
176
177
  toBeSucceedId,
177
178
  toBeAncestorId,
@@ -297,7 +298,7 @@ export const graphData2TreeData = (
297
298
  };
298
299
 
299
300
  /**
300
- * Travere a tree data from top to bottom.
301
+ * Traverse a tree data from top to bottom.
301
302
  * @param treeData
302
303
  * @param callback
303
304
  */
@@ -310,7 +311,7 @@ export const traverse = (treeData, callback) => {
310
311
  }
311
312
  };
312
313
 
313
- export const DEFAULT_ACTIVE_DATA_LIFECYCLE = ['read'];
314
+ export const DEFAULT_ACTIVE_DATA_LIFECYCLE = 'all';
314
315
 
315
316
  export const AVAILABLE_DATA_LIFECYCLE = [
316
317
  'read',
@@ -320,32 +321,42 @@ export const AVAILABLE_DATA_LIFECYCLE = [
320
321
  'removeData',
321
322
  ];
322
323
 
323
- export const dataLifecycleMap: Record<string, string> = {
324
+ export const dataLifecycleMap: Record<string, DataLifecycleType> = {
324
325
  replace: 'read',
325
326
  mergeReplace: 'changeData',
326
327
  union: 'addData',
327
328
  remove: 'removeData',
328
329
  update: 'updateData',
330
+ updatePosition: 'updatePosition',
329
331
  };
330
332
 
331
333
  /**
332
334
  * Whether the graph is empty.
333
335
  * @param graph graph instance.
334
- * @param excludeInvisibles whether exclude invisibles. true means the function should test without visible items.
336
+ * @param excludeInvisible whether exclude invisible. true means the function should test without visible items.
335
337
  * @returns graph is empty or not.
336
338
  */
337
- export const isEmptyGraph = (graph, excludeInvisibles = false): Boolean => {
339
+ export const isEmptyGraph = (graph, excludeInvisible = false): boolean => {
338
340
  const nodes = graph.getAllNodesData();
339
341
  const combos = graph.getAllCombosData();
340
342
  if (nodes.length === 0 && combos.length === 0) return true;
341
343
 
342
- if (excludeInvisibles) {
344
+ if (excludeInvisible) {
343
345
  const edges = graph.getAllEdgesData();
344
- const hasVisibleItems =
345
- nodes.filter((node) => graph.getItemVisible(node.id)).length +
346
- edges.filter((edge) => graph.getItemVisible(edge.id)).length +
347
- combos.filter((combo) => graph.getItemVisible(combo.id)).length;
348
- if (!hasVisibleItems) return true;
346
+ if (nodes.find((node) => graph.getItemVisible(node.id))) return false;
347
+ if (edges.find((edge) => graph.getItemVisible(edge.id))) return false;
348
+ if (combos.find((combo) => graph.getItemVisible(combo.id))) return false;
349
+ return true;
349
350
  }
350
351
  return false;
351
352
  };
353
+
354
+ /**
355
+ * Clone an object by JSON stringify and parse
356
+ * @param obj
357
+ * @returns
358
+ */
359
+ export const cloneJSON = (obj) => {
360
+ if (!obj) return obj;
361
+ return JSON.parse(JSON.stringify(obj));
362
+ };
package/src/util/dom.ts CHANGED
@@ -4,14 +4,14 @@
4
4
  * @returns
5
5
  */
6
6
  export function createDOM(str: string): HTMLElement {
7
- const container = document.createElement('div');
8
- container.innerHTML = str;
7
+ const containerDOM = document.createElement('div');
8
+ containerDOM.innerHTML = str;
9
9
 
10
- const dom = container.childNodes[0];
11
- if (dom && container.contains(dom)) {
12
- container.removeChild(dom);
10
+ let dom = containerDOM.childNodes[0] as HTMLElement;
11
+ if (dom && containerDOM.contains(dom)) {
12
+ dom = containerDOM.removeChild(dom);
13
13
  }
14
- return dom as HTMLElement;
14
+ return dom;
15
15
  }
16
16
 
17
17
  /**
@@ -5,7 +5,7 @@ import { EdgeRegistry } from '../types/edge';
5
5
  import { LayoutRegistry } from '../types/layout';
6
6
  import { PluginRegistry } from '../types/plugin';
7
7
  import { Graph } from '../runtime/graph';
8
- import registry from '../stdlib';
8
+ import { registry } from '../stdlib';
9
9
 
10
10
  /**
11
11
  * Extend graph class with custom libs (extendLibrary), and extendLibrary will be merged into useLib.
package/src/util/item.ts CHANGED
@@ -32,6 +32,8 @@ export const upsertTransientItem = (
32
32
  nodeGroup: Group,
33
33
  edgeGroup: Group,
34
34
  comboGroup: Group,
35
+ nodeLabelGroup: Group,
36
+ edgeLabelGroup: Group,
35
37
  transientItemMap: Map<ID, Node | Edge | Combo | Group>,
36
38
  itemMap: Map<ID, Node | Edge | Combo>,
37
39
  graphCore?: GraphCore,
@@ -56,7 +58,7 @@ export const upsertTransientItem = (
56
58
  visible = true,
57
59
  } = drawOptions;
58
60
  if (item.type === 'node') {
59
- transientItem = item.clone(nodeGroup, shapeIds, true);
61
+ transientItem = item.clone(nodeGroup, nodeLabelGroup, shapeIds, true);
60
62
  } else if (item.type === 'edge') {
61
63
  let source;
62
64
  let target;
@@ -66,6 +68,8 @@ export const upsertTransientItem = (
66
68
  nodeGroup,
67
69
  edgeGroup,
68
70
  comboGroup,
71
+ nodeLabelGroup,
72
+ edgeLabelGroup,
69
73
  transientItemMap,
70
74
  itemMap,
71
75
  graphCore,
@@ -79,6 +83,8 @@ export const upsertTransientItem = (
79
83
  nodeGroup,
80
84
  edgeGroup,
81
85
  comboGroup,
86
+ nodeLabelGroup,
87
+ edgeLabelGroup,
82
88
  transientItemMap,
83
89
  itemMap,
84
90
  graphCore,
@@ -88,10 +94,13 @@ export const upsertTransientItem = (
88
94
  }
89
95
  transientItem = item.clone(
90
96
  edgeGroup,
97
+ edgeLabelGroup,
91
98
  source,
92
99
  target,
93
100
  shapeIds,
94
101
  true,
102
+ visible,
103
+ transientItemMap,
95
104
  ) as Edge;
96
105
  } else {
97
106
  // find the succeeds to upsert transients
@@ -106,6 +115,8 @@ export const upsertTransientItem = (
106
115
  nodeGroup,
107
116
  edgeGroup,
108
117
  comboGroup,
118
+ nodeLabelGroup,
119
+ edgeLabelGroup,
109
120
  transientItemMap,
110
121
  itemMap,
111
122
  graphCore,
@@ -117,6 +128,7 @@ export const upsertTransientItem = (
117
128
  });
118
129
  transientItem = (item as Combo).clone(
119
130
  comboGroup,
131
+ nodeLabelGroup,
120
132
  shapeIds,
121
133
  true,
122
134
  () => getCombinedBoundsByItem(childItems), // getCombinedBounds
@@ -143,6 +155,8 @@ export const upsertTransientItem = (
143
155
  nodeGroup,
144
156
  edgeGroup,
145
157
  comboGroup,
158
+ nodeLabelGroup,
159
+ edgeLabelGroup,
146
160
  transientItemMap,
147
161
  itemMap,
148
162
  graphCore,
@@ -169,5 +183,5 @@ export const upsertTransientItem = (
169
183
  * @returns
170
184
  */
171
185
  export function generateEdgeID(source: ID, target: ID) {
172
- return [source, uniqueId(), target].join('->');
186
+ return [source, uniqueId(), target].join('-');
173
187
  }
@@ -32,7 +32,7 @@ export const DEFAULT_MAPPER = {
32
32
  },
33
33
  edge: (innerEdgeModel) => {
34
34
  const { id, source, target, data } = innerEdgeModel;
35
- const { color, label, icon, badge, keyShape } = data;
35
+ const { color, label, icon, badge, keyShape } = data || {};
36
36
  const resultData: NodeDisplayModelData = {
37
37
  ...data,
38
38
  keyShape: { ...keyShape },
package/src/util/math.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Point, PolyPoint } from '../types/common';
2
2
 
3
3
  /**
4
- * Whether the value is begween the range of [min, max]
4
+ * Whether the value is between the range of [min, max]
5
5
  * @param {number} value the value to be judged
6
6
  * @param {number} min the min of the range
7
7
  * @param {number} max the max of the range
package/src/util/path.ts CHANGED
@@ -6,7 +6,7 @@ import { Point } from '../types/common';
6
6
  * @param {IPoint} startPoint Start point with x and y.
7
7
  * @param {IPoint} endPoint End point with x and y.
8
8
  * @param {Number} percent Control point's position percentage between source and end point, ranges from 0 to 1.
9
- * @param {Number} offset Offsest from the control point to the line start at startPoint and end at endPoint.
9
+ * @param {Number} offset Offset from the control point to the line start at startPoint and end at endPoint.
10
10
  * @return {IPoint} The control point with x and y.
11
11
  */
12
12
  export const getControlPoint = (
@@ -35,9 +35,79 @@ export const getControlPoint = (
35
35
  return point;
36
36
  };
37
37
 
38
- export const pathToPoints = (path: any[]) => {
38
+ const PATH_COMMANDS = {
39
+ M: ['x', 'y'],
40
+ m: ['dx', 'dy'],
41
+ H: ['x'],
42
+ h: ['dx'],
43
+ V: ['y'],
44
+ v: ['dy'],
45
+ L: ['x', 'y'],
46
+ l: ['dx', 'dy'],
47
+ Z: [],
48
+ C: ['x1', 'y1', 'x2', 'y2', 'x', 'y'],
49
+ c: ['dx1', 'dy1', 'dx2', 'dy2', 'dx', 'dy'],
50
+ S: ['x2', 'y2', 'x', 'y'],
51
+ s: ['dx2', 'dy2', 'dx', 'dy'],
52
+ Q: ['x1', 'y1', 'x', 'y'],
53
+ q: ['dx1', 'dy1', 'dx', 'dy'],
54
+ T: ['x', 'y'],
55
+ t: ['dx', 'dy'],
56
+ A: ['rx', 'ry', 'rotation', 'large-arc', 'sweep', 'x', 'y'],
57
+ a: ['rx', 'ry', 'rotation', 'large-arc', 'sweep', 'dx', 'dy'],
58
+ };
59
+
60
+ /**
61
+ * Converts a path string to an array of path segments.
62
+ * @param {string} path - The path string to convert.
63
+ * @returns {Array} - An array of path segments.
64
+ **/
65
+ const fromPathToArray = (path: string) => {
66
+ const items = path
67
+ .replace(/[\n\r]/g, '')
68
+ .replace(/-/g, ' -')
69
+ .replace(/(\d*\.)(\d+)(?=\.)/g, '$1$2 ')
70
+ .trim()
71
+ .split(/\s*,|\s+/);
72
+ const segments = [];
73
+ let currentCommand = '';
74
+ let currentElement = {};
75
+ while (items.length > 0) {
76
+ let it = items.shift();
77
+ if (PATH_COMMANDS.hasOwnProperty(it)) {
78
+ currentCommand = it;
79
+ } else {
80
+ items.unshift(it);
81
+ }
82
+ currentElement = { type: currentCommand };
83
+ PATH_COMMANDS[currentCommand].forEach((prop) => {
84
+ it = items.shift(); // TODO sanity check
85
+ currentElement[prop] = it;
86
+ });
87
+ if (currentCommand === 'M') {
88
+ currentCommand = 'L';
89
+ } else if (currentCommand === 'm') {
90
+ currentCommand = 'l';
91
+ }
92
+ segments.push(currentElement);
93
+ }
94
+ return segments;
95
+ };
96
+
97
+ /**
98
+ * Converts a path to an array of points.
99
+ * @param {Array|string} path - The path to convert to points.
100
+ * @returns {Array} - An array of points.
101
+ */
102
+ export const pathToPoints = (path: any[] | string) => {
39
103
  const points = [];
40
- path.forEach((seg) => {
104
+ let segments = [];
105
+ if (typeof path === 'string') {
106
+ segments = fromPathToArray(path);
107
+ } else {
108
+ segments = path;
109
+ }
110
+ segments.forEach((seg) => {
41
111
  const command = seg[0];
42
112
  if (command !== 'A') {
43
113
  for (let i = 1; i < seg.length; i = i + 2) {
@@ -1,7 +1,10 @@
1
1
  import { AABB } from '@antv/g';
2
2
  import { each } from '@antv/util';
3
3
  import { ID } from '@antv/graphlib';
4
+ import { EdgeDisplayModel } from '../types/edge';
5
+ import { NodeDisplayModel } from '../types';
4
6
  import Node from '../item/node';
7
+ import Item from '../item/item';
5
8
  import { Point, PolyPoint } from '../types/common';
6
9
  import {
7
10
  getBBoxFromPoint,
@@ -18,24 +21,6 @@ import { manhattanDist } from './math';
18
21
  import { RouterCfg } from './router';
19
22
  import { isBending } from './point';
20
23
 
21
- // class PolylineHistory {
22
- // private pathMap: Map<ID, Point[]>;
23
-
24
- // constructor() {
25
- // this.pathMap = new Map<ID, Point[]>();
26
- // }
27
-
28
- // public addPath(edgeId: ID, points: Point[]): void {
29
- // this.pathMap.set(edgeId, points);
30
- // }
31
-
32
- // public getPointsById(edgeId: ID): Point[] | undefined {
33
- // return this.pathMap.get(edgeId);
34
- // }
35
- // }
36
-
37
- // const polylineHistory = new PolylineHistory();
38
-
39
24
  /**
40
25
  * Simplify points of polyline by removing duplicated points
41
26
  * @param points list of 2d points
@@ -341,9 +326,6 @@ export const getPolylinePath = (
341
326
 
342
327
  const newPoints = removeRedundantPoint(points);
343
328
 
344
- // Record polyline points
345
- // polylineHistory.addPath(id, newPoints);
346
-
347
329
  return pointsToPolyline(newPoints, radius, z);
348
330
  };
349
331
 
@@ -436,8 +418,6 @@ export const getPolylinePoints = (
436
418
  start,
437
419
  end,
438
420
  );
439
- pathPoints.unshift(start);
440
- pathPoints.push(end);
441
421
 
442
422
  return simplifyPolylinePoints(pathPoints);
443
423
  };
@@ -485,7 +465,7 @@ export const removeRedundantPoint = (points: Point[]) => {
485
465
  };
486
466
 
487
467
  /**
488
- * sorted array ascendly
468
+ * sorted array ascend
489
469
  * add new item to proper index when calling add
490
470
  */
491
471
  export class SortedArray {
@@ -572,7 +552,7 @@ interface ComputedEdge {
572
552
  bbox: AABB;
573
553
  }
574
554
 
575
- /** Define a quadtree */
555
+ /** Define a quad-tree */
576
556
  export class QuadTree {
577
557
  private readonly capacity: number;
578
558
  private edges: ComputedEdge[] = [];
@@ -610,7 +590,7 @@ export class QuadTree {
610
590
  );
611
591
  }
612
592
 
613
- // Divide the quadtree into four subtrees
593
+ // Divide the quad-tree into four subtrees
614
594
  subdivide() {
615
595
  const x = this.boundary.center[0];
616
596
  const y = this.boundary.center[1];
@@ -675,3 +655,30 @@ export class EdgeCollisionChecker {
675
655
  return potentialCollisions;
676
656
  }
677
657
  }
658
+
659
+ /**
660
+ * Check if the edge is a polyline and obstacle avoidance is enabled
661
+ */
662
+ export const isPolylineWithObstacleAvoidance = (
663
+ displayModel: EdgeDisplayModel,
664
+ polylineEdgeType = ['polyline-edge'],
665
+ ) => {
666
+ const { type, keyShape } = displayModel.data;
667
+ const isPolyline = polylineEdgeType.includes(type);
668
+ if (!isPolyline) return false;
669
+ // @ts-ignore
670
+ const isObstacleAvoidanceEnabled = (keyShape?.routeCfg as RouterCfg)
671
+ ?.enableObstacleAvoidance;
672
+ return isObstacleAvoidanceEnabled;
673
+ };
674
+
675
+ /**
676
+ * Check if the node prevents polyline edges from overlapping
677
+ */
678
+ export const isPointPreventPolylineOverlap = (
679
+ displayModel: NodeDisplayModel,
680
+ ) => {
681
+ if (!displayModel) return false;
682
+ const { preventPolylineEdgeOverlap } = displayModel.data;
683
+ return preventPolylineEdgeOverlap || false;
684
+ };
@@ -12,6 +12,7 @@ import {
12
12
  } from './bbox';
13
13
  import { getLineIntersect } from './shape';
14
14
  import { eulerDist, manhattanDist } from './math';
15
+ import { getNearestPoint } from './point';
15
16
 
16
17
  export interface RouterCfg {
17
18
  name: 'orth' | 'er';
@@ -43,13 +44,13 @@ export interface RouterCfg {
43
44
  * Whether to automatically avoid other nodes (obstacles) on the path
44
45
  * Defaults to false.
45
46
  */
46
- obstacleAvoidance?: boolean;
47
+ enableObstacleAvoidance?: boolean;
47
48
  }
48
49
 
49
50
  const defaultCfg: RouterCfg = {
50
51
  name: 'orth',
51
- obstacleAvoidance: false,
52
- offset: 20,
52
+ enableObstacleAvoidance: false,
53
+ offset: 2,
53
54
  maxAllowedDirectionChange: Math.PI / 2,
54
55
  maximumLoops: 2000,
55
56
  gridSize: 10,
@@ -251,7 +252,7 @@ const getBoxPoints = (
251
252
  ];
252
253
  for (let i = 0; i < 4; i++) {
253
254
  const boundLine = bounds[i];
254
- const insterctP = getLineIntersect(
255
+ const intersectP = getLineIntersect(
255
256
  point,
256
257
  {
257
258
  x: point.x + dir.stepX * getBBoxWidth(expandBBox),
@@ -260,18 +261,18 @@ const getBoxPoints = (
260
261
  boundLine[0],
261
262
  boundLine[1],
262
263
  ) as PolyPoint;
263
- if (insterctP && !isSegmentCrossingBBox(point, insterctP, bbox)) {
264
- insterctP.id = `${insterctP.x}|||${insterctP.y}`;
265
- points.push(insterctP);
264
+ if (intersectP && !isSegmentCrossingBBox(point, intersectP, bbox)) {
265
+ intersectP.id = `${intersectP.x}|||${intersectP.y}`;
266
+ points.push(intersectP);
266
267
  }
267
268
  }
268
269
  }
269
270
  return points;
270
271
  }
271
272
  // If the anchorPoint is on the node, there is only one optional direction
272
- const insterctP = getExpandedBBoxPoint(expandBBox, point, anotherPoint);
273
- insterctP.id = `${insterctP.x}|||${insterctP.y}`;
274
- return [insterctP];
273
+ const intersectP = getExpandedBBoxPoint(expandBBox, point, anotherPoint);
274
+ intersectP.id = `${intersectP.x}|||${intersectP.y}`;
275
+ return [intersectP];
275
276
  };
276
277
 
277
278
  const getDirectionChange = (
@@ -307,11 +308,11 @@ const getControlPoints = (
307
308
  cameFrom,
308
309
  scaleStartPoint,
309
310
  endPoint,
310
- startPoint,
311
+ startPoints,
311
312
  scaleEndPoint,
312
313
  gridSize,
313
314
  ) => {
314
- const controlPoints = [endPoint];
315
+ const controlPoints = [];
315
316
  let pointZero = endPoint;
316
317
  let currentId = current.id;
317
318
  let currentX = current.x;
@@ -321,13 +322,13 @@ const getControlPoints = (
321
322
  y: currentY,
322
323
  id: currentId,
323
324
  };
324
- if (getDirectionChange(lastPoint, scaleEndPoint, cameFrom, scaleStartPoint)) {
325
- pointZero = {
326
- x: scaleEndPoint.x === endPoint.x ? endPoint.x : lastPoint.x * gridSize,
327
- y: scaleEndPoint.y === endPoint.y ? endPoint.y : lastPoint.y * gridSize,
328
- };
329
- controlPoints.unshift(pointZero);
330
- }
325
+ // append endPoint
326
+ pointZero = {
327
+ x: scaleEndPoint.x === endPoint.x ? endPoint.x : lastPoint.x * gridSize,
328
+ y: scaleEndPoint.y === endPoint.y ? endPoint.y : lastPoint.y * gridSize,
329
+ };
330
+ controlPoints.unshift(pointZero);
331
+
331
332
  let currentCameFrom = cameFrom[currentId];
332
333
  while (currentCameFrom && currentCameFrom.id !== currentId) {
333
334
  const point = {
@@ -360,11 +361,12 @@ const getControlPoints = (
360
361
  currentCameFrom = cameFrom[currentId];
361
362
  }
362
363
 
363
- // Align with startNode
364
- controlPoints[0].x =
365
- currentX === scaleStartPoint.x ? startPoint.x : pointZero.x;
366
- controlPoints[0].y =
367
- currentY === scaleStartPoint.y ? startPoint.y : pointZero.y;
364
+ // append startPoint
365
+ const realStartPoints = startPoints.map((point) => ({
366
+ x: point.x * gridSize,
367
+ y: point.y * gridSize,
368
+ }));
369
+ const startPoint = getNearestPoint(realStartPoints, pointZero).nearestPoint;
368
370
  controlPoints.unshift(startPoint);
369
371
  return controlPoints;
370
372
  };
@@ -391,7 +393,7 @@ export const pathFinder = (
391
393
 
392
394
  const cfg: RouterCfg = deepMix(defaultCfgs, routerCfg);
393
395
 
394
- if (!cfg.obstacleAvoidance) {
396
+ if (!cfg.enableObstacleAvoidance) {
395
397
  return cfg.fallbackRoute(startPoint, endPoint, startNode, endNode, cfg);
396
398
  }
397
399
 
@@ -497,7 +499,7 @@ export const pathFinder = (
497
499
  cameFrom,
498
500
  scaleStartPoint,
499
501
  endPoint,
500
- startPoint,
502
+ startPoints,
501
503
  scaleEndPoint,
502
504
  gridSize,
503
505
  );