@antv/g6 5.0.0-beta.27 → 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 (464) hide show
  1. package/LICENSE +21 -0
  2. package/dist/g6.min.js +2 -2
  3. package/esm/constant/shape.d.ts +1 -1
  4. package/esm/index.d.ts +4 -2
  5. package/esm/index.js +1 -1
  6. package/esm/index.js.map +1 -1
  7. package/esm/item/combo.js +3 -1
  8. package/esm/item/combo.js.map +1 -1
  9. package/esm/item/edge.js +7 -2
  10. package/esm/item/edge.js.map +1 -1
  11. package/esm/item/item.d.ts +2 -2
  12. package/esm/item/item.js +13 -6
  13. package/esm/item/item.js.map +1 -1
  14. package/esm/item/node.d.ts +1 -0
  15. package/esm/item/node.js +12 -2
  16. package/esm/item/node.js.map +1 -1
  17. package/esm/runtime/controller/data.js +15 -10
  18. package/esm/runtime/controller/data.js.map +1 -1
  19. package/esm/runtime/controller/interaction.js +4 -3
  20. package/esm/runtime/controller/interaction.js.map +1 -1
  21. package/esm/runtime/controller/item.d.ts +3 -2
  22. package/esm/runtime/controller/item.js +45 -22
  23. package/esm/runtime/controller/item.js.map +1 -1
  24. package/esm/runtime/controller/layout.js +7 -10
  25. package/esm/runtime/controller/layout.js.map +1 -1
  26. package/esm/runtime/controller/plugin.js +1 -1
  27. package/esm/runtime/controller/plugin.js.map +1 -1
  28. package/esm/runtime/graph.d.ts +19 -6
  29. package/esm/runtime/graph.js +62 -27
  30. package/esm/runtime/graph.js.map +1 -1
  31. package/esm/runtime/hooks.d.ts +2 -2
  32. package/esm/runtime/hooks.js +2 -2
  33. package/esm/stdlib/behavior/create-edge.d.ts +1 -1
  34. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
  35. package/esm/stdlib/behavior/drag-node.d.ts +1 -1
  36. package/esm/stdlib/behavior/drag-node.js +1 -1
  37. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  38. package/esm/stdlib/behavior/hover-activate.d.ts +1 -1
  39. package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
  40. package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
  41. package/esm/stdlib/behavior/scroll-canvas.js +5 -5
  42. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
  43. package/esm/stdlib/behavior/track-canvas-3d.d.ts +1 -1
  44. package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
  45. package/esm/stdlib/behavior/zoom-canvas.d.ts +16 -0
  46. package/esm/stdlib/behavior/zoom-canvas.js +107 -5
  47. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  48. package/esm/stdlib/data/transformV4Data.js +12 -6
  49. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  50. package/esm/stdlib/index.d.ts +6 -4
  51. package/esm/stdlib/index.js +8 -6
  52. package/esm/stdlib/index.js.map +1 -1
  53. package/esm/stdlib/item/combo/circle.js +12 -7
  54. package/esm/stdlib/item/combo/circle.js.map +1 -1
  55. package/esm/stdlib/item/combo/rect.js +12 -7
  56. package/esm/stdlib/item/combo/rect.js.map +1 -1
  57. package/esm/stdlib/item/edge/base.d.ts +22 -5
  58. package/esm/stdlib/item/edge/base.js +48 -16
  59. package/esm/stdlib/item/edge/base.js.map +1 -1
  60. package/esm/stdlib/item/edge/cubic.js +11 -6
  61. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  62. package/esm/stdlib/item/edge/line.js +12 -7
  63. package/esm/stdlib/item/edge/line.js.map +1 -1
  64. package/esm/stdlib/item/edge/loop.js +6 -1
  65. package/esm/stdlib/item/edge/loop.js.map +1 -1
  66. package/esm/stdlib/item/edge/polyline.js +11 -6
  67. package/esm/stdlib/item/edge/polyline.js.map +1 -1
  68. package/esm/stdlib/item/edge/quadratic.js +11 -6
  69. package/esm/stdlib/item/edge/quadratic.js.map +1 -1
  70. package/esm/stdlib/item/node/base.d.ts +24 -13
  71. package/esm/stdlib/item/node/base.js +90 -48
  72. package/esm/stdlib/item/node/base.js.map +1 -1
  73. package/esm/stdlib/item/node/base3d.d.ts +11 -2
  74. package/esm/stdlib/item/node/base3d.js +14 -3
  75. package/esm/stdlib/item/node/base3d.js.map +1 -1
  76. package/esm/stdlib/item/node/circle.js +13 -7
  77. package/esm/stdlib/item/node/circle.js.map +1 -1
  78. package/esm/stdlib/item/node/cube.d.ts +0 -2
  79. package/esm/stdlib/item/node/cube.js +12 -9
  80. package/esm/stdlib/item/node/cube.js.map +1 -1
  81. package/esm/stdlib/item/node/diamond.js +20 -11
  82. package/esm/stdlib/item/node/diamond.js.map +1 -1
  83. package/esm/stdlib/item/node/donut.js +18 -8
  84. package/esm/stdlib/item/node/donut.js.map +1 -1
  85. package/esm/stdlib/item/node/ellipse.js +11 -6
  86. package/esm/stdlib/item/node/ellipse.js.map +1 -1
  87. package/esm/stdlib/item/node/hexagon.js +12 -7
  88. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  89. package/esm/stdlib/item/node/image.js +13 -3
  90. package/esm/stdlib/item/node/image.js.map +1 -1
  91. package/esm/stdlib/item/node/index.d.ts +1 -0
  92. package/esm/stdlib/item/node/index.js +1 -0
  93. package/esm/stdlib/item/node/index.js.map +1 -1
  94. package/esm/stdlib/item/node/modelRect.d.ts +33 -1
  95. package/esm/stdlib/item/node/modelRect.js +135 -78
  96. package/esm/stdlib/item/node/modelRect.js.map +1 -1
  97. package/esm/stdlib/item/node/plane.d.ts +38 -0
  98. package/esm/stdlib/item/node/plane.js +62 -0
  99. package/esm/stdlib/item/node/plane.js.map +1 -0
  100. package/esm/stdlib/item/node/rect.js +12 -7
  101. package/esm/stdlib/item/node/rect.js.map +1 -1
  102. package/esm/stdlib/item/node/sphere.js +12 -7
  103. package/esm/stdlib/item/node/sphere.js.map +1 -1
  104. package/esm/stdlib/item/node/star.d.ts +1 -3
  105. package/esm/stdlib/item/node/star.js +16 -10
  106. package/esm/stdlib/item/node/star.js.map +1 -1
  107. package/esm/stdlib/item/node/triangle.js +17 -7
  108. package/esm/stdlib/item/node/triangle.js.map +1 -1
  109. package/esm/stdlib/plugin/edgeBundling/index.d.ts +75 -0
  110. package/esm/stdlib/plugin/edgeBundling/index.js +364 -0
  111. package/esm/stdlib/plugin/edgeBundling/index.js.map +1 -0
  112. package/esm/stdlib/plugin/hull/bubbleset.d.ts +1 -1
  113. package/esm/stdlib/plugin/hull/bubbleset.js +13 -13
  114. package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -1
  115. package/esm/stdlib/plugin/hull/index.js +4 -4
  116. package/esm/stdlib/plugin/hull/util.js +1 -1
  117. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  118. package/esm/stdlib/plugin/index.d.ts +1 -0
  119. package/esm/stdlib/plugin/index.js +1 -0
  120. package/esm/stdlib/plugin/index.js.map +1 -1
  121. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  122. package/esm/stdlib/plugin/legend/index.js +10 -10
  123. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  124. package/esm/stdlib/plugin/lodController/index.js +10 -8
  125. package/esm/stdlib/plugin/lodController/index.js.map +1 -1
  126. package/esm/stdlib/plugin/menu/index.js +1 -1
  127. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  128. package/esm/stdlib/plugin/snapline/index.d.ts +2 -2
  129. package/esm/stdlib/plugin/snapline/index.js +2 -2
  130. package/esm/stdlib/plugin/snapline/index.js.map +1 -1
  131. package/esm/stdlib/plugin/tooltip/index.d.ts +1 -1
  132. package/esm/stdlib/plugin/tooltip/index.js +3 -3
  133. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  134. package/esm/stdlib/plugin/{watermaker → watermarker}/index.d.ts +1 -1
  135. package/esm/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
  136. package/esm/stdlib/plugin/watermarker/index.js.map +1 -0
  137. package/esm/stdlib/selector/lasso.js +3 -3
  138. package/esm/stdlib/selector/lasso.js.map +1 -1
  139. package/esm/stdlib/theme/dark.js +1 -1
  140. package/esm/stdlib/theme/dark.js.map +1 -1
  141. package/esm/stdlib/theme/light.js +4 -1
  142. package/esm/stdlib/theme/light.js.map +1 -1
  143. package/esm/stdlib/themeSolver/spec.js +3 -3
  144. package/esm/stdlib/themeSolver/subject.d.ts +1 -1
  145. package/esm/stdlib/themeSolver/subject.js +1 -1
  146. package/esm/types/animate.d.ts +1 -1
  147. package/esm/types/data.d.ts +3 -1
  148. package/esm/types/graph.d.ts +54 -11
  149. package/esm/types/hook.d.ts +13 -3
  150. package/esm/types/index.d.ts +2 -1
  151. package/esm/types/index.js +1 -0
  152. package/esm/types/index.js.map +1 -1
  153. package/esm/types/item.d.ts +8 -10
  154. package/esm/types/item.js.map +1 -1
  155. package/esm/types/layout.d.ts +1 -1
  156. package/esm/types/node.d.ts +1 -31
  157. package/esm/types/plugin.d.ts +1 -1
  158. package/esm/types/plugin.js +1 -1
  159. package/esm/types/spec.d.ts +5 -5
  160. package/esm/types/theme.d.ts +1 -1
  161. package/esm/types/view.d.ts +1 -1
  162. package/esm/util/animate.js +1 -1
  163. package/esm/util/animate.js.map +1 -1
  164. package/esm/util/canvas.d.ts +1 -1
  165. package/esm/util/canvas.js +7 -1
  166. package/esm/util/canvas.js.map +1 -1
  167. package/esm/util/data.d.ts +10 -10
  168. package/esm/util/data.js +10 -9
  169. package/esm/util/data.js.map +1 -1
  170. package/esm/util/extend.js +1 -1
  171. package/esm/util/extend.js.map +1 -1
  172. package/esm/util/item.js +1 -1
  173. package/esm/util/item.js.map +1 -1
  174. package/esm/util/math.d.ts +1 -1
  175. package/esm/util/math.js +1 -1
  176. package/esm/util/path.d.ts +1 -1
  177. package/esm/util/path.js +1 -1
  178. package/esm/util/polyline.d.ts +2 -2
  179. package/esm/util/polyline.js +3 -3
  180. package/esm/util/polyline.js.map +1 -1
  181. package/esm/util/router.js +7 -7
  182. package/esm/util/router.js.map +1 -1
  183. package/esm/util/shape.d.ts +25 -13
  184. package/esm/util/shape.js +29 -20
  185. package/esm/util/shape.js.map +1 -1
  186. package/esm/util/shape3d.d.ts +2 -2
  187. package/esm/util/shape3d.js +9 -12
  188. package/esm/util/shape3d.js.map +1 -1
  189. package/lib/constant/shape.d.ts +1 -1
  190. package/lib/index.d.ts +4 -2
  191. package/lib/index.js +1 -1
  192. package/lib/index.js.map +1 -1
  193. package/lib/item/combo.js +3 -1
  194. package/lib/item/combo.js.map +1 -1
  195. package/lib/item/edge.js +7 -2
  196. package/lib/item/edge.js.map +1 -1
  197. package/lib/item/item.d.ts +2 -2
  198. package/lib/item/item.js +13 -6
  199. package/lib/item/item.js.map +1 -1
  200. package/lib/item/node.d.ts +1 -0
  201. package/lib/item/node.js +12 -2
  202. package/lib/item/node.js.map +1 -1
  203. package/lib/runtime/controller/data.js +14 -9
  204. package/lib/runtime/controller/data.js.map +1 -1
  205. package/lib/runtime/controller/interaction.js +3 -2
  206. package/lib/runtime/controller/interaction.js.map +1 -1
  207. package/lib/runtime/controller/item.d.ts +3 -2
  208. package/lib/runtime/controller/item.js +44 -21
  209. package/lib/runtime/controller/item.js.map +1 -1
  210. package/lib/runtime/controller/layout.js +7 -33
  211. package/lib/runtime/controller/layout.js.map +1 -1
  212. package/lib/runtime/controller/plugin.js +1 -1
  213. package/lib/runtime/controller/plugin.js.map +1 -1
  214. package/lib/runtime/graph.d.ts +19 -6
  215. package/lib/runtime/graph.js +62 -27
  216. package/lib/runtime/graph.js.map +1 -1
  217. package/lib/runtime/hooks.d.ts +2 -2
  218. package/lib/runtime/hooks.js +2 -2
  219. package/lib/stdlib/behavior/create-edge.d.ts +1 -1
  220. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
  221. package/lib/stdlib/behavior/drag-node.d.ts +1 -1
  222. package/lib/stdlib/behavior/drag-node.js +1 -1
  223. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  224. package/lib/stdlib/behavior/hover-activate.d.ts +1 -1
  225. package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +1 -1
  226. package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +2 -2
  227. package/lib/stdlib/behavior/scroll-canvas.js +5 -5
  228. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
  229. package/lib/stdlib/behavior/track-canvas-3d.d.ts +1 -1
  230. package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -1
  231. package/lib/stdlib/behavior/zoom-canvas.d.ts +16 -0
  232. package/lib/stdlib/behavior/zoom-canvas.js +106 -4
  233. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  234. package/lib/stdlib/data/transformV4Data.js +12 -6
  235. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  236. package/lib/stdlib/index.d.ts +6 -4
  237. package/lib/stdlib/index.js +10 -8
  238. package/lib/stdlib/index.js.map +1 -1
  239. package/lib/stdlib/item/combo/circle.js +12 -7
  240. package/lib/stdlib/item/combo/circle.js.map +1 -1
  241. package/lib/stdlib/item/combo/rect.js +12 -7
  242. package/lib/stdlib/item/combo/rect.js.map +1 -1
  243. package/lib/stdlib/item/edge/base.d.ts +22 -5
  244. package/lib/stdlib/item/edge/base.js +48 -16
  245. package/lib/stdlib/item/edge/base.js.map +1 -1
  246. package/lib/stdlib/item/edge/cubic.js +11 -6
  247. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  248. package/lib/stdlib/item/edge/line.js +12 -7
  249. package/lib/stdlib/item/edge/line.js.map +1 -1
  250. package/lib/stdlib/item/edge/loop.js +6 -1
  251. package/lib/stdlib/item/edge/loop.js.map +1 -1
  252. package/lib/stdlib/item/edge/polyline.js +11 -6
  253. package/lib/stdlib/item/edge/polyline.js.map +1 -1
  254. package/lib/stdlib/item/edge/quadratic.js +11 -6
  255. package/lib/stdlib/item/edge/quadratic.js.map +1 -1
  256. package/lib/stdlib/item/node/base.d.ts +24 -13
  257. package/lib/stdlib/item/node/base.js +90 -48
  258. package/lib/stdlib/item/node/base.js.map +1 -1
  259. package/lib/stdlib/item/node/base3d.d.ts +11 -2
  260. package/lib/stdlib/item/node/base3d.js +14 -3
  261. package/lib/stdlib/item/node/base3d.js.map +1 -1
  262. package/lib/stdlib/item/node/circle.js +13 -7
  263. package/lib/stdlib/item/node/circle.js.map +1 -1
  264. package/lib/stdlib/item/node/cube.d.ts +0 -2
  265. package/lib/stdlib/item/node/cube.js +12 -9
  266. package/lib/stdlib/item/node/cube.js.map +1 -1
  267. package/lib/stdlib/item/node/diamond.js +20 -11
  268. package/lib/stdlib/item/node/diamond.js.map +1 -1
  269. package/lib/stdlib/item/node/donut.js +18 -8
  270. package/lib/stdlib/item/node/donut.js.map +1 -1
  271. package/lib/stdlib/item/node/ellipse.js +11 -6
  272. package/lib/stdlib/item/node/ellipse.js.map +1 -1
  273. package/lib/stdlib/item/node/hexagon.js +12 -7
  274. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  275. package/lib/stdlib/item/node/image.js +13 -3
  276. package/lib/stdlib/item/node/image.js.map +1 -1
  277. package/lib/stdlib/item/node/index.d.ts +1 -0
  278. package/lib/stdlib/item/node/index.js +1 -0
  279. package/lib/stdlib/item/node/index.js.map +1 -1
  280. package/lib/stdlib/item/node/modelRect.d.ts +33 -1
  281. package/lib/stdlib/item/node/modelRect.js +135 -78
  282. package/lib/stdlib/item/node/modelRect.js.map +1 -1
  283. package/lib/stdlib/item/node/plane.d.ts +38 -0
  284. package/lib/stdlib/item/node/plane.js +66 -0
  285. package/lib/stdlib/item/node/plane.js.map +1 -0
  286. package/lib/stdlib/item/node/rect.js +12 -7
  287. package/lib/stdlib/item/node/rect.js.map +1 -1
  288. package/lib/stdlib/item/node/sphere.js +12 -7
  289. package/lib/stdlib/item/node/sphere.js.map +1 -1
  290. package/lib/stdlib/item/node/star.d.ts +1 -3
  291. package/lib/stdlib/item/node/star.js +16 -10
  292. package/lib/stdlib/item/node/star.js.map +1 -1
  293. package/lib/stdlib/item/node/triangle.js +17 -7
  294. package/lib/stdlib/item/node/triangle.js.map +1 -1
  295. package/lib/stdlib/plugin/edgeBundling/index.d.ts +75 -0
  296. package/lib/stdlib/plugin/edgeBundling/index.js +368 -0
  297. package/lib/stdlib/plugin/edgeBundling/index.js.map +1 -0
  298. package/lib/stdlib/plugin/hull/bubbleset.d.ts +1 -1
  299. package/lib/stdlib/plugin/hull/bubbleset.js +13 -13
  300. package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -1
  301. package/lib/stdlib/plugin/hull/index.js +4 -4
  302. package/lib/stdlib/plugin/hull/util.js +1 -1
  303. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  304. package/lib/stdlib/plugin/index.d.ts +1 -0
  305. package/lib/stdlib/plugin/index.js +1 -0
  306. package/lib/stdlib/plugin/index.js.map +1 -1
  307. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  308. package/lib/stdlib/plugin/legend/index.js +10 -10
  309. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  310. package/lib/stdlib/plugin/lodController/index.js +10 -8
  311. package/lib/stdlib/plugin/lodController/index.js.map +1 -1
  312. package/lib/stdlib/plugin/menu/index.js +1 -1
  313. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  314. package/lib/stdlib/plugin/snapline/index.d.ts +2 -2
  315. package/lib/stdlib/plugin/snapline/index.js +2 -2
  316. package/lib/stdlib/plugin/snapline/index.js.map +1 -1
  317. package/lib/stdlib/plugin/tooltip/index.d.ts +1 -1
  318. package/lib/stdlib/plugin/tooltip/index.js +3 -3
  319. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  320. package/lib/stdlib/plugin/{watermaker → watermarker}/index.d.ts +1 -1
  321. package/lib/stdlib/plugin/{watermaker → watermarker}/index.js +7 -7
  322. package/lib/stdlib/plugin/watermarker/index.js.map +1 -0
  323. package/lib/stdlib/selector/lasso.js +3 -3
  324. package/lib/stdlib/selector/lasso.js.map +1 -1
  325. package/lib/stdlib/theme/dark.js +1 -1
  326. package/lib/stdlib/theme/dark.js.map +1 -1
  327. package/lib/stdlib/theme/light.js +4 -1
  328. package/lib/stdlib/theme/light.js.map +1 -1
  329. package/lib/stdlib/themeSolver/spec.js +3 -3
  330. package/lib/stdlib/themeSolver/subject.d.ts +1 -1
  331. package/lib/stdlib/themeSolver/subject.js +1 -1
  332. package/lib/types/animate.d.ts +1 -1
  333. package/lib/types/data.d.ts +3 -1
  334. package/lib/types/graph.d.ts +54 -11
  335. package/lib/types/hook.d.ts +13 -3
  336. package/lib/types/index.d.ts +2 -1
  337. package/lib/types/index.js +3 -1
  338. package/lib/types/index.js.map +1 -1
  339. package/lib/types/item.d.ts +8 -10
  340. package/lib/types/item.js.map +1 -1
  341. package/lib/types/layout.d.ts +1 -1
  342. package/lib/types/node.d.ts +1 -31
  343. package/lib/types/plugin.d.ts +1 -1
  344. package/lib/types/plugin.js +1 -1
  345. package/lib/types/spec.d.ts +5 -5
  346. package/lib/types/theme.d.ts +1 -1
  347. package/lib/types/view.d.ts +1 -1
  348. package/lib/util/animate.js +1 -1
  349. package/lib/util/animate.js.map +1 -1
  350. package/lib/util/canvas.d.ts +1 -1
  351. package/lib/util/canvas.js +7 -1
  352. package/lib/util/canvas.js.map +1 -1
  353. package/lib/util/data.d.ts +10 -10
  354. package/lib/util/data.js +12 -11
  355. package/lib/util/data.js.map +1 -1
  356. package/lib/util/extend.js +4 -7
  357. package/lib/util/extend.js.map +1 -1
  358. package/lib/util/item.js +1 -1
  359. package/lib/util/item.js.map +1 -1
  360. package/lib/util/math.d.ts +1 -1
  361. package/lib/util/math.js +1 -1
  362. package/lib/util/path.d.ts +1 -1
  363. package/lib/util/path.js +1 -1
  364. package/lib/util/polyline.d.ts +2 -2
  365. package/lib/util/polyline.js +3 -3
  366. package/lib/util/polyline.js.map +1 -1
  367. package/lib/util/router.js +7 -7
  368. package/lib/util/router.js.map +1 -1
  369. package/lib/util/shape.d.ts +25 -13
  370. package/lib/util/shape.js +28 -19
  371. package/lib/util/shape.js.map +1 -1
  372. package/lib/util/shape3d.d.ts +2 -2
  373. package/lib/util/shape3d.js +9 -12
  374. package/lib/util/shape3d.js.map +1 -1
  375. package/package.json +37 -53
  376. package/src/index.ts +1 -1
  377. package/src/item/combo.ts +2 -1
  378. package/src/item/edge.ts +9 -2
  379. package/src/item/item.ts +21 -10
  380. package/src/item/node.ts +22 -6
  381. package/src/runtime/controller/data.ts +16 -14
  382. package/src/runtime/controller/interaction.ts +5 -4
  383. package/src/runtime/controller/item.ts +78 -36
  384. package/src/runtime/controller/layout.ts +7 -9
  385. package/src/runtime/controller/plugin.ts +1 -1
  386. package/src/runtime/graph.ts +128 -71
  387. package/src/runtime/hooks.ts +2 -2
  388. package/src/stdlib/behavior/create-edge.ts +1 -1
  389. package/src/stdlib/behavior/drag-canvas.ts +1 -1
  390. package/src/stdlib/behavior/drag-node.ts +1 -1
  391. package/src/stdlib/behavior/hover-activate.ts +1 -1
  392. package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
  393. package/src/stdlib/behavior/rotate-canvas-3d.ts +2 -2
  394. package/src/stdlib/behavior/scroll-canvas.ts +5 -5
  395. package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
  396. package/src/stdlib/behavior/zoom-canvas-3d.ts +1 -1
  397. package/src/stdlib/behavior/zoom-canvas.ts +134 -13
  398. package/src/stdlib/data/transformV4Data.ts +27 -3
  399. package/src/stdlib/index.ts +8 -4
  400. package/src/stdlib/item/combo/circle.ts +26 -11
  401. package/src/stdlib/item/combo/rect.ts +26 -11
  402. package/src/stdlib/item/edge/base.ts +45 -24
  403. package/src/stdlib/item/edge/cubic.ts +26 -4
  404. package/src/stdlib/item/edge/line.ts +27 -5
  405. package/src/stdlib/item/edge/loop.ts +6 -1
  406. package/src/stdlib/item/edge/polyline.ts +26 -4
  407. package/src/stdlib/item/edge/quadratic.ts +26 -4
  408. package/src/stdlib/item/node/base.ts +74 -48
  409. package/src/stdlib/item/node/base3d.ts +19 -3
  410. package/src/stdlib/item/node/circle.ts +29 -8
  411. package/src/stdlib/item/node/cube.ts +26 -12
  412. package/src/stdlib/item/node/diamond.ts +35 -11
  413. package/src/stdlib/item/node/donut.ts +32 -18
  414. package/src/stdlib/item/node/ellipse.ts +25 -11
  415. package/src/stdlib/item/node/hexagon.ts +27 -7
  416. package/src/stdlib/item/node/image.ts +13 -5
  417. package/src/stdlib/item/node/index.ts +1 -0
  418. package/src/stdlib/item/node/modelRect.ts +230 -136
  419. package/src/stdlib/item/node/plane.ts +121 -0
  420. package/src/stdlib/item/node/rect.ts +27 -7
  421. package/src/stdlib/item/node/sphere.ts +26 -10
  422. package/src/stdlib/item/node/star.ts +32 -11
  423. package/src/stdlib/item/node/triangle.ts +32 -9
  424. package/src/stdlib/plugin/edgeBundling/index.ts +529 -0
  425. package/src/stdlib/plugin/hull/bubbleset.ts +14 -14
  426. package/src/stdlib/plugin/hull/index.ts +4 -4
  427. package/src/stdlib/plugin/hull/util.ts +1 -1
  428. package/src/stdlib/plugin/index.ts +1 -0
  429. package/src/stdlib/plugin/legend/index.ts +11 -12
  430. package/src/stdlib/plugin/lodController/index.ts +9 -8
  431. package/src/stdlib/plugin/menu/index.ts +1 -1
  432. package/src/stdlib/plugin/snapline/index.ts +3 -3
  433. package/src/stdlib/plugin/tooltip/index.ts +4 -4
  434. package/src/stdlib/plugin/{watermaker → watermarker}/index.ts +8 -8
  435. package/src/stdlib/selector/lasso.ts +3 -3
  436. package/src/stdlib/theme/dark.ts +0 -1
  437. package/src/stdlib/theme/light.ts +3 -1
  438. package/src/stdlib/themeSolver/spec.ts +3 -3
  439. package/src/stdlib/themeSolver/subject.ts +1 -1
  440. package/src/types/animate.ts +2 -2
  441. package/src/types/data.ts +5 -1
  442. package/src/types/graph.ts +82 -11
  443. package/src/types/hook.ts +32 -3
  444. package/src/types/index.ts +2 -1
  445. package/src/types/item.ts +15 -16
  446. package/src/types/layout.ts +1 -1
  447. package/src/types/node.ts +1 -31
  448. package/src/types/plugin.ts +1 -1
  449. package/src/types/spec.ts +5 -5
  450. package/src/types/theme.ts +1 -1
  451. package/src/types/view.ts +1 -1
  452. package/src/util/animate.ts +1 -1
  453. package/src/util/canvas.ts +8 -0
  454. package/src/util/data.ts +12 -10
  455. package/src/util/extend.ts +1 -1
  456. package/src/util/item.ts +1 -1
  457. package/src/util/math.ts +1 -1
  458. package/src/util/path.ts +1 -1
  459. package/src/util/polyline.ts +3 -3
  460. package/src/util/router.ts +7 -7
  461. package/src/util/shape.ts +70 -33
  462. package/src/util/shape3d.ts +16 -10
  463. package/esm/stdlib/plugin/watermaker/index.js.map +0 -1
  464. package/lib/stdlib/plugin/watermaker/index.js.map +0 -1
@@ -20,14 +20,20 @@ import {
20
20
  NodeDisplayModel,
21
21
  NodeEncode,
22
22
  NodeModelData,
23
+ NodeShapesEncode,
23
24
  } from '../../types';
24
- import { ComboDisplayModel, ComboEncode } from '../../types/combo';
25
+ import {
26
+ ComboDisplayModel,
27
+ ComboEncode,
28
+ ComboShapesEncode,
29
+ } from '../../types/combo';
25
30
  import { GraphCore } from '../../types/data';
26
31
  import {
27
32
  EdgeDisplayModel,
28
33
  EdgeEncode,
29
34
  EdgeModel,
30
35
  EdgeModelData,
36
+ EdgeShapesEncode,
31
37
  } from '../../types/edge';
32
38
  import Node from '../../item/node';
33
39
  import Edge from '../../item/edge';
@@ -233,6 +239,9 @@ export class ItemController {
233
239
  this.graph.hooks.render.tap(this.onRender.bind(this));
234
240
  this.graph.hooks.itemchange.tap(this.onChange.bind(this));
235
241
  this.graph.hooks.itemstatechange.tap(this.onItemStateChange.bind(this));
242
+ this.graph.hooks.itemstateconfigchange.tap(
243
+ this.onItemStateConfigChange.bind(this),
244
+ );
236
245
  this.graph.hooks.itemvisibilitychange.tap(
237
246
  this.onItemVisibilityChange.bind(this),
238
247
  );
@@ -520,15 +529,21 @@ export class ItemController {
520
529
  const { dataTypeField: nodeDataTypeField } = nodeTheme;
521
530
  const edgeIdsToUpdate: Set<ID> = new Set<ID>();
522
531
  const comboIdsToUpdate: Set<ID> = new Set<ID>();
523
- const updateRelates = (edgeIds?: Set<ID>) => {
524
- const ids = edgeIds
525
- ? [...edgeIds]
526
- : [...comboIdsToUpdate, ...edgeIdsToUpdate];
527
- ids.forEach((nid) => {
532
+ const updateRelates = (param: { edgeIds?: Set<ID>; callback?: any }) => {
533
+ const { edgeIds, callback } = param;
534
+ edgeIds.forEach((nid) => {
535
+ const item = itemMap.get(nid) as Edge | Combo;
536
+ if (item && !item.destroyed) item.forceUpdate();
537
+ });
538
+ callback?.();
539
+ };
540
+ const updateAllRelates = () => {
541
+ [...comboIdsToUpdate, ...edgeIdsToUpdate].forEach((nid) => {
528
542
  const item = itemMap.get(nid) as Edge | Combo;
529
543
  if (item && !item.destroyed) item.forceUpdate();
530
544
  });
531
545
  };
546
+ const debounceUpdateAllRelates = debounce(updateAllRelates, 16, false);
532
547
  const debounceUpdateRelates = debounce(updateRelates, 16, false);
533
548
 
534
549
  Object.values(nodeComboUpdate).forEach((updateObj: any) => {
@@ -557,7 +572,8 @@ export class ItemController {
557
572
  this.expandCombo(graphCore, innerModel as ComboModel);
558
573
  }
559
574
  }
560
- const previousParentId = item.displayModel.data.parentId;
575
+ const previousParentId =
576
+ item.displayModel.data.parentId || previous.parentId;
561
577
  // update the current parent combo tree
562
578
  // if the node has previous parent, related previous parent combo should be updated to
563
579
  if (upsertAncestors) {
@@ -629,7 +645,7 @@ export class ItemController {
629
645
  nodeRelatedIdsToUpdate.add(edge.id);
630
646
  });
631
647
 
632
- item.onframe = () => updateRelates(nodeRelatedIdsToUpdate);
648
+ item.onframe = () => updateRelates({ edgeIds: nodeRelatedIdsToUpdate });
633
649
  let statesCache;
634
650
  if (
635
651
  innerModel.data._isCombo &&
@@ -646,23 +662,19 @@ export class ItemController {
646
662
  onlyMove,
647
663
  animate,
648
664
  // call after updating finished
649
- throttle(
650
- (_, canceled) => {
651
- item.onframe?.(true);
652
- item.onframe = undefined;
653
- if (statesCache) {
654
- statesCache.forEach((state) =>
655
- this.graph.setItemState(id, state, true),
656
- );
657
- }
658
- callback(innerModel, canceled);
659
- },
660
- 500,
661
- {
662
- leading: true,
663
- trailing: true,
664
- },
665
- ),
665
+ (_, canceled) => {
666
+ item.onframe = undefined;
667
+ if (statesCache) {
668
+ statesCache.forEach((state) =>
669
+ this.graph.setItemState(id, state, true),
670
+ );
671
+ }
672
+ // @ts-ignore
673
+ debounceUpdateRelates({
674
+ edgeIds: nodeRelatedIdsToUpdate,
675
+ callback: () => callback(innerModel, canceled),
676
+ });
677
+ },
666
678
  );
667
679
 
668
680
  const parentItem = this.itemMap.get(current.parentId);
@@ -672,7 +684,7 @@ export class ItemController {
672
684
  });
673
685
  }
674
686
  });
675
- debounceUpdateRelates();
687
+ debounceUpdateAllRelates();
676
688
  }
677
689
  // === 6. update edges' data ===
678
690
  if (groupedChanges.EdgeDataUpdated.length) {
@@ -794,6 +806,36 @@ export class ItemController {
794
806
  });
795
807
  }
796
808
 
809
+ private onItemStateConfigChange(param: {
810
+ itemType: ITEM_TYPE;
811
+ stateConfig:
812
+ | {
813
+ [stateName: string]:
814
+ | ((data: NodeModel) => NodeDisplayModel)
815
+ | NodeShapesEncode;
816
+ }
817
+ | {
818
+ [stateName: string]:
819
+ | ((data: EdgeModel) => EdgeDisplayModel)
820
+ | EdgeShapesEncode;
821
+ }
822
+ | {
823
+ [stateName: string]:
824
+ | ((data: ComboModel) => ComboDisplayModel)
825
+ | ComboShapesEncode;
826
+ };
827
+ }) {
828
+ const { itemType, stateConfig } = param;
829
+ const fieldName = `${itemType}StateMapper`;
830
+ this[fieldName] = stateConfig;
831
+ this.graph.getAllNodesData().forEach((node) => {
832
+ const item = this.itemMap.get(node.id);
833
+ if (item) {
834
+ item.stateMapper = stateConfig;
835
+ }
836
+ });
837
+ }
838
+
797
839
  private onItemVisibilityChange(param: {
798
840
  ids: ID[];
799
841
  shapeIds: string[];
@@ -1209,12 +1251,9 @@ export class ItemController {
1209
1251
  }
1210
1252
 
1211
1253
  const idStr = String(id);
1212
- const shape = upsertShape(
1213
- type,
1214
- idStr,
1215
- style,
1216
- Object.fromEntries(transientObjectMap),
1217
- );
1254
+ const shape = upsertShape(type, idStr, style, {
1255
+ shapeMap: Object.fromEntries(transientObjectMap),
1256
+ });
1218
1257
  transientObjectMap.set(idStr, shape);
1219
1258
  shape.style.pointerEvents = capture ? 'auto' : 'none';
1220
1259
  if (shape.parentNode === null) canvas.getRoot().appendChild(shape);
@@ -1248,7 +1287,7 @@ export class ItemController {
1248
1287
 
1249
1288
  /**
1250
1289
  * Create nodes with inner data to canvas.
1251
- * @param models nodes' inner datas
1290
+ * @param models nodes' inner data
1252
1291
  */
1253
1292
  private async renderNodes(
1254
1293
  models: NodeModel[],
@@ -1421,7 +1460,7 @@ export class ItemController {
1421
1460
 
1422
1461
  /**
1423
1462
  * Create edges with inner data to canvas.
1424
- * @param models edges' inner datas
1463
+ * @param models edges' inner data
1425
1464
  */
1426
1465
  private renderEdges(
1427
1466
  models: EdgeModel[],
@@ -1641,7 +1680,8 @@ export class ItemController {
1641
1680
 
1642
1681
  return false;
1643
1682
  }
1644
- return item.isVisible();
1683
+ const transientVisible = this.transientItemMap.get(id);
1684
+ return item.isVisible() || transientVisible?.isVisible();
1645
1685
  }
1646
1686
 
1647
1687
  public sortByComboTree(graphCore: GraphCore) {
@@ -1845,7 +1885,9 @@ export class ItemController {
1845
1885
  undefined,
1846
1886
  !animate,
1847
1887
  (model, canceled) => {
1848
- this.graph.hideItem(model.id, { disableAnimate: canceled });
1888
+ positions.forEach((position) => {
1889
+ this.graph.hideItem(position.id, { disableAnimate: canceled });
1890
+ });
1849
1891
  },
1850
1892
  );
1851
1893
  }
@@ -7,7 +7,7 @@ import {
7
7
  OutNode,
8
8
  Supervisor,
9
9
  } from '@antv/layout';
10
- import registery, { Extensions, stdLib } from '../../stdlib';
10
+ import { Extensions, registry, stdLib } from '../../stdlib';
11
11
  import {
12
12
  IGraph,
13
13
  isImmediatelyInvokedLayoutOptions,
@@ -219,7 +219,7 @@ export class LayoutController {
219
219
  let { workerEnabled = false } = options;
220
220
 
221
221
  // Find built-in layout algorithms.
222
- const layoutCtor = stdLib.layouts[type] || registery.useLib.layouts[type];
222
+ const layoutCtor = stdLib.layouts[type] || registry.useLib.layouts[type];
223
223
  if (!layoutCtor) {
224
224
  throw new Error(`Unknown layout algorithm: ${type}`);
225
225
  }
@@ -302,7 +302,7 @@ export class LayoutController {
302
302
  positions = await layout.execute(layoutGraphCore, {
303
303
  onTick: (positionsOnTick: LayoutMapping) => {
304
304
  // Display the animated process of layout.
305
- this.updateNodesPosition(positionsOnTick);
305
+ this.updateNodesPosition(positionsOnTick, false);
306
306
  this.graph.emit('tick', positionsOnTick);
307
307
  },
308
308
  });
@@ -380,17 +380,15 @@ export class LayoutController {
380
380
  node.data.x = meanCenter.x / meanCenter.count + Math.random();
381
381
  node.data.y = meanCenter.y / meanCenter.count + Math.random();
382
382
  node.data.z = meanCenter.z / meanCenter.count + Math.random();
383
- } else {
384
- node.data.x = center[0] + Math.random();
385
- node.data.y = center[1] + Math.random();
386
- node.data.z = Math.random();
383
+ initNaNPositions.nodes.push(node);
387
384
  }
388
- initNaNPositions.nodes.push(node);
389
385
  } else {
390
386
  nodeWithPostions.set(node.id, 1);
391
387
  }
392
388
  });
393
- this.updateNodesPosition(initNaNPositions, false, false);
389
+ if (initNaNPositions.nodes.length) {
390
+ this.updateNodesPosition(initNaNPositions, false, false);
391
+ }
394
392
  return nodeWithPostions;
395
393
  };
396
394
 
@@ -141,7 +141,7 @@ export class PluginController {
141
141
  return config.required;
142
142
  }
143
143
  const Plugin = getExtension(config, registry.useLib, 'plugin');
144
- return Plugin.required;
144
+ return Plugin?.required;
145
145
  }
146
146
 
147
147
  private onPluginChange(params: {
@@ -33,10 +33,19 @@ import type {
33
33
  } from '../types';
34
34
  import type { CameraAnimationOptions } from '../types/animate';
35
35
  import type { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
36
- import type { ComboDisplayModel, ComboModel } from '../types/combo';
36
+ import type {
37
+ ComboDisplayModel,
38
+ ComboModel,
39
+ ComboShapesEncode,
40
+ } from '../types/combo';
37
41
  import type { Bounds, Padding, Point } from '../types/common';
38
42
  import type { DataChangeType, DataConfig, GraphCore } from '../types/data';
39
- import type { EdgeDisplayModel, EdgeModel, EdgeModelData } from '../types/edge';
43
+ import type {
44
+ EdgeDisplayModel,
45
+ EdgeModel,
46
+ EdgeModelData,
47
+ EdgeShapesEncode,
48
+ } from '../types/edge';
40
49
  import type { StackType } from '../types/history';
41
50
  import type { Hooks, ViewportChangeHookParams } from '../types/hook';
42
51
  import type { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from '../types/item';
@@ -45,7 +54,12 @@ import type {
45
54
  LayoutOptions,
46
55
  StandardLayoutOptions,
47
56
  } from '../types/layout';
48
- import type { NodeDisplayModel, NodeModel, NodeModelData } from '../types/node';
57
+ import type {
58
+ NodeDisplayModel,
59
+ NodeModel,
60
+ NodeModelData,
61
+ NodeShapesEncode,
62
+ } from '../types/node';
49
63
  import { Plugin as PluginBase } from '../types/plugin';
50
64
  import type { RendererName } from '../types/render';
51
65
  import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
@@ -85,7 +99,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
85
99
  // the container dom for the graph canvas
86
100
  public container: HTMLElement;
87
101
  // the tag to indicate whether the graph instance is destroyed
88
- public destroyed: boolean;
102
+ public destroyed: boolean = false;
89
103
  // the renderer type of current graph
90
104
  public rendererType: RendererName;
91
105
  // for transient shapes for interactions, e.g. transient node and related edges while draging, delegates
@@ -158,16 +172,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
158
172
  }
159
173
 
160
174
  private initCanvas() {
161
- const {
162
- renderer,
163
- container,
164
- canvas,
165
- backgroundCanvas,
166
- transientCanvas,
167
- transientLabelCanvas,
168
- width,
169
- height,
170
- } = this.specification;
175
+ const { renderer, container, width, height } = this.specification;
171
176
 
172
177
  let pixelRatio: number;
173
178
  if (renderer && !isString(renderer)) {
@@ -180,14 +185,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
180
185
  this.rendererType = renderer || 'canvas';
181
186
  }
182
187
 
183
- /**
184
- * These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
185
- */
186
- if (canvas) {
187
- this.canvas = canvas;
188
- this.backgroundCanvas = backgroundCanvas;
189
- this.transientCanvas = transientCanvas;
190
- this.transientLabelCanvas = transientLabelCanvas;
188
+ if (container) {
191
189
  this.container = container as HTMLElement;
192
190
  } else {
193
191
  const containerDOM = isString(container)
@@ -201,52 +199,32 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
201
199
  this.destroy();
202
200
  return;
203
201
  }
204
-
205
202
  this.container = containerDOM;
206
- const size = [width, height];
207
- if (size[0] === undefined) {
208
- size[0] = containerDOM.scrollWidth;
209
- }
210
- if (size[1] === undefined) {
211
- size[1] = containerDOM.scrollHeight;
212
- }
213
- this.backgroundCanvas = createCanvas(
214
- this.rendererType,
215
- containerDOM,
216
- size[0],
217
- size[1],
218
- pixelRatio,
219
- );
220
- this.canvas = createCanvas(
221
- this.rendererType,
222
- containerDOM,
223
- size[0],
224
- size[1],
225
- pixelRatio,
226
- );
227
- this.labelCanvas = createCanvas(
228
- 'canvas',
229
- containerDOM,
230
- size[0],
231
- size[1],
232
- pixelRatio,
233
- );
234
- this.transientCanvas = createCanvas(
235
- this.rendererType,
236
- containerDOM,
237
- size[0],
238
- size[1],
239
- pixelRatio,
240
- );
241
- this.transientLabelCanvas = createCanvas(
242
- 'canvas',
243
- containerDOM,
244
- size[0],
245
- size[1],
246
- pixelRatio,
247
- );
248
203
  }
249
204
 
205
+ [
206
+ 'backgroundCanvas',
207
+ 'canvas',
208
+ 'labelCanvas',
209
+ 'transientCanvas',
210
+ 'transientLabelCanvas',
211
+ ].forEach((name) => {
212
+ this[name] =
213
+ this.specification[name] ||
214
+ createCanvas(
215
+ ['labelCanvas', 'transientLabelCanvas'].includes(name)
216
+ ? 'canvas'
217
+ : this.rendererType,
218
+ this.container,
219
+ width ?? this.container.scrollWidth,
220
+ height ?? this.container.scrollHeight,
221
+ pixelRatio,
222
+ undefined,
223
+ // enable dom interaction only for main canvas
224
+ name === 'canvas' ? [] : ['dom-interaction'],
225
+ );
226
+ });
227
+
250
228
  Promise.all(
251
229
  [
252
230
  this.backgroundCanvas,
@@ -360,6 +338,27 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
360
338
  }>({
361
339
  name: 'itemstatechange',
362
340
  }),
341
+ itemstateconfigchange: new Hook<{
342
+ itemType: ITEM_TYPE;
343
+ stateConfig:
344
+ | {
345
+ [stateName: string]:
346
+ | ((data: NodeModel) => NodeDisplayModel)
347
+ | NodeShapesEncode;
348
+ }
349
+ | {
350
+ [stateName: string]:
351
+ | ((data: EdgeModel) => EdgeDisplayModel)
352
+ | EdgeShapesEncode;
353
+ }
354
+ | {
355
+ [stateName: string]:
356
+ | ((data: ComboModel) => ComboDisplayModel)
357
+ | ComboShapesEncode;
358
+ };
359
+ }>({
360
+ name: 'itemstateconfigchange',
361
+ }),
363
362
  itemvisibilitychange: new Hook<{ ids: ID[]; value: boolean }>({
364
363
  name: 'itemvisibilitychange',
365
364
  }),
@@ -428,11 +427,28 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
428
427
  * Update the specs(configurations).
429
428
  */
430
429
  public updateSpecification(spec: Specification<B, T>): Specification<B, T> {
430
+ const {
431
+ node,
432
+ edge,
433
+ combo,
434
+ theme,
435
+ nodeState,
436
+ edgeState,
437
+ comboState,
438
+ ...others
439
+ } = spec;
440
+ if (node) this.updateMapper('node', node);
441
+ if (edge) this.updateMapper('edge', edge);
442
+ if (combo) this.updateMapper('combo', combo);
443
+ if (theme) this.updateTheme(theme);
444
+ if (nodeState) this.updateStateConfig('node', nodeState, 'replace');
445
+ if (edgeState) this.updateStateConfig('edge', edgeState, 'replace');
446
+ if (comboState) this.updateStateConfig('combo', comboState, 'replace');
447
+
431
448
  const newSpec = Object.assign(
432
449
  this.specification,
433
- this.formatSpecification(spec),
450
+ this.formatSpecification(others),
434
451
  );
435
- // TODO: update something
436
452
  return newSpec;
437
453
  }
438
454
  /**
@@ -481,6 +497,47 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
481
497
  });
482
498
  }
483
499
 
500
+ /**
501
+ * Updates the state configuration for the specified item type, corresponds to the nodeState, edgeState, or comboState on the graph spec.
502
+ * @param {string} itemType - The type of item (node, edge, or combo).
503
+ * @param {object} stateConfig - The state configuration to update.
504
+ * @param {string} updateType - The type of update ('mergeReplace' or 'replace'). Default is 'mergeReplace'.
505
+ **/
506
+ public updateStateConfig(
507
+ itemType: ITEM_TYPE,
508
+ stateConfig:
509
+ | {
510
+ [stateName: string]:
511
+ | ((data: NodeModel) => NodeDisplayModel)
512
+ | NodeShapesEncode;
513
+ }
514
+ | {
515
+ [stateName: string]:
516
+ | ((data: EdgeModel) => EdgeDisplayModel)
517
+ | EdgeShapesEncode;
518
+ }
519
+ | {
520
+ [stateName: string]:
521
+ | ((data: ComboModel) => ComboDisplayModel)
522
+ | ComboShapesEncode;
523
+ },
524
+ updateType: 'mergeReplace' | 'replace' = 'mergeReplace',
525
+ ) {
526
+ if (isEmpty(stateConfig)) return;
527
+ const stateField = `${itemType}State`;
528
+ if (updateType === 'mergeReplace') {
529
+ const config = {
530
+ ...this.specification[stateField],
531
+ ...stateConfig,
532
+ };
533
+ this.specification[itemType] = config;
534
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig: config });
535
+ } else {
536
+ this.specification[itemType] = stateConfig;
537
+ this.hooks.itemstateconfigchange.emit({ itemType, stateConfig });
538
+ }
539
+ }
540
+
484
541
  /**
485
542
  * Get the copy of specs(configurations).
486
543
  * @returns graph specs
@@ -1110,7 +1167,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1110
1167
  return this.dataController.findRelatedEdges(nodeId, direction);
1111
1168
  }
1112
1169
  /**
1113
- * Get nearby edges from a start node using quadtree collision detection.
1170
+ * Get nearby edges from a start node using quad-tree collision detection.
1114
1171
  * @param nodeId id of the start node
1115
1172
  * @returns nearby edges' data array
1116
1173
  */
@@ -1543,7 +1600,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1543
1600
  edges: [],
1544
1601
  combos: type === 'combo' ? (modelArr as ComboUserModel[]) : [],
1545
1602
  },
1546
- type: 'update',
1603
+ type: 'updatePosition',
1547
1604
  });
1548
1605
  const dataList = this.dataController.findData(
1549
1606
  type,
@@ -1866,7 +1923,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1866
1923
 
1867
1924
  /**
1868
1925
  * Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
1869
- * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
1926
+ * Different from addData with combo type, this API update the succeeds' combo tree structures in the same time.
1870
1927
  * @param model combo user data.
1871
1928
  * @param childrenIds the ids of the children nodes / combos to move into the new combo.
1872
1929
  * @returns whether success
@@ -2340,7 +2397,7 @@ export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
2340
2397
  /**
2341
2398
  * Draw or update a G shape or group to the transient canvas.
2342
2399
  * @param type shape type or item type
2343
- * @param id new shape id or updated shape id for a interation shape, node/edge/combo id for item interaction group drawing
2400
+ * @param id new shape id or updated shape id for a interaction shape, node/edge/combo id for item interaction group drawing
2344
2401
  * @returns upserted shape or group
2345
2402
  * @group Interaction
2346
2403
  */
@@ -1,8 +1,8 @@
1
1
  import { IHook } from '../types/hook';
2
2
 
3
3
  /**
4
- * A hook class unified the definitions of tap, untap, and emit.
5
- * One hook corresponds to one lifecyle on a graph.
4
+ * A hook class unified the definitions of tap, un-tap, and emit.
5
+ * One hook corresponds to one lifecycle on a graph.
6
6
  */
7
7
  export default class Hook<T> implements IHook<T> {
8
8
  public name: string;
@@ -20,7 +20,7 @@ interface CreateEdgeOptions {
20
20
  trigger: (typeof EVENT_TRIGGERS)[number];
21
21
  /**
22
22
  * The assistant secondary key on keyboard. If it is not assigned, the behavior will be triggered when trigger happens.
23
- * cound be 'shift', 'ctrl', 'control', 'alt', 'meta', undefined.
23
+ * could be 'shift', 'ctrl', 'control', 'alt', 'meta', undefined.
24
24
  */
25
25
  secondaryKey?: (typeof KEYBOARD_TRIGGERS)[number];
26
26
  /**
@@ -27,7 +27,7 @@ export interface DragCanvasOptions {
27
27
  */
28
28
  secondaryKey?: string;
29
29
  /**
30
- * The assistant secondary key on keyboard to prevent the behavior to be tiggered. 'shift' by default.
30
+ * The assistant secondary key on keyboard to prevent the behavior to be triggered. 'shift' by default.
31
31
  */
32
32
  secondaryKeyToDisable?: string;
33
33
  /**
@@ -179,7 +179,7 @@ export class DragNode extends Behavior {
179
179
  return relatedNodes;
180
180
  }
181
181
 
182
- /** Retrieve the nearby edges for a given node using quadtree collision detection. */
182
+ /** Retrieve the nearby edges for a given node using quad-tree collision detection. */
183
183
  private getNearEdgesForNodes(
184
184
  nodeIds: ID[],
185
185
  shouldBegin?: (edge: EdgeModel) => boolean,
@@ -15,7 +15,7 @@ export interface HoverActivateOptions {
15
15
  */
16
16
  activateState?: string;
17
17
  /**
18
- * Item types to be able to acitvate.
18
+ * Item types to be able to activate.
19
19
  * Defaults to `["node", "edge"]`.
20
20
  * Should be an array of "node", "edge", or "combo".
21
21
  */
@@ -8,7 +8,7 @@ const VALID_TRIGGERS = ['drag', 'directionKeys'];
8
8
 
9
9
  export interface OrbitCanvas3DOptions {
10
10
  /**
11
- * The way to tranlate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
11
+ * The way to translate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
12
12
  */
13
13
  trigger?: 'drag' | 'directionKeys';
14
14
  /**
@@ -7,7 +7,7 @@ const VALID_TRIGGERS = ['drag', 'directionKeys'];
7
7
 
8
8
  export interface RotateCanvas3DOptions {
9
9
  /**
10
- * The way to tranlate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
10
+ * The way to translate the canvas. 'drag' (default) means dragged by mouse, 'directionKeys' means the up/down/left/right key on keyBoard.
11
11
  */
12
12
  trigger?: 'drag' | 'directionKeys';
13
13
  /**
@@ -18,7 +18,7 @@ export interface RotateCanvas3DOptions {
18
18
  */
19
19
  secondaryKey?: string;
20
20
  /**
21
- * To speed up rotating while pressing and rotate the canvas by direciton keys (trigger = 'directionKeys').
21
+ * To speed up rotating while pressing and rotate the canvas by direction keys (trigger = 'directionKeys').
22
22
  */
23
23
  speedUpKey?: string;
24
24
  /**
@@ -222,10 +222,10 @@ export class ScrollCanvas extends Behavior {
222
222
  graph.getSpecification().optimize || {};
223
223
  const { optimizeZoom } = options;
224
224
  const optimize = this.options.enableOptimize || graphBehaviorOptimize;
225
- const shouldOptimzie = isNumber(optimize)
225
+ const shouldOptimize = isNumber(optimize)
226
226
  ? graph.getAllNodesData().length > optimize
227
227
  : optimize;
228
- if (shouldOptimzie) {
228
+ if (shouldOptimize) {
229
229
  const currentZoom = graph.getZoom();
230
230
  const newHiddenEdgeIds = graph
231
231
  .getAllEdgesData()
@@ -278,7 +278,7 @@ export class ScrollCanvas extends Behavior {
278
278
  const { optimizeZoom } = this.options;
279
279
 
280
280
  // hide the shapes when the zoom ratio is smaller than optimizeZoom
281
- // hide the shapes when zoomming
281
+ // hide the shapes when zooming
282
282
  if (currentZoom < optimizeZoom) {
283
283
  return;
284
284
  }
@@ -286,10 +286,10 @@ export class ScrollCanvas extends Behavior {
286
286
  const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
287
287
  graph.getSpecification().optimize || {};
288
288
  const optimize = this.options.enableOptimize || graphBehaviorOptimize;
289
- const shouldOptimzie = isNumber(optimize)
289
+ const shouldOptimize = isNumber(optimize)
290
290
  ? graph.getAllNodesData().length > optimize
291
291
  : optimize;
292
- if (!shouldOptimzie) {
292
+ if (!shouldOptimize) {
293
293
  this.hiddenEdgeIds = this.hiddenNodeIds = [];
294
294
  return;
295
295
  }