@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
@@ -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
 
@@ -97,11 +97,18 @@ export abstract class BaseNode {
97
97
  }
98
98
 
99
99
  /**
100
- * Merge default style with the style Customized by users
100
+ * Get merged styles from `getMergedStyles` and assigns the merged styles to the 'mergedStyles' property.
101
+ * @param model - The NodeDisplayModel or ComboDisplayModel to merge the styles from.
101
102
  */
102
103
  public mergeStyles(model: NodeDisplayModel | ComboDisplayModel) {
103
104
  this.mergedStyles = this.getMergedStyles(model);
104
105
  }
106
+
107
+ /**
108
+ * Merge style
109
+ * @param model - The NodeDisplayModel or ComboDisplayModel to retrieve the merged styles from.
110
+ * @returns The merged styles as a NodeShapeStyles object.
111
+ */
105
112
  public getMergedStyles(model: NodeDisplayModel | ComboDisplayModel) {
106
113
  const { data } = model;
107
114
  const dataStyles = {} as NodeShapeStyles | ComboShapeStyles;
@@ -151,6 +158,7 @@ export abstract class BaseNode {
151
158
  }
152
159
  /**
153
160
  * Call it after calling draw function to update cache about bounds and zoom levels.
161
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
154
162
  */
155
163
  public updateCache(shapeMap) {
156
164
  ['keyShape', 'labelShape']
@@ -178,18 +186,23 @@ export abstract class BaseNode {
178
186
  });
179
187
  this.zoomCache.levelShapes = levelShapes;
180
188
 
181
- if (shapeMap.labelShape && this.boundsCache.keyShapeLocal) {
189
+ if (shapeMap.labelShape) {
182
190
  const { maxWidth = '200%' } = this.mergedStyles.labelShape || {};
183
191
  this.zoomCache.wordWrapWidth = getWordWrapWidthByBox(
184
- this.boundsCache.keyShapeLocal,
192
+ shapeMap.keyShape.getLocalBounds(),
185
193
  maxWidth,
186
194
  1,
187
195
  );
188
196
  }
189
197
  }
190
198
  /**
191
- * Draw all elements related to the graphic.
199
+ * Draw all elements related to the node.
192
200
  * You should call `drawKeyShape` and `drawAnchorShape`,`drawLabelShape`,`drawIconShape`...as you like.
201
+ * @param model The displayed model of this node, only for drawing and not received by users.
202
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
203
+ * @param diffData An object that contains previous and current data.
204
+ * @param diffState An object that contains previous and current node's state.
205
+ * @returns An object containing the keyShape and optional labelShape, iconShape, and some otherShapes properties
193
206
  */
194
207
  abstract draw(
195
208
  model: NodeDisplayModel | ComboDisplayModel,
@@ -206,6 +219,13 @@ export abstract class BaseNode {
206
219
  [otherShapeId: string]: DisplayObject;
207
220
  };
208
221
 
222
+ /**
223
+ * Perform additional drawing operations or add custom shapes after drawing node.
224
+ * @param model The displayed model of this node, only for drawing and not received by users.
225
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
226
+ * @param shapesChanged An array of shape IDs that have changed and need to be updated.
227
+ * @returns An object that contains some new shapes to be added to the node.
228
+ */
209
229
  public afterDraw(
210
230
  model: NodeDisplayModel | ComboDisplayModel,
211
231
  shapeMap: { [shapeId: string]: DisplayObject },
@@ -214,6 +234,13 @@ export abstract class BaseNode {
214
234
  return {};
215
235
  }
216
236
  // shouldUpdate: (model: NodeDisplayModel, prevModel: NodeDisplayModel) => boolean = () => true;
237
+
238
+ /**
239
+ * Set the state for the node.
240
+ * @param state state name
241
+ * @param value state value
242
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
243
+ */
217
244
  public setState: (
218
245
  name: string,
219
246
  value: boolean,
@@ -222,7 +249,12 @@ export abstract class BaseNode {
222
249
 
223
250
  /**
224
251
  * The key function of drawing shape.
225
- * Defined the basic shape of the node.
252
+ * Draw the key shape of the node based on the provided model and shape map.
253
+ * @param model The displayed model of this node, only for drawing and not received by users.
254
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
255
+ * @param diffData An object that contains previous and current data.
256
+ * @param diffState An object that contains previous and current node's state.
257
+ * @returns The display object representing the key shape of the node.
226
258
  */
227
259
  abstract drawKeyShape(
228
260
  model: NodeDisplayModel | ComboDisplayModel,
@@ -235,7 +267,12 @@ export abstract class BaseNode {
235
267
  ): DisplayObject;
236
268
 
237
269
  /**
238
- * Draw the label of the node
270
+ * Draw the label shape of the node
271
+ * @param model The displayed model of this node, only for drawing and not received by users.
272
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
273
+ * @param diffData An object that contains previous and current data.
274
+ * @param diffState An object that contains previous and current node's state.
275
+ * @returns The display object representing the label shape of the node.
239
276
  */
240
277
  public drawLabelShape(
241
278
  model: NodeDisplayModel | ComboDisplayModel,
@@ -247,14 +284,12 @@ export abstract class BaseNode {
247
284
  diffState?: { previous: State[]; current: State[] },
248
285
  ): DisplayObject {
249
286
  const { labelShape: shapeStyle } = this.mergedStyles;
250
- if (!shapeStyle) return;
287
+ if (!shapeStyle || !shapeStyle.text || !model.data.labelShape) return;
251
288
  const { keyShape } = shapeMap;
252
- this.boundsCache.keyShapeLocal =
253
- this.boundsCache.keyShapeLocal || keyShape.getLocalBounds();
254
289
  const keyShapeBox = getShapeLocalBoundsByStyle(
255
290
  keyShape,
256
291
  this.mergedStyles.keyShape,
257
- this.boundsCache.keyShapeLocal,
292
+ keyShape.getLocalBounds(),
258
293
  );
259
294
  const {
260
295
  position,
@@ -338,7 +373,12 @@ export abstract class BaseNode {
338
373
  }
339
374
 
340
375
  /**
341
- * Draw the label background of the node
376
+ * Draw the label background shape of the node
377
+ * @param model The displayed model of this node, only for drawing and not received by users.
378
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
379
+ * @param diffData An object that contains previous and current data.
380
+ * @param diffState An object that contains previous and current node's state.
381
+ * @returns The display object representing the label background shape of the node.
342
382
  */
343
383
  public drawLabelBackgroundShape(
344
384
  model: NodeDisplayModel | ComboDisplayModel,
@@ -350,7 +390,7 @@ export abstract class BaseNode {
350
390
  diffState?: { oldState: State[]; newState: State[] },
351
391
  ): DisplayObject {
352
392
  const { labelShape } = shapeMap;
353
- if (!labelShape || !model.data.labelShape) return;
393
+ if (!labelShape || !labelShape.style.text || !model.data.labelShape) return;
354
394
  if (
355
395
  !this.boundsCache.labelShapeGeometry ||
356
396
  labelShape.getAttribute(LOCAL_BOUNDS_DIRTY_FLAG_KEY)
@@ -390,7 +430,12 @@ export abstract class BaseNode {
390
430
  }
391
431
 
392
432
  /**
393
- * Draw the icon of the node
433
+ * Draw the icon shape of the node
434
+ * @param model The displayed model of this node, only for drawing and not received by users.
435
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
436
+ * @param diffData An object that contains previous and current data.
437
+ * @param diffState An object that contains previous and current node's state.
438
+ * @returns The display object representing the icon shape of the node.
394
439
  */
395
440
  public drawIconShape(
396
441
  model: NodeDisplayModel | ComboDisplayModel,
@@ -436,7 +481,12 @@ export abstract class BaseNode {
436
481
  }
437
482
 
438
483
  /**
439
- * Draw the halo of the node
484
+ * Draw the halo shape of the node
485
+ * @param model The displayed model of this node, only for drawing and not received by users.
486
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
487
+ * @param diffData An object that contains previous and current data.
488
+ * @param diffState An object that contains previous and current node's state.
489
+ * @returns The display object representing the halo shape of the node.
440
490
  */
441
491
  public drawHaloShape(
442
492
  model: NodeDisplayModel | ComboDisplayModel,
@@ -471,7 +521,12 @@ export abstract class BaseNode {
471
521
  }
472
522
 
473
523
  /**
474
- * Draw the anchors of the node
524
+ * Draw the anchors shape of the node
525
+ * @param model The displayed model of this node, only for drawing and not received by users.
526
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
527
+ * @param diffData An object that contains previous and current data.
528
+ * @param diffState An object that contains previous and current node's state.
529
+ * @returns The display object representing the anchors shape of the node.
475
530
  */
476
531
  public drawAnchorShapes(
477
532
  model: NodeDisplayModel | ComboDisplayModel,
@@ -520,12 +575,12 @@ export abstract class BaseNode {
520
575
  position: string | [number, number],
521
576
  anchorPositionMap: IAnchorPositionMap,
522
577
  ): [number, number] {
523
- const keyShapeBBox = this.boundsCache.keyShapeLocal;
578
+ const keyShapeBBox = this.boundsCache.keyShapeLocal!;
524
579
  const keyShapeWidth = keyShapeBBox.max[0] - keyShapeBBox.min[0];
525
580
  const keyShapeHeight = keyShapeBBox.max[1] - keyShapeBBox.min[1];
526
581
  const defaultPosition: [number, number] = [
527
- keyShapeBBox.max[0],
528
- keyShapeBBox.min[1],
582
+ keyShapeBBox.max[0] - keyShapeBBox.center[0],
583
+ keyShapeBBox.min[1] - keyShapeBBox.center[1],
529
584
  ]; //topRight
530
585
  if (position instanceof Array) {
531
586
  return [
@@ -546,10 +601,10 @@ export abstract class BaseNode {
546
601
  }
547
602
 
548
603
  /**
549
- * Configure anchor position by keyShapeStyle. return the configuration.
550
- * e.g CircleNode `return {"right":keyShapeStyle.x+keyShapeStyle.r, keyShapeStyle.y}`
551
- * @param {*} keyShapeStyle
552
- * @return {IAnchorPositionMap} anchorpositionMap
604
+ * Configures the anchor positions based on the provided keyShapeStyle and returns the configuration.
605
+ * e.g for a CircleNode, it returns: `{"right":keyShapeStyle.x+keyShapeStyle.r, keyShapeStyle.y}`
606
+ * @param keyShapeStyle - The keyShapeStyle object that contains the style information of the key shape.
607
+ * @returns The anchor position configuration as an IAnchorPositionMap object.
553
608
  */
554
609
  public calculateAnchorPosition(keyShapeStyle: any): IAnchorPositionMap {
555
610
  const x = convertToNumber(keyShapeStyle.x);
@@ -564,7 +619,12 @@ export abstract class BaseNode {
564
619
  }
565
620
 
566
621
  /**
567
- * Draw the badges of the node
622
+ * Draw the badges shape of the node
623
+ * @param model The displayed model of this node, only for drawing and not received by users.
624
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
625
+ * @param diffData An object that contains previous and current data.
626
+ * @param diffState An object that contains previous and current node's state.
627
+ * @returns The display object representing the badges shape of the node.
568
628
  */
569
629
  public drawBadgeShapes(
570
630
  model: NodeDisplayModel | ComboDisplayModel,
@@ -583,12 +643,10 @@ export abstract class BaseNode {
583
643
  (style) => style.tag === 'badgeShape',
584
644
  );
585
645
  if (!individualConfigs.length) return {};
586
- this.boundsCache.keyShapeLocal =
587
- this.boundsCache.keyShapeLocal || shapeMap.keyShape.getLocalBounds();
588
646
  const keyShapeBBox = getShapeLocalBoundsByStyle(
589
647
  shapeMap.keyShape,
590
648
  keyShapeStyle,
591
- this.boundsCache.keyShapeLocal,
649
+ shapeMap.keyShape.getLocalBounds(),
592
650
  );
593
651
  const keyShapeSize = Math.min(
594
652
  keyShapeBBox.max[0] - keyShapeBBox.min[0],
@@ -697,8 +755,6 @@ export abstract class BaseNode {
697
755
  (text as string).length <= 1
698
756
  ? bgHeight
699
757
  : Math.max(bgHeight, bbox.max[0] - bbox.min[0]) + 8;
700
- let bgX = isLeft ? pos.x - bgWidth : pos.x;
701
- if (isCenter) bgX = pos.x - bgWidth / 2;
702
758
  shapes[bgShapeId] = this.upsertShape(
703
759
  'rect',
704
760
  bgShapeId,
@@ -709,8 +765,8 @@ export abstract class BaseNode {
709
765
  width: bgWidth,
710
766
  radius: bgHeight / 2,
711
767
  zIndex,
712
- x: bgX,
713
- y: pos.y,
768
+ x: bbox.center[0] - bgWidth / 2,
769
+ y: bbox.center[1] - bgHeight / 2,
714
770
  ...otherStyles,
715
771
  } as GShapeStyle,
716
772
  shapeMap,
@@ -723,6 +779,11 @@ export abstract class BaseNode {
723
779
 
724
780
  /**
725
781
  * Draw other shapes(such as preRect,stateIcon) of the node
782
+ * @param model The displayed model of this node, only for drawing and not received by users.
783
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
784
+ * @param diffData An object that contains previous and current data.
785
+ * @param diffState An object that contains previous and current node's state.
786
+ * @returns The display object representing the other shapes of the node.
726
787
  */
727
788
  public drawOtherShapes(
728
789
  model: NodeDisplayModel | ComboDisplayModel,
@@ -740,10 +801,14 @@ export abstract class BaseNode {
740
801
  * The listener for graph zooming.
741
802
  * 1. show / hide some shapes while zoom level changed;
742
803
  * 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
743
- * @param shapeMap
744
- * @param zoom
804
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
805
+ * @param zoom The zoom level of the graph.
745
806
  */
746
- public onZoom = (shapeMap: NodeShapeMap | ComboShapeMap, zoom: number) => {
807
+ public onZoom = (
808
+ shapeMap: NodeShapeMap | ComboShapeMap,
809
+ zoom: number,
810
+ cacheHiddenShape = {},
811
+ ) => {
747
812
  // zoomLevel changed
748
813
  if (this.lodStrategy) {
749
814
  const { levels } = this.lodStrategy;
@@ -764,7 +829,7 @@ export abstract class BaseNode {
764
829
  // zoomLevel changed, from higher to lower, hide something
765
830
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
766
831
  levelShapes[String(i)]?.forEach((id) => {
767
- if (!shapeMap[id]) return;
832
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
768
833
  shapeMap[id].hide();
769
834
  hiddenShape[id] = true;
770
835
  });
@@ -813,8 +878,7 @@ export abstract class BaseNode {
813
878
  const balanceRatio = 1 / zoom || 1;
814
879
  this.zoomCache.balanceRatio = balanceRatio;
815
880
  if (!labelShape || !labelShape.isVisible()) return;
816
- const { labelShape: labelStyle } = this.mergedStyles;
817
- const { position = 'bottom' } = labelStyle;
881
+ const { position = 'bottom' } = this.mergedStyles.labelShape;
818
882
 
819
883
  const keyShapeLocal = keyShape.getLocalBounds();
820
884
  if (zoom < 1) {
@@ -856,21 +920,20 @@ export abstract class BaseNode {
856
920
  const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
857
921
  labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
858
922
  this.scaleTransformCache = scaleTransform;
859
- const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
860
- labelShape.style.wordWrapWidth = wordWrapWidth;
923
+ labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
861
924
 
862
925
  if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
863
926
 
864
- const { padding } = this.mergedStyles.labelBackgroundShape;
927
+ const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
928
+ .mergedStyles.labelBackgroundShape.padding as number[];
929
+ const sidePadding = paddingRight + paddingLeft;
865
930
  const { width, height, x, y } = labelBackgroundShape.attributes;
866
- const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
867
- padding as number[];
868
931
 
869
932
  switch (position) {
870
933
  case 'top':
871
934
  // if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
872
935
  labelBackgroundShape.style.transformOrigin = `${
873
- paddingLeft + (width - paddingLeft - paddingRight) / 2
936
+ paddingLeft + (width - sidePadding) / 2
874
937
  } ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
875
938
  break;
876
939
  case 'left':
@@ -885,7 +948,7 @@ export abstract class BaseNode {
885
948
  break;
886
949
  case 'bottom':
887
950
  labelBackgroundShape.style.transformOrigin = `${
888
- paddingLeft + (width - paddingLeft - paddingRight) / 2
951
+ paddingLeft + (width - sidePadding) / 2
889
952
  } ${
890
953
  zoom < 1
891
954
  ? paddingTop + (height - paddingTop - paddingBottom) / 2
@@ -895,18 +958,26 @@ export abstract class BaseNode {
895
958
  default:
896
959
  // center
897
960
  labelBackgroundShape.style.transformOrigin = `${
898
- paddingLeft + (width - paddingLeft - paddingRight) / 2
961
+ paddingLeft + (width - sidePadding) / 2
899
962
  } ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
900
963
  }
901
964
 
902
965
  const { labelShapeGeometry: labelBBox } = this.boundsCache;
903
966
  const labelWidth = labelBBox.max[0] - labelBBox.min[0];
904
- const xAxistRatio =
905
- (labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
967
+ const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
906
968
 
907
969
  labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
908
970
  }
909
971
 
972
+ /**
973
+ * Create (if does not exit in shapeMap) or update the shape according to the configurations.
974
+ * @param type shape's type
975
+ * @param id unique string to indicates the shape
976
+ * @param style style to be updated
977
+ * @param shapeMap the shape map of a node / combo
978
+ * @param model data model of the node / combo
979
+ * @returns The display object representing the shape.
980
+ */
910
981
  public upsertShape(
911
982
  type: SHAPE_TYPE | SHAPE_TYPE_3D,
912
983
  id: string,
@@ -21,12 +21,20 @@ 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;
27
28
  }
28
29
 
29
- // TODO: 3d text - billboard 2d shape
30
+ /**
31
+ * Draw the label shape of the 3D node
32
+ * @param model The displayed model of this 3D node, only for drawing and not received by users.
33
+ * @param shapeMap The shape map that contains all of the elements to show on the 3D node.
34
+ * @param diffData An object that contains previous and current data.
35
+ * @param diffState An object that contains previous and current 3D node's state.
36
+ * @returns The display object representing the label shape of the 3D node.
37
+ */
30
38
  public drawLabelShape(
31
39
  model: NodeDisplayModel,
32
40
  shapeMap: NodeShapeMap,
@@ -49,13 +57,6 @@ export abstract class BaseNode3D extends BaseNode {
49
57
  ...otherStyle
50
58
  } = shapeStyle;
51
59
 
52
- // TODO
53
- // const wordWrapWidth = getWordWrapWidthByBox(
54
- // keyShapeBox,
55
- // maxWidth,
56
- // this.zoomCache.zoom,
57
- // );
58
-
59
60
  const positionPreset = {
60
61
  x: keyShapeBox.center[0],
61
62
  y: keyShapeBox.max[1],
@@ -109,7 +110,14 @@ export abstract class BaseNode3D extends BaseNode {
109
110
  return this.upsertShape('text', 'labelShape', style, shapeMap);
110
111
  }
111
112
 
112
- // TODO: 3d icon? - billboard image or text for alpha
113
+ /**
114
+ * Draw the icon shape of the 3D node
115
+ * @param model The displayed model of this 3D node, only for drawing and not received by users.
116
+ * @param shapeMap The shape map that contains all of the elements to show on the 3D node.
117
+ * @param diffData An object that contains previous and current data.
118
+ * @param diffState An object that contains previous and current 3D node's state.
119
+ * @returns The display object representing the icon shape of the 3D node.
120
+ */
113
121
  public drawIconShape(
114
122
  model: NodeDisplayModel,
115
123
  shapeMap: NodeShapeMap,
@@ -192,5 +200,12 @@ export abstract class BaseNode3D extends BaseNode {
192
200
  return upsertShape3D(type, id, style as GShapeStyle, shapeMap, this.device);
193
201
  }
194
202
 
203
+ /**
204
+ * The listener for graph zooming.
205
+ * 1. show / hide some shapes while zoom level changed;
206
+ * 2. change the shapes' sizes to make them have same visual size while zooming, e.g. labelShape, labelBackgroundShape.
207
+ * @param shapeMap The shape map that contains all of the elements to show on the node.
208
+ * @param zoom The zoom level of the graph.
209
+ */
195
210
  public onZoom = (shapeMap: NodeShapeMap, zoom: number) => {};
196
211
  }
@@ -12,7 +12,7 @@ type PathArray = any; //TODO: cannot import type PathArray
12
12
  export class DiamondNode extends BaseNode {
13
13
  override defaultStyles = {
14
14
  keyShape: {
15
- size: [50, 30],
15
+ size: [32, 32],
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -11,8 +11,8 @@ import { BaseNode } from './base';
11
11
  export class EllipseNode extends BaseNode {
12
12
  override defaultStyles = {
13
13
  keyShape: {
14
- rx: 30,
15
- ry: 20,
14
+ rx: 16,
15
+ ry: 12,
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -9,13 +9,18 @@ import {
9
9
  } from '../../../types/node';
10
10
  import { BaseNode } from './base';
11
11
 
12
+ const offsetAngleMap = {
13
+ horizontal: 0,
14
+ vertical: Math.PI / 2,
15
+ };
16
+
12
17
  export class HexagonNode extends BaseNode {
13
18
  override defaultStyles = {
14
19
  keyShape: {
15
- r: 20,
20
+ r: 16,
16
21
  x: 0,
17
22
  y: 0,
18
- direction: 'horizontal',
23
+ direction: 'vertical',
19
24
  },
20
25
  };
21
26
  mergedStyles: NodeShapeStyles;
@@ -119,9 +124,9 @@ export class HexagonNode extends BaseNode {
119
124
  private getHexagonPoints(r: number, direction: string): [number, number][] {
120
125
  const angleIncrement = Math.PI / 3; //The angle increment between vertex.
121
126
  const v = [];
122
- const offsetAngle = direction === 'horizontal' ? 0 : Math.PI / 2;
127
+
123
128
  for (let i = 0; i < 6; i++) {
124
- const angle = i * angleIncrement + offsetAngle;
129
+ const angle = i * angleIncrement + offsetAngleMap[direction];
125
130
  const vx = r * Math.cos(angle);
126
131
  const vy = r * Math.sin(angle);
127
132
  v.push([vx, vy]);
@@ -153,8 +158,7 @@ export class HexagonNode extends BaseNode {
153
158
  ? anchorPositionHorizontal
154
159
  : anchorPositionVertical;
155
160
  const angleIncrement = Math.PI / 3; //The angle increment between vertex.
156
- const offsetAngle =
157
- keyShapeStyle.direction === 'horizontal' ? 0 : Math.PI / 2;
161
+ const offsetAngle = offsetAngleMap[keyShapeStyle.direction];
158
162
  const r = keyShapeStyle.r;
159
163
  const anchorPositionMap = {};
160
164
  for (let i = 0; i < 6; i++) {
@@ -163,6 +167,10 @@ export class HexagonNode extends BaseNode {
163
167
  const vy = r * Math.sin(angle);
164
168
  anchorPositionMap[anchorPositionDirection[i]] = [vx, vy];
165
169
  }
170
+ if (!anchorPositionMap.hasOwnProperty('default')) {
171
+ anchorPositionMap['default'] =
172
+ anchorPositionMap[anchorPositionDirection[0]];
173
+ }
166
174
  return anchorPositionMap;
167
175
  }
168
176
  }