@antv/g6 5.0.0-beta.1 → 5.0.0-beta.11

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 (409) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/constant/shape.d.ts +4 -1
  3. package/esm/constant/shape.js.map +1 -1
  4. package/esm/index.d.ts +22 -7
  5. package/esm/index.js +3 -2
  6. package/esm/index.js.map +1 -1
  7. package/esm/item/combo.d.ts +1 -1
  8. package/esm/item/combo.js +16 -9
  9. package/esm/item/combo.js.map +1 -1
  10. package/esm/item/edge.d.ts +20 -3
  11. package/esm/item/edge.js +99 -43
  12. package/esm/item/edge.js.map +1 -1
  13. package/esm/item/item.d.ts +3 -2
  14. package/esm/item/item.js +21 -11
  15. package/esm/item/item.js.map +1 -1
  16. package/esm/item/node.d.ts +2 -1
  17. package/esm/item/node.js +32 -16
  18. package/esm/item/node.js.map +1 -1
  19. package/esm/runtime/controller/data.d.ts +7 -10
  20. package/esm/runtime/controller/data.js +125 -281
  21. package/esm/runtime/controller/data.js.map +1 -1
  22. package/esm/runtime/controller/item.d.ts +1 -0
  23. package/esm/runtime/controller/item.js +267 -151
  24. package/esm/runtime/controller/item.js.map +1 -1
  25. package/esm/runtime/graph.d.ts +103 -23
  26. package/esm/runtime/graph.js +460 -88
  27. package/esm/runtime/graph.js.map +1 -1
  28. package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
  29. package/esm/stdlib/behavior/activate-relations.js +8 -8
  30. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  31. package/esm/stdlib/behavior/brush-select.js +1 -2
  32. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  33. package/esm/stdlib/behavior/click-select.js +1 -1
  34. package/esm/stdlib/behavior/click-select.js.map +1 -1
  35. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  36. package/esm/stdlib/behavior/create-edge.js +207 -0
  37. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  38. package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
  39. package/esm/stdlib/behavior/drag-canvas.js +59 -28
  40. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  41. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  42. package/esm/stdlib/behavior/drag-combo.js +43 -32
  43. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  44. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  45. package/esm/stdlib/behavior/drag-node.js +76 -63
  46. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  47. package/esm/stdlib/behavior/index.d.ts +3 -0
  48. package/esm/stdlib/behavior/index.js +3 -0
  49. package/esm/stdlib/behavior/index.js.map +1 -1
  50. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  51. package/esm/stdlib/behavior/lasso-select.js +1 -2
  52. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  53. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  54. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  55. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  56. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  57. package/esm/stdlib/behavior/shortcuts-call.js +80 -0
  58. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  59. package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
  60. package/esm/stdlib/behavior/zoom-canvas.js +55 -24
  61. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  62. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  63. package/esm/stdlib/data/mapNodeSize.js +2 -2
  64. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  65. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  66. package/esm/stdlib/data/transformV4Data.js +2 -2
  67. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  68. package/esm/stdlib/data/validateData.d.ts +2 -2
  69. package/esm/stdlib/data/validateData.js +9 -9
  70. package/esm/stdlib/data/validateData.js.map +1 -1
  71. package/esm/stdlib/index.d.ts +16 -6
  72. package/esm/stdlib/index.js +20 -10
  73. package/esm/stdlib/index.js.map +1 -1
  74. package/esm/stdlib/item/edge/base.d.ts +10 -1
  75. package/esm/stdlib/item/edge/base.js +20 -13
  76. package/esm/stdlib/item/edge/base.js.map +1 -1
  77. package/esm/stdlib/item/edge/line.js +5 -2
  78. package/esm/stdlib/item/edge/line.js.map +1 -1
  79. package/esm/stdlib/item/edge/polyline.d.ts +3 -2
  80. package/esm/stdlib/item/edge/polyline.js +3 -3
  81. package/esm/stdlib/item/edge/polyline.js.map +1 -1
  82. package/esm/stdlib/item/node/base.d.ts +1 -1
  83. package/esm/stdlib/item/node/base.js +18 -26
  84. package/esm/stdlib/item/node/base.js.map +1 -1
  85. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  86. package/esm/stdlib/item/node/base3d.js +1 -0
  87. package/esm/stdlib/item/node/base3d.js.map +1 -1
  88. package/esm/stdlib/item/node/diamond.js +1 -1
  89. package/esm/stdlib/item/node/ellipse.js +2 -2
  90. package/esm/stdlib/item/node/hexagon.js +12 -5
  91. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  92. package/esm/stdlib/item/node/image.d.ts +40 -0
  93. package/esm/stdlib/item/node/image.js +110 -0
  94. package/esm/stdlib/item/node/image.js.map +1 -0
  95. package/esm/stdlib/item/node/index.d.ts +1 -0
  96. package/esm/stdlib/item/node/index.js +1 -0
  97. package/esm/stdlib/item/node/index.js.map +1 -1
  98. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  99. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  100. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  101. package/esm/stdlib/plugin/history/index.js +14 -14
  102. package/esm/stdlib/plugin/history/index.js.map +1 -1
  103. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  104. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  105. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  106. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  107. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  108. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  109. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  110. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  111. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  112. package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
  113. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  114. package/esm/stdlib/plugin/index.d.ts +2 -0
  115. package/esm/stdlib/plugin/index.js +2 -0
  116. package/esm/stdlib/plugin/index.js.map +1 -1
  117. package/esm/stdlib/plugin/legend/index.js +1 -1
  118. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  119. package/esm/stdlib/plugin/map/index.d.ts +118 -0
  120. package/esm/stdlib/plugin/map/index.js +683 -0
  121. package/esm/stdlib/plugin/map/index.js.map +1 -0
  122. package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
  123. package/esm/stdlib/plugin/minimap/index.js +116 -9
  124. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  125. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  126. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  127. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  128. package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
  129. package/esm/stdlib/plugin/timebar/index.js +303 -0
  130. package/esm/stdlib/plugin/timebar/index.js.map +1 -0
  131. package/esm/stdlib/plugin/toolbar/index.js +1 -1
  132. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  133. package/esm/stdlib/plugin/types.d.ts +2 -0
  134. package/esm/stdlib/theme/dark.js +42 -2
  135. package/esm/stdlib/theme/dark.js.map +1 -1
  136. package/esm/stdlib/theme/light.js +4 -4
  137. package/esm/types/common.d.ts +1 -0
  138. package/esm/types/event.d.ts +1 -0
  139. package/esm/types/graph.d.ts +48 -22
  140. package/esm/types/hook.d.ts +22 -2
  141. package/esm/types/item.d.ts +6 -0
  142. package/esm/types/item.js.map +1 -1
  143. package/esm/types/spec.d.ts +19 -3
  144. package/esm/types/view.d.ts +5 -0
  145. package/esm/util/bbox.d.ts +16 -1
  146. package/esm/util/bbox.js +29 -0
  147. package/esm/util/bbox.js.map +1 -1
  148. package/esm/util/canvas.d.ts +2 -2
  149. package/esm/util/canvas.js +5 -11
  150. package/esm/util/canvas.js.map +1 -1
  151. package/esm/util/event.d.ts +3 -1
  152. package/esm/util/event.js +8 -1
  153. package/esm/util/event.js.map +1 -1
  154. package/esm/util/item.d.ts +16 -1
  155. package/esm/util/item.js +31 -8
  156. package/esm/util/item.js.map +1 -1
  157. package/esm/util/layout.d.ts +11 -0
  158. package/esm/util/layout.js +45 -0
  159. package/esm/util/layout.js.map +1 -1
  160. package/esm/util/point.js +9 -2
  161. package/esm/util/point.js.map +1 -1
  162. package/esm/util/router.d.ts +4 -3
  163. package/esm/util/router.js +8 -5
  164. package/esm/util/router.js.map +1 -1
  165. package/esm/util/shape.d.ts +3 -3
  166. package/esm/util/shape.js +8 -12
  167. package/esm/util/shape.js.map +1 -1
  168. package/esm/util/warn.d.ts +14 -0
  169. package/esm/util/warn.js +4 -0
  170. package/esm/util/warn.js.map +1 -0
  171. package/lib/constant/shape.d.ts +4 -1
  172. package/lib/constant/shape.js.map +1 -1
  173. package/lib/index.d.ts +22 -7
  174. package/lib/index.js +4 -2
  175. package/lib/index.js.map +1 -1
  176. package/lib/item/combo.d.ts +1 -1
  177. package/lib/item/combo.js +16 -9
  178. package/lib/item/combo.js.map +1 -1
  179. package/lib/item/edge.d.ts +20 -3
  180. package/lib/item/edge.js +98 -42
  181. package/lib/item/edge.js.map +1 -1
  182. package/lib/item/item.d.ts +3 -2
  183. package/lib/item/item.js +21 -11
  184. package/lib/item/item.js.map +1 -1
  185. package/lib/item/node.d.ts +2 -1
  186. package/lib/item/node.js +32 -16
  187. package/lib/item/node.js.map +1 -1
  188. package/lib/runtime/controller/data.d.ts +7 -10
  189. package/lib/runtime/controller/data.js +125 -281
  190. package/lib/runtime/controller/data.js.map +1 -1
  191. package/lib/runtime/controller/item.d.ts +1 -0
  192. package/lib/runtime/controller/item.js +266 -150
  193. package/lib/runtime/controller/item.js.map +1 -1
  194. package/lib/runtime/graph.d.ts +103 -23
  195. package/lib/runtime/graph.js +460 -88
  196. package/lib/runtime/graph.js.map +1 -1
  197. package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
  198. package/lib/stdlib/behavior/activate-relations.js +8 -8
  199. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  200. package/lib/stdlib/behavior/brush-select.js +1 -2
  201. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  202. package/lib/stdlib/behavior/click-select.js +1 -1
  203. package/lib/stdlib/behavior/click-select.js.map +1 -1
  204. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  205. package/lib/stdlib/behavior/create-edge.js +211 -0
  206. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  207. package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
  208. package/lib/stdlib/behavior/drag-canvas.js +59 -28
  209. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  210. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  211. package/lib/stdlib/behavior/drag-combo.js +43 -32
  212. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  213. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  214. package/lib/stdlib/behavior/drag-node.js +76 -63
  215. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  216. package/lib/stdlib/behavior/index.d.ts +3 -0
  217. package/lib/stdlib/behavior/index.js +3 -0
  218. package/lib/stdlib/behavior/index.js.map +1 -1
  219. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  220. package/lib/stdlib/behavior/lasso-select.js +1 -2
  221. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  222. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  223. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  224. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  225. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  226. package/lib/stdlib/behavior/shortcuts-call.js +84 -0
  227. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  228. package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
  229. package/lib/stdlib/behavior/zoom-canvas.js +55 -24
  230. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  231. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  232. package/lib/stdlib/data/mapNodeSize.js +2 -2
  233. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  234. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  235. package/lib/stdlib/data/transformV4Data.js +2 -2
  236. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  237. package/lib/stdlib/data/validateData.d.ts +2 -2
  238. package/lib/stdlib/data/validateData.js +9 -9
  239. package/lib/stdlib/data/validateData.js.map +1 -1
  240. package/lib/stdlib/index.d.ts +16 -6
  241. package/lib/stdlib/index.js +20 -10
  242. package/lib/stdlib/index.js.map +1 -1
  243. package/lib/stdlib/item/edge/base.d.ts +10 -1
  244. package/lib/stdlib/item/edge/base.js +20 -13
  245. package/lib/stdlib/item/edge/base.js.map +1 -1
  246. package/lib/stdlib/item/edge/line.js +5 -2
  247. package/lib/stdlib/item/edge/line.js.map +1 -1
  248. package/lib/stdlib/item/edge/polyline.d.ts +3 -2
  249. package/lib/stdlib/item/edge/polyline.js +3 -3
  250. package/lib/stdlib/item/edge/polyline.js.map +1 -1
  251. package/lib/stdlib/item/node/base.d.ts +1 -1
  252. package/lib/stdlib/item/node/base.js +18 -26
  253. package/lib/stdlib/item/node/base.js.map +1 -1
  254. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  255. package/lib/stdlib/item/node/base3d.js +1 -0
  256. package/lib/stdlib/item/node/base3d.js.map +1 -1
  257. package/lib/stdlib/item/node/diamond.js +1 -1
  258. package/lib/stdlib/item/node/ellipse.js +2 -2
  259. package/lib/stdlib/item/node/hexagon.js +12 -5
  260. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  261. package/lib/stdlib/item/node/image.d.ts +40 -0
  262. package/lib/stdlib/item/node/image.js +114 -0
  263. package/lib/stdlib/item/node/image.js.map +1 -0
  264. package/lib/stdlib/item/node/index.d.ts +1 -0
  265. package/lib/stdlib/item/node/index.js +1 -0
  266. package/lib/stdlib/item/node/index.js.map +1 -1
  267. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  268. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  269. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  270. package/lib/stdlib/plugin/history/index.js +14 -14
  271. package/lib/stdlib/plugin/history/index.js.map +1 -1
  272. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  273. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  274. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  275. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  276. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  277. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  278. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  279. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  280. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  281. package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
  282. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  283. package/lib/stdlib/plugin/index.d.ts +2 -0
  284. package/lib/stdlib/plugin/index.js +2 -0
  285. package/lib/stdlib/plugin/index.js.map +1 -1
  286. package/lib/stdlib/plugin/legend/index.js +1 -1
  287. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  288. package/lib/stdlib/plugin/map/index.d.ts +118 -0
  289. package/lib/stdlib/plugin/map/index.js +687 -0
  290. package/lib/stdlib/plugin/map/index.js.map +1 -0
  291. package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
  292. package/lib/stdlib/plugin/minimap/index.js +116 -9
  293. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  294. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  295. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  296. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  297. package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
  298. package/lib/stdlib/plugin/timebar/index.js +307 -0
  299. package/lib/stdlib/plugin/timebar/index.js.map +1 -0
  300. package/lib/stdlib/plugin/toolbar/index.js +1 -1
  301. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  302. package/lib/stdlib/plugin/types.d.ts +2 -0
  303. package/lib/stdlib/theme/dark.js +42 -2
  304. package/lib/stdlib/theme/dark.js.map +1 -1
  305. package/lib/stdlib/theme/light.js +4 -4
  306. package/lib/types/common.d.ts +1 -0
  307. package/lib/types/event.d.ts +1 -0
  308. package/lib/types/graph.d.ts +48 -22
  309. package/lib/types/hook.d.ts +22 -2
  310. package/lib/types/item.d.ts +6 -0
  311. package/lib/types/item.js.map +1 -1
  312. package/lib/types/spec.d.ts +19 -3
  313. package/lib/types/view.d.ts +5 -0
  314. package/lib/util/bbox.d.ts +16 -1
  315. package/lib/util/bbox.js +32 -1
  316. package/lib/util/bbox.js.map +1 -1
  317. package/lib/util/canvas.d.ts +2 -2
  318. package/lib/util/canvas.js +5 -11
  319. package/lib/util/canvas.js.map +1 -1
  320. package/lib/util/event.d.ts +3 -1
  321. package/lib/util/event.js +8 -1
  322. package/lib/util/event.js.map +1 -1
  323. package/lib/util/item.d.ts +16 -1
  324. package/lib/util/item.js +33 -9
  325. package/lib/util/item.js.map +1 -1
  326. package/lib/util/layout.d.ts +11 -0
  327. package/lib/util/layout.js +47 -1
  328. package/lib/util/layout.js.map +1 -1
  329. package/lib/util/point.js +9 -2
  330. package/lib/util/point.js.map +1 -1
  331. package/lib/util/router.d.ts +4 -3
  332. package/lib/util/router.js +8 -5
  333. package/lib/util/router.js.map +1 -1
  334. package/lib/util/shape.d.ts +3 -3
  335. package/lib/util/shape.js +8 -12
  336. package/lib/util/shape.js.map +1 -1
  337. package/lib/util/warn.d.ts +14 -0
  338. package/lib/util/warn.js +8 -0
  339. package/lib/util/warn.js.map +1 -0
  340. package/package.json +10 -10
  341. package/src/constant/shape.ts +2 -1
  342. package/src/index.ts +4 -2
  343. package/src/item/combo.ts +14 -9
  344. package/src/item/edge.ts +131 -57
  345. package/src/item/item.ts +24 -15
  346. package/src/item/node.ts +37 -24
  347. package/src/runtime/controller/data.ts +140 -339
  348. package/src/runtime/controller/item.ts +236 -72
  349. package/src/runtime/graph.ts +592 -96
  350. package/src/stdlib/behavior/activate-relations.ts +8 -8
  351. package/src/stdlib/behavior/brush-select.ts +4 -2
  352. package/src/stdlib/behavior/click-select.ts +1 -1
  353. package/src/stdlib/behavior/create-edge.ts +296 -0
  354. package/src/stdlib/behavior/drag-canvas.ts +78 -29
  355. package/src/stdlib/behavior/drag-combo.ts +10 -10
  356. package/src/stdlib/behavior/drag-node.ts +18 -18
  357. package/src/stdlib/behavior/index.ts +3 -0
  358. package/src/stdlib/behavior/lasso-select.ts +5 -3
  359. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  360. package/src/stdlib/behavior/shortcuts-call.ts +120 -0
  361. package/src/stdlib/behavior/zoom-canvas.ts +72 -25
  362. package/src/stdlib/data/mapNodeSize.ts +2 -2
  363. package/src/stdlib/data/transformV4Data.ts +2 -2
  364. package/src/stdlib/data/validateData.ts +9 -9
  365. package/src/stdlib/index.ts +33 -9
  366. package/src/stdlib/item/edge/base.ts +26 -13
  367. package/src/stdlib/item/edge/line.ts +8 -2
  368. package/src/stdlib/item/edge/polyline.ts +7 -5
  369. package/src/stdlib/item/node/base.ts +24 -29
  370. package/src/stdlib/item/node/base3d.ts +1 -0
  371. package/src/stdlib/item/node/diamond.ts +1 -1
  372. package/src/stdlib/item/node/ellipse.ts +2 -2
  373. package/src/stdlib/item/node/hexagon.ts +14 -6
  374. package/src/stdlib/item/node/image.ts +190 -0
  375. package/src/stdlib/item/node/index.ts +1 -0
  376. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  377. package/src/stdlib/plugin/history/index.ts +14 -14
  378. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  379. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  380. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  381. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  382. package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
  383. package/src/stdlib/plugin/index.ts +2 -0
  384. package/src/stdlib/plugin/legend/index.ts +1 -1
  385. package/src/stdlib/plugin/map/index.ts +808 -0
  386. package/src/stdlib/plugin/minimap/index.ts +120 -10
  387. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  388. package/src/stdlib/plugin/timebar/index.ts +473 -0
  389. package/src/stdlib/plugin/toolbar/index.ts +1 -1
  390. package/src/stdlib/plugin/types.ts +2 -0
  391. package/src/stdlib/theme/dark.ts +66 -2
  392. package/src/stdlib/theme/light.ts +4 -4
  393. package/src/types/common.ts +1 -0
  394. package/src/types/event.ts +1 -0
  395. package/src/types/graph.ts +59 -25
  396. package/src/types/hook.ts +22 -2
  397. package/src/types/item.ts +10 -0
  398. package/src/types/spec.ts +22 -3
  399. package/src/types/view.ts +8 -3
  400. package/src/util/bbox.ts +38 -1
  401. package/src/util/canvas.ts +5 -5
  402. package/src/util/event.ts +14 -1
  403. package/src/util/item.ts +65 -28
  404. package/src/util/layout.ts +45 -0
  405. package/src/util/point.ts +8 -3
  406. package/src/util/router.ts +15 -6
  407. package/src/util/shape.ts +16 -14
  408. package/src/util/warn.ts +20 -0
  409. package/src/api-doc/readme.md +0 -59
@@ -1,4 +1,5 @@
1
- import { ID, IG6GraphEvent } from 'types';
1
+ import { isNumber } from '@antv/util';
2
+ import { ID, IG6GraphEvent } from '../../types';
2
3
  import { Behavior } from '../../types/behavior';
3
4
 
4
5
  const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
@@ -56,7 +57,7 @@ export interface ZoomCanvasOptions {
56
57
  }
57
58
 
58
59
  const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
59
- enableOptimize: false,
60
+ enableOptimize: undefined,
60
61
  triggerOnItems: true,
61
62
  sensitivity: 2,
62
63
  trigger: 'wheel',
@@ -75,6 +76,7 @@ export class ZoomCanvas extends Behavior {
75
76
  private hiddenEdgeIds: ID[];
76
77
  private hiddenNodeIds: ID[];
77
78
  private zoomTimer: ReturnType<typeof setTimeout>;
79
+ private tileRequestId?: number;
78
80
 
79
81
  constructor(options: Partial<ZoomCanvasOptions>) {
80
82
  const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
@@ -114,43 +116,88 @@ export class ZoomCanvas extends Behavior {
114
116
 
115
117
  private hideShapes() {
116
118
  const { graph } = this;
117
- if (this.options.enableOptimize) {
119
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
120
+ graph.getSpecification().optimize || {};
121
+ const optimize =
122
+ this.options.enableOptimize !== undefined
123
+ ? this.options.enableOptimize
124
+ : graphBehaviorOptimize;
125
+ const shouldOptimze = isNumber(optimize)
126
+ ? graph.getAllNodesData().length > optimize
127
+ : optimize;
128
+ if (shouldOptimze) {
118
129
  this.hiddenEdgeIds = graph
119
130
  .getAllEdgesData()
120
131
  .map((edge) => edge.id)
121
132
  .filter((id) => graph.getItemVisible(id) === true);
122
- // TODO
123
- graph.hideItem(this.hiddenEdgeIds, false);
124
133
  this.hiddenNodeIds = graph
125
134
  .getAllNodesData()
126
135
  .map((node) => node.id)
127
136
  .filter((id) => graph.getItemVisible(id) === true);
128
- // draw node's keyShapes on transient, and then hidden the real nodes;
129
- // this.hiddenNodeIds.forEach((id) => {
130
- // graph.drawTransient('node', id, {
131
- // onlyDrawKeyShape: true,
132
- // });
133
- // });
134
- // graph.hideItem(this.hiddenNodeIds, false);
137
+
138
+ const hiddenIds = [...this.hiddenNodeIds];
139
+ const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
140
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
141
+ hiddenIds.slice(
142
+ i * tileBehaviorSize,
143
+ i * tileBehaviorSize + tileBehaviorSize,
144
+ ),
145
+ );
146
+ const update = () => {
147
+ if (!sections.length && this.tileRequestId) {
148
+ cancelAnimationFrame(this.tileRequestId);
149
+ this.tileRequestId = undefined;
150
+ return;
151
+ }
152
+ const section = sections.shift();
153
+ graph.startHistoryBatch();
154
+ graph.hideItem(section, false, true);
155
+ graph.stopHistoryBatch();
156
+ this.tileRequestId = requestAnimationFrame(update);
157
+ };
158
+ this.tileRequestId = requestAnimationFrame(update);
135
159
  }
136
160
  }
137
161
 
138
162
  private endZoom() {
139
- const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
140
- const { enableOptimize } = this.options;
163
+ const { graph, hiddenEdgeIds = [], hiddenNodeIds } = this;
164
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
165
+ graph.getSpecification().optimize || {};
166
+ const optimize =
167
+ this.options.enableOptimize !== undefined
168
+ ? this.options.enableOptimize
169
+ : graphBehaviorOptimize;
170
+ const shouldOptimze = isNumber(optimize)
171
+ ? graph.getAllNodesData().length > optimize
172
+ : optimize;
141
173
  this.zooming = false;
142
- if (enableOptimize) {
143
- // restore hidden items
144
- if (hiddenEdgeIds) {
145
- graph.showItem(hiddenEdgeIds, false);
174
+ if (shouldOptimze) {
175
+ if (this.tileRequestId) {
176
+ cancelAnimationFrame(this.tileRequestId);
177
+ this.tileRequestId = undefined;
178
+ }
179
+ if (hiddenNodeIds) {
180
+ const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
181
+ const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
182
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
183
+ hiddenIds.slice(
184
+ i * tileBehaviorSize,
185
+ i * tileBehaviorSize + tileBehaviorSize,
186
+ ),
187
+ );
188
+ const update = () => {
189
+ if (!sections.length && this.tileRequestId) {
190
+ cancelAnimationFrame(this.tileRequestId);
191
+ this.tileRequestId = undefined;
192
+ return;
193
+ }
194
+ graph.executeWithNoStack(() => {
195
+ graph.showItem(sections.shift(), false);
196
+ });
197
+ this.tileRequestId = requestAnimationFrame(update);
198
+ };
199
+ this.tileRequestId = requestAnimationFrame(update);
146
200
  }
147
- // TODO
148
- // if (hiddenNodeIds) {
149
- // hiddenNodeIds.forEach((id) => {
150
- // graph.drawTransient('node', id, { action: 'remove' });
151
- // });
152
- // graph.showItem(hiddenNodeIds, false);
153
- // }
154
201
  }
155
202
  this.hiddenEdgeIds = [];
156
203
  this.hiddenNodeIds = [];
@@ -9,7 +9,7 @@ import {
9
9
  /**
10
10
  * Validate and format the graph data.
11
11
  * @param data input user data.
12
- * @param userGraphCore the graph core stores the previous data.
12
+ * @param graphCore the graph core stores the previous data.
13
13
  * @returns formatted data.
14
14
  */
15
15
  export const MapNodeSize = (
@@ -18,7 +18,7 @@ export const MapNodeSize = (
18
18
  field?: string;
19
19
  range?: [number, number];
20
20
  } = {},
21
- userGraphCore?: GraphCore,
21
+ graphCore?: GraphCore,
22
22
  ): GraphData => {
23
23
  const { field, range = [8, 40] } = options;
24
24
  if (!field) return data;
@@ -10,13 +10,13 @@ import {
10
10
  /**
11
11
  * Validate and format the graph data.
12
12
  * @param data input user data.
13
- * @param userGraphCore the graph core stores the previous data.
13
+ * @param graphCore the graph core stores the previous data.
14
14
  * @returns formatted data.
15
15
  */
16
16
  export const TransformV4Data = (
17
17
  data: GraphData,
18
18
  options = {},
19
- userGraphCore?: GraphCore,
19
+ graphCore?: GraphCore,
20
20
  ): GraphData => {
21
21
  const { nodes = [], edges = [], combos = [] } = data;
22
22
  const formattedNodes = nodes.map((node: any) => {
@@ -10,13 +10,13 @@ import {
10
10
  /**
11
11
  * Validate and format the graph data.
12
12
  * @param data input user data.
13
- * @param userGraphCore the graph core stores the previous data.
13
+ * @param graphCore the graph core stores the previous data.
14
14
  * @returns formatted data.
15
15
  */
16
16
  export const ValidateData = (
17
17
  data: GraphData,
18
18
  options = {},
19
- userGraphCore?: GraphCore,
19
+ graphCore?: GraphCore,
20
20
  ): GraphData => {
21
21
  const { nodes, edges, combos } = data;
22
22
  const idMap = new Map();
@@ -64,7 +64,7 @@ export const ValidateData = (
64
64
  if (
65
65
  parentId !== undefined &&
66
66
  !comboIdMap.has(parentId) &&
67
- (!userGraphCore || !userGraphCore.hasNode(parentId))
67
+ (!graphCore || !graphCore.hasNode(parentId))
68
68
  ) {
69
69
  console.error(
70
70
  `The parentId of combo with id ${combo.id} will be removed since it is not exist in combos.`,
@@ -80,9 +80,9 @@ export const ValidateData = (
80
80
  if (
81
81
  parentId !== undefined &&
82
82
  !comboIdMap.has(parentId) &&
83
- (!userGraphCore || !userGraphCore.hasNode(parentId))
83
+ (!graphCore || !graphCore.hasNode(parentId))
84
84
  ) {
85
- // TODO: parentId is a node in userGraphCore
85
+ // TODO: parentId is a node in graphCore
86
86
  console.error(
87
87
  `The parentId of node with id ${node.id} will be removed since it is not exist in combos.`,
88
88
  );
@@ -100,8 +100,8 @@ export const ValidateData = (
100
100
  let { source, target } = edge;
101
101
  if (!idAndDataCheck(edge, 'edge', true)) return false;
102
102
 
103
- if (userGraphCore?.hasEdge(id)) {
104
- const existEdge = userGraphCore?.getEdge(id);
103
+ if (graphCore?.hasEdge(id)) {
104
+ const existEdge = graphCore?.getEdge(id);
105
105
  if (source === undefined) source = existEdge.source;
106
106
  if (target === undefined) target = existEdge.target;
107
107
  }
@@ -121,7 +121,7 @@ export const ValidateData = (
121
121
  if (
122
122
  !nodeIdMap.has(source) &&
123
123
  !comboIdMap.has(source) &&
124
- (!userGraphCore || !userGraphCore.hasNode(source))
124
+ (!graphCore || !graphCore.hasNode(source))
125
125
  ) {
126
126
  console.error(
127
127
  `The edge with id ${id} will be ignored since its source ${source} is not existed in nodes and combos.`,
@@ -131,7 +131,7 @@ export const ValidateData = (
131
131
  if (
132
132
  !nodeIdMap.has(target) &&
133
133
  !comboIdMap.has(target) &&
134
- (!userGraphCore || !userGraphCore.hasNode(target))
134
+ (!graphCore || !graphCore.hasNode(target))
135
135
  ) {
136
136
  console.error(
137
137
  `The edge with id ${id} will be ignored since its target ${target} is not existed in nodes and combos.`,
@@ -31,6 +31,7 @@ const {
31
31
  TriangleNode,
32
32
  EllipseNode,
33
33
  ModelRectNode,
34
+ ImageNode,
34
35
  } = Nodes;
35
36
 
36
37
  const {
@@ -60,9 +61,22 @@ const {
60
61
  DragNode,
61
62
  DragCombo,
62
63
  ClickSelect,
64
+ CreateEdge,
65
+ ShortcutsCall,
66
+ ScrollCanvas,
63
67
  } = Behaviors;
64
- const { History, Tooltip, Minimap, Grid, Menu, Fisheye, Legend, Toolbar } =
65
- Plugins;
68
+ const {
69
+ History,
70
+ Tooltip,
71
+ Minimap,
72
+ Grid,
73
+ Menu,
74
+ Fisheye,
75
+ Legend,
76
+ Toolbar,
77
+ Timebar,
78
+ Snapline,
79
+ } = Plugins;
66
80
 
67
81
  const {
68
82
  ForceLayout,
@@ -81,6 +95,7 @@ const {
81
95
 
82
96
  import lassoSelector from './selector/lasso';
83
97
  import rectSelector from './selector/rect';
98
+ import Hull from './plugin/hull';
84
99
 
85
100
  const stdLib = {
86
101
  transforms: {
@@ -108,6 +123,7 @@ const stdLib = {
108
123
  'zoom-canvas': ZoomCanvas,
109
124
  'drag-node': DragNode,
110
125
  'drag-combo': DragCombo,
126
+ 'create-edge': CreateEdge,
111
127
  'collapse-expand-combo': CollapseExpandCombo,
112
128
  'collapse-expand-tree': CollapseExpandTree,
113
129
  'click-select': ClickSelect,
@@ -118,9 +134,11 @@ const stdLib = {
118
134
  nodes: {
119
135
  'circle-node': CircleNode,
120
136
  'rect-node': RectNode,
137
+ 'image-node': ImageNode,
121
138
  },
122
139
  edges: {
123
140
  'line-edge': LineEdge,
141
+ 'loop-edge': LoopEdge,
124
142
  },
125
143
  combos: {
126
144
  'circle-combo': CircleCombo,
@@ -193,13 +211,13 @@ const Extensions = {
193
211
  ValidateData,
194
212
  TransformV4Data,
195
213
  MapNodeSize,
196
- //themes
214
+ // themes
197
215
  LightTheme,
198
216
  DarkTheme,
199
- //themeSolvers
217
+ // themeSolvers
200
218
  SpecThemeSolver,
201
219
  SubjectThemeSolver,
202
- //layout
220
+ // layout
203
221
  ForceLayout,
204
222
  GridLayout,
205
223
  CircularLayout,
@@ -212,12 +230,12 @@ const Extensions = {
212
230
  ForceAtlas2Layout,
213
231
  DagreLayout,
214
232
  ComboCombinedLayout,
215
- //Hierarchy
233
+ // Hierarchy
216
234
  compactBox,
217
235
  dendrogram,
218
236
  indented,
219
237
  mindmap,
220
- //nodes
238
+ // nodes
221
239
  CircleNode,
222
240
  RectNode,
223
241
  DiamondNode,
@@ -239,7 +257,7 @@ const Extensions = {
239
257
  // combos
240
258
  CircleCombo,
241
259
  RectCombo,
242
- //behaviors
260
+ // behaviors
243
261
  BaseBehavior,
244
262
  ActivateRelations,
245
263
  BrushSelect,
@@ -255,7 +273,10 @@ const Extensions = {
255
273
  CollapseExpandCombo,
256
274
  DragNode,
257
275
  DragCombo,
258
- //plugins
276
+ CreateEdge,
277
+ ShortcutsCall,
278
+ ScrollCanvas,
279
+ // plugins
259
280
  BasePlugin,
260
281
  History,
261
282
  Toolbar,
@@ -265,6 +286,9 @@ const Extensions = {
265
286
  Menu,
266
287
  Fisheye,
267
288
  Legend,
289
+ Timebar,
290
+ Hull,
291
+ Snapline,
268
292
  };
269
293
 
270
294
  export default registery;
@@ -534,6 +534,15 @@ export abstract class BaseEdge {
534
534
  );
535
535
  }
536
536
 
537
+ public drawOtherShapes(
538
+ model: EdgeDisplayModel,
539
+ shapeMap: EdgeShapeMap,
540
+ diffData?: { previous: EdgeModelData; current: EdgeModelData },
541
+ diffState?: { previous: State[]; current: State[] },
542
+ ): { [id: string]: DisplayObject } {
543
+ return {};
544
+ }
545
+
537
546
  /**
538
547
  * The listener for graph zooming.
539
548
  * 1. show / hide some shapes while zoom level changed;
@@ -541,7 +550,11 @@ export abstract class BaseEdge {
541
550
  * @param shapeMap The shape map that contains all of the elements to show on the edge.
542
551
  * @param zoom The zoom level of the graph.
543
552
  */
544
- public onZoom = (shapeMap: EdgeShapeMap, zoom: number) => {
553
+ public onZoom = (
554
+ shapeMap: EdgeShapeMap,
555
+ zoom: number,
556
+ cacheHiddenShape = {},
557
+ ) => {
545
558
  // balance the size for label, badges
546
559
  this.balanceShapeSize(shapeMap, zoom);
547
560
 
@@ -565,7 +578,10 @@ export abstract class BaseEdge {
565
578
  // zoomLevel changed, from higher to lower, hide something
566
579
  if (firstRender) {
567
580
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
568
- levelShapes[String(i)]?.forEach((id) => shapeMap[id]?.hide());
581
+ levelShapes[String(i)]?.forEach((id) => {
582
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
583
+ shapeMap[id]?.hide();
584
+ });
569
585
  }
570
586
  } else {
571
587
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
@@ -577,7 +593,8 @@ export abstract class BaseEdge {
577
593
  } else if (currentLevel > previousLevel) {
578
594
  // zoomLevel changed, from lower to higher, show something
579
595
  for (let i = currentLevel; i >= minLevel; i--) {
580
- levelShapes[String(i)]?.forEach((id) =>
596
+ levelShapes[String(i)]?.forEach((id) => {
597
+ if (hiddenShape[id]) return;
581
598
  fadeIn(
582
599
  id,
583
600
  shapeMap[id],
@@ -585,8 +602,8 @@ export abstract class BaseEdge {
585
602
  this.mergedStyles[id.replace('Background', '')],
586
603
  hiddenShape,
587
604
  animateConfig,
588
- ),
589
- );
605
+ );
606
+ });
590
607
  }
591
608
  }
592
609
 
@@ -669,12 +686,9 @@ export abstract class BaseEdge {
669
686
  resultStyle[`${markerField}Offset`] = 0;
670
687
  return;
671
688
  }
672
- let arrowStyle = {} as ArrowStyle;
673
- if (isBoolean(arrowConfig)) {
674
- arrowStyle = { ...DEFAULT_ARROW_CONFIG } as ArrowStyle;
675
- } else {
676
- arrowStyle = arrowConfig;
677
- }
689
+ const arrowStyle = isBoolean(arrowConfig)
690
+ ? ({ ...DEFAULT_ARROW_CONFIG } as ArrowStyle)
691
+ : arrowConfig;
678
692
  const {
679
693
  type = 'triangle',
680
694
  width = 10,
@@ -683,14 +697,13 @@ export abstract class BaseEdge {
683
697
  offset = 0,
684
698
  ...others
685
699
  } = arrowStyle;
686
- const path = propPath ? propPath : getArrowPath(type, width, height);
687
700
  resultStyle[markerField] = this.upsertShape(
688
701
  'path',
689
702
  `${markerField}Shape`,
690
703
  {
691
704
  ...bodyStyle,
692
705
  fill: type === 'simple' ? '' : bodyStyle.stroke,
693
- path,
706
+ path: propPath || getArrowPath(type, width, height),
694
707
  anchor: '0.5 0.5',
695
708
  transformOrigin: 'center',
696
709
  ...others,
@@ -35,7 +35,7 @@ export class LineEdge extends BaseEdge {
35
35
  ): EdgeShapeMap {
36
36
  const { data = {} } = model;
37
37
 
38
- const shapes: EdgeShapeMap = { keyShape: undefined };
38
+ let shapes: EdgeShapeMap = { keyShape: undefined };
39
39
 
40
40
  shapes.keyShape = this.drawKeyShape(
41
41
  model,
@@ -66,7 +66,13 @@ export class LineEdge extends BaseEdge {
66
66
  shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
67
67
  }
68
68
 
69
- // TODO: other shapes
69
+ // otherShapes
70
+ if (data.otherShapes) {
71
+ shapes = {
72
+ ...shapes,
73
+ ...this.drawOtherShapes(model, shapeMap, diffData),
74
+ };
75
+ }
70
76
 
71
77
  return shapes;
72
78
  }
@@ -8,7 +8,7 @@ import {
8
8
  } from '../../../types/edge';
9
9
  import { State } from '../../../types/item';
10
10
  import { getPolylinePath } from '../../../util/polyline';
11
- import { pathFinder } from '../../../util/router';
11
+ import { RouterCfg, pathFinder } from '../../../util/router';
12
12
  import Node from '../../../item/node';
13
13
  import { LineEdge } from './line';
14
14
  export class PolylineEdge extends LineEdge {
@@ -74,7 +74,7 @@ export class PolylineEdge extends LineEdge {
74
74
 
75
75
  return shapes;
76
76
  }
77
- private getControlPoints(
77
+ public getControlPoints(
78
78
  model: EdgeDisplayModel,
79
79
  sourcePoint: Point,
80
80
  targetPoint: Point,
@@ -95,16 +95,18 @@ export class PolylineEdge extends LineEdge {
95
95
  model: EdgeDisplayModel,
96
96
  points: Point[],
97
97
  radius: number,
98
- routeCfg?: Record<string, any>,
98
+ routeCfg?: RouterCfg,
99
99
  auto?: boolean,
100
100
  ): string {
101
101
  const { id: edgeId, source: sourceNodeId, target: targetNodeId } = model;
102
102
 
103
103
  // Draw a polyline with control points
104
- if (!auto) return getPolylinePath(edgeId, points, radius);
104
+ if (!auto && routeCfg.name !== 'er')
105
+ return getPolylinePath(edgeId, points, radius);
105
106
 
106
107
  // Find the shortest path computed by A* routing algorithm
107
108
  const polylinePoints = pathFinder(
109
+ points,
108
110
  sourceNodeId,
109
111
  targetNodeId,
110
112
  this.nodeMap as unknown as Map<ID, Node>,
@@ -136,7 +138,7 @@ export class PolylineEdge extends LineEdge {
136
138
 
137
139
  const routeCfg = mix(
138
140
  {},
139
- { offset: keyShapeStyle.offset },
141
+ { offset: keyShapeStyle.offset, name: 'orth' },
140
142
  keyShapeStyle.routeCfg,
141
143
  );
142
144
 
@@ -186,10 +186,10 @@ export abstract class BaseNode {
186
186
  });
187
187
  this.zoomCache.levelShapes = levelShapes;
188
188
 
189
- if (shapeMap.labelShape && this.boundsCache.keyShapeLocal) {
189
+ if (shapeMap.labelShape) {
190
190
  const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
191
191
  this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
192
- this.boundsCache.keyShapeLocal,
192
+ shapeMap.keyShape.getLocalBounds(),
193
193
  maxWidth,
194
194
  1,
195
195
  );
@@ -286,12 +286,10 @@ export abstract class BaseNode {
286
286
  const { labelShape: shapeStyle } = this.mergedStyles;
287
287
  if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
288
288
  const { keyShape } = shapeMap;
289
- this.boundsCache.keyShapeLocal =
290
- this.boundsCache.keyShapeLocal || keyShape.getLocalBounds();
291
289
  const keyShapeBox = getShapeLocalBoundsByStyle(
292
290
  keyShape,
293
291
  this.mergedStyles.keyShape,
294
- this.boundsCache.keyShapeLocal,
292
+ keyShape.getLocalBounds(),
295
293
  );
296
294
  const {
297
295
  position,
@@ -577,12 +575,12 @@ export abstract class BaseNode {
577
575
  position: string | [number, number],
578
576
  anchorPositionMap: IAnchorPositionMap,
579
577
  ): [number, number] {
580
- const keyShapeBBox = this.boundsCache.keyShapeLocal;
578
+ const keyShapeBBox = this.boundsCache.keyShapeLocal!;
581
579
  const keyShapeWidth = keyShapeBBox.max[0] - keyShapeBBox.min[0];
582
580
  const keyShapeHeight = keyShapeBBox.max[1] - keyShapeBBox.min[1];
583
581
  const defaultPosition: [number, number] = [
584
- keyShapeBBox.max[0],
585
- keyShapeBBox.min[1],
582
+ keyShapeBBox.max[0] - keyShapeBBox.center[0],
583
+ keyShapeBBox.min[1] - keyShapeBBox.center[1],
586
584
  ]; //topRight
587
585
  if (position instanceof Array) {
588
586
  return [
@@ -645,12 +643,10 @@ export abstract class BaseNode {
645
643
  (style) => style.tag === 'badgeShape',
646
644
  );
647
645
  if (!individualConfigs.length) return {};
648
- this.boundsCache.keyShapeLocal =
649
- this.boundsCache.keyShapeLocal || shapeMap.keyShape.getLocalBounds();
650
646
  const keyShapeBBox = getShapeLocalBoundsByStyle(
651
647
  shapeMap.keyShape,
652
648
  keyShapeStyle,
653
- this.boundsCache.keyShapeLocal,
649
+ shapeMap.keyShape.getLocalBounds(),
654
650
  );
655
651
  const keyShapeSize = Math.min(
656
652
  keyShapeBBox.max[0] - keyShapeBBox.min[0],
@@ -759,8 +755,6 @@ export abstract class BaseNode {
759
755
  (text as string).length <= 1
760
756
  ? bgHeight
761
757
  : Math.max(bgHeight, bbox.max[0] - bbox.min[0]) + 8;
762
- let bgX = isLeft ? pos.x - bgWidth : pos.x;
763
- if (isCenter) bgX = pos.x - bgWidth / 2;
764
758
  shapes[bgShapeId] = this.upsertShape(
765
759
  'rect',
766
760
  bgShapeId,
@@ -771,8 +765,8 @@ export abstract class BaseNode {
771
765
  width: bgWidth,
772
766
  radius: bgHeight / 2,
773
767
  zIndex,
774
- x: bgX,
775
- y: pos.y,
768
+ x: bbox.center[0] - bgWidth / 2,
769
+ y: bbox.center[1] - bgHeight / 2,
776
770
  ...otherStyles,
777
771
  } as GShapeStyle,
778
772
  shapeMap,
@@ -810,7 +804,11 @@ export abstract class BaseNode {
810
804
  * @param shapeMap The shape map that contains all of the elements to show on the node.
811
805
  * @param zoom The zoom level of the graph.
812
806
  */
813
- public onZoom = (shapeMap: NodeShapeMap | ComboShapeMap, zoom: number) => {
807
+ public onZoom = (
808
+ shapeMap: NodeShapeMap | ComboShapeMap,
809
+ zoom: number,
810
+ cacheHiddenShape = {},
811
+ ) => {
814
812
  // zoomLevel changed
815
813
  if (this.lodStrategy) {
816
814
  const { levels } = this.lodStrategy;
@@ -831,7 +829,7 @@ export abstract class BaseNode {
831
829
  // zoomLevel changed, from higher to lower, hide something
832
830
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
833
831
  levelShapes[String(i)]?.forEach((id) => {
834
- if (!shapeMap[id]) return;
832
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
835
833
  shapeMap[id].hide();
836
834
  hiddenShape[id] = true;
837
835
  });
@@ -880,8 +878,7 @@ export abstract class BaseNode {
880
878
  const balanceRatio = 1 / zoom || 1;
881
879
  this.zoomCache.balanceRatio = balanceRatio;
882
880
  if (!labelShape || !labelShape.isVisible()) return;
883
- const { labelShape: labelStyle } = this.mergedStyles;
884
- const { position = 'bottom' } = labelStyle;
881
+ const { position = 'bottom' } = this.mergedStyles.labelShape;
885
882
 
886
883
  const keyShapeLocal = keyShape.getLocalBounds();
887
884
  if (zoom < 1) {
@@ -923,21 +920,20 @@ export abstract class BaseNode {
923
920
  const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
924
921
  labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
925
922
  this.scaleTransformCache = scaleTransform;
926
- const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
927
- labelShape.style.wordWrapWidth = wordWrapWidth;
923
+ labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
928
924
 
929
925
  if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
930
926
 
931
- const { padding } = this.mergedStyles.labelBackgroundShape;
927
+ const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
928
+ .mergedStyles.labelBackgroundShape.padding as number[];
929
+ const sidePadding = paddingRight + paddingLeft;
932
930
  const { width, height, x, y } = labelBackgroundShape.attributes;
933
- const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
934
- padding as number[];
935
931
 
936
932
  switch (position) {
937
933
  case 'top':
938
934
  // if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
939
935
  labelBackgroundShape.style.transformOrigin = `${
940
- paddingLeft + (width - paddingLeft - paddingRight) / 2
936
+ paddingLeft + (width - sidePadding) / 2
941
937
  } ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
942
938
  break;
943
939
  case 'left':
@@ -952,7 +948,7 @@ export abstract class BaseNode {
952
948
  break;
953
949
  case 'bottom':
954
950
  labelBackgroundShape.style.transformOrigin = `${
955
- paddingLeft + (width - paddingLeft - paddingRight) / 2
951
+ paddingLeft + (width - sidePadding) / 2
956
952
  } ${
957
953
  zoom < 1
958
954
  ? paddingTop + (height - paddingTop - paddingBottom) / 2
@@ -962,14 +958,13 @@ export abstract class BaseNode {
962
958
  default:
963
959
  // center
964
960
  labelBackgroundShape.style.transformOrigin = `${
965
- paddingLeft + (width - paddingLeft - paddingRight) / 2
961
+ paddingLeft + (width - sidePadding) / 2
966
962
  } ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
967
963
  }
968
964
 
969
965
  const { labelShapeGeometry: labelBBox } = this.boundsCache;
970
966
  const labelWidth = labelBBox.max[0] - labelBBox.min[0];
971
- const xAxistRatio =
972
- (labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
967
+ const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
973
968
 
974
969
  labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
975
970
  }
@@ -21,6 +21,7 @@ export abstract class BaseNode3D extends BaseNode {
21
21
  themeStyles: NodeShapeStyles;
22
22
  mergedStyles: NodeShapeStyles;
23
23
  device: any; // for 3d renderer
24
+ dimensions: number = 3;
24
25
  constructor(props) {
25
26
  super(props);
26
27
  this.device = props.device;