@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
@@ -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) => {
@@ -1,3 +1,4 @@
1
+ import { uniqueId } from '@antv/util';
1
2
  import { GraphCore } from '../../types/data';
2
3
  import {
3
4
  GraphData,
@@ -9,21 +10,25 @@ import {
9
10
  /**
10
11
  * Validate and format the graph data.
11
12
  * @param data input user data.
12
- * @param userGraphCore the graph core stores the previous data.
13
+ * @param graphCore the graph core stores the previous data.
13
14
  * @returns formatted data.
14
15
  */
15
16
  export const ValidateData = (
16
17
  data: GraphData,
17
18
  options = {},
18
- userGraphCore?: GraphCore,
19
+ graphCore?: GraphCore,
19
20
  ): GraphData => {
20
21
  const { nodes, edges, combos } = data;
21
22
  const idMap = new Map();
22
23
  const nodeIdMap = new Map();
23
24
  const comboIdMap = new Map();
24
25
 
25
- const idAndDataCheck = (item, type) => {
26
+ const idAndDataCheck = (item, type, generateId = false) => {
26
27
  if (item.id === undefined) {
28
+ if (generateId) {
29
+ item.id = `${type}-${uniqueId()}`;
30
+ return;
31
+ }
27
32
  console.error(
28
33
  `Unique global id is neccessary for graph items. The ${type} ${JSON.stringify(
29
34
  item,
@@ -59,7 +64,7 @@ export const ValidateData = (
59
64
  if (
60
65
  parentId !== undefined &&
61
66
  !comboIdMap.has(parentId) &&
62
- (!userGraphCore || !userGraphCore.hasNode(parentId))
67
+ (!graphCore || !graphCore.hasNode(parentId))
63
68
  ) {
64
69
  console.error(
65
70
  `The parentId of combo with id ${combo.id} will be removed since it is not exist in combos.`,
@@ -75,9 +80,9 @@ export const ValidateData = (
75
80
  if (
76
81
  parentId !== undefined &&
77
82
  !comboIdMap.has(parentId) &&
78
- (!userGraphCore || !userGraphCore.hasNode(parentId))
83
+ (!graphCore || !graphCore.hasNode(parentId))
79
84
  ) {
80
- // TODO: parentId is a node in userGraphCore
85
+ // TODO: parentId is a node in graphCore
81
86
  console.error(
82
87
  `The parentId of node with id ${node.id} will be removed since it is not exist in combos.`,
83
88
  );
@@ -93,10 +98,10 @@ export const ValidateData = (
93
98
  ?.map((edge) => {
94
99
  const { id } = edge;
95
100
  let { source, target } = edge;
96
- if (!idAndDataCheck(edge, 'edge')) return false;
101
+ if (!idAndDataCheck(edge, 'edge', true)) return false;
97
102
 
98
- if (userGraphCore?.hasEdge(id)) {
99
- const existEdge = userGraphCore?.getEdge(id);
103
+ if (graphCore?.hasEdge(id)) {
104
+ const existEdge = graphCore?.getEdge(id);
100
105
  if (source === undefined) source = existEdge.source;
101
106
  if (target === undefined) target = existEdge.target;
102
107
  }
@@ -116,7 +121,7 @@ export const ValidateData = (
116
121
  if (
117
122
  !nodeIdMap.has(source) &&
118
123
  !comboIdMap.has(source) &&
119
- (!userGraphCore || !userGraphCore.hasNode(source))
124
+ (!graphCore || !graphCore.hasNode(source))
120
125
  ) {
121
126
  console.error(
122
127
  `The edge with id ${id} will be ignored since its source ${source} is not existed in nodes and combos.`,
@@ -126,7 +131,7 @@ export const ValidateData = (
126
131
  if (
127
132
  !nodeIdMap.has(target) &&
128
133
  !comboIdMap.has(target) &&
129
- (!userGraphCore || !userGraphCore.hasNode(target))
134
+ (!graphCore || !graphCore.hasNode(target))
130
135
  ) {
131
136
  console.error(
132
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;
@@ -97,9 +97,20 @@ export abstract class BaseEdge {
97
97
  ...lodStrategy?.animateCfg,
98
98
  };
99
99
  }
100
+
101
+ /**
102
+ * Get merged styles from `getMergedStyles` and assigns the merged styles to the 'mergedStyles' property.
103
+ * @param model - The EdgeDisplayModel to merge the styles from.
104
+ */
100
105
  public mergeStyles(model: EdgeDisplayModel) {
101
106
  this.mergedStyles = this.getMergedStyles(model);
102
107
  }
108
+
109
+ /**
110
+ * Merge style
111
+ * @param model - The EdgeDisplayModel to retrieve the merged styles from.
112
+ * @returns The merged styles as a EdgeShapeStyles object.
113
+ */
103
114
  public getMergedStyles(model: EdgeDisplayModel) {
104
115
  const { data } = model;
105
116
  const dataStyles = {} as EdgeShapeStyles;
@@ -131,6 +142,7 @@ export abstract class BaseEdge {
131
142
 
132
143
  /**
133
144
  * Call it after calling draw function to update cache about bounds and zoom levels.
145
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
134
146
  */
135
147
  public updateCache(shapeMap) {
136
148
  ['labelShape', 'labelBackgroundShape'].forEach((id) => {
@@ -165,6 +177,15 @@ export abstract class BaseEdge {
165
177
  if (zoom !== 1) this.onZoom(shapeMap, zoom);
166
178
  }
167
179
 
180
+ /**
181
+ * Draw all elements related to the edge.
182
+ * You should call `drawKeyShape` and `drawAnchorShape`,`drawLabelShape`,`drawIconShape`...as you like.
183
+ * @param model The displayed model of this edge, only for drawing and not received by users.
184
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
185
+ * @param diffData An object that contains previous and current data.
186
+ * @param diffState An object that contains previous and current edge's state.
187
+ * @returns An object containing the keyShape and optional labelShape, iconShape, and some otherShapes properties
188
+ */
168
189
  abstract draw(
169
190
  model: EdgeDisplayModel,
170
191
  sourcePoint: Point,
@@ -178,6 +199,14 @@ export abstract class BaseEdge {
178
199
  iconShape?: DisplayObject;
179
200
  [otherShapeId: string]: DisplayObject;
180
201
  };
202
+
203
+ /**
204
+ * Perform additional drawing operations or add custom shapes after drawing edge.
205
+ * @param model The displayed model of this edge, only for drawing and not received by users.
206
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
207
+ * @param shapesChanged An array of shape IDs that have changed and need to be updated.
208
+ * @returns An object that contains some new shapes to be added to the edge.
209
+ */
181
210
  public afterDraw(
182
211
  model: EdgeDisplayModel,
183
212
  shapeMap: { [shapeId: string]: DisplayObject },
@@ -186,12 +215,27 @@ export abstract class BaseEdge {
186
215
  return {};
187
216
  }
188
217
  // shouldUpdate: (model: EdgeDisplayModel, prevModel: EdgeDisplayModel) => boolean = () => true;
218
+
219
+ /**
220
+ * Set the state for the edge.
221
+ * @param state state name
222
+ * @param value state value
223
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
224
+ */
189
225
  public setState: (
190
226
  name: string,
191
227
  value: boolean,
192
228
  shapeMap: { [shapeId: string]: DisplayObject },
193
229
  ) => void;
194
230
 
231
+ /**
232
+ * Draw the label shape of the edge
233
+ * @param model The displayed model of this edge, only for drawing and not received by users.
234
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
235
+ * @param diffData An object that contains previous and current data.
236
+ * @param diffState An object that contains previous and current edge's state.
237
+ * @returns The display object representing the label shape of the edge.
238
+ */
195
239
  public drawLabelShape(
196
240
  model: EdgeDisplayModel,
197
241
  shapeMap: EdgeShapeMap,
@@ -201,7 +245,8 @@ export abstract class BaseEdge {
201
245
  const { keyShape } = shapeMap;
202
246
 
203
247
  const { labelShape: shapeStyle } = this.mergedStyles;
204
- if (!shapeStyle) return;
248
+ if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
249
+
205
250
  const {
206
251
  position,
207
252
  offsetX: propsOffsetX,
@@ -297,6 +342,14 @@ export abstract class BaseEdge {
297
342
  return this.upsertShape('text', 'labelShape', style, shapeMap, model);
298
343
  }
299
344
 
345
+ /**
346
+ * Draw the label background shape of the edge
347
+ * @param model The displayed model of this edge, only for drawing and not received by users.
348
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
349
+ * @param diffData An object that contains previous and current data.
350
+ * @param diffState An object that contains previous and current edge's state.
351
+ * @returns The display object representing the label background shape of the edge.
352
+ */
300
353
  public drawLabelBackgroundShape(
301
354
  model: EdgeDisplayModel,
302
355
  shapeMap: EdgeShapeMap,
@@ -356,6 +409,14 @@ export abstract class BaseEdge {
356
409
  );
357
410
  }
358
411
 
412
+ /**
413
+ * Draw the icon shape of the edge
414
+ * @param model The displayed model of this edge, only for drawing and not received by users.
415
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
416
+ * @param diffData An object that contains previous and current data.
417
+ * @param diffState An object that contains previous and current edge's state.
418
+ * @returns The display object representing the icon shape of the edge.
419
+ */
359
420
  public drawIconShape(
360
421
  model: EdgeDisplayModel,
361
422
  shapeMap: EdgeShapeMap,
@@ -442,6 +503,14 @@ export abstract class BaseEdge {
442
503
  );
443
504
  }
444
505
 
506
+ /**
507
+ * Draw the halo shape of the edge
508
+ * @param model The displayed model of this edge, only for drawing and not received by users.
509
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
510
+ * @param diffData An object that contains previous and current data.
511
+ * @param diffState An object that contains previous and current edge's state.
512
+ * @returns The display object representing the halo shape of the edge.
513
+ */
445
514
  public drawHaloShape(
446
515
  model: EdgeDisplayModel,
447
516
  shapeMap: EdgeShapeMap,
@@ -465,14 +534,27 @@ export abstract class BaseEdge {
465
534
  );
466
535
  }
467
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
+
468
546
  /**
469
547
  * The listener for graph zooming.
470
548
  * 1. show / hide some shapes while zoom level changed;
471
549
  * 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
472
- * @param shapeMap
473
- * @param zoom
550
+ * @param shapeMap The shape map that contains all of the elements to show on the edge.
551
+ * @param zoom The zoom level of the graph.
474
552
  */
475
- public onZoom = (shapeMap: EdgeShapeMap, zoom: number) => {
553
+ public onZoom = (
554
+ shapeMap: EdgeShapeMap,
555
+ zoom: number,
556
+ cacheHiddenShape = {},
557
+ ) => {
476
558
  // balance the size for label, badges
477
559
  this.balanceShapeSize(shapeMap, zoom);
478
560
 
@@ -496,7 +578,10 @@ export abstract class BaseEdge {
496
578
  // zoomLevel changed, from higher to lower, hide something
497
579
  if (firstRender) {
498
580
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
499
- 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
+ });
500
585
  }
501
586
  } else {
502
587
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
@@ -508,7 +593,8 @@ export abstract class BaseEdge {
508
593
  } else if (currentLevel > previousLevel) {
509
594
  // zoomLevel changed, from lower to higher, show something
510
595
  for (let i = currentLevel; i >= minLevel; i--) {
511
- levelShapes[String(i)]?.forEach((id) =>
596
+ levelShapes[String(i)]?.forEach((id) => {
597
+ if (hiddenShape[id]) return;
512
598
  fadeIn(
513
599
  id,
514
600
  shapeMap[id],
@@ -516,8 +602,8 @@ export abstract class BaseEdge {
516
602
  this.mergedStyles[id.replace('Background', '')],
517
603
  hiddenShape,
518
604
  animateConfig,
519
- ),
520
- );
605
+ );
606
+ });
521
607
  }
522
608
  }
523
609
 
@@ -557,7 +643,7 @@ export abstract class BaseEdge {
557
643
 
558
644
  /**
559
645
  * Update the source point { x, y } for the edge. Called in item's draw func.
560
- * @param point
646
+ * @param point source point
561
647
  */
562
648
  public setSourcePoint(point: Point) {
563
649
  this.sourcePoint = point;
@@ -565,7 +651,7 @@ export abstract class BaseEdge {
565
651
 
566
652
  /**
567
653
  * Update the target point { x, y } for the edge. Called in item's draw func.
568
- * @param point
654
+ * @param point target point
569
655
  */
570
656
  public setTargetPoint(point: Point) {
571
657
  this.targetPoint = point;
@@ -573,12 +659,20 @@ export abstract class BaseEdge {
573
659
 
574
660
  /**
575
661
  * Update all visible nodes on the canvas to be aware of obstacles. Called in item's draw func.
576
- * @param nodeMap
662
+ * @param nodeMap The Map object representing the node map, where keys are node IDs and values are nodes.
577
663
  */
578
664
  public setNodeMap(nodeMap: Map<ID, Node>) {
579
665
  this.nodeMap = nodeMap;
580
666
  }
581
667
 
668
+ /**
669
+ * Adds or updates an arrow marker on the specified position of an edge.
670
+ * @param position - The position where the arrow marker should be added or updated. Can be either 'start' or 'end'.
671
+ * @param arrowConfig - The configuration for the arrow marker. Can be a boolean indicating whether to use the default arrow configuration, or an ArrowStyle object with custom arrow properties.
672
+ * @param bodyStyle - The style of the edge body.
673
+ * @param model - The EdgeDisplayModel that contains the data and style information for the edge.
674
+ * @param resultStyle - The style object where the arrow marker properties will be added or updated.
675
+ */
582
676
  public upsertArrow(
583
677
  position: 'start' | 'end',
584
678
  arrowConfig: boolean | ArrowStyle,
@@ -592,12 +686,9 @@ export abstract class BaseEdge {
592
686
  resultStyle[`${markerField}Offset`] = 0;
593
687
  return;
594
688
  }
595
- let arrowStyle = {} as ArrowStyle;
596
- if (isBoolean(arrowConfig)) {
597
- arrowStyle = { ...DEFAULT_ARROW_CONFIG } as ArrowStyle;
598
- } else {
599
- arrowStyle = arrowConfig;
600
- }
689
+ const arrowStyle = isBoolean(arrowConfig)
690
+ ? ({ ...DEFAULT_ARROW_CONFIG } as ArrowStyle)
691
+ : arrowConfig;
601
692
  const {
602
693
  type = 'triangle',
603
694
  width = 10,
@@ -606,14 +697,13 @@ export abstract class BaseEdge {
606
697
  offset = 0,
607
698
  ...others
608
699
  } = arrowStyle;
609
- const path = propPath ? propPath : getArrowPath(type, width, height);
610
700
  resultStyle[markerField] = this.upsertShape(
611
701
  'path',
612
702
  `${markerField}Shape`,
613
703
  {
614
704
  ...bodyStyle,
615
705
  fill: type === 'simple' ? '' : bodyStyle.stroke,
616
- path,
706
+ path: propPath || getArrowPath(type, width, height),
617
707
  anchor: '0.5 0.5',
618
708
  transformOrigin: 'center',
619
709
  ...others,
@@ -624,6 +714,15 @@ export abstract class BaseEdge {
624
714
  resultStyle[`${markerField}Offset`] = width / 2 + offset;
625
715
  }
626
716
 
717
+ /**
718
+ * Create (if does not exit in shapeMap) or update the shape according to the configurations.
719
+ * @param type shape's type
720
+ * @param id unique string to indicates the shape
721
+ * @param style style to be updated
722
+ * @param shapeMap the shape map of a edge
723
+ * @param model data model of the edge
724
+ * @returns The display object representing the shape.
725
+ */
627
726
  public upsertShape(
628
727
  type: SHAPE_TYPE,
629
728
  id: string,
@@ -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
  }