@antv/g6 5.0.0-beta.0 → 5.0.0-beta.10

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 (421) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/item.d.ts +2 -0
  3. package/esm/api-doc/item.js +2 -0
  4. package/esm/api-doc/item.js.map +1 -1
  5. package/esm/constant/shape.d.ts +4 -1
  6. package/esm/constant/shape.js.map +1 -1
  7. package/esm/index.d.ts +22 -7
  8. package/esm/index.js +3 -2
  9. package/esm/index.js.map +1 -1
  10. package/esm/item/combo.d.ts +1 -1
  11. package/esm/item/combo.js +16 -9
  12. package/esm/item/combo.js.map +1 -1
  13. package/esm/item/edge.d.ts +20 -3
  14. package/esm/item/edge.js +99 -43
  15. package/esm/item/edge.js.map +1 -1
  16. package/esm/item/item.d.ts +3 -2
  17. package/esm/item/item.js +21 -11
  18. package/esm/item/item.js.map +1 -1
  19. package/esm/item/node.d.ts +2 -1
  20. package/esm/item/node.js +33 -16
  21. package/esm/item/node.js.map +1 -1
  22. package/esm/runtime/controller/data.d.ts +7 -10
  23. package/esm/runtime/controller/data.js +127 -283
  24. package/esm/runtime/controller/data.js.map +1 -1
  25. package/esm/runtime/controller/item.d.ts +1 -0
  26. package/esm/runtime/controller/item.js +267 -151
  27. package/esm/runtime/controller/item.js.map +1 -1
  28. package/esm/runtime/controller/plugin.js +3 -3
  29. package/esm/runtime/controller/plugin.js.map +1 -1
  30. package/esm/runtime/graph.d.ts +103 -23
  31. package/esm/runtime/graph.js +460 -88
  32. package/esm/runtime/graph.js.map +1 -1
  33. package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
  34. package/esm/stdlib/behavior/activate-relations.js +8 -8
  35. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  36. package/esm/stdlib/behavior/brush-select.js +1 -2
  37. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  38. package/esm/stdlib/behavior/click-select.js +1 -1
  39. package/esm/stdlib/behavior/click-select.js.map +1 -1
  40. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  41. package/esm/stdlib/behavior/create-edge.js +207 -0
  42. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  43. package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
  44. package/esm/stdlib/behavior/drag-canvas.js +57 -26
  45. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  46. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  47. package/esm/stdlib/behavior/drag-combo.js +43 -32
  48. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  49. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  50. package/esm/stdlib/behavior/drag-node.js +76 -63
  51. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  52. package/esm/stdlib/behavior/index.d.ts +3 -0
  53. package/esm/stdlib/behavior/index.js +3 -0
  54. package/esm/stdlib/behavior/index.js.map +1 -1
  55. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  56. package/esm/stdlib/behavior/lasso-select.js +1 -2
  57. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  58. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  59. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  60. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  61. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  62. package/esm/stdlib/behavior/shortcuts-call.js +80 -0
  63. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  64. package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
  65. package/esm/stdlib/behavior/zoom-canvas.js +55 -24
  66. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  67. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  68. package/esm/stdlib/data/mapNodeSize.js +2 -2
  69. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  70. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  71. package/esm/stdlib/data/transformV4Data.js +2 -2
  72. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  73. package/esm/stdlib/data/validateData.d.ts +2 -2
  74. package/esm/stdlib/data/validateData.js +16 -11
  75. package/esm/stdlib/data/validateData.js.map +1 -1
  76. package/esm/stdlib/index.d.ts +16 -6
  77. package/esm/stdlib/index.js +20 -10
  78. package/esm/stdlib/index.js.map +1 -1
  79. package/esm/stdlib/item/edge/base.d.ts +96 -6
  80. package/esm/stdlib/item/edge/base.js +92 -19
  81. package/esm/stdlib/item/edge/base.js.map +1 -1
  82. package/esm/stdlib/item/edge/line.js +5 -2
  83. package/esm/stdlib/item/edge/line.js.map +1 -1
  84. package/esm/stdlib/item/edge/polyline.d.ts +3 -2
  85. package/esm/stdlib/item/edge/polyline.js +3 -3
  86. package/esm/stdlib/item/edge/polyline.js.map +1 -1
  87. package/esm/stdlib/item/node/base.d.ts +90 -16
  88. package/esm/stdlib/item/node/base.js +91 -41
  89. package/esm/stdlib/item/node/base.js.map +1 -1
  90. package/esm/stdlib/item/node/base3d.d.ts +24 -0
  91. package/esm/stdlib/item/node/base3d.js +24 -8
  92. package/esm/stdlib/item/node/base3d.js.map +1 -1
  93. package/esm/stdlib/item/node/diamond.js +1 -1
  94. package/esm/stdlib/item/node/ellipse.js +2 -2
  95. package/esm/stdlib/item/node/hexagon.js +12 -5
  96. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  97. package/esm/stdlib/item/node/image.d.ts +40 -0
  98. package/esm/stdlib/item/node/image.js +110 -0
  99. package/esm/stdlib/item/node/image.js.map +1 -0
  100. package/esm/stdlib/item/node/index.d.ts +1 -0
  101. package/esm/stdlib/item/node/index.js +1 -0
  102. package/esm/stdlib/item/node/index.js.map +1 -1
  103. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  104. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  105. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  106. package/esm/stdlib/plugin/history/index.js +14 -14
  107. package/esm/stdlib/plugin/history/index.js.map +1 -1
  108. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  109. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  110. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  111. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  112. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  113. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  114. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  115. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  116. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  117. package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
  118. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  119. package/esm/stdlib/plugin/index.d.ts +2 -0
  120. package/esm/stdlib/plugin/index.js +2 -0
  121. package/esm/stdlib/plugin/index.js.map +1 -1
  122. package/esm/stdlib/plugin/legend/index.js +5 -3
  123. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  124. package/esm/stdlib/plugin/map/index.d.ts +118 -0
  125. package/esm/stdlib/plugin/map/index.js +683 -0
  126. package/esm/stdlib/plugin/map/index.js.map +1 -0
  127. package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
  128. package/esm/stdlib/plugin/minimap/index.js +116 -9
  129. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  130. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  131. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  132. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  133. package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
  134. package/esm/stdlib/plugin/timebar/index.js +303 -0
  135. package/esm/stdlib/plugin/timebar/index.js.map +1 -0
  136. package/esm/stdlib/plugin/toolbar/index.js +1 -1
  137. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  138. package/esm/stdlib/plugin/types.d.ts +2 -0
  139. package/esm/stdlib/theme/dark.js +42 -2
  140. package/esm/stdlib/theme/dark.js.map +1 -1
  141. package/esm/stdlib/theme/light.js +4 -4
  142. package/esm/types/common.d.ts +1 -0
  143. package/esm/types/event.d.ts +1 -0
  144. package/esm/types/graph.d.ts +48 -22
  145. package/esm/types/hook.d.ts +22 -2
  146. package/esm/types/item.d.ts +6 -0
  147. package/esm/types/item.js.map +1 -1
  148. package/esm/types/spec.d.ts +20 -4
  149. package/esm/types/view.d.ts +5 -0
  150. package/esm/util/bbox.d.ts +16 -1
  151. package/esm/util/bbox.js +29 -0
  152. package/esm/util/bbox.js.map +1 -1
  153. package/esm/util/canvas.d.ts +2 -2
  154. package/esm/util/canvas.js +5 -11
  155. package/esm/util/canvas.js.map +1 -1
  156. package/esm/util/event.d.ts +3 -1
  157. package/esm/util/event.js +8 -1
  158. package/esm/util/event.js.map +1 -1
  159. package/esm/util/item.d.ts +16 -1
  160. package/esm/util/item.js +31 -8
  161. package/esm/util/item.js.map +1 -1
  162. package/esm/util/layout.d.ts +11 -0
  163. package/esm/util/layout.js +45 -0
  164. package/esm/util/layout.js.map +1 -1
  165. package/esm/util/point.js +9 -2
  166. package/esm/util/point.js.map +1 -1
  167. package/esm/util/router.d.ts +4 -3
  168. package/esm/util/router.js +8 -5
  169. package/esm/util/router.js.map +1 -1
  170. package/esm/util/shape.d.ts +3 -3
  171. package/esm/util/shape.js +8 -12
  172. package/esm/util/shape.js.map +1 -1
  173. package/esm/util/warn.d.ts +14 -0
  174. package/esm/util/warn.js +4 -0
  175. package/esm/util/warn.js.map +1 -0
  176. package/lib/api-doc/item.d.ts +2 -0
  177. package/lib/api-doc/item.js +5 -1
  178. package/lib/api-doc/item.js.map +1 -1
  179. package/lib/constant/shape.d.ts +4 -1
  180. package/lib/constant/shape.js.map +1 -1
  181. package/lib/index.d.ts +22 -7
  182. package/lib/index.js +4 -2
  183. package/lib/index.js.map +1 -1
  184. package/lib/item/combo.d.ts +1 -1
  185. package/lib/item/combo.js +16 -9
  186. package/lib/item/combo.js.map +1 -1
  187. package/lib/item/edge.d.ts +20 -3
  188. package/lib/item/edge.js +98 -42
  189. package/lib/item/edge.js.map +1 -1
  190. package/lib/item/item.d.ts +3 -2
  191. package/lib/item/item.js +21 -11
  192. package/lib/item/item.js.map +1 -1
  193. package/lib/item/node.d.ts +2 -1
  194. package/lib/item/node.js +33 -16
  195. package/lib/item/node.js.map +1 -1
  196. package/lib/runtime/controller/data.d.ts +7 -10
  197. package/lib/runtime/controller/data.js +127 -283
  198. package/lib/runtime/controller/data.js.map +1 -1
  199. package/lib/runtime/controller/item.d.ts +1 -0
  200. package/lib/runtime/controller/item.js +266 -150
  201. package/lib/runtime/controller/item.js.map +1 -1
  202. package/lib/runtime/controller/plugin.js +3 -3
  203. package/lib/runtime/controller/plugin.js.map +1 -1
  204. package/lib/runtime/graph.d.ts +103 -23
  205. package/lib/runtime/graph.js +460 -88
  206. package/lib/runtime/graph.js.map +1 -1
  207. package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
  208. package/lib/stdlib/behavior/activate-relations.js +8 -8
  209. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  210. package/lib/stdlib/behavior/brush-select.js +1 -2
  211. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  212. package/lib/stdlib/behavior/click-select.js +1 -1
  213. package/lib/stdlib/behavior/click-select.js.map +1 -1
  214. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  215. package/lib/stdlib/behavior/create-edge.js +211 -0
  216. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  217. package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
  218. package/lib/stdlib/behavior/drag-canvas.js +57 -26
  219. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  220. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  221. package/lib/stdlib/behavior/drag-combo.js +43 -32
  222. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  223. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  224. package/lib/stdlib/behavior/drag-node.js +76 -63
  225. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  226. package/lib/stdlib/behavior/index.d.ts +3 -0
  227. package/lib/stdlib/behavior/index.js +3 -0
  228. package/lib/stdlib/behavior/index.js.map +1 -1
  229. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  230. package/lib/stdlib/behavior/lasso-select.js +1 -2
  231. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  232. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  233. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  234. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  235. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  236. package/lib/stdlib/behavior/shortcuts-call.js +84 -0
  237. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  238. package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
  239. package/lib/stdlib/behavior/zoom-canvas.js +55 -24
  240. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  241. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  242. package/lib/stdlib/data/mapNodeSize.js +2 -2
  243. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  244. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  245. package/lib/stdlib/data/transformV4Data.js +2 -2
  246. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  247. package/lib/stdlib/data/validateData.d.ts +2 -2
  248. package/lib/stdlib/data/validateData.js +16 -11
  249. package/lib/stdlib/data/validateData.js.map +1 -1
  250. package/lib/stdlib/index.d.ts +16 -6
  251. package/lib/stdlib/index.js +20 -10
  252. package/lib/stdlib/index.js.map +1 -1
  253. package/lib/stdlib/item/edge/base.d.ts +96 -6
  254. package/lib/stdlib/item/edge/base.js +92 -19
  255. package/lib/stdlib/item/edge/base.js.map +1 -1
  256. package/lib/stdlib/item/edge/line.js +5 -2
  257. package/lib/stdlib/item/edge/line.js.map +1 -1
  258. package/lib/stdlib/item/edge/polyline.d.ts +3 -2
  259. package/lib/stdlib/item/edge/polyline.js +3 -3
  260. package/lib/stdlib/item/edge/polyline.js.map +1 -1
  261. package/lib/stdlib/item/node/base.d.ts +90 -16
  262. package/lib/stdlib/item/node/base.js +91 -41
  263. package/lib/stdlib/item/node/base.js.map +1 -1
  264. package/lib/stdlib/item/node/base3d.d.ts +24 -0
  265. package/lib/stdlib/item/node/base3d.js +24 -8
  266. package/lib/stdlib/item/node/base3d.js.map +1 -1
  267. package/lib/stdlib/item/node/diamond.js +1 -1
  268. package/lib/stdlib/item/node/ellipse.js +2 -2
  269. package/lib/stdlib/item/node/hexagon.js +12 -5
  270. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  271. package/lib/stdlib/item/node/image.d.ts +40 -0
  272. package/lib/stdlib/item/node/image.js +114 -0
  273. package/lib/stdlib/item/node/image.js.map +1 -0
  274. package/lib/stdlib/item/node/index.d.ts +1 -0
  275. package/lib/stdlib/item/node/index.js +1 -0
  276. package/lib/stdlib/item/node/index.js.map +1 -1
  277. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  278. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  279. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  280. package/lib/stdlib/plugin/history/index.js +14 -14
  281. package/lib/stdlib/plugin/history/index.js.map +1 -1
  282. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  283. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  284. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  285. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  286. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  287. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  288. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  289. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  290. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  291. package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
  292. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  293. package/lib/stdlib/plugin/index.d.ts +2 -0
  294. package/lib/stdlib/plugin/index.js +2 -0
  295. package/lib/stdlib/plugin/index.js.map +1 -1
  296. package/lib/stdlib/plugin/legend/index.js +5 -3
  297. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  298. package/lib/stdlib/plugin/map/index.d.ts +118 -0
  299. package/lib/stdlib/plugin/map/index.js +687 -0
  300. package/lib/stdlib/plugin/map/index.js.map +1 -0
  301. package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
  302. package/lib/stdlib/plugin/minimap/index.js +116 -9
  303. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  304. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  305. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  306. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  307. package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
  308. package/lib/stdlib/plugin/timebar/index.js +307 -0
  309. package/lib/stdlib/plugin/timebar/index.js.map +1 -0
  310. package/lib/stdlib/plugin/toolbar/index.js +1 -1
  311. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  312. package/lib/stdlib/plugin/types.d.ts +2 -0
  313. package/lib/stdlib/theme/dark.js +42 -2
  314. package/lib/stdlib/theme/dark.js.map +1 -1
  315. package/lib/stdlib/theme/light.js +4 -4
  316. package/lib/types/common.d.ts +1 -0
  317. package/lib/types/event.d.ts +1 -0
  318. package/lib/types/graph.d.ts +48 -22
  319. package/lib/types/hook.d.ts +22 -2
  320. package/lib/types/item.d.ts +6 -0
  321. package/lib/types/item.js.map +1 -1
  322. package/lib/types/spec.d.ts +20 -4
  323. package/lib/types/view.d.ts +5 -0
  324. package/lib/util/bbox.d.ts +16 -1
  325. package/lib/util/bbox.js +32 -1
  326. package/lib/util/bbox.js.map +1 -1
  327. package/lib/util/canvas.d.ts +2 -2
  328. package/lib/util/canvas.js +5 -11
  329. package/lib/util/canvas.js.map +1 -1
  330. package/lib/util/event.d.ts +3 -1
  331. package/lib/util/event.js +8 -1
  332. package/lib/util/event.js.map +1 -1
  333. package/lib/util/item.d.ts +16 -1
  334. package/lib/util/item.js +33 -9
  335. package/lib/util/item.js.map +1 -1
  336. package/lib/util/layout.d.ts +11 -0
  337. package/lib/util/layout.js +47 -1
  338. package/lib/util/layout.js.map +1 -1
  339. package/lib/util/point.js +9 -2
  340. package/lib/util/point.js.map +1 -1
  341. package/lib/util/router.d.ts +4 -3
  342. package/lib/util/router.js +8 -5
  343. package/lib/util/router.js.map +1 -1
  344. package/lib/util/shape.d.ts +3 -3
  345. package/lib/util/shape.js +8 -12
  346. package/lib/util/shape.js.map +1 -1
  347. package/lib/util/warn.d.ts +14 -0
  348. package/lib/util/warn.js +8 -0
  349. package/lib/util/warn.js.map +1 -0
  350. package/package.json +10 -10
  351. package/src/api-doc/item.ts +2 -0
  352. package/src/constant/shape.ts +2 -1
  353. package/src/index.ts +4 -2
  354. package/src/item/combo.ts +14 -9
  355. package/src/item/edge.ts +131 -57
  356. package/src/item/item.ts +24 -15
  357. package/src/item/node.ts +38 -24
  358. package/src/runtime/controller/data.ts +142 -341
  359. package/src/runtime/controller/item.ts +236 -72
  360. package/src/runtime/controller/plugin.ts +15 -3
  361. package/src/runtime/graph.ts +592 -96
  362. package/src/stdlib/behavior/activate-relations.ts +8 -8
  363. package/src/stdlib/behavior/brush-select.ts +4 -2
  364. package/src/stdlib/behavior/click-select.ts +1 -1
  365. package/src/stdlib/behavior/create-edge.ts +296 -0
  366. package/src/stdlib/behavior/drag-canvas.ts +76 -27
  367. package/src/stdlib/behavior/drag-combo.ts +10 -10
  368. package/src/stdlib/behavior/drag-node.ts +18 -18
  369. package/src/stdlib/behavior/index.ts +3 -0
  370. package/src/stdlib/behavior/lasso-select.ts +5 -3
  371. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  372. package/src/stdlib/behavior/shortcuts-call.ts +120 -0
  373. package/src/stdlib/behavior/zoom-canvas.ts +72 -25
  374. package/src/stdlib/data/mapNodeSize.ts +2 -2
  375. package/src/stdlib/data/transformV4Data.ts +2 -2
  376. package/src/stdlib/data/validateData.ts +16 -11
  377. package/src/stdlib/index.ts +33 -9
  378. package/src/stdlib/item/edge/base.ts +118 -19
  379. package/src/stdlib/item/edge/line.ts +8 -2
  380. package/src/stdlib/item/edge/polyline.ts +7 -5
  381. package/src/stdlib/item/node/base.ts +117 -46
  382. package/src/stdlib/item/node/base3d.ts +24 -9
  383. package/src/stdlib/item/node/diamond.ts +1 -1
  384. package/src/stdlib/item/node/ellipse.ts +2 -2
  385. package/src/stdlib/item/node/hexagon.ts +14 -6
  386. package/src/stdlib/item/node/image.ts +190 -0
  387. package/src/stdlib/item/node/index.ts +1 -0
  388. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  389. package/src/stdlib/plugin/history/index.ts +14 -14
  390. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  391. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  392. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  393. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  394. package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
  395. package/src/stdlib/plugin/index.ts +2 -0
  396. package/src/stdlib/plugin/legend/index.ts +5 -4
  397. package/src/stdlib/plugin/map/index.ts +808 -0
  398. package/src/stdlib/plugin/minimap/index.ts +120 -10
  399. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  400. package/src/stdlib/plugin/timebar/index.ts +473 -0
  401. package/src/stdlib/plugin/toolbar/index.ts +1 -1
  402. package/src/stdlib/plugin/types.ts +2 -0
  403. package/src/stdlib/theme/dark.ts +66 -2
  404. package/src/stdlib/theme/light.ts +4 -4
  405. package/src/types/common.ts +1 -0
  406. package/src/types/event.ts +1 -0
  407. package/src/types/graph.ts +59 -25
  408. package/src/types/hook.ts +22 -2
  409. package/src/types/item.ts +10 -0
  410. package/src/types/spec.ts +23 -4
  411. package/src/types/view.ts +8 -3
  412. package/src/util/bbox.ts +38 -1
  413. package/src/util/canvas.ts +5 -5
  414. package/src/util/event.ts +14 -1
  415. package/src/util/item.ts +65 -28
  416. package/src/util/layout.ts +45 -0
  417. package/src/util/point.ts +8 -3
  418. package/src/util/router.ts +15 -6
  419. package/src/util/shape.ts +16 -14
  420. package/src/util/warn.ts +20 -0
  421. package/src/api-doc/readme.md +0 -59
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.warn = void 0;
4
+ function warn({ optionName, shouldBe, now, scope }) {
5
+ console.warn(`G6 [${scope}]: Invalid option, ${optionName} must be one of ${shouldBe.join(', ')}, but got ${now}`);
6
+ }
7
+ exports.warn = warn;
8
+ //# sourceMappingURL=warn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.js","sourceRoot":"src/","sources":["util/warn.ts"],"names":[],"mappings":";;;AAaA,SAAgB,IAAI,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAc;IACnE,OAAO,CAAC,IAAI,CACV,OAAO,KAAK,sBAAsB,UAAU,mBAAmB,QAAQ,CAAC,IAAI,CAC1E,IAAI,CACL,aAAa,GAAG,EAAE,CACpB,CAAC;AACJ,CAAC;AAND,oBAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.10",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -69,16 +69,16 @@
69
69
  "@antv/g-plugin-control": "^1.7.43",
70
70
  "@antv/g-plugin-dragndrop": "^1.8.1",
71
71
  "@antv/g-svg": "^1.8.36",
72
- "@antv/g-webgl": "^1.9.18",
72
+ "@antv/g-webgl": "^1.9.19",
73
73
  "@antv/graphlib": "^2.0.2",
74
- "@antv/gui": "^0.5.0-alpha.16",
75
- "@antv/layout": "^1.2.9",
74
+ "@antv/gui": "0.5.1-alpha.1",
76
75
  "@antv/hierarchy": "latest",
76
+ "@antv/layout": "^1.2.9",
77
77
  "@antv/layout-gpu": "^1.1.5",
78
78
  "@antv/layout-wasm": "1.3.1",
79
79
  "@antv/matrix-util": "^3.0.4",
80
- "@antv/util": "~2.0.5",
81
80
  "@antv/path-util": "3.0.1",
81
+ "@antv/util": "~2.0.5",
82
82
  "color": "^4.2.3",
83
83
  "insert-css": "^2.0.0",
84
84
  "stats-js": "^1.0.1",
@@ -95,13 +95,13 @@
95
95
  "@types/pixelmatch": "^5.2.4",
96
96
  "@types/pngjs": "^6.0.1",
97
97
  "@types/xmlserializer": "^0.6.3",
98
- "@typescript-eslint/eslint-plugin": "^4.18.0",
99
- "@typescript-eslint/parser": "^4.18.0",
98
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
99
+ "@typescript-eslint/parser": "^6.5.0",
100
100
  "@umijs/fabric": "^2.0.0",
101
101
  "babel-loader": "^8.0.6",
102
102
  "canvas": "2.11.0",
103
- "eslint": "^7.22.0",
104
- "eslint-plugin-import": "^2.22.1",
103
+ "eslint": "^8.48.0",
104
+ "eslint-plugin-import": "^2.28.1",
105
105
  "father": "^2.29.1",
106
106
  "gl": "^6.0.2",
107
107
  "jest": "^28.1.3",
@@ -113,7 +113,7 @@
113
113
  "npm-run-all": "^4.1.5",
114
114
  "pixelmatch": "5.3.0",
115
115
  "pngjs": "^6.0.0",
116
- "prettier": "^2.8.8",
116
+ "prettier": "^3.0.3",
117
117
  "rimraf": "^3.0.0",
118
118
  "rollup": "^2.79.1",
119
119
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -40,4 +40,6 @@ export type {
40
40
  export type { NodeUserModelData, NodeShapeStyles } from '../types/node';
41
41
  export type { GShapeStyle } from '../types/item';
42
42
  export { BaseNode as CustomNode } from '../stdlib/item/node/base';
43
+ export { BaseNode3D as CustomNode3D } from '../stdlib/item/node/base3d';
44
+ export { BaseEdge as CustomEdge } from '../stdlib/item/edge/base';
43
45
  export * from '../stdlib/item/node';
@@ -1,3 +1,4 @@
1
+ import type { StandardPadding } from 'types/common';
1
2
  import { ShapeStyle } from '../types/item';
2
3
 
3
4
  export const RESERVED_SHAPE_IDS = [
@@ -12,7 +13,7 @@ export const RESERVED_SHAPE_IDS = [
12
13
  ];
13
14
  export const OTHER_SHAPES_FIELD_NAME = 'otherShapes';
14
15
 
15
- export const DEFAULT_LABEL_BG_PADDING = [4, 4, 4, 4];
16
+ export const DEFAULT_LABEL_BG_PADDING: StandardPadding = [4, 4, 4, 4];
16
17
  /** Default shape style to avoid shape value missing */
17
18
  export const DEFAULT_SHAPE_STYLE = {
18
19
  opacity: 1,
package/src/index.ts CHANGED
@@ -14,10 +14,12 @@ runtime.enableCSSParsing = false;
14
14
  * Extend the graph class with std lib
15
15
  */
16
16
 
17
+ const version = '5.0.0-beta.10';
18
+
17
19
  const Graph = extend(EmptyGraph, stdLib);
18
20
 
19
- const G6 = { Graph, Util, stdLib, Extensions, extend };
21
+ const G6 = { Graph, Util, stdLib, Extensions, extend, version };
20
22
 
21
- export { Extensions, Graph, Util, extend, stdLib };
23
+ export { Extensions, Graph, Util, extend, stdLib, version };
22
24
 
23
25
  export default G6;
package/src/item/combo.ts CHANGED
@@ -264,7 +264,7 @@ export default class Combo extends Node {
264
264
  // @ts-ignore
265
265
  public clone(
266
266
  containerGroup: Group,
267
- onlyKeyShape?: boolean,
267
+ shapeIds?: string[],
268
268
  disableAnimate?: boolean,
269
269
  getCombinedBounds?: () =>
270
270
  | {
@@ -276,14 +276,19 @@ export default class Combo extends Node {
276
276
  | false,
277
277
  getChildren?: () => (Node | Combo)[],
278
278
  ) {
279
- if (onlyKeyShape) {
280
- const clonedKeyShape = this.shapeMap.keyShape.cloneNode();
281
- const pos = this.group.getPosition();
282
- const clonedGroup = new Group();
283
- clonedGroup.setPosition(pos);
284
- clonedGroup.appendChild(clonedKeyShape);
285
- containerGroup.appendChild(clonedGroup);
286
- return clonedGroup;
279
+ if (shapeIds?.length) {
280
+ const group = new Group();
281
+ shapeIds.forEach((shapeId) => {
282
+ if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
283
+ const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
284
+ // TODO: other animating attributes?
285
+ clonedKeyShape.style.opacity =
286
+ this.renderExt.mergedStyles[shapeId]?.opacity || 1;
287
+ group.appendChild(clonedKeyShape);
288
+ });
289
+ group.setPosition(this.group.getPosition());
290
+ containerGroup.appendChild(group);
291
+ return group;
287
292
  }
288
293
  const clonedModel = clone(this.model);
289
294
  clonedModel.data.disableAnimate = disableAnimate;
package/src/item/edge.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Circle, Group } from '@antv/g';
2
2
  import { clone, throttle } from '@antv/util';
3
- import { EdgeDisplayModel, EdgeModel, ID } from '../types';
3
+ import { EdgeDisplayModel, EdgeModel, ID, Point } from '../types';
4
4
  import { EdgeModelData } from '../types/edge';
5
5
  import { DisplayMapper, State, LodStrategyObj } from '../types/item';
6
6
  import { updateShapes } from '../util/shape';
@@ -28,6 +28,7 @@ interface IProps {
28
28
  };
29
29
  onframe?: Function;
30
30
  nodeMap?: Map<ID, Node>;
31
+ delayFirstDraw?: boolean;
31
32
  }
32
33
 
33
34
  export default class Edge extends Item {
@@ -37,11 +38,20 @@ export default class Edge extends Item {
37
38
  // display data model
38
39
  public displayModel: EdgeDisplayModel;
39
40
  /** Set to different value in implements */
40
- public type: 'edge' = 'edge';
41
+ public type = 'edge' as const;
41
42
  public nodeMap: Map<ID, Node>;
42
43
  public sourceItem: Node | Combo;
43
44
  public targetItem: Node | Combo;
44
45
 
46
+ /** Caches to avoid unnecessary calculations. */
47
+ private cache: {
48
+ sourcePositionCache?: Point;
49
+ targetPositionCache?: Point;
50
+ controlPointsCache?: Point;
51
+ sourcePointCache?: Point;
52
+ targetPointCache?: Point;
53
+ } = {};
54
+
45
55
  constructor(props: IProps) {
46
56
  super(props);
47
57
  this.init({ ...props, type: 'edge' });
@@ -56,7 +66,9 @@ export default class Edge extends Item {
56
66
  if (sourceItem.getType() === 'node') {
57
67
  this.nodeMap.set(targetItem.getID(), targetItem as Node);
58
68
  }
59
- this.draw(this.displayModel);
69
+ if (!props.delayFirstDraw) {
70
+ this.draw(this.displayModel);
71
+ }
60
72
  }
61
73
  public draw(
62
74
  displayModel: EdgeDisplayModel,
@@ -65,40 +77,7 @@ export default class Edge extends Item {
65
77
  animate = true,
66
78
  onfinish: Function = () => {},
67
79
  ) {
68
- // get the point near the other end
69
- const { sourceAnchor, targetAnchor, keyShape } = displayModel.data;
70
- const sourcePosition = this.sourceItem.getPosition();
71
- const targetPosition = this.targetItem.getPosition();
72
-
73
- let targetPrevious = sourcePosition;
74
- let sourcePrevious = targetPosition;
75
-
76
- // TODO: type
77
- // @ts-ignore
78
- if (keyShape?.controlPoints?.length) {
79
- // @ts-ignore
80
- const controlPointsBesideEnds = keyShape.controlPoints.filter(
81
- (point) =>
82
- !isSamePoint(point, sourcePosition) &&
83
- !isSamePoint(point, targetPosition),
84
- );
85
- sourcePrevious = getNearestPoint(
86
- controlPointsBesideEnds,
87
- sourcePosition,
88
- ).nearestPoint;
89
- targetPrevious = getNearestPoint(
90
- controlPointsBesideEnds,
91
- targetPosition,
92
- ).nearestPoint;
93
- }
94
- const sourcePoint = this.sourceItem.getAnchorPoint(
95
- sourcePrevious,
96
- sourceAnchor,
97
- );
98
- const targetPoint = this.targetItem.getAnchorPoint(
99
- targetPrevious,
100
- targetAnchor,
101
- );
80
+ const { sourcePoint, targetPoint } = this.getEndPoints(displayModel);
102
81
  this.renderExt.mergeStyles(displayModel);
103
82
  const firstRendering = !this.shapeMap?.keyShape;
104
83
  this.renderExt.setSourcePoint(sourcePoint);
@@ -161,16 +140,23 @@ export default class Edge extends Item {
161
140
  * Sometimes no changes on edge data, but need to re-draw it
162
141
  * e.g. source and target nodes' position changed
163
142
  */
164
- public forceUpdate = throttle(
165
- () => {
166
- if (!this.destroyed) this.draw(this.displayModel);
167
- },
168
- 16,
169
- {
170
- leading: true,
171
- trailing: true,
172
- },
173
- );
143
+ public forceUpdate() {
144
+ if (this.destroyed) return;
145
+ const { sourcePoint, targetPoint, changed } = this.getEndPoints(
146
+ this.displayModel,
147
+ );
148
+ if (!changed) return;
149
+ this.renderExt.setSourcePoint(sourcePoint);
150
+ this.renderExt.setTargetPoint(targetPoint);
151
+ const shapeMap = this.renderExt.draw(
152
+ this.displayModel,
153
+ sourcePoint,
154
+ targetPoint,
155
+ this.shapeMap,
156
+ );
157
+ // add shapes to group, and update shapeMap
158
+ this.shapeMap = updateShapes(this.shapeMap, shapeMap, this.group);
159
+ }
174
160
 
175
161
  /**
176
162
  * Update end item for item and re-draw the edge
@@ -183,23 +169,111 @@ export default class Edge extends Item {
183
169
  this.draw(this.displayModel);
184
170
  }
185
171
 
186
- // public update(model: EdgeModel) {
187
- // super.update(model);
188
- // }
172
+ /**
173
+ * Calculate the source and target points according to the source and target nodes and the anchorPoints and controlPoints.
174
+ * @param displayModel
175
+ * @returns
176
+ */
177
+ private getEndPoints(displayModel: EdgeDisplayModel) {
178
+ // get the point near the other end
179
+ const { sourceAnchor, targetAnchor, keyShape } = displayModel.data;
180
+ const sourcePosition = this.sourceItem.getPosition();
181
+ const targetPosition = this.targetItem.getPosition();
182
+
183
+ if (
184
+ !this.shouldUpdatePoints(
185
+ sourcePosition,
186
+ targetPosition,
187
+ // @ts-ignore
188
+ keyShape?.controlPoints,
189
+ )
190
+ ) {
191
+ return {
192
+ sourcePoint: this.cache.sourcePointCache,
193
+ targetPoint: this.cache.targetPointCache,
194
+ changed: false,
195
+ };
196
+ }
197
+
198
+ let targetPrevious = sourcePosition;
199
+ let sourcePrevious = targetPosition;
200
+
201
+ // TODO: type
202
+ // @ts-ignore
203
+ if (keyShape?.controlPoints?.length) {
204
+ // @ts-ignore
205
+ const controlPointsBesideEnds = keyShape.controlPoints.filter(
206
+ (point) =>
207
+ !isSamePoint(point, sourcePosition) &&
208
+ !isSamePoint(point, targetPosition),
209
+ );
210
+ sourcePrevious = getNearestPoint(
211
+ controlPointsBesideEnds,
212
+ sourcePosition,
213
+ ).nearestPoint;
214
+ targetPrevious = getNearestPoint(
215
+ controlPointsBesideEnds,
216
+ targetPosition,
217
+ ).nearestPoint;
218
+ }
219
+ this.cache.sourcePointCache = this.sourceItem.getAnchorPoint(
220
+ sourcePrevious,
221
+ sourceAnchor,
222
+ );
223
+ this.cache.targetPointCache = this.targetItem.getAnchorPoint(
224
+ targetPrevious,
225
+ targetAnchor,
226
+ );
227
+ return {
228
+ sourcePoint: this.cache.sourcePointCache,
229
+ targetPoint: this.cache.targetPointCache,
230
+ changed: true,
231
+ };
232
+ }
233
+
234
+ /**
235
+ * Returns false if the source, target, controlPoints are not changed, avoiding unnecessary computations.
236
+ * @param sourcePosition
237
+ * @param targetPosition
238
+ * @param controlPoints
239
+ * @returns
240
+ */
241
+ private shouldUpdatePoints(sourcePosition, targetPosition, controlPoints) {
242
+ const isComboEnd =
243
+ this.sourceItem.type === 'combo' || this.targetItem.type === 'combo';
244
+ const changed =
245
+ !(
246
+ isSamePoint(sourcePosition, this.cache.sourcePositionCache) &&
247
+ isSamePoint(targetPosition, this.cache.targetPositionCache) &&
248
+ controlPoints === this.cache.controlPointsCache
249
+ ) || isComboEnd;
250
+ if (changed) {
251
+ this.cache.sourcePositionCache = sourcePosition;
252
+ this.cache.targetPositionCache = targetPosition;
253
+ this.cache.controlPointsCache = controlPoints;
254
+ }
255
+ return changed;
256
+ }
189
257
 
190
258
  public clone(
191
259
  containerGroup: Group,
192
260
  sourceItem: Node | Combo,
193
261
  targetItem: Node | Combo,
194
- onlyKeyShape?: boolean,
262
+ shapeIds?: string[],
195
263
  disableAnimate?: boolean,
196
264
  ) {
197
- if (onlyKeyShape) {
198
- const clonedKeyShape = this.shapeMap.keyShape.cloneNode();
199
- const clonedGroup = new Group();
200
- clonedGroup.appendChild(clonedKeyShape);
201
- containerGroup.appendChild(clonedGroup);
202
- return clonedGroup;
265
+ if (shapeIds?.length) {
266
+ const group = new Group();
267
+ shapeIds.forEach((shapeId) => {
268
+ if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
269
+ const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
270
+ // TODO: other animating attributes?
271
+ clonedKeyShape.style.opacity =
272
+ this.renderExt.mergedStyles[shapeId]?.opacity || 1;
273
+ group.appendChild(clonedKeyShape);
274
+ });
275
+ containerGroup.appendChild(group);
276
+ return group;
203
277
  }
204
278
  const clonedModel = clone(this.model);
205
279
  clonedModel.data.disableAnimate = disableAnimate;
package/src/item/item.ts CHANGED
@@ -90,7 +90,8 @@ export default abstract class Item implements IItem {
90
90
  /** Cache the dirty tags for states when data changed, to re-map the state styles when state changed */
91
91
  private stateDirtyMap: { [stateName: string]: boolean } = {};
92
92
  private cacheStateStyles: { [stateName: string]: ItemShapeStyles } = {};
93
- private cacheHiddenShape: { [shapeId: string]: boolean } = {};
93
+ private cacheNotHiddenByItem: { [shapeId: string]: boolean } = {};
94
+ private cacheHiddenByItem: { [shapeId: string]: boolean } = {};
94
95
 
95
96
  // TODO: props type
96
97
  constructor(props) {
@@ -411,7 +412,7 @@ export default abstract class Item implements IItem {
411
412
  /** Show the item. */
412
413
  public show(animate = true) {
413
414
  Promise.all(this.stopAnimations()).finally(() => {
414
- if (this.destroyed || this.visible) return;
415
+ if (this.destroyed) return;
415
416
  const { animates = {} } = this.displayModel.data;
416
417
  if (animate && animates.show?.length) {
417
418
  const showAnimateFieldsMap: any = {};
@@ -424,7 +425,7 @@ export default abstract class Item implements IItem {
424
425
  const targetStyleMap = {};
425
426
  Object.keys(this.shapeMap).forEach((id) => {
426
427
  const shape = this.shapeMap[id];
427
- if (!this.cacheHiddenShape[id]) {
428
+ if (this.cacheHiddenByItem[id]) {
428
429
  // set the animate fields to initial value
429
430
  if (showAnimateFieldsMap[id]) {
430
431
  targetStyleMap[id] = targetStyleMap[id] || {};
@@ -439,7 +440,7 @@ export default abstract class Item implements IItem {
439
440
  shape.show();
440
441
  }
441
442
  });
442
- if (showAnimateFieldsMap.group) {
443
+ if (showAnimateFieldsMap.group && !this.shapeMap.keyShape.isVisible()) {
443
444
  showAnimateFieldsMap.group.forEach((field) => {
444
445
  const usingField = field === 'size' ? 'transform' : field;
445
446
  if (GROUP_ANIMATE_STYLES[0].hasOwnProperty(usingField)) {
@@ -449,34 +450,42 @@ export default abstract class Item implements IItem {
449
450
  });
450
451
  }
451
452
 
452
- this.animations = this.runWithAnimates(
453
- animates,
454
- 'show',
455
- targetStyleMap,
456
- );
453
+ if (Object.keys(targetStyleMap).length) {
454
+ this.animations = this.runWithAnimates(
455
+ animates,
456
+ 'show',
457
+ targetStyleMap,
458
+ );
459
+ }
457
460
  } else {
458
461
  Object.keys(this.shapeMap).forEach((id) => {
459
462
  const shape = this.shapeMap[id];
460
- if (!this.cacheHiddenShape[id]) shape.show();
463
+ if (this.cacheHiddenByItem[id]) shape.show();
461
464
  });
462
465
  }
463
466
 
464
467
  this.visible = true;
468
+ this.cacheHiddenByItem = {};
465
469
  });
466
470
  }
467
471
 
468
472
  /** Hides the item. */
469
- public hide(animate = true) {
473
+ public hide(animate = true, keepKeyShape = false) {
474
+ this.cacheNotHiddenByItem = {};
470
475
  const func = () => {
471
476
  Object.keys(this.shapeMap).forEach((id) => {
477
+ if (keepKeyShape && id === 'keyShape') return;
472
478
  const shape = this.shapeMap[id];
473
- if (!this.visible && !shape.isVisible())
474
- this.cacheHiddenShape[id] = true;
479
+ if (!shape.isVisible()) {
480
+ this.cacheNotHiddenByItem[id] = true;
481
+ return;
482
+ }
475
483
  shape.hide();
484
+ this.cacheHiddenByItem[id] = true;
476
485
  });
477
486
  };
478
487
  Promise.all(this.stopAnimations()).then(() => {
479
- if (this.destroyed || !this.visible) return;
488
+ if (this.destroyed) return;
480
489
  const { animates = {} } = this.displayModel.data;
481
490
  if (animate && animates.hide?.length) {
482
491
  this.animations = this.runWithAnimates(
@@ -802,7 +811,7 @@ export default abstract class Item implements IItem {
802
811
  */
803
812
  public updateZoom(zoom) {
804
813
  this.zoom = zoom;
805
- this.renderExt.onZoom(this.shapeMap, zoom);
814
+ this.renderExt.onZoom(this.shapeMap, zoom, this.cacheHiddenByItem);
806
815
  }
807
816
 
808
817
  /** Destroy the item. */
package/src/item/node.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Circle, Group, Rect } from '@antv/g';
1
+ import { Group } from '@antv/g';
2
2
  import { clone } from '@antv/util';
3
3
  import { Point } from '../types/common';
4
4
  import { ComboDisplayModel, ComboModel, NodeModel } from '../types';
@@ -14,7 +14,6 @@ import {
14
14
  getRectIntersectByPoint,
15
15
  } from '../util/point';
16
16
  import { ComboModelData } from '../types/combo';
17
- import { isArraySame } from '../util/array';
18
17
  import Item from './item';
19
18
 
20
19
  interface IProps {
@@ -34,6 +33,7 @@ interface IProps {
34
33
  onframe?: Function;
35
34
  onfinish?: Function;
36
35
  type?: 'node' | 'combo';
36
+ delayFirstDraw?: boolean;
37
37
  }
38
38
  export default class Node extends Item {
39
39
  public type: 'node' | 'combo';
@@ -41,13 +41,15 @@ export default class Node extends Item {
41
41
  constructor(props: IProps) {
42
42
  super(props);
43
43
  this.init({ ...props, type: props.type || 'node' });
44
- this.draw(
45
- this.displayModel as NodeDisplayModel | ComboDisplayModel,
46
- undefined,
47
- undefined,
48
- !this.displayModel.data.disableAnimate,
49
- props.onfinish,
50
- );
44
+ if (!props.delayFirstDraw) {
45
+ this.draw(
46
+ this.displayModel as NodeDisplayModel | ComboDisplayModel,
47
+ undefined,
48
+ undefined,
49
+ !this.displayModel.data.disableAnimate,
50
+ props.onfinish,
51
+ );
52
+ }
51
53
  }
52
54
  public draw(
53
55
  displayModel: NodeDisplayModel | ComboDisplayModel,
@@ -76,7 +78,9 @@ export default class Node extends Item {
76
78
  const { animates, disableAnimate, x = 0, y = 0, z = 0 } = displayModel.data;
77
79
  if (firstRendering) {
78
80
  // first rendering, move the group
79
- group.setLocalPosition(x, y, z);
81
+ group.style.x = x;
82
+ group.style.y = y;
83
+ group.style.z = z;
80
84
  } else {
81
85
  // terminate previous animations
82
86
  this.stopAnimations();
@@ -192,23 +196,30 @@ export default class Node extends Item {
192
196
  return;
193
197
  }
194
198
  }
195
- group.setLocalPosition([position.x, position.y, position.z]);
199
+ group.style.x = position.x;
200
+ group.style.y = position.y;
201
+ group.style.z = position.z;
196
202
  onfinish(displayModel.id, !animate);
197
203
  }
198
204
 
199
205
  public clone(
200
206
  containerGroup: Group,
201
- onlyKeyShape?: boolean,
207
+ shapeIds?: string[],
202
208
  disableAnimate?: boolean,
203
209
  ) {
204
- if (onlyKeyShape) {
205
- const clonedKeyShape = this.shapeMap.keyShape.cloneNode();
206
- const pos = this.group.getPosition();
207
- const clonedGroup = new Group();
208
- clonedGroup.setPosition(pos);
209
- clonedGroup.appendChild(clonedKeyShape);
210
- containerGroup.appendChild(clonedGroup);
211
- return clonedGroup;
210
+ if (shapeIds?.length) {
211
+ const group = new Group();
212
+ shapeIds.forEach((shapeId) => {
213
+ if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
214
+ const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
215
+ // TODO: other animating attributes?
216
+ clonedKeyShape.style.opacity =
217
+ this.renderExt.mergedStyles[shapeId]?.opacity || 1;
218
+ group.appendChild(clonedKeyShape);
219
+ });
220
+ group.setPosition(this.group.getPosition());
221
+ containerGroup.appendChild(group);
222
+ return group;
212
223
  }
213
224
  const clonedModel = clone(this.model);
214
225
  clonedModel.data.disableAnimate = disableAnimate;
@@ -266,6 +277,7 @@ export default class Node extends Item {
266
277
  };
267
278
  });
268
279
 
280
+ console.log('anchorIdx', anchorIdx, anchorPositions, shapeType, innerPoint);
269
281
  if (anchorIdx !== undefined && anchorPositions[anchorIdx]) {
270
282
  return anchorPositions[anchorIdx];
271
283
  }
@@ -297,12 +309,13 @@ export default class Node extends Item {
297
309
  intersectPoint = innerPoint;
298
310
  break;
299
311
  default: {
312
+ // boundsCache can be removed here since `getBounds` has already done.
300
313
  intersectPoint = getRectIntersectByPoint(
301
314
  {
302
315
  x: keyShapeRenderBBox.min[0],
303
316
  y: keyShapeRenderBBox.min[1],
304
- width: keyShapeRenderBBox.max[0] - keyShapeRenderBBox.min[0],
305
- height: keyShapeRenderBBox.max[1] - keyShapeRenderBBox.min[1],
317
+ width: keyShapeWidth,
318
+ height: keyShapeHeight,
306
319
  },
307
320
  point,
308
321
  );
@@ -321,15 +334,16 @@ export default class Node extends Item {
321
334
  }
322
335
  if (!linkPoint) {
323
336
  // If the calculations above are all failed, return the data's position
324
- return { x, y };
337
+ return { x, y, z };
325
338
  }
339
+ if (!isNaN(z)) linkPoint.z = z;
326
340
  return linkPoint;
327
341
  }
328
342
 
329
343
  public getPosition(): Point {
330
344
  const initiated =
331
345
  this.shapeMap.keyShape && this.group.attributes.x !== undefined;
332
- if (initiated) {
346
+ if (initiated && this.renderExt.dimensions !== 3) {
333
347
  const { center } = this.shapeMap.keyShape.getRenderBounds();
334
348
  return { x: center[0], y: center[1], z: center[2] };
335
349
  }