@antv/g6 5.0.19 → 5.0.21

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 (440) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/base-behavior.d.ts +10 -0
  3. package/dist/lib/behaviors/drag-canvas.d.ts +9 -0
  4. package/dist/lib/behaviors/hover-activate.d.ts +16 -2
  5. package/dist/lib/behaviors/scroll-canvas.d.ts +9 -0
  6. package/dist/lib/elements/combos/circle.d.ts +1 -1
  7. package/dist/lib/elements/edges/cubic-radial.d.ts +24 -0
  8. package/dist/lib/elements/edges/index.d.ts +2 -0
  9. package/dist/lib/elements/edges/line.d.ts +0 -2
  10. package/dist/lib/elements/nodes/base-node.d.ts +2 -1
  11. package/dist/lib/elements/nodes/circle.d.ts +1 -1
  12. package/dist/lib/elements/nodes/ellipse.d.ts +1 -1
  13. package/dist/lib/elements/shapes/base-shape.d.ts +29 -14
  14. package/dist/lib/elements/shapes/polygon.d.ts +1 -1
  15. package/dist/lib/exports.d.ts +9 -7
  16. package/dist/lib/layouts/base-layout.d.ts +5 -0
  17. package/dist/lib/plugins/background/index.d.ts +1 -0
  18. package/dist/lib/plugins/base-plugin.d.ts +5 -0
  19. package/dist/lib/plugins/bubble-sets.d.ts +1 -0
  20. package/dist/lib/plugins/contextmenu/index.d.ts +1 -0
  21. package/dist/lib/plugins/grid-line.d.ts +1 -0
  22. package/dist/lib/plugins/history/index.d.ts +1 -0
  23. package/dist/lib/plugins/hull/index.d.ts +1 -0
  24. package/dist/lib/plugins/legend.d.ts +1 -0
  25. package/dist/lib/plugins/minimap/index.d.ts +8 -2
  26. package/dist/lib/plugins/snapline/index.d.ts +10 -0
  27. package/dist/lib/plugins/timebar.d.ts +1 -0
  28. package/dist/lib/plugins/toolbar/index.d.ts +1 -0
  29. package/dist/lib/plugins/tooltip.d.ts +11 -0
  30. package/dist/lib/plugins/watermark/index.d.ts +1 -0
  31. package/dist/lib/runtime/data.d.ts +1 -0
  32. package/dist/lib/runtime/element.d.ts +1 -0
  33. package/dist/lib/runtime/graph.d.ts +2 -0
  34. package/dist/lib/runtime/layout.d.ts +1 -0
  35. package/dist/lib/transforms/base-transform.d.ts +6 -0
  36. package/dist/lib/transforms/index.d.ts +3 -0
  37. package/dist/lib/transforms/position-radial-labels.d.ts +27 -0
  38. package/dist/lib/transforms/process-parallel-edges.d.ts +7 -9
  39. package/dist/lib/transforms/utils.d.ts +5 -5
  40. package/dist/lib/types/element.d.ts +2 -1
  41. package/dist/lib/utils/bbox.d.ts +12 -3
  42. package/dist/lib/utils/data.d.ts +14 -0
  43. package/dist/lib/utils/diff.d.ts +2 -1
  44. package/dist/lib/utils/padding.d.ts +4 -4
  45. package/dist/lib/utils/point.d.ts +17 -5
  46. package/dist/lib/utils/position.d.ts +8 -0
  47. package/dist/lib/utils/prefix.d.ts +1 -1
  48. package/dist/lib/utils/relation.d.ts +6 -4
  49. package/dist/lib/utils/router/orth.d.ts +1 -1
  50. package/dist/lib/utils/size.d.ts +3 -1
  51. package/dist/lib/utils/transform.d.ts +5 -5
  52. package/dist/lib/utils/vector.d.ts +8 -0
  53. package/dist/lib/version.d.ts +1 -1
  54. package/esm/behaviors/base-behavior.d.ts +10 -0
  55. package/esm/behaviors/base-behavior.js +5 -0
  56. package/esm/behaviors/base-behavior.js.map +1 -1
  57. package/esm/behaviors/drag-canvas.d.ts +9 -0
  58. package/esm/behaviors/drag-canvas.js +28 -3
  59. package/esm/behaviors/drag-canvas.js.map +1 -1
  60. package/esm/behaviors/hover-activate.d.ts +16 -2
  61. package/esm/behaviors/hover-activate.js +17 -7
  62. package/esm/behaviors/hover-activate.js.map +1 -1
  63. package/esm/behaviors/scroll-canvas.d.ts +9 -0
  64. package/esm/behaviors/scroll-canvas.js +31 -4
  65. package/esm/behaviors/scroll-canvas.js.map +1 -1
  66. package/esm/elements/combos/base-combo.js +2 -2
  67. package/esm/elements/combos/base-combo.js.map +1 -1
  68. package/esm/elements/combos/circle.d.ts +1 -1
  69. package/esm/elements/combos/circle.js +2 -2
  70. package/esm/elements/combos/circle.js.map +1 -1
  71. package/esm/elements/edges/cubic-radial.d.ts +24 -0
  72. package/esm/elements/edges/cubic-radial.js +52 -0
  73. package/esm/elements/edges/cubic-radial.js.map +1 -0
  74. package/esm/elements/edges/index.d.ts +2 -0
  75. package/esm/elements/edges/index.js +1 -0
  76. package/esm/elements/edges/index.js.map +1 -1
  77. package/esm/elements/edges/line.d.ts +0 -2
  78. package/esm/elements/edges/line.js +0 -2
  79. package/esm/elements/edges/line.js.map +1 -1
  80. package/esm/elements/edges/polyline.js.map +1 -1
  81. package/esm/elements/nodes/base-node.d.ts +2 -1
  82. package/esm/elements/nodes/base-node.js +3 -2
  83. package/esm/elements/nodes/base-node.js.map +1 -1
  84. package/esm/elements/nodes/circle.d.ts +1 -1
  85. package/esm/elements/nodes/circle.js +2 -2
  86. package/esm/elements/nodes/circle.js.map +1 -1
  87. package/esm/elements/nodes/ellipse.d.ts +1 -1
  88. package/esm/elements/nodes/ellipse.js +2 -2
  89. package/esm/elements/nodes/ellipse.js.map +1 -1
  90. package/esm/elements/nodes/html.js +4 -1
  91. package/esm/elements/nodes/html.js.map +1 -1
  92. package/esm/elements/shapes/base-shape.d.ts +29 -14
  93. package/esm/elements/shapes/base-shape.js +27 -12
  94. package/esm/elements/shapes/base-shape.js.map +1 -1
  95. package/esm/elements/shapes/polygon.d.ts +1 -1
  96. package/esm/elements/shapes/polygon.js +2 -2
  97. package/esm/elements/shapes/polygon.js.map +1 -1
  98. package/esm/exports.d.ts +9 -7
  99. package/esm/exports.js +6 -4
  100. package/esm/exports.js.map +1 -1
  101. package/esm/layouts/base-layout.d.ts +5 -0
  102. package/esm/layouts/base-layout.js +5 -0
  103. package/esm/layouts/base-layout.js.map +1 -1
  104. package/esm/plugins/background/index.d.ts +1 -0
  105. package/esm/plugins/background/index.js +1 -0
  106. package/esm/plugins/background/index.js.map +1 -1
  107. package/esm/plugins/base-plugin.d.ts +5 -0
  108. package/esm/plugins/base-plugin.js +5 -0
  109. package/esm/plugins/base-plugin.js.map +1 -1
  110. package/esm/plugins/bubble-sets.d.ts +1 -0
  111. package/esm/plugins/bubble-sets.js +1 -0
  112. package/esm/plugins/bubble-sets.js.map +1 -1
  113. package/esm/plugins/contextmenu/index.d.ts +1 -0
  114. package/esm/plugins/contextmenu/index.js +1 -0
  115. package/esm/plugins/contextmenu/index.js.map +1 -1
  116. package/esm/plugins/grid-line.d.ts +1 -0
  117. package/esm/plugins/grid-line.js +1 -0
  118. package/esm/plugins/grid-line.js.map +1 -1
  119. package/esm/plugins/history/index.d.ts +1 -0
  120. package/esm/plugins/history/index.js +1 -0
  121. package/esm/plugins/history/index.js.map +1 -1
  122. package/esm/plugins/hull/index.d.ts +1 -0
  123. package/esm/plugins/hull/index.js +1 -0
  124. package/esm/plugins/hull/index.js.map +1 -1
  125. package/esm/plugins/legend.d.ts +1 -0
  126. package/esm/plugins/legend.js +1 -0
  127. package/esm/plugins/legend.js.map +1 -1
  128. package/esm/plugins/minimap/index.d.ts +8 -2
  129. package/esm/plugins/minimap/index.js +5 -0
  130. package/esm/plugins/minimap/index.js.map +1 -1
  131. package/esm/plugins/snapline/index.d.ts +10 -0
  132. package/esm/plugins/snapline/index.js +5 -0
  133. package/esm/plugins/snapline/index.js.map +1 -1
  134. package/esm/plugins/timebar.d.ts +1 -0
  135. package/esm/plugins/timebar.js +1 -0
  136. package/esm/plugins/timebar.js.map +1 -1
  137. package/esm/plugins/toolbar/index.d.ts +1 -0
  138. package/esm/plugins/toolbar/index.js +1 -0
  139. package/esm/plugins/toolbar/index.js.map +1 -1
  140. package/esm/plugins/tooltip.d.ts +11 -0
  141. package/esm/plugins/tooltip.js +11 -2
  142. package/esm/plugins/tooltip.js.map +1 -1
  143. package/esm/plugins/watermark/index.d.ts +1 -0
  144. package/esm/plugins/watermark/index.js +1 -0
  145. package/esm/plugins/watermark/index.js.map +1 -1
  146. package/esm/registry/build-in.js +4 -2
  147. package/esm/registry/build-in.js.map +1 -1
  148. package/esm/runtime/animation.js +12 -10
  149. package/esm/runtime/animation.js.map +1 -1
  150. package/esm/runtime/data.d.ts +1 -0
  151. package/esm/runtime/data.js +21 -13
  152. package/esm/runtime/data.js.map +1 -1
  153. package/esm/runtime/element.d.ts +1 -0
  154. package/esm/runtime/element.js +21 -11
  155. package/esm/runtime/element.js.map +1 -1
  156. package/esm/runtime/graph.d.ts +2 -0
  157. package/esm/runtime/graph.js +42 -22
  158. package/esm/runtime/graph.js.map +1 -1
  159. package/esm/runtime/layout.d.ts +1 -0
  160. package/esm/runtime/layout.js +5 -0
  161. package/esm/runtime/layout.js.map +1 -1
  162. package/esm/transforms/base-transform.d.ts +6 -0
  163. package/esm/transforms/base-transform.js +6 -0
  164. package/esm/transforms/base-transform.js.map +1 -1
  165. package/esm/transforms/collapse-expand-combo.js +3 -0
  166. package/esm/transforms/collapse-expand-combo.js.map +1 -1
  167. package/esm/transforms/collapse-expand-node.js +2 -0
  168. package/esm/transforms/collapse-expand-node.js.map +1 -1
  169. package/esm/transforms/index.d.ts +3 -0
  170. package/esm/transforms/index.js +1 -0
  171. package/esm/transforms/index.js.map +1 -1
  172. package/esm/transforms/position-radial-labels.d.ts +27 -0
  173. package/esm/transforms/position-radial-labels.js +50 -0
  174. package/esm/transforms/position-radial-labels.js.map +1 -0
  175. package/esm/transforms/process-parallel-edges.d.ts +7 -9
  176. package/esm/transforms/process-parallel-edges.js.map +1 -1
  177. package/esm/transforms/utils.d.ts +5 -5
  178. package/esm/transforms/utils.js +5 -5
  179. package/esm/types/element.d.ts +2 -1
  180. package/esm/utils/bbox.d.ts +12 -3
  181. package/esm/utils/bbox.js +16 -4
  182. package/esm/utils/bbox.js.map +1 -1
  183. package/esm/utils/data.d.ts +14 -0
  184. package/esm/utils/data.js +39 -0
  185. package/esm/utils/data.js.map +1 -1
  186. package/esm/utils/diff.d.ts +2 -1
  187. package/esm/utils/diff.js +3 -2
  188. package/esm/utils/diff.js.map +1 -1
  189. package/esm/utils/edge.js +4 -4
  190. package/esm/utils/edge.js.map +1 -1
  191. package/esm/utils/padding.d.ts +4 -4
  192. package/esm/utils/padding.js +4 -4
  193. package/esm/utils/point.d.ts +17 -5
  194. package/esm/utils/point.js +27 -8
  195. package/esm/utils/point.js.map +1 -1
  196. package/esm/utils/position.d.ts +8 -0
  197. package/esm/utils/position.js +11 -0
  198. package/esm/utils/position.js.map +1 -1
  199. package/esm/utils/prefix.d.ts +1 -1
  200. package/esm/utils/prefix.js +1 -1
  201. package/esm/utils/relation.d.ts +6 -4
  202. package/esm/utils/relation.js +10 -8
  203. package/esm/utils/relation.js.map +1 -1
  204. package/esm/utils/router/orth.d.ts +1 -1
  205. package/esm/utils/router/orth.js +27 -11
  206. package/esm/utils/router/orth.js.map +1 -1
  207. package/esm/utils/size.d.ts +3 -1
  208. package/esm/utils/size.js +3 -1
  209. package/esm/utils/size.js.map +1 -1
  210. package/esm/utils/transform.d.ts +5 -5
  211. package/esm/utils/transform.js +5 -5
  212. package/esm/utils/vector.d.ts +8 -0
  213. package/esm/utils/vector.js +13 -0
  214. package/esm/utils/vector.js.map +1 -1
  215. package/esm/version.d.ts +1 -1
  216. package/esm/version.js +1 -1
  217. package/lib/behaviors/base-behavior.d.ts +10 -0
  218. package/lib/behaviors/base-behavior.js +5 -0
  219. package/lib/behaviors/base-behavior.js.map +1 -1
  220. package/lib/behaviors/drag-canvas.d.ts +9 -0
  221. package/lib/behaviors/drag-canvas.js +27 -2
  222. package/lib/behaviors/drag-canvas.js.map +1 -1
  223. package/lib/behaviors/hover-activate.d.ts +16 -2
  224. package/lib/behaviors/hover-activate.js +17 -7
  225. package/lib/behaviors/hover-activate.js.map +1 -1
  226. package/lib/behaviors/scroll-canvas.d.ts +9 -0
  227. package/lib/behaviors/scroll-canvas.js +31 -4
  228. package/lib/behaviors/scroll-canvas.js.map +1 -1
  229. package/lib/elements/combos/base-combo.js +1 -1
  230. package/lib/elements/combos/base-combo.js.map +1 -1
  231. package/lib/elements/combos/circle.d.ts +1 -1
  232. package/lib/elements/combos/circle.js +2 -2
  233. package/lib/elements/combos/circle.js.map +1 -1
  234. package/lib/elements/edges/cubic-radial.d.ts +24 -0
  235. package/lib/elements/edges/cubic-radial.js +56 -0
  236. package/lib/elements/edges/cubic-radial.js.map +1 -0
  237. package/lib/elements/edges/index.d.ts +2 -0
  238. package/lib/elements/edges/index.js +3 -1
  239. package/lib/elements/edges/index.js.map +1 -1
  240. package/lib/elements/edges/line.d.ts +0 -2
  241. package/lib/elements/edges/line.js +0 -2
  242. package/lib/elements/edges/line.js.map +1 -1
  243. package/lib/elements/edges/polyline.js.map +1 -1
  244. package/lib/elements/nodes/base-node.d.ts +2 -1
  245. package/lib/elements/nodes/base-node.js +3 -2
  246. package/lib/elements/nodes/base-node.js.map +1 -1
  247. package/lib/elements/nodes/circle.d.ts +1 -1
  248. package/lib/elements/nodes/circle.js +2 -2
  249. package/lib/elements/nodes/circle.js.map +1 -1
  250. package/lib/elements/nodes/ellipse.d.ts +1 -1
  251. package/lib/elements/nodes/ellipse.js +2 -2
  252. package/lib/elements/nodes/ellipse.js.map +1 -1
  253. package/lib/elements/nodes/html.js +3 -0
  254. package/lib/elements/nodes/html.js.map +1 -1
  255. package/lib/elements/shapes/base-shape.d.ts +29 -14
  256. package/lib/elements/shapes/base-shape.js +27 -12
  257. package/lib/elements/shapes/base-shape.js.map +1 -1
  258. package/lib/elements/shapes/polygon.d.ts +1 -1
  259. package/lib/elements/shapes/polygon.js +2 -2
  260. package/lib/elements/shapes/polygon.js.map +1 -1
  261. package/lib/exports.d.ts +9 -7
  262. package/lib/exports.js +15 -6
  263. package/lib/exports.js.map +1 -1
  264. package/lib/layouts/base-layout.d.ts +5 -0
  265. package/lib/layouts/base-layout.js +5 -0
  266. package/lib/layouts/base-layout.js.map +1 -1
  267. package/lib/plugins/background/index.d.ts +1 -0
  268. package/lib/plugins/background/index.js +1 -0
  269. package/lib/plugins/background/index.js.map +1 -1
  270. package/lib/plugins/base-plugin.d.ts +5 -0
  271. package/lib/plugins/base-plugin.js +5 -0
  272. package/lib/plugins/base-plugin.js.map +1 -1
  273. package/lib/plugins/bubble-sets.d.ts +1 -0
  274. package/lib/plugins/bubble-sets.js +1 -0
  275. package/lib/plugins/bubble-sets.js.map +1 -1
  276. package/lib/plugins/contextmenu/index.d.ts +1 -0
  277. package/lib/plugins/contextmenu/index.js +1 -0
  278. package/lib/plugins/contextmenu/index.js.map +1 -1
  279. package/lib/plugins/grid-line.d.ts +1 -0
  280. package/lib/plugins/grid-line.js +1 -0
  281. package/lib/plugins/grid-line.js.map +1 -1
  282. package/lib/plugins/history/index.d.ts +1 -0
  283. package/lib/plugins/history/index.js +1 -0
  284. package/lib/plugins/history/index.js.map +1 -1
  285. package/lib/plugins/hull/index.d.ts +1 -0
  286. package/lib/plugins/hull/index.js +1 -0
  287. package/lib/plugins/hull/index.js.map +1 -1
  288. package/lib/plugins/legend.d.ts +1 -0
  289. package/lib/plugins/legend.js +1 -0
  290. package/lib/plugins/legend.js.map +1 -1
  291. package/lib/plugins/minimap/index.d.ts +8 -2
  292. package/lib/plugins/minimap/index.js +5 -0
  293. package/lib/plugins/minimap/index.js.map +1 -1
  294. package/lib/plugins/snapline/index.d.ts +10 -0
  295. package/lib/plugins/snapline/index.js +5 -0
  296. package/lib/plugins/snapline/index.js.map +1 -1
  297. package/lib/plugins/timebar.d.ts +1 -0
  298. package/lib/plugins/timebar.js +1 -0
  299. package/lib/plugins/timebar.js.map +1 -1
  300. package/lib/plugins/toolbar/index.d.ts +1 -0
  301. package/lib/plugins/toolbar/index.js +1 -0
  302. package/lib/plugins/toolbar/index.js.map +1 -1
  303. package/lib/plugins/tooltip.d.ts +11 -0
  304. package/lib/plugins/tooltip.js +11 -2
  305. package/lib/plugins/tooltip.js.map +1 -1
  306. package/lib/plugins/watermark/index.d.ts +1 -0
  307. package/lib/plugins/watermark/index.js +1 -0
  308. package/lib/plugins/watermark/index.js.map +1 -1
  309. package/lib/registry/build-in.js +2 -0
  310. package/lib/registry/build-in.js.map +1 -1
  311. package/lib/runtime/animation.js +12 -10
  312. package/lib/runtime/animation.js.map +1 -1
  313. package/lib/runtime/data.d.ts +1 -0
  314. package/lib/runtime/data.js +19 -11
  315. package/lib/runtime/data.js.map +1 -1
  316. package/lib/runtime/element.d.ts +1 -0
  317. package/lib/runtime/element.js +21 -11
  318. package/lib/runtime/element.js.map +1 -1
  319. package/lib/runtime/graph.d.ts +2 -0
  320. package/lib/runtime/graph.js +42 -22
  321. package/lib/runtime/graph.js.map +1 -1
  322. package/lib/runtime/layout.d.ts +1 -0
  323. package/lib/runtime/layout.js +5 -0
  324. package/lib/runtime/layout.js.map +1 -1
  325. package/lib/transforms/base-transform.d.ts +6 -0
  326. package/lib/transforms/base-transform.js +6 -0
  327. package/lib/transforms/base-transform.js.map +1 -1
  328. package/lib/transforms/collapse-expand-combo.js +3 -0
  329. package/lib/transforms/collapse-expand-combo.js.map +1 -1
  330. package/lib/transforms/collapse-expand-node.js +2 -0
  331. package/lib/transforms/collapse-expand-node.js.map +1 -1
  332. package/lib/transforms/index.d.ts +3 -0
  333. package/lib/transforms/index.js +3 -1
  334. package/lib/transforms/index.js.map +1 -1
  335. package/lib/transforms/position-radial-labels.d.ts +27 -0
  336. package/lib/transforms/position-radial-labels.js +54 -0
  337. package/lib/transforms/position-radial-labels.js.map +1 -0
  338. package/lib/transforms/process-parallel-edges.d.ts +7 -9
  339. package/lib/transforms/process-parallel-edges.js.map +1 -1
  340. package/lib/transforms/utils.d.ts +5 -5
  341. package/lib/transforms/utils.js +5 -5
  342. package/lib/types/element.d.ts +2 -1
  343. package/lib/utils/bbox.d.ts +12 -3
  344. package/lib/utils/bbox.js +19 -6
  345. package/lib/utils/bbox.js.map +1 -1
  346. package/lib/utils/data.d.ts +14 -0
  347. package/lib/utils/data.js +40 -0
  348. package/lib/utils/data.js.map +1 -1
  349. package/lib/utils/diff.d.ts +2 -1
  350. package/lib/utils/diff.js +3 -2
  351. package/lib/utils/diff.js.map +1 -1
  352. package/lib/utils/edge.js +3 -3
  353. package/lib/utils/edge.js.map +1 -1
  354. package/lib/utils/padding.d.ts +4 -4
  355. package/lib/utils/padding.js +4 -4
  356. package/lib/utils/point.d.ts +17 -5
  357. package/lib/utils/point.js +28 -8
  358. package/lib/utils/point.js.map +1 -1
  359. package/lib/utils/position.d.ts +8 -0
  360. package/lib/utils/position.js +12 -0
  361. package/lib/utils/position.js.map +1 -1
  362. package/lib/utils/prefix.d.ts +1 -1
  363. package/lib/utils/prefix.js +1 -1
  364. package/lib/utils/relation.d.ts +6 -4
  365. package/lib/utils/relation.js +10 -8
  366. package/lib/utils/relation.js.map +1 -1
  367. package/lib/utils/router/orth.d.ts +1 -1
  368. package/lib/utils/router/orth.js +25 -9
  369. package/lib/utils/router/orth.js.map +1 -1
  370. package/lib/utils/size.d.ts +3 -1
  371. package/lib/utils/size.js +3 -1
  372. package/lib/utils/size.js.map +1 -1
  373. package/lib/utils/transform.d.ts +5 -5
  374. package/lib/utils/transform.js +5 -5
  375. package/lib/utils/vector.d.ts +8 -0
  376. package/lib/utils/vector.js +14 -0
  377. package/lib/utils/vector.js.map +1 -1
  378. package/lib/version.d.ts +1 -1
  379. package/lib/version.js +1 -1
  380. package/package.json +10 -10
  381. package/src/behaviors/base-behavior.ts +10 -0
  382. package/src/behaviors/drag-canvas.ts +42 -3
  383. package/src/behaviors/hover-activate.ts +39 -9
  384. package/src/behaviors/scroll-canvas.ts +45 -4
  385. package/src/elements/combos/base-combo.ts +2 -2
  386. package/src/elements/combos/circle.ts +2 -2
  387. package/src/elements/edges/cubic-radial.ts +77 -0
  388. package/src/elements/edges/index.ts +2 -0
  389. package/src/elements/edges/line.ts +0 -2
  390. package/src/elements/edges/polyline.ts +2 -0
  391. package/src/elements/nodes/base-node.ts +3 -2
  392. package/src/elements/nodes/circle.ts +2 -2
  393. package/src/elements/nodes/ellipse.ts +2 -2
  394. package/src/elements/nodes/html.ts +4 -1
  395. package/src/elements/shapes/base-shape.ts +29 -14
  396. package/src/elements/shapes/polygon.ts +2 -2
  397. package/src/exports.ts +21 -7
  398. package/src/layouts/base-layout.ts +5 -0
  399. package/src/plugins/background/index.ts +1 -0
  400. package/src/plugins/base-plugin.ts +5 -0
  401. package/src/plugins/bubble-sets.ts +1 -0
  402. package/src/plugins/contextmenu/index.ts +1 -0
  403. package/src/plugins/grid-line.ts +1 -0
  404. package/src/plugins/history/index.ts +1 -0
  405. package/src/plugins/hull/index.ts +1 -0
  406. package/src/plugins/legend.ts +1 -0
  407. package/src/plugins/minimap/index.ts +8 -2
  408. package/src/plugins/snapline/index.ts +10 -0
  409. package/src/plugins/timebar.ts +1 -0
  410. package/src/plugins/toolbar/index.ts +1 -0
  411. package/src/plugins/tooltip.ts +15 -2
  412. package/src/plugins/watermark/index.ts +1 -0
  413. package/src/registry/build-in.ts +4 -0
  414. package/src/runtime/animation.ts +16 -11
  415. package/src/runtime/data.ts +20 -13
  416. package/src/runtime/element.ts +23 -11
  417. package/src/runtime/graph.ts +51 -22
  418. package/src/runtime/layout.ts +7 -0
  419. package/src/transforms/base-transform.ts +7 -0
  420. package/src/transforms/collapse-expand-combo.ts +2 -0
  421. package/src/transforms/collapse-expand-node.ts +3 -0
  422. package/src/transforms/index.ts +3 -0
  423. package/src/transforms/position-radial-labels.ts +76 -0
  424. package/src/transforms/process-parallel-edges.ts +7 -9
  425. package/src/transforms/utils.ts +5 -5
  426. package/src/types/element.ts +2 -1
  427. package/src/utils/bbox.ts +17 -4
  428. package/src/utils/data.ts +49 -0
  429. package/src/utils/diff.ts +8 -2
  430. package/src/utils/edge.ts +4 -4
  431. package/src/utils/padding.ts +4 -4
  432. package/src/utils/point.ts +27 -7
  433. package/src/utils/position.ts +12 -0
  434. package/src/utils/prefix.ts +1 -1
  435. package/src/utils/relation.ts +22 -9
  436. package/src/utils/router/orth.ts +29 -11
  437. package/src/utils/size.ts +3 -1
  438. package/src/utils/transform.ts +5 -5
  439. package/src/utils/vector.ts +13 -0
  440. package/src/version.ts +1 -1
@@ -14,6 +14,11 @@ import { getExtension } from './../../registry/get';
14
14
 
15
15
  export interface BaseShapeStyleProps extends BaseStyleProps {}
16
16
 
17
+ /**
18
+ * <zh/> 图形基类
19
+ *
20
+ * <en/> Base class for shapes
21
+ */
17
22
  export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends CustomElement<StyleProps> {
18
23
  constructor(options: DisplayObjectConfig<StyleProps>) {
19
24
  super(options);
@@ -23,34 +28,43 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
23
28
  this.bindEvents();
24
29
  }
25
30
 
31
+ /**
32
+ * <zh/> 解析后的属性
33
+ *
34
+ * <en/> parsed attributes
35
+ * @returns <zh/> 解析后的属性 | <en/> parsed attributes
36
+ * @internal
37
+ */
26
38
  protected get parsedAttributes() {
27
39
  return this.attributes as Required<StyleProps>;
28
40
  }
29
41
 
30
42
  /**
31
- * <zh> 图形实例映射表
43
+ * <zh/> 图形实例映射表
32
44
  *
33
- * <en> shape instance map
45
+ * <en/> shape instance map
46
+ * @internal
34
47
  */
35
48
  protected shapeMap: Record<string, DisplayObject> = {};
36
49
 
37
50
  /**
38
- * <zh> 动画实例映射表
51
+ * <zh/> 动画实例映射表
39
52
  *
40
- * <en> animation instance map
53
+ * <en/> animation instance map
54
+ * @internal
41
55
  */
42
56
  protected animateMap: Record<string, IAnimation> = {};
43
57
 
44
58
  /**
45
- * <zh> 创建、更新或删除图形
59
+ * <zh/> 创建、更新或删除图形
46
60
  *
47
- * <en> create, update or remove shape
48
- * @param className - <zh> 图形名称 | <en> shape name
49
- * @param Ctor - <zh> 图形类型 | <en> shape type
50
- * @param style - <zh> 图形样式。若要删除图形,传入 false | <en> shape style. Pass false to remove the shape
51
- * @param container - <zh> 容器 | <en> container
52
- * @param hooks - <zh> 钩子函数 | <en> hooks
53
- * @returns <zh> 图形实例 | <en> shape instance
61
+ * <en/> create, update or remove shape
62
+ * @param className - <zh/> 图形名称 | <en/> shape name
63
+ * @param Ctor - <zh/> 图形类型 | <en/> shape type
64
+ * @param style - <zh/> 图形样式。若要删除图形,传入 false | <en/> shape style. Pass false to remove the shape
65
+ * @param container - <zh/> 容器 | <en/> container
66
+ * @param hooks - <zh/> 钩子函数 | <en/> hooks
67
+ * @returns <zh/> 图形实例 | <en/> shape instance
54
68
  */
55
69
  protected upsert<T extends DisplayObject>(
56
70
  className: string,
@@ -125,9 +139,9 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
125
139
  }
126
140
 
127
141
  /**
128
- * <zh> 在初始化时会被自动调用
142
+ * <zh/> 在初始化时会被自动调用
129
143
  *
130
- * <en> will be called automatically when initializing
144
+ * <en/> will be called automatically when initializing
131
145
  * @param attributes
132
146
  * @param container
133
147
  */
@@ -155,6 +169,7 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
155
169
  /**
156
170
  * Get the prefix pairs for composite shapes used to handle animation
157
171
  * @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
172
+ * @internal
158
173
  */
159
174
  protected get compositeShapes(): [string, string][] {
160
175
  return [
@@ -43,9 +43,9 @@ export abstract class Polygon<T extends PolygonStyleProps = PolygonStyleProps> e
43
43
 
44
44
  protected abstract getPoints(attributes: Required<T>): Point[];
45
45
 
46
- public getIntersectPoint(point: Point): Point {
46
+ public getIntersectPoint(point: Point, useExtendedLine = false): Point {
47
47
  const { points } = this.getShape<GPolygon>('key').attributes;
48
48
  const center: Point = [+(this.attributes?.x || 0), +(this.attributes?.y || 0)];
49
- return getPolygonIntersectPoint(point, center, points!).point;
49
+ return getPolygonIntersectPoint(point, center, points!, true, useExtendedLine).point;
50
50
  }
51
51
  }
package/src/exports.ts CHANGED
@@ -27,7 +27,17 @@ export {
27
27
  NodeEvent,
28
28
  } from './constants';
29
29
  export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
30
- export { BaseEdge, Cubic, CubicHorizontal, CubicVertical, Line, Polyline, Quadratic } from './elements/edges';
30
+ export {
31
+ BaseEdge,
32
+ Cubic,
33
+ CubicHorizontal,
34
+ CubicRadial,
35
+ CubicVertical,
36
+ Line,
37
+ Polyline,
38
+ Quadratic,
39
+ } from './elements/edges';
40
+ export { effect } from './elements/effect';
31
41
  export {
32
42
  BaseNode,
33
43
  Circle,
@@ -47,22 +57,23 @@ export {
47
57
  BaseLayout,
48
58
  CircularLayout,
49
59
  ComboCombinedLayout,
60
+ compactBox as CompactBoxLayout,
50
61
  ConcentricLayout,
51
62
  D3ForceLayout,
52
63
  DagreLayout,
64
+ dendrogram as DendrogramLayout,
53
65
  ForceAtlas2Layout,
54
66
  ForceLayout,
55
67
  FruchtermanLayout,
56
68
  GridLayout,
69
+ indented as IndentedLayout,
57
70
  MDSLayout,
71
+ mindmap as MindmapLayout,
58
72
  RadialLayout,
59
73
  RandomLayout,
60
- compactBox,
61
- dendrogram,
62
- indented,
63
- mindmap,
64
74
  } from './layouts';
65
75
  export {
76
+ Background,
66
77
  BasePlugin,
67
78
  BubbleSets,
68
79
  CameraSetting,
@@ -84,10 +95,11 @@ export {
84
95
  export { getExtension, getExtensions } from './registry/get';
85
96
  export { register } from './registry/register';
86
97
  export { Graph } from './runtime/graph';
87
- export { BaseTransform } from './transforms';
98
+ export { BaseTransform, PositionRadialLabels, ProcessParallelEdges } from './transforms';
88
99
  export { isCollapsed } from './utils/collapsibility';
89
100
  export { idOf } from './utils/id';
90
101
  export { invokeLayoutMethod } from './utils/layout';
102
+ export { positionOf } from './utils/position';
91
103
  export { omitStyleProps, subStyleProps } from './utils/prefix';
92
104
  export { Shortcut } from './utils/shortcut';
93
105
  export { parseSize } from './utils/size';
@@ -135,6 +147,7 @@ export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps }
135
147
  export type {
136
148
  BaseEdgeStyleProps,
137
149
  CubicHorizontalStyleProps,
150
+ CubicRadialStyleProps,
138
151
  CubicStyleProps,
139
152
  CubicVerticalStyleProps,
140
153
  LineStyleProps,
@@ -166,6 +179,7 @@ export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shape
166
179
  export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
167
180
  export type { CategoricalPalette } from './palettes/types';
168
181
  export type {
182
+ BackgroundOptions,
169
183
  BasePluginOptions,
170
184
  BubbleSetsOptions,
171
185
  CameraSettingOptions,
@@ -205,7 +219,7 @@ export type { CustomBehaviorOption } from './spec/behavior';
205
219
  export type { AnimationStage } from './spec/element/animation';
206
220
  export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
207
221
  export type { CustomPluginOption } from './spec/plugin';
208
- export type { BaseTransformOptions } from './transforms';
222
+ export type { BaseTransformOptions, PositionRadialLabelsOptions, ProcessParallelEdgesOptions } from './transforms';
209
223
  export type { DrawData } from './transforms/types';
210
224
  export type {
211
225
  BaseElementStyleProps,
@@ -2,6 +2,11 @@ import type { RuntimeContext } from '../runtime/types';
2
2
  import type { GraphData } from '../spec';
3
3
  import type { BaseLayoutOptions } from './types';
4
4
 
5
+ /**
6
+ * <zh/> 布局的基类
7
+ *
8
+ * <en/> Base class for layout
9
+ */
5
10
  export abstract class BaseLayout<O extends BaseLayoutOptions = any> {
6
11
  public abstract id: string;
7
12
 
@@ -55,6 +55,7 @@ export class Background extends BasePlugin<BackgroundOptions> {
55
55
  * <zh/> 销毁背景图
56
56
  *
57
57
  * <en/> Destroy the background image
58
+ * @internal
58
59
  */
59
60
  public destroy(): void {
60
61
  super.destroy();
@@ -3,4 +3,9 @@ import type { CustomPluginOption } from '../spec/plugin';
3
3
 
4
4
  export interface BasePluginOptions extends CustomPluginOption {}
5
5
 
6
+ /**
7
+ * <zh/> 插件的基类
8
+ *
9
+ * <en/> Base class for plugins
10
+ */
6
11
  export abstract class BasePlugin<T extends BasePluginOptions> extends BaseExtension<T> {}
@@ -289,6 +289,7 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
289
289
  * <zh/> 销毁
290
290
  *
291
291
  * <en/> Destroy
292
+ * @internal
292
293
  */
293
294
  public destroy(): void {
294
295
  this.context.graph.off(GraphEvent.AFTER_RENDER, this.drawBubbleSets);
@@ -171,6 +171,7 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
171
171
  * <zh/> 销毁上下文菜单
172
172
  *
173
173
  * <en/> Destroy the contextmenu
174
+ * @internal
174
175
  */
175
176
  public destroy(): void {
176
177
  this.unbindEvents();
@@ -156,6 +156,7 @@ export class GridLine extends BasePlugin<GridLineOptions> {
156
156
  * <zh/> 销毁网格线
157
157
  *
158
158
  * <en/> Destroy the grid line
159
+ * @internal
159
160
  */
160
161
  public destroy(): void {
161
162
  this.context.graph.off(GraphEvent.AFTER_TRANSFORM, this.onTransform);
@@ -239,6 +239,7 @@ export class History extends BasePlugin<HistoryOptions> {
239
239
  * <zh/> 销毁
240
240
  *
241
241
  * <en/> Destroy
242
+ * @internal
242
243
  */
243
244
  public destroy(): void {
244
245
  const { graph } = this.context;
@@ -204,6 +204,7 @@ export class Hull extends BasePlugin<HullOptions> {
204
204
  * <zh/> 销毁 Hull
205
205
  *
206
206
  * <en/> Destroy Hull
207
+ * @internal
207
208
  */
208
209
  public destroy(): void {
209
210
  this.context.graph.off(GraphEvent.AFTER_DRAW, this.drawHull);
@@ -396,6 +396,7 @@ export class Legend extends BasePlugin<LegendOptions> {
396
396
  * <zh/>销毁图例
397
397
  *
398
398
  * <en/> Destroy the legend
399
+ * @internal
399
400
  */
400
401
  public destroy(): void {
401
402
  this.clear();
@@ -13,15 +13,16 @@ import type { BasePluginOptions } from '../base-plugin';
13
13
  import { BasePlugin } from '../base-plugin';
14
14
 
15
15
  /**
16
- * <zh/> 缩略图插件的配置项
16
+ * <zh/> 缩略图插件配置项
17
17
  *
18
- * <en/> The configuration item of the Minimap plugin
18
+ * <en/> Minimap plugin options
19
19
  */
20
20
  export interface MinimapOptions extends BasePluginOptions {
21
21
  /**
22
22
  * <zh/> 宽度和高度
23
23
  *
24
24
  * <en/> Width and height
25
+ * @defaultValue [240, 160]
25
26
  */
26
27
  size?: [number, number];
27
28
  /**
@@ -94,6 +95,11 @@ export interface MinimapOptions extends BasePluginOptions {
94
95
  renderer?: IRenderer;
95
96
  }
96
97
 
98
+ /**
99
+ * <zh/> 缩略图插件
100
+ *
101
+ * <en/> Minimap plugin
102
+ */
97
103
  export class Minimap extends BasePlugin<MinimapOptions> {
98
104
  static defaultOptions: Partial<MinimapOptions> = {
99
105
  size: [240, 160],
@@ -8,6 +8,11 @@ import { divide } from '../../utils/vector';
8
8
  import type { BasePluginOptions } from '../base-plugin';
9
9
  import { BasePlugin } from '../base-plugin';
10
10
 
11
+ /**
12
+ * <zh/> 对齐线插件配置项
13
+ *
14
+ * <en/> Snapline plugin options
15
+ */
11
16
  export interface SnaplineOptions extends BasePluginOptions {
12
17
  /**
13
18
  * <zh/> 对齐精度,即移动节点时与目标位置的距离小于 tolerance 时触发显示对齐线
@@ -79,6 +84,11 @@ type Metadata = {
79
84
  horizontalMaxX: number | null;
80
85
  };
81
86
 
87
+ /**
88
+ * <zh/> 对齐线插件
89
+ *
90
+ * <en/> Snapline plugin
91
+ */
82
92
  export class Snapline extends BasePlugin<SnaplineOptions> {
83
93
  static defaultOptions: Partial<SnaplineOptions> = {
84
94
  tolerance: 5,
@@ -430,6 +430,7 @@ export class Timebar extends BasePlugin<TimebarOptions> {
430
430
  * <zh/> 销毁时间条
431
431
  *
432
432
  * <en/> Destroy the timebar
433
+ * @internal
433
434
  */
434
435
  public destroy(): void {
435
436
  const { graph } = this.context;
@@ -97,6 +97,7 @@ export class Toolbar extends BasePlugin<ToolbarOptions> {
97
97
  * <zh/> 销毁工具栏
98
98
  *
99
99
  * <en/> Destroy the toolbar
100
+ * @internal
100
101
  */
101
102
  public destroy(): void {
102
103
  this.$element.removeEventListener('click', this.onToolbarItemClick);
@@ -7,6 +7,11 @@ import { isToBeDestroyed } from '../utils/element';
7
7
  import type { BasePluginOptions } from './base-plugin';
8
8
  import { BasePlugin } from './base-plugin';
9
9
 
10
+ /**
11
+ * <zh/> 提示框插件配置项
12
+ *
13
+ * <en/> Tooltip plugin options
14
+ */
10
15
  export interface TooltipOptions
11
16
  extends BasePluginOptions,
12
17
  Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container' | 'title'> {
@@ -36,6 +41,11 @@ export interface TooltipOptions
36
41
  enable?: boolean | ((event: IElementEvent) => boolean);
37
42
  }
38
43
 
44
+ /**
45
+ * <zh/> 提示框插件
46
+ *
47
+ * <en/> Tooltip plugin
48
+ */
39
49
  export class Tooltip extends BasePlugin<TooltipOptions> {
40
50
  static defaultOptions: Partial<TooltipOptions> = {
41
51
  trigger: 'hover',
@@ -151,8 +161,8 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
151
161
  } = event;
152
162
  // click the same item twice, tooltip will be hidden
153
163
  if (this.currentTarget === id) {
154
- this.currentTarget = null;
155
164
  this.hide(event);
165
+ this.currentTarget = null;
156
166
  } else {
157
167
  this.currentTarget = id;
158
168
  this.show(event);
@@ -294,7 +304,9 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
294
304
  this.tooltipElement?.hide();
295
305
  return;
296
306
  }
297
- if (!this.tooltipElement || !this.isEnable(event)) return;
307
+ if (!this.tooltipElement) return;
308
+ // No target node: tooltip has been hidden. No need for duplicated call.
309
+ if (!this.currentTarget) return;
298
310
  const {
299
311
  client: { x, y },
300
312
  } = event;
@@ -336,6 +348,7 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
336
348
  * <zh/> 销毁tooltip
337
349
  *
338
350
  * <en/> Destroy tooltip
351
+ * @internal
339
352
  */
340
353
  public destroy(): void {
341
354
  this.unbindEvents();
@@ -230,6 +230,7 @@ export class Watermark extends BasePlugin<WatermarkOptions> {
230
230
  * <zh/> 销毁水印
231
231
  *
232
232
  * <en/> Destroy the watermark
233
+ * @internal
233
234
  */
234
235
  public destroy(): void {
235
236
  super.destroy();
@@ -32,6 +32,7 @@ import {
32
32
  CircleCombo,
33
33
  Cubic,
34
34
  CubicHorizontal,
35
+ CubicRadial,
35
36
  CubicVertical,
36
37
  Diamond,
37
38
  Donut,
@@ -92,6 +93,7 @@ import {
92
93
  CollapseExpandCombo,
93
94
  CollapseExpandNode,
94
95
  GetEdgeActualEnds,
96
+ PositionRadialLabels,
95
97
  ProcessParallelEdges,
96
98
  UpdateRelatedEdge,
97
99
  } from '../transforms';
@@ -138,6 +140,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
138
140
  polyline: Polyline,
139
141
  quadratic: Quadratic,
140
142
  'cubic-horizontal': CubicHorizontal,
143
+ 'cubic-radial': CubicRadial,
141
144
  'cubic-vertical': CubicVertical,
142
145
  },
143
146
  layout: {
@@ -207,6 +210,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
207
210
  'collapse-expand-node': CollapseExpandNode,
208
211
  'process-parallel-edges': ProcessParallelEdges,
209
212
  'get-edge-actual-ends': GetEdgeActualEnds,
213
+ 'position-radial-labels': PositionRadialLabels,
210
214
  },
211
215
  shape: {
212
216
  circle: GCircle,
@@ -79,12 +79,14 @@ export class Animation {
79
79
  * @param options - <zh/> 扩展选项 | <en/> Extend options
80
80
  * @returns <zh/> 始态样式与终态样式 | <en/> Initial style and final style
81
81
  */
82
- public inferStyle(context: AnimationContext, options?: ExtendOptions) {
82
+ public inferStyle(
83
+ context: AnimationContext,
84
+ options?: ExtendOptions,
85
+ ): [Record<string, unknown>, Record<string, unknown>] {
83
86
  const { element, elementType, stage, originalStyle, modifiedStyle } = context;
84
87
 
85
- const fromStyle = { ...originalStyle };
86
- const toStyle = { ...modifiedStyle };
87
- const getCacheOpacity = () => getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity');
88
+ const fromStyle: Record<string, unknown> = {};
89
+ const toStyle: Record<string, unknown> = {};
88
90
 
89
91
  if (stage === 'enter') {
90
92
  Object.assign(fromStyle, { opacity: 0 });
@@ -92,9 +94,9 @@ export class Animation {
92
94
  Object.assign(toStyle, { opacity: 0 });
93
95
  } else if (stage === 'show') {
94
96
  Object.assign(fromStyle, { opacity: 0 });
95
- Object.assign(toStyle, { opacity: getCacheOpacity() });
97
+ Object.assign(toStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
96
98
  } else if (stage === 'hide') {
97
- Object.assign(fromStyle, { opacity: getCacheOpacity() });
99
+ Object.assign(fromStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
98
100
  Object.assign(toStyle, { opacity: 0 });
99
101
  } else if (stage === 'collapse') {
100
102
  const { collapse } = options || {};
@@ -109,10 +111,10 @@ export class Animation {
109
111
  } else if (elementType === 'combo') {
110
112
  if (element.id === target || descendants.includes(element.id)) {
111
113
  const [x, y] = position;
112
- Object.assign(toStyle, { x, y, childrenNode: fromStyle.childrenNode });
114
+ Object.assign(toStyle, { x, y, childrenNode: originalStyle.childrenNode });
113
115
  }
114
116
  } else if (elementType === 'edge') {
115
- Object.assign(toStyle, { sourceNode: fromStyle.sourceNode, targetNode: fromStyle.targetNode });
117
+ Object.assign(toStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
116
118
  }
117
119
  } else if (stage === 'expand') {
118
120
  const { expand } = options || {};
@@ -129,16 +131,19 @@ export class Animation {
129
131
  // Set the child elements of the expanded combo
130
132
  if (element.id === target || descendants.includes(element.id)) {
131
133
  const [x, y, z] = position;
132
- Object.assign(fromStyle, { x, y, z, childrenNode: toStyle.childrenNode });
134
+ Object.assign(fromStyle, { x, y, z, childrenNode: modifiedStyle.childrenNode });
133
135
  }
134
136
  } else if (elementType === 'edge') {
135
137
  // 设置展开后的边的起点和终点
136
138
  // Set the starting point and end point of the edge after expansion
137
- Object.assign(fromStyle, { sourceNode: toStyle.sourceNode, targetNode: toStyle.targetNode });
139
+ Object.assign(fromStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
138
140
  }
139
141
  }
140
142
 
141
- return [fromStyle, toStyle] as [Record<string, unknown>, Record<string, unknown>];
143
+ return [
144
+ Object.keys(fromStyle).length > 0 ? Object.assign({}, originalStyle, fromStyle) : originalStyle,
145
+ Object.keys(toStyle).length > 0 ? Object.assign({}, modifiedStyle, toStyle) : modifiedStyle,
146
+ ];
142
147
  }
143
148
 
144
149
  public stop() {
@@ -1,5 +1,5 @@
1
1
  import { Graph as GraphLib } from '@antv/graphlib';
2
- import { isEqual, isUndefined, uniq } from '@antv/util';
2
+ import { isUndefined, uniq } from '@antv/util';
3
3
  import { COMBO_KEY, ChangeType, TREE_KEY } from '../constants';
4
4
  import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
5
5
  import type {
@@ -20,7 +20,7 @@ import type {
20
20
  } from '../types';
21
21
  import type { EdgeDirection } from '../types/edge';
22
22
  import type { ElementType } from '../types/element';
23
- import { cloneElementData, mergeElementsData } from '../utils/data';
23
+ import { cloneElementData, isElementDataEqual, mergeElementsData } from '../utils/data';
24
24
  import { arrayDiff } from '../utils/diff';
25
25
  import { toG6Data, toGraphlibData } from '../utils/graphlib';
26
26
  import { idOf, parentIdOf } from '../utils/id';
@@ -166,6 +166,10 @@ export class DataController {
166
166
  }, [] as ComboData[]);
167
167
  }
168
168
 
169
+ public getRootsData(hierarchyKey: HierarchyKey = TREE_KEY) {
170
+ return this.model.getRoots(hierarchyKey).map(toG6Data);
171
+ }
172
+
169
173
  public getAncestorsData(id: ID, hierarchyKey: HierarchyKey): NodeLikeData[] {
170
174
  const { model } = this;
171
175
  if (!model.hasNode(id) || !model.hasTreeStructure(hierarchyKey)) return [];
@@ -292,9 +296,9 @@ export class DataController {
292
296
  const { nodes: modifiedNodes = [], edges: modifiedEdges = [], combos: modifiedCombos = [] } = data;
293
297
  const { nodes: originalNodes, edges: originalEdges, combos: originalCombos } = this.getData();
294
298
 
295
- const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node));
296
- const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge));
297
- const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo));
299
+ const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node), isElementDataEqual);
300
+ const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge), isElementDataEqual);
301
+ const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo), isElementDataEqual);
298
302
 
299
303
  this.batch(() => {
300
304
  this.addData({
@@ -381,13 +385,16 @@ export class DataController {
381
385
 
382
386
  data.forEach((datum) => {
383
387
  const id = idOf(datum);
388
+ const parent = parentIdOf(datum);
384
389
 
385
- model.attachTreeStructure(COMBO_KEY);
386
- this.setParent(id, parentIdOf(datum), COMBO_KEY);
390
+ if (parent) {
391
+ if (!model.hasTreeStructure(COMBO_KEY)) model.attachTreeStructure(COMBO_KEY);
392
+ this.setParent(id, parentIdOf(datum), COMBO_KEY);
393
+ }
387
394
 
388
- const children = (datum as NodeData).children;
389
- if (children !== undefined) {
390
- model.attachTreeStructure(TREE_KEY);
395
+ const children = (datum as NodeData).children || [];
396
+ if (children.length) {
397
+ if (!model.hasTreeStructure(TREE_KEY)) model.attachTreeStructure(TREE_KEY);
391
398
  const _children = children.filter((child) => model.hasNode(child));
392
399
  _children.forEach((child) => this.setParent(child, id, TREE_KEY));
393
400
  if (_children.length !== children.length) {
@@ -430,7 +437,7 @@ export class DataController {
430
437
  nodes.forEach((modifiedNode) => {
431
438
  const id = idOf(modifiedNode);
432
439
  const originalNode = toG6Data(model.getNode(id));
433
- if (isEqual(originalNode, modifiedNode)) return;
440
+ if (isElementDataEqual(originalNode, modifiedNode)) return;
434
441
 
435
442
  const value = mergeElementsData(originalNode, modifiedNode);
436
443
  this.pushChange({ value, original: originalNode, type: ChangeType.NodeUpdated });
@@ -476,7 +483,7 @@ export class DataController {
476
483
  edges.forEach((modifiedEdge) => {
477
484
  const id = idOf(modifiedEdge);
478
485
  const originalEdge = toG6Data(model.getEdge(id));
479
- if (isEqual(originalEdge, modifiedEdge)) return;
486
+ if (isElementDataEqual(originalEdge, modifiedEdge)) return;
480
487
 
481
488
  if (modifiedEdge.source && originalEdge.source !== modifiedEdge.source) {
482
489
  model.updateEdgeSource(id, modifiedEdge.source);
@@ -499,7 +506,7 @@ export class DataController {
499
506
  combos.forEach((modifiedCombo) => {
500
507
  const id = idOf(modifiedCombo);
501
508
  const originalCombo = toG6Data(model.getNode(id)) as ComboData;
502
- if (isEqual(originalCombo, modifiedCombo)) return;
509
+ if (isElementDataEqual(originalCombo, modifiedCombo)) return;
503
510
 
504
511
  const value = mergeElementsData(originalCombo, modifiedCombo);
505
512
  this.pushChange({ value, original: originalCombo, type: ChangeType.ComboUpdated });