@antv/g6 5.0.0-beta.34 → 5.0.0-beta.35

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 (352) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/animations/types.d.ts +3 -4
  3. package/dist/lib/behaviors/base-behavior.d.ts +2 -1
  4. package/dist/lib/behaviors/brush-select.d.ts +31 -13
  5. package/dist/lib/behaviors/click-element.d.ts +28 -5
  6. package/dist/lib/behaviors/collapse-expand.d.ts +2 -0
  7. package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
  8. package/dist/lib/behaviors/drag-element.d.ts +2 -2
  9. package/dist/lib/behaviors/index.d.ts +2 -0
  10. package/dist/lib/behaviors/lasso-select.d.ts +2 -1
  11. package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
  12. package/dist/lib/behaviors/types.d.ts +2 -1
  13. package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
  14. package/dist/lib/constants/events/graph.d.ts +5 -1
  15. package/dist/lib/elements/combos/base-combo.d.ts +1 -1
  16. package/dist/lib/elements/edges/base-edge.d.ts +0 -5
  17. package/dist/lib/elements/nodes/base-node.d.ts +1 -7
  18. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  19. package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
  20. package/dist/lib/elements/shapes/index.d.ts +2 -0
  21. package/dist/lib/exports.d.ts +12 -20
  22. package/dist/lib/plugins/bubble-sets.d.ts +45 -0
  23. package/dist/lib/plugins/camera-setting.d.ts +4 -2
  24. package/dist/lib/plugins/contextmenu.d.ts +1 -0
  25. package/dist/lib/plugins/grid-line.d.ts +51 -8
  26. package/dist/lib/plugins/hull/index.d.ts +43 -11
  27. package/dist/lib/plugins/index.d.ts +4 -0
  28. package/dist/lib/plugins/timebar.d.ts +225 -0
  29. package/dist/lib/plugins/tooltip.d.ts +2 -2
  30. package/dist/lib/registry/index.d.ts +1 -1
  31. package/dist/lib/runtime/data.d.ts +9 -3
  32. package/dist/lib/runtime/element.d.ts +3 -7
  33. package/dist/lib/runtime/graph.d.ts +530 -42
  34. package/dist/lib/runtime/types.d.ts +3 -3
  35. package/dist/lib/runtime/viewport.d.ts +2 -2
  36. package/dist/lib/spec/canvas.d.ts +6 -2
  37. package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
  38. package/dist/lib/spec/index.d.ts +1 -1
  39. package/dist/lib/spec/theme.d.ts +1 -4
  40. package/dist/lib/spec/viewport.d.ts +1 -1
  41. package/dist/lib/themes/types.d.ts +0 -1
  42. package/dist/lib/transforms/process-parallel-edges.d.ts +1 -1
  43. package/dist/lib/types/data.d.ts +2 -2
  44. package/dist/lib/types/viewport.d.ts +4 -4
  45. package/dist/lib/utils/animation.d.ts +5 -5
  46. package/dist/lib/utils/data.d.ts +2 -2
  47. package/dist/lib/utils/element.d.ts +1 -1
  48. package/dist/lib/utils/event/events.d.ts +1 -1
  49. package/dist/lib/utils/event/index.d.ts +1 -1
  50. package/dist/lib/utils/palette.d.ts +1 -1
  51. package/dist/lib/utils/relation.d.ts +2 -2
  52. package/dist/lib/utils/visibility.d.ts +1 -1
  53. package/esm/animations/types.d.ts +3 -4
  54. package/esm/behaviors/base-behavior.d.ts +2 -1
  55. package/esm/behaviors/brush-select.d.ts +31 -13
  56. package/esm/behaviors/brush-select.js +7 -2
  57. package/esm/behaviors/brush-select.js.map +1 -1
  58. package/esm/behaviors/click-element.d.ts +28 -5
  59. package/esm/behaviors/click-element.js +11 -0
  60. package/esm/behaviors/click-element.js.map +1 -1
  61. package/esm/behaviors/collapse-expand.d.ts +2 -0
  62. package/esm/behaviors/collapse-expand.js +2 -2
  63. package/esm/behaviors/collapse-expand.js.map +1 -1
  64. package/esm/behaviors/drag-canvas.d.ts +7 -0
  65. package/esm/behaviors/drag-canvas.js.map +1 -1
  66. package/esm/behaviors/drag-element.d.ts +2 -2
  67. package/esm/behaviors/index.d.ts +2 -0
  68. package/esm/behaviors/index.js +1 -0
  69. package/esm/behaviors/index.js.map +1 -1
  70. package/esm/behaviors/lasso-select.d.ts +2 -1
  71. package/esm/behaviors/lasso-select.js +1 -1
  72. package/esm/behaviors/lasso-select.js.map +1 -1
  73. package/esm/behaviors/scroll-canvas.d.ts +64 -0
  74. package/esm/behaviors/scroll-canvas.js +80 -0
  75. package/esm/behaviors/scroll-canvas.js.map +1 -0
  76. package/esm/behaviors/types.d.ts +2 -1
  77. package/esm/behaviors/zoom-canvas.d.ts +1 -1
  78. package/esm/constants/events/graph.d.ts +5 -1
  79. package/esm/constants/events/graph.js +4 -0
  80. package/esm/constants/events/graph.js.map +1 -1
  81. package/esm/elements/combos/base-combo.d.ts +1 -1
  82. package/esm/elements/edges/base-edge.d.ts +0 -5
  83. package/esm/elements/edges/base-edge.js +1 -2
  84. package/esm/elements/edges/base-edge.js.map +1 -1
  85. package/esm/elements/nodes/base-node.d.ts +1 -7
  86. package/esm/elements/nodes/base-node.js +2 -2
  87. package/esm/elements/nodes/base-node.js.map +1 -1
  88. package/esm/elements/shapes/badge.d.ts +1 -1
  89. package/{lib/plugins/hull/shape.d.ts → esm/elements/shapes/contour.d.ts} +17 -17
  90. package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
  91. package/esm/elements/shapes/contour.js.map +1 -0
  92. package/esm/elements/shapes/index.d.ts +2 -0
  93. package/esm/elements/shapes/index.js +1 -0
  94. package/esm/elements/shapes/index.js.map +1 -1
  95. package/esm/exports.d.ts +12 -20
  96. package/esm/exports.js +6 -17
  97. package/esm/exports.js.map +1 -1
  98. package/esm/plugins/bubble-sets.d.ts +45 -0
  99. package/esm/plugins/bubble-sets.js +212 -0
  100. package/esm/plugins/bubble-sets.js.map +1 -0
  101. package/esm/plugins/camera-setting.d.ts +4 -2
  102. package/esm/plugins/camera-setting.js.map +1 -1
  103. package/esm/plugins/contextmenu.d.ts +1 -0
  104. package/esm/plugins/contextmenu.js +1 -0
  105. package/esm/plugins/contextmenu.js.map +1 -1
  106. package/esm/plugins/grid-line.d.ts +51 -8
  107. package/esm/plugins/grid-line.js.map +1 -1
  108. package/esm/plugins/history/utils.js +6 -2
  109. package/esm/plugins/history/utils.js.map +1 -1
  110. package/esm/plugins/hull/index.d.ts +43 -11
  111. package/esm/plugins/hull/index.js +46 -16
  112. package/esm/plugins/hull/index.js.map +1 -1
  113. package/esm/plugins/index.d.ts +4 -0
  114. package/esm/plugins/index.js +2 -0
  115. package/esm/plugins/index.js.map +1 -1
  116. package/esm/plugins/legend.js +2 -1
  117. package/esm/plugins/legend.js.map +1 -1
  118. package/esm/plugins/timebar.d.ts +225 -0
  119. package/esm/plugins/timebar.js +253 -0
  120. package/esm/plugins/timebar.js.map +1 -0
  121. package/esm/plugins/tooltip.d.ts +2 -2
  122. package/esm/registry/build-in.js +10 -7
  123. package/esm/registry/build-in.js.map +1 -1
  124. package/esm/registry/index.d.ts +1 -1
  125. package/esm/registry/index.js +1 -1
  126. package/esm/runtime/canvas.js +2 -2
  127. package/esm/runtime/canvas.js.map +1 -1
  128. package/esm/runtime/data.d.ts +9 -3
  129. package/esm/runtime/data.js +20 -3
  130. package/esm/runtime/data.js.map +1 -1
  131. package/esm/runtime/element.d.ts +3 -7
  132. package/esm/runtime/element.js +6 -4
  133. package/esm/runtime/element.js.map +1 -1
  134. package/esm/runtime/graph.d.ts +530 -42
  135. package/esm/runtime/graph.js +409 -33
  136. package/esm/runtime/graph.js.map +1 -1
  137. package/esm/runtime/types.d.ts +3 -3
  138. package/esm/runtime/viewport.d.ts +2 -2
  139. package/esm/runtime/viewport.js +2 -2
  140. package/esm/spec/canvas.d.ts +6 -2
  141. package/{dist/lib/spec/spec.d.ts → esm/spec/graph.d.ts} +12 -4
  142. package/esm/spec/graph.js +2 -0
  143. package/esm/spec/graph.js.map +1 -0
  144. package/esm/spec/index.d.ts +1 -1
  145. package/esm/spec/theme.d.ts +1 -4
  146. package/esm/spec/viewport.d.ts +1 -1
  147. package/esm/themes/base.js +9 -9
  148. package/esm/themes/base.js.map +1 -1
  149. package/esm/themes/types.d.ts +0 -1
  150. package/esm/transforms/process-parallel-edges.d.ts +1 -1
  151. package/esm/types/data.d.ts +2 -2
  152. package/esm/types/viewport.d.ts +4 -4
  153. package/esm/utils/animation.d.ts +5 -5
  154. package/esm/utils/animation.js +2 -2
  155. package/esm/utils/animation.js.map +1 -1
  156. package/esm/utils/change.js +8 -1
  157. package/esm/utils/change.js.map +1 -1
  158. package/esm/utils/data.d.ts +2 -2
  159. package/esm/utils/data.js +2 -2
  160. package/esm/utils/element.d.ts +1 -1
  161. package/esm/utils/element.js +2 -2
  162. package/esm/utils/event/events.d.ts +1 -1
  163. package/esm/utils/event/events.js.map +1 -1
  164. package/esm/utils/event/index.d.ts +1 -1
  165. package/esm/utils/event/index.js +1 -1
  166. package/esm/utils/palette.d.ts +1 -1
  167. package/esm/utils/palette.js +1 -1
  168. package/esm/utils/relation.d.ts +2 -2
  169. package/esm/utils/relation.js +2 -2
  170. package/esm/utils/visibility.d.ts +1 -1
  171. package/esm/utils/visibility.js +1 -1
  172. package/lib/animations/types.d.ts +3 -4
  173. package/lib/behaviors/base-behavior.d.ts +2 -1
  174. package/lib/behaviors/brush-select.d.ts +31 -13
  175. package/lib/behaviors/brush-select.js +7 -2
  176. package/lib/behaviors/brush-select.js.map +1 -1
  177. package/lib/behaviors/click-element.d.ts +28 -5
  178. package/lib/behaviors/click-element.js +11 -0
  179. package/lib/behaviors/click-element.js.map +1 -1
  180. package/lib/behaviors/collapse-expand.d.ts +2 -0
  181. package/lib/behaviors/collapse-expand.js +2 -2
  182. package/lib/behaviors/collapse-expand.js.map +1 -1
  183. package/lib/behaviors/drag-canvas.d.ts +7 -0
  184. package/lib/behaviors/drag-canvas.js.map +1 -1
  185. package/lib/behaviors/drag-element.d.ts +2 -2
  186. package/lib/behaviors/index.d.ts +2 -0
  187. package/lib/behaviors/index.js +3 -1
  188. package/lib/behaviors/index.js.map +1 -1
  189. package/lib/behaviors/lasso-select.d.ts +2 -1
  190. package/lib/behaviors/lasso-select.js +1 -1
  191. package/lib/behaviors/lasso-select.js.map +1 -1
  192. package/lib/behaviors/scroll-canvas.d.ts +64 -0
  193. package/lib/behaviors/scroll-canvas.js +84 -0
  194. package/lib/behaviors/scroll-canvas.js.map +1 -0
  195. package/lib/behaviors/types.d.ts +2 -1
  196. package/lib/behaviors/zoom-canvas.d.ts +1 -1
  197. package/lib/constants/events/graph.d.ts +5 -1
  198. package/lib/constants/events/graph.js +4 -0
  199. package/lib/constants/events/graph.js.map +1 -1
  200. package/lib/elements/combos/base-combo.d.ts +1 -1
  201. package/lib/elements/edges/base-edge.d.ts +0 -5
  202. package/lib/elements/edges/base-edge.js +1 -2
  203. package/lib/elements/edges/base-edge.js.map +1 -1
  204. package/lib/elements/nodes/base-node.d.ts +1 -7
  205. package/lib/elements/nodes/base-node.js +2 -2
  206. package/lib/elements/nodes/base-node.js.map +1 -1
  207. package/lib/elements/shapes/badge.d.ts +1 -1
  208. package/{esm/plugins/hull/shape.d.ts → lib/elements/shapes/contour.d.ts} +17 -17
  209. package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
  210. package/lib/elements/shapes/contour.js.map +1 -0
  211. package/lib/elements/shapes/index.d.ts +2 -0
  212. package/lib/elements/shapes/index.js +3 -1
  213. package/lib/elements/shapes/index.js.map +1 -1
  214. package/lib/exports.d.ts +12 -20
  215. package/lib/exports.js +46 -17
  216. package/lib/exports.js.map +1 -1
  217. package/lib/plugins/bubble-sets.d.ts +45 -0
  218. package/lib/plugins/bubble-sets.js +216 -0
  219. package/lib/plugins/bubble-sets.js.map +1 -0
  220. package/lib/plugins/camera-setting.d.ts +4 -2
  221. package/lib/plugins/camera-setting.js.map +1 -1
  222. package/lib/plugins/contextmenu.d.ts +1 -0
  223. package/lib/plugins/contextmenu.js +1 -0
  224. package/lib/plugins/contextmenu.js.map +1 -1
  225. package/lib/plugins/grid-line.d.ts +51 -8
  226. package/lib/plugins/grid-line.js.map +1 -1
  227. package/lib/plugins/history/utils.js +6 -2
  228. package/lib/plugins/history/utils.js.map +1 -1
  229. package/lib/plugins/hull/index.d.ts +43 -11
  230. package/lib/plugins/hull/index.js +46 -16
  231. package/lib/plugins/hull/index.js.map +1 -1
  232. package/lib/plugins/index.d.ts +4 -0
  233. package/lib/plugins/index.js +5 -1
  234. package/lib/plugins/index.js.map +1 -1
  235. package/lib/plugins/legend.js +2 -1
  236. package/lib/plugins/legend.js.map +1 -1
  237. package/lib/plugins/timebar.d.ts +225 -0
  238. package/lib/plugins/timebar.js +257 -0
  239. package/lib/plugins/timebar.js.map +1 -0
  240. package/lib/plugins/tooltip.d.ts +2 -2
  241. package/lib/registry/build-in.js +8 -5
  242. package/lib/registry/build-in.js.map +1 -1
  243. package/lib/registry/index.d.ts +1 -1
  244. package/lib/registry/index.js +1 -1
  245. package/lib/runtime/canvas.js +2 -2
  246. package/lib/runtime/canvas.js.map +1 -1
  247. package/lib/runtime/data.d.ts +9 -3
  248. package/lib/runtime/data.js +20 -3
  249. package/lib/runtime/data.js.map +1 -1
  250. package/lib/runtime/element.d.ts +3 -7
  251. package/lib/runtime/element.js +6 -4
  252. package/lib/runtime/element.js.map +1 -1
  253. package/lib/runtime/graph.d.ts +530 -42
  254. package/lib/runtime/graph.js +409 -33
  255. package/lib/runtime/graph.js.map +1 -1
  256. package/lib/runtime/types.d.ts +3 -3
  257. package/lib/runtime/viewport.d.ts +2 -2
  258. package/lib/runtime/viewport.js +2 -2
  259. package/lib/spec/canvas.d.ts +6 -2
  260. package/{esm/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
  261. package/lib/spec/{spec.js → graph.js} +1 -1
  262. package/lib/spec/graph.js.map +1 -0
  263. package/lib/spec/index.d.ts +1 -1
  264. package/lib/spec/theme.d.ts +1 -4
  265. package/lib/spec/viewport.d.ts +1 -1
  266. package/lib/themes/base.js +9 -9
  267. package/lib/themes/base.js.map +1 -1
  268. package/lib/themes/types.d.ts +0 -1
  269. package/lib/transforms/process-parallel-edges.d.ts +1 -1
  270. package/lib/types/data.d.ts +2 -2
  271. package/lib/types/viewport.d.ts +4 -4
  272. package/lib/utils/animation.d.ts +5 -5
  273. package/lib/utils/animation.js +2 -2
  274. package/lib/utils/animation.js.map +1 -1
  275. package/lib/utils/change.js +8 -1
  276. package/lib/utils/change.js.map +1 -1
  277. package/lib/utils/data.d.ts +2 -2
  278. package/lib/utils/data.js +2 -2
  279. package/lib/utils/element.d.ts +1 -1
  280. package/lib/utils/element.js +2 -2
  281. package/lib/utils/event/events.d.ts +1 -1
  282. package/lib/utils/event/events.js.map +1 -1
  283. package/lib/utils/event/index.d.ts +1 -1
  284. package/lib/utils/event/index.js +1 -1
  285. package/lib/utils/palette.d.ts +1 -1
  286. package/lib/utils/palette.js +1 -1
  287. package/lib/utils/relation.d.ts +2 -2
  288. package/lib/utils/relation.js +2 -2
  289. package/lib/utils/visibility.d.ts +1 -1
  290. package/lib/utils/visibility.js +1 -1
  291. package/package.json +2 -1
  292. package/src/animations/types.ts +3 -4
  293. package/src/behaviors/base-behavior.ts +1 -1
  294. package/src/behaviors/brush-select.ts +33 -14
  295. package/src/behaviors/click-element.ts +28 -5
  296. package/src/behaviors/collapse-expand.ts +4 -2
  297. package/src/behaviors/drag-canvas.ts +7 -0
  298. package/src/behaviors/drag-element.ts +2 -2
  299. package/src/behaviors/index.ts +2 -0
  300. package/src/behaviors/lasso-select.ts +2 -2
  301. package/src/behaviors/scroll-canvas.ts +143 -0
  302. package/src/behaviors/types.ts +2 -1
  303. package/src/behaviors/zoom-canvas.ts +1 -1
  304. package/src/constants/events/graph.ts +4 -0
  305. package/src/elements/combos/base-combo.ts +1 -1
  306. package/src/elements/edges/base-edge.ts +1 -7
  307. package/src/elements/nodes/base-node.ts +3 -12
  308. package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
  309. package/src/elements/shapes/index.ts +2 -0
  310. package/src/exports.ts +104 -24
  311. package/src/plugins/bubble-sets.ts +268 -0
  312. package/src/plugins/camera-setting.ts +4 -2
  313. package/src/plugins/contextmenu.ts +1 -0
  314. package/src/plugins/grid-line.ts +51 -8
  315. package/src/plugins/history/utils.ts +6 -2
  316. package/src/plugins/hull/index.ts +57 -20
  317. package/src/plugins/index.ts +4 -0
  318. package/src/plugins/legend.ts +3 -1
  319. package/src/plugins/timebar.ts +450 -0
  320. package/src/plugins/tooltip.ts +2 -2
  321. package/src/registry/build-in.ts +21 -6
  322. package/src/registry/index.ts +1 -1
  323. package/src/runtime/canvas.ts +2 -2
  324. package/src/runtime/data.ts +21 -3
  325. package/src/runtime/element.ts +5 -4
  326. package/src/runtime/graph.ts +543 -48
  327. package/src/runtime/types.ts +3 -3
  328. package/src/runtime/viewport.ts +2 -2
  329. package/src/spec/canvas.ts +6 -2
  330. package/src/spec/{spec.ts → graph.ts} +12 -4
  331. package/src/spec/index.ts +1 -1
  332. package/src/spec/theme.ts +1 -5
  333. package/src/spec/viewport.ts +1 -1
  334. package/src/themes/base.ts +9 -9
  335. package/src/themes/types.ts +0 -2
  336. package/src/transforms/process-parallel-edges.ts +1 -1
  337. package/src/types/data.ts +2 -2
  338. package/src/types/viewport.ts +4 -4
  339. package/src/utils/animation.ts +4 -4
  340. package/src/utils/change.ts +6 -1
  341. package/src/utils/data.ts +2 -2
  342. package/src/utils/element.ts +2 -2
  343. package/src/utils/event/events.ts +3 -1
  344. package/src/utils/event/index.ts +1 -1
  345. package/src/utils/palette.ts +1 -1
  346. package/src/utils/relation.ts +2 -2
  347. package/src/utils/visibility.ts +1 -1
  348. package/esm/plugins/hull/shape.js.map +0 -1
  349. package/esm/spec/spec.js +0 -2
  350. package/esm/spec/spec.js.map +0 -1
  351. package/lib/plugins/hull/shape.js.map +0 -1
  352. package/lib/spec/spec.js.map +0 -1
@@ -10,8 +10,8 @@ import type {
10
10
  ComboOptions,
11
11
  EdgeData,
12
12
  EdgeOptions,
13
- G6Spec,
14
13
  GraphData,
14
+ GraphOptions,
15
15
  LayoutOptions,
16
16
  NodeData,
17
17
  NodeOptions,
@@ -61,9 +61,12 @@ import { RuntimeContext } from './types';
61
61
  import { ViewportController } from './viewport';
62
62
 
63
63
  export class Graph extends EventEmitter {
64
- private options: G6Spec;
64
+ private options: GraphOptions;
65
65
 
66
- static defaultOptions: G6Spec = {
66
+ /**
67
+ * @internal
68
+ */
69
+ static defaultOptions: GraphOptions = {
67
70
  autoResize: false,
68
71
  theme: 'light',
69
72
  rotation: 0,
@@ -71,6 +74,11 @@ export class Graph extends EventEmitter {
71
74
  zoomRange: [0.01, 10],
72
75
  };
73
76
 
77
+ /**
78
+ * <zh/> 当前图实例是否已经被销毁
79
+ *
80
+ * <en/> Whether the current graph instance has been destroyed
81
+ */
74
82
  public destroyed = false;
75
83
 
76
84
  // @ts-expect-error will be initialized in createRuntime
@@ -78,7 +86,7 @@ export class Graph extends EventEmitter {
78
86
  model: new DataController(),
79
87
  };
80
88
 
81
- constructor(options: G6Spec) {
89
+ constructor(options: GraphOptions) {
82
90
  super();
83
91
  this.options = Object.assign({}, Graph.defaultOptions, options);
84
92
  this.setOptions(this.options);
@@ -93,8 +101,9 @@ export class Graph extends EventEmitter {
93
101
  *
94
102
  * <en/> Get options
95
103
  * @returns <zh/> 配置项 | <en/> options
104
+ * @apiCategory option
96
105
  */
97
- public getOptions(): G6Spec {
106
+ public getOptions(): GraphOptions {
98
107
  return this.options;
99
108
  }
100
109
 
@@ -103,12 +112,13 @@ export class Graph extends EventEmitter {
103
112
  *
104
113
  * <en/> Set options
105
114
  * @param options - <zh/> 配置项 | <en/> options
106
- * @description
115
+ * @remarks
107
116
  * <zh/> 要更新 devicePixelRatio、container 属性请销毁后重新创建实例
108
117
  *
109
118
  * <en/> To update devicePixelRatio and container properties, please destroy and recreate the instance
119
+ * @apiCategory option
110
120
  */
111
- public setOptions(options: G6Spec): void {
121
+ public setOptions(options: GraphOptions): void {
112
122
  const {
113
123
  animation,
114
124
  background,
@@ -147,49 +157,130 @@ export class Graph extends EventEmitter {
147
157
  if (isNumber(padding) || isArray(padding)) this.options.padding = padding;
148
158
  }
149
159
 
150
- public setBackground(background: G6Spec['background']): void {
160
+ /**
161
+ * <zh/> 设置画布背景色
162
+ *
163
+ * <en/> Set canvas background color
164
+ * @param background - <zh/> 背景色 | <en/> background color
165
+ * @apiCategory canvas
166
+ */
167
+ public setBackground(background: GraphOptions['background']): void {
151
168
  this.options.background = background;
152
169
  this.context.canvas?.setBackground(background);
153
170
  }
154
171
 
155
- public getBackground(): G6Spec['background'] {
172
+ /**
173
+ * <zh/> 获取画布背景色
174
+ *
175
+ * <en/> Get canvas background color
176
+ * @returns <zh/> 背景色 | <en/> background color
177
+ * @apiCategory canvas
178
+ */
179
+ public getBackground(): GraphOptions['background'] {
156
180
  return this.options.background;
157
181
  }
158
182
 
183
+ /**
184
+ * <zh/> 获取当前图容器的大小
185
+ *
186
+ * <en/> Get the size of the current canvas container
187
+ * @returns <zh/> 画布尺寸 | <en/> canvas size
188
+ * @apiCategory canvas
189
+ */
159
190
  public getSize(): [number, number] {
160
191
  if (this.context.canvas) return this.context.canvas.getSize();
161
192
  return [this.options.width || 0, this.options.height || 0];
162
193
  }
163
194
 
195
+ /**
196
+ * <zh/> 获取当前图容器的大小
197
+ *
198
+ * <en/> Get the size of the current canvas container
199
+ * @param width - <zh/> 画布宽度 | <en/> canvas width
200
+ * @param height - <zh/> 画布高度 | <en/> canvas height
201
+ * @apiCategory canvas
202
+ */
164
203
  public setSize(width: number, height: number): void {
165
204
  this.options.width = width;
166
205
  this.options.height = height;
167
206
  }
168
207
 
169
- public setZoomRange(zoomRange: G6Spec['zoomRange']): void {
208
+ /**
209
+ * <zh/> 获取当前图的缩放区间
210
+ *
211
+ * <en/> Get the zoom range of the current graph
212
+ * @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
213
+ * @apiCategory viewport
214
+ */
215
+ public setZoomRange(zoomRange: GraphOptions['zoomRange']): void {
170
216
  this.options.zoomRange = zoomRange;
171
217
  }
172
218
 
173
- public getZoomRange(): G6Spec['zoomRange'] {
219
+ /**
220
+ * <zh/> 获取当前图的缩放区间
221
+ *
222
+ * <en/> Get the zoom range of the current graph
223
+ * @returns <zh/> 缩放区间 | <en/> zoom range
224
+ * @apiCategory viewport
225
+ */
226
+ public getZoomRange(): GraphOptions['zoomRange'] {
174
227
  return this.options.zoomRange;
175
228
  }
176
229
 
230
+ /**
231
+ * <zh/> 设置节点样式映射
232
+ *
233
+ * <en/> Set node mapper
234
+ * @param node - <zh/> 节点配置 | <en/> node configuration
235
+ * @apiCategory element
236
+ */
177
237
  public setNode(node: NodeOptions): void {
178
238
  this.options.node = node;
239
+ this.context.model.refreshData();
179
240
  }
180
241
 
242
+ /**
243
+ * <zh/> 设置边样式映射
244
+ *
245
+ * <en/> Set edge mapper
246
+ * @param edge - <zh/> 边配置 | <en/> edge configuration
247
+ * @apiCategory element
248
+ */
181
249
  public setEdge(edge: EdgeOptions): void {
182
250
  this.options.edge = edge;
251
+ this.context.model.refreshData();
183
252
  }
184
253
 
254
+ /**
255
+ * <zh/> 设置组合样式映射
256
+ *
257
+ * <en/> Set combo mapper
258
+ * @param combo - <zh/> 组合配置 | <en/> combo configuration
259
+ * @apiCategory element
260
+ */
185
261
  public setCombo(combo: ComboOptions): void {
186
262
  this.options.combo = combo;
263
+ this.context.model.refreshData();
187
264
  }
188
265
 
266
+ /**
267
+ * <zh/> 获取主题
268
+ *
269
+ * <en/> Get theme
270
+ * @returns <zh/> 主题配置 | <en/> theme configuration
271
+ * @apiCategory theme
272
+ */
189
273
  public getTheme(): ThemeOptions {
190
274
  return this.options.theme!;
191
275
  }
192
276
 
277
+ /**
278
+ * <zh/> 设置主题
279
+ *
280
+ * <en/> Set theme
281
+ * @param theme - <zh/> 主题配置 | <en/> theme configuration
282
+ * @apiCategory theme
283
+ */
193
284
  public setTheme(theme: CallableValue<ThemeOptions>): void {
194
285
  this.options.theme = isFunction(theme) ? theme(this.getTheme()) : theme;
195
286
 
@@ -199,10 +290,24 @@ export class Graph extends EventEmitter {
199
290
  }
200
291
  }
201
292
 
293
+ /**
294
+ * <zh/> 设置布局
295
+ *
296
+ * <en/> Set layout
297
+ * @param layout - <zh/> 布局配置 | <en/> layout configuration
298
+ * @apiCategory layout
299
+ */
202
300
  public setLayout(layout: CallableValue<LayoutOptions>): void {
203
301
  this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
204
302
  }
205
303
 
304
+ /**
305
+ * <zh/> 获取布局
306
+ *
307
+ * <en/> Get layout
308
+ * @returns <zh/> 布局配置 | <en/> layout configuration
309
+ * @apiCategory layout
310
+ */
206
311
  public getLayout(): LayoutOptions {
207
312
  return this.options.layout!;
208
313
  }
@@ -212,6 +317,7 @@ export class Graph extends EventEmitter {
212
317
  *
213
318
  * <en/> Set behaviors
214
319
  * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
320
+ * @apiCategory behavior
215
321
  */
216
322
  public setBehaviors(behaviors: CallableValue<BehaviorOptions>): void {
217
323
  this.options.behaviors = isFunction(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
@@ -223,6 +329,7 @@ export class Graph extends EventEmitter {
223
329
  *
224
330
  * <en/> Update behavior
225
331
  * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
332
+ * @apiCategory behavior
226
333
  */
227
334
  public updateBehavior(behavior: UpdateBehaviorOption): void {
228
335
  this.setBehaviors((behaviors) =>
@@ -240,6 +347,7 @@ export class Graph extends EventEmitter {
240
347
  *
241
348
  * <en/> Get behaviors
242
349
  * @returns <zh/> 交互配置 | <en/> behavior configuration
350
+ * @apiCategory behavior
243
351
  */
244
352
  public getBehaviors(): BehaviorOptions {
245
353
  return this.options.behaviors || [];
@@ -250,6 +358,7 @@ export class Graph extends EventEmitter {
250
358
  *
251
359
  * <en/> Set plugins
252
360
  * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
361
+ * @apiCategory plugin
253
362
  */
254
363
  public setPlugins(plugins: CallableValue<PluginOptions>): void {
255
364
  this.options.plugins = isFunction(plugins) ? plugins(this.getPlugins()) : plugins;
@@ -261,6 +370,7 @@ export class Graph extends EventEmitter {
261
370
  *
262
371
  * <en/> Update plugin
263
372
  * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
373
+ * @apiCategory plugin
264
374
  */
265
375
  public updatePlugin(plugin: UpdatePluginOption): void {
266
376
  this.setPlugins((plugins) =>
@@ -278,6 +388,7 @@ export class Graph extends EventEmitter {
278
388
  *
279
389
  * <en/> Get plugins
280
390
  * @returns <zh/> 插件配置 | <en/> plugin configuration
391
+ * @apiCategory plugin
281
392
  */
282
393
  public getPlugins(): PluginOptions {
283
394
  return this.options.plugins || [];
@@ -289,6 +400,7 @@ export class Graph extends EventEmitter {
289
400
  * <en/> Get plugin instance
290
401
  * @param key - <zh/> 插件 key | <en/> plugin key
291
402
  * @returns <zh/> 插件实例 | <en/> plugin instance
403
+ * @apiCategory plugin
292
404
  */
293
405
  public getPluginInstance<T extends Plugin>(key: string) {
294
406
  return this.context.plugin!.getPluginInstance(key) as unknown as T;
@@ -299,6 +411,7 @@ export class Graph extends EventEmitter {
299
411
  *
300
412
  * <en/> Set data transforms
301
413
  * @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
414
+ * @apiCategory transform
302
415
  */
303
416
  public setTransforms(transforms: CallableValue<TransformOptions>): void {
304
417
  this.options.transforms = isFunction(transforms) ? transforms(this.getTransforms()) : transforms;
@@ -310,6 +423,7 @@ export class Graph extends EventEmitter {
310
423
  *
311
424
  * <en/> Update data transform
312
425
  * @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
426
+ * @apiCategory transform
313
427
  */
314
428
  public updateTransform(transform: UpdateTransformOption): void {
315
429
  this.setTransforms((transforms) =>
@@ -327,17 +441,48 @@ export class Graph extends EventEmitter {
327
441
  *
328
442
  * <en/> Get data transforms
329
443
  * @returns <zh/> 数据转换器实例 | <en/> data transform instance
444
+ * @apiCategory transform
330
445
  */
331
446
  public getTransforms(): TransformOptions {
332
447
  return this.options.transforms || [];
333
448
  }
334
449
 
450
+ /**
451
+ * <zh/> 获取数据
452
+ *
453
+ * <en/> Get data
454
+ * @returns <zh/> 数据 | <en/> data
455
+ * @apiCategory data
456
+ */
335
457
  public getData(): GraphData {
336
458
  return this.context.model.getData();
337
459
  }
338
460
 
461
+ /**
462
+ * <zh/> 获取所有节点数据
463
+ *
464
+ * <en/> Get all node data
465
+ * @returns <zh/> 节点数据 | <en/> node data
466
+ * @apiCategory data
467
+ */
339
468
  public getNodeData(): NodeData[];
469
+ /**
470
+ * <zh/> 获取单个节点数据
471
+ *
472
+ * <en/> Get single node data
473
+ * @param id - <zh/> 节点 ID | <en/> node ID
474
+ * @returns <zh/> 节点数据 | <en/> node data
475
+ * @apiCategory data
476
+ */
340
477
  public getNodeData(id: ID): NodeData;
478
+ /**
479
+ * <zh/> 批量获取多个节点数据
480
+ *
481
+ * <en/> Get multiple node data in batch
482
+ * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
483
+ * @returns <zh/> 节点数据 | <en/> node data
484
+ * @apiCategory data
485
+ */
341
486
  public getNodeData(ids: ID[]): NodeData[];
342
487
  public getNodeData(id?: ID | ID[]): NodeData | NodeData[] {
343
488
  if (id === undefined) return this.context.model.getNodeData();
@@ -345,8 +490,31 @@ export class Graph extends EventEmitter {
345
490
  return this.context.model.getNodeData([id])?.[0];
346
491
  }
347
492
 
493
+ /**
494
+ * <zh/> 获取所有边数据
495
+ *
496
+ * <en/> Get all edge data
497
+ * @returns <zh/> 边数据 | <en/> edge data
498
+ * @apiCategory data
499
+ */
348
500
  public getEdgeData(): EdgeData[];
501
+ /**
502
+ * <zh/> 获取单条边数据
503
+ *
504
+ * <en/> Get single edge data
505
+ * @param id - <zh/> 边 ID | <en/> edge ID
506
+ * @returns <zh/> 边数据 | <en/> edge data
507
+ * @apiCategory data
508
+ */
349
509
  public getEdgeData(id: ID): EdgeData;
510
+ /**
511
+ * <zh/> 批量获取多条边数据
512
+ *
513
+ * <en/> Get multiple edge data in batch
514
+ * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
515
+ * @returns <zh/> 边数据 | <en/> edge data
516
+ * @apiCategory data
517
+ */
350
518
  public getEdgeData(ids: ID[]): EdgeData[];
351
519
  public getEdgeData(id?: ID | ID[]): EdgeData | EdgeData[] {
352
520
  if (id === undefined) return this.context.model.getEdgeData();
@@ -354,8 +522,31 @@ export class Graph extends EventEmitter {
354
522
  return this.context.model.getEdgeData([id])?.[0];
355
523
  }
356
524
 
525
+ /**
526
+ * <zh/> 获取所有组合数据
527
+ *
528
+ * <en/> Get all combo data
529
+ * @returns <zh/> 组合数据 | <en/> combo data
530
+ * @apiCategory data
531
+ */
357
532
  public getComboData(): ComboData[];
533
+ /**
534
+ * <zh/> 获取单个组合数据
535
+ *
536
+ * <en/> Get single combo data
537
+ * @param id - <zh/> 组合ID | <en/> combo ID
538
+ * @returns <zh/> 组合数据 | <en/> combo data
539
+ * @apiCategory data
540
+ */
358
541
  public getComboData(id: ID): ComboData;
542
+ /**
543
+ * <zh/> 批量获取多个组合数据
544
+ *
545
+ * <en/> Get multiple combo data in batch
546
+ * @param ids - <zh/> 组合ID 数组 | <en/> combo ID array
547
+ * @returns <zh/> 组合数据 | <en/> combo data
548
+ * @apiCategory data
549
+ */
359
550
  public getComboData(ids: ID[]): ComboData[];
360
551
  public getComboData(id?: ID | ID[]): ComboData | ComboData[] {
361
552
  if (id === undefined) return this.context.model.getComboData();
@@ -363,111 +554,254 @@ export class Graph extends EventEmitter {
363
554
  return this.context.model.getComboData([id])?.[0];
364
555
  }
365
556
 
557
+ /**
558
+ * <zh/> 设置全量数据
559
+ *
560
+ * <en/> Set full data
561
+ * @param data - <zh/> 数据 | <en/> data
562
+ * @apiCategory data
563
+ */
366
564
  public setData(data: CallableValue<GraphData>): void {
367
565
  this.context.model.setData(isFunction(data) ? data(this.getData()) : data);
368
566
  }
369
567
 
568
+ /**
569
+ * <zh/> 新增元素数据
570
+ *
571
+ * <en/> Add element data
572
+ * @param data - <zh/> 元素数据 | <en/> element data
573
+ * @apiCategory data
574
+ */
370
575
  public addData(data: CallableValue<GraphData>): void {
371
576
  this.context.model.addData(isFunction(data) ? data(this.getData()) : data);
372
577
  }
373
578
 
579
+ /**
580
+ * <zh/> 新增节点数据
581
+ *
582
+ * <en/> Add node data
583
+ * @param data - <zh/> 节点数据 | <en/> node data
584
+ * @apiCategory data
585
+ */
374
586
  public addNodeData(data: CallableValue<NodeData[]>): void {
375
587
  this.context.model.addNodeData(isFunction(data) ? data(this.getNodeData()) : data);
376
588
  }
377
589
 
590
+ /**
591
+ * <zh/> 新增边数据
592
+ *
593
+ * <en/> Add edge data
594
+ * @param data - <zh/> 边数据 | <en/> edge data
595
+ * @apiCategory data
596
+ */
378
597
  public addEdgeData(data: CallableValue<EdgeData[]>): void {
379
598
  this.context.model.addEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
380
599
  }
381
600
 
601
+ /**
602
+ * <zh/> 新增组合数据
603
+ *
604
+ * <en/> Add combo data
605
+ * @param data - <zh/> 组合数据 | <en/> combo data
606
+ * @apiCategory data
607
+ */
382
608
  public addComboData(data: CallableValue<ComboData[]>): void {
383
609
  this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
384
610
  }
385
611
 
612
+ /**
613
+ * <zh/> 更新元素数据
614
+ *
615
+ * <en/> Update element data
616
+ * @param data - <zh/> 元素数据 | <en/> element data
617
+ * @apiCategory data
618
+ */
386
619
  public updateData(data: CallableValue<PartialGraphData>): void {
387
620
  this.context.model.updateData(isFunction(data) ? data(this.getData()) : data);
388
621
  }
389
622
 
623
+ /**
624
+ * <zh/> 更新节点数据
625
+ *
626
+ * <en/> Update node data
627
+ * @param data - <zh/> 节点数据 | <en/> node data
628
+ * @apiCategory data
629
+ */
390
630
  public updateNodeData(data: CallableValue<PartialNodeLikeData<NodeData>[]>): void {
391
631
  this.context.model.updateNodeData(isFunction(data) ? data(this.getNodeData()) : data);
392
632
  }
393
633
 
634
+ /**
635
+ * <zh/> 更新边数据
636
+ *
637
+ * <en/> Update edge data
638
+ * @param data - <zh/> 边数据 | <en/> edge data
639
+ * @apiCategory data
640
+ */
394
641
  public updateEdgeData(data: CallableValue<PartialEdgeData<EdgeData>[]>): void {
395
642
  this.context.model.updateEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
396
643
  }
397
644
 
645
+ /**
646
+ * <zh/> 更新 组合数据
647
+ *
648
+ * <en/> Update combo data
649
+ * @param data - <zh/> 组合数据 | <en/> combo data
650
+ * @apiCategory data
651
+ */
398
652
  public updateComboData(data: CallableValue<PartialNodeLikeData<ComboData>[]>): void {
399
653
  this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
400
654
  }
401
655
 
402
- public removeData(id: DataID | ((data: GraphData) => DataID)): void {
403
- this.context.model.removeData(isFunction(id) ? id(this.getData()) : id);
656
+ /**
657
+ * <zh/> 删除多条元素数据
658
+ *
659
+ * <en/> Remove multiple element data
660
+ * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
661
+ * @apiCategory data
662
+ */
663
+ public removeData(ids: DataID | ((data: GraphData) => DataID)): void {
664
+ this.context.model.removeData(isFunction(ids) ? ids(this.getData()) : ids);
404
665
  }
405
666
 
667
+ /**
668
+ * <zh/> 删除多条节点数据
669
+ *
670
+ * <en/> Remove multiple node data
671
+ * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
672
+ * @apiCategory data
673
+ */
406
674
  public removeNodeData(ids: ID[] | ((data: NodeData[]) => ID[])): void {
407
675
  this.context.model.removeNodeData(isFunction(ids) ? ids(this.getNodeData()) : ids);
408
676
  }
409
677
 
678
+ /**
679
+ * <zh/> 删除多条边数据
680
+ *
681
+ * <en/> Remove multiple edge data
682
+ * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
683
+ * @apiCategory data
684
+ */
410
685
  public removeEdgeData(ids: ID[] | ((data: EdgeData[]) => ID[])): void {
411
686
  this.context.model.removeEdgeData(isFunction(ids) ? ids(this.getEdgeData()) : ids);
412
687
  }
413
688
 
689
+ /**
690
+ * <zh/> 删除多条组合数据
691
+ *
692
+ * <en/> Remove multiple combo data
693
+ * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
694
+ * @apiCategory data
695
+ */
414
696
  public removeComboData(ids: ID[] | ((data: ComboData[]) => ID[])): void {
415
697
  this.context.model.removeComboData(isFunction(ids) ? ids(this.getComboData()) : ids);
416
698
  }
417
699
 
700
+ /**
701
+ * <zh/> 获取元素类型
702
+ *
703
+ * <en/> Get element type
704
+ * @param id - <zh/> 元素 ID | <en/> element ID
705
+ * @returns <zh/> 元素类型 | <en/> element type
706
+ * @apiCategory element
707
+ */
418
708
  public getElementType(id: ID): ElementType {
419
709
  return this.context.model.getElementType(id);
420
710
  }
421
711
 
712
+ /**
713
+ * <zh/> 获取节点或组合相关的边数据
714
+ *
715
+ * <en/> Get the edge data related to the node or combo
716
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
717
+ * @param direction - <zh/> 边的方向 | <en/> edge direction
718
+ * @returns <zh/> 边数据 | <en/> edge data
719
+ * @apiCategory data
720
+ */
422
721
  public getRelatedEdgesData(id: ID, direction: EdgeDirection = 'both'): EdgeData[] {
423
722
  return this.context.model.getRelatedEdgesData(id, direction);
424
723
  }
425
724
 
725
+ /**
726
+ * <zh/> 获取节点或组合的一跳邻居节点数据
727
+ *
728
+ * <en/> Get the one-hop neighbor node data of the node or combo
729
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
730
+ * @returns <zh/> 邻居节点数据 | <en/> neighbor node data
731
+ * @apiCategory data
732
+ */
426
733
  public getNeighborNodesData(id: ID): NodeData[] {
427
734
  return this.context.model.getNeighborNodesData(id);
428
735
  }
429
736
 
430
737
  /**
431
- * <zh/> 获取节点或 combo 的祖先元素数据
738
+ * <zh/> 获取节点或组合的祖先元素数据
432
739
  *
433
740
  * <en/> Get the ancestor element data of the node or combo
434
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
435
- * @param hierarchy - <zh/> 指定树图层级关系还是 combo 层级关系 | <en/> specify tree or combo hierarchy relationship
741
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
742
+ * @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
436
743
  * @returns <zh/> 祖先元素数据 | <en/> ancestor element data
437
- * @description
744
+ * @remarks
438
745
  * <zh/> 数组中的顺序是从父节点到祖先节点
439
746
  *
440
747
  * <en/> The order in the array is from the parent node to the ancestor node
748
+ * @apiCategory data
441
749
  */
442
750
  public getAncestorsData(id: ID, hierarchy: HierarchyKey): NodeLikeData[] {
443
751
  return this.context.model.getAncestorsData(id, hierarchy);
444
752
  }
445
753
 
446
754
  /**
447
- * <zh/> 获取节点或 combo 的父元素数据
755
+ * <zh/> 获取节点或组合的父元素数据
448
756
  *
449
757
  * <en/> Get the parent element data of the node or combo
450
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
451
- * @param hierarchy - <zh/> 指定树图层级关系还是 combo 层级关系 | <en/> specify tree or combo hierarchy relationship
758
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
759
+ * @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
452
760
  * @returns <zh/> 父元素数据 | <en/> parent element data
761
+ * @apiCategory data
453
762
  */
454
763
  public getParentData(id: ID, hierarchy: HierarchyKey): NodeLikeData | undefined {
455
764
  return this.context.model.getParentData(id, hierarchy);
456
765
  }
457
766
 
458
767
  /**
459
- * <zh/> 获取节点或 combo 的子元素数据
768
+ * <zh/> 获取节点或组合的子元素数据
460
769
  *
461
770
  * <en/> Get the child element data of the node or combo
462
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
771
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
463
772
  * @returns <zh/> 子元素数据 | <en/> child element data
773
+ * @apiCategory data
464
774
  */
465
775
  public getChildrenData(id: ID): NodeLikeData[] {
466
776
  return this.context.model.getChildrenData(id);
467
777
  }
468
778
 
779
+ /**
780
+ * <zh/> 获取具体某一状态下的节点数据
781
+ *
782
+ * <en/> Get node data in a specific state
783
+ * @param state - <zh/> 状态 | <en/> state
784
+ * @returns <zh/> 节点数据 | <en/> node data
785
+ * @apiCategory data
786
+ */
469
787
  public getElementDataByState(elementType: 'node', state: State): NodeData[];
788
+ /**
789
+ * <zh/> 获取具体某一状态下的边数据
790
+ *
791
+ * <en/> Get edge data in a specific state
792
+ * @param state - <zh/> 状态 | <en/> state
793
+ * @returns <zh/> 边数据 | <en/> edge data
794
+ * @apiCategory data
795
+ */
470
796
  public getElementDataByState(elementType: 'edge', state: State): EdgeData[];
797
+ /**
798
+ * <zh/> 获取具体某一状态下的组合数据
799
+ *
800
+ * <en/> Get combo data in a specific state
801
+ * @param state - <zh/> 状态 | <en/> state
802
+ * @returns <zh/> 组合数据 | <en/> combo data
803
+ * @apiCategory data
804
+ */
471
805
  public getElementDataByState(elementType: 'combo', state: State): ComboData[];
472
806
  public getElementDataByState(elementType: ElementType, state: State): ElementDatum[] {
473
807
  return this.context.model.getElementDataByState(elementType, state);
@@ -490,8 +824,8 @@ export class Graph extends EventEmitter {
490
824
 
491
825
  const canvas = new Canvas({
492
826
  container: $container!,
493
- width: width ?? containerSize[0],
494
- height: height ?? containerSize[1],
827
+ width: width || containerSize[0],
828
+ height: height || containerSize[1],
495
829
  renderer,
496
830
  });
497
831
 
@@ -527,10 +861,11 @@ export class Graph extends EventEmitter {
527
861
  * <zh/> 执行渲染
528
862
  *
529
863
  * <en/> Render
530
- * @description
864
+ * @remarks
531
865
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
532
866
  *
533
867
  * <en/> This process will execute data update, element rendering, and layout execution
868
+ * @apiCategory render
534
869
  */
535
870
  public async render(): Promise<void> {
536
871
  await this.prepare();
@@ -545,31 +880,57 @@ export class Graph extends EventEmitter {
545
880
  *
546
881
  * <en/> Draw elements
547
882
  * @returns <zh/> 渲染结果 | <en/> draw result
883
+ * @apiCategory element
548
884
  */
549
885
  public async draw(): Promise<void> {
550
886
  await this.prepare();
551
887
  return this.context.element!.draw();
552
888
  }
553
889
 
554
- public layout(): Promise<void> {
555
- return this.context.layout!.layout();
890
+ /**
891
+ * <zh/> 执行布局
892
+ *
893
+ * <en/> Execute layout
894
+ * @apiCategory layout
895
+ */
896
+ public layout() {
897
+ this.context.layout!.layout();
556
898
  }
557
899
 
900
+ /**
901
+ * <zh/> 停止布局
902
+ *
903
+ * <en/> Stop layout
904
+ * @remarks
905
+ * <zh/> 适用于带有迭代动画的布局,目前有 `force` 属于此类布局,即停止力导布局的迭代,一般用于布局迭代时间过长情况下的手动停止迭代动画,例如在点击画布/节点的监听中调用
906
+ *
907
+ * <en/> Suitable for layouts with iterative animations. Currently, `force` belongs to this type of layout, that is, stop the iteration of the force-directed layout. It is generally used to manually stop the iteration animation when the layout iteration time is too long, such as calling in the click canvas/node listener
908
+ * @apiCategory layout
909
+ */
558
910
  public stopLayout() {
559
- return this.context.layout!.stopLayout();
911
+ this.context.layout!.stopLayout();
560
912
  }
561
913
 
562
914
  /**
563
915
  * <zh/> 清空画布元素
564
916
  *
565
917
  * <en/> Clear canvas elements
918
+ * @apiCategory canvas
566
919
  */
567
920
  public async clear(): Promise<void> {
568
921
  this.context.model.setData({});
569
922
  await this.draw();
570
923
  }
571
924
 
925
+ /**
926
+ * <zh/> 销毁当前图实例
927
+ *
928
+ * <en/> Destroy the current graph instance
929
+ * @apiCategory instance
930
+ */
572
931
  public destroy(): void {
932
+ emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_DESTROY));
933
+
573
934
  const { layout, element, model, canvas, behavior, plugin } = this.context;
574
935
  plugin?.destroy();
575
936
  behavior?.destroy();
@@ -585,13 +946,36 @@ export class Graph extends EventEmitter {
585
946
  window.removeEventListener('resize', this.onResize);
586
947
 
587
948
  this.destroyed = true;
949
+
950
+ emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_DESTROY));
588
951
  }
589
952
 
953
+ /**
954
+ * <zh/> 获取画布实例
955
+ *
956
+ * <en/> Get canvas instance
957
+ * @returns - <zh/> 画布实例 | <en/> canvas instance
958
+ * @apiCategory canvas
959
+ */
590
960
  public getCanvas(): Canvas {
591
961
  return this.context.canvas;
592
962
  }
593
963
 
964
+ /**
965
+ * <zh/> 调整画布大小为图容器大小
966
+ *
967
+ * <en/> Resize the canvas to the size of the graph container
968
+ * @apiCategory viewport
969
+ */
594
970
  public resize(): void;
971
+ /**
972
+ * <zh/> 调整画布大小为指定宽高
973
+ *
974
+ * <en/> Resize the canvas to the specified width and height
975
+ * @param width - <zh/> 宽度 | <en/> width
976
+ * @param height - <zh/> 高度 | <en/> height
977
+ * @apiCategory viewport
978
+ */
595
979
  public resize(width: number, height: number): void;
596
980
  public resize(width?: number, height?: number): void {
597
981
  const size: Vector2 = !width || !height ? sizeOf(this.context.canvas!.getContainer()!) : [width, height];
@@ -607,6 +991,7 @@ export class Graph extends EventEmitter {
607
991
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
608
992
  * @param options - <zh/> 适配配置 | <en/> fit options
609
993
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
994
+ * @apiCategory viewport
610
995
  */
611
996
  public async fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void> {
612
997
  await this.context.viewport?.fitView(options, animation);
@@ -617,6 +1002,7 @@ export class Graph extends EventEmitter {
617
1002
  *
618
1003
  * <en/> Move the graph to the center of the viewport
619
1004
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1005
+ * @apiCategory viewport
620
1006
  */
621
1007
  public async fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void> {
622
1008
  await this.context.viewport?.fitCenter(animation);
@@ -636,6 +1022,14 @@ export class Graph extends EventEmitter {
636
1022
  }
637
1023
  }
638
1024
 
1025
+ /**
1026
+ * <zh/> 移动图,使得元素对齐到视口中心
1027
+ *
1028
+ * <en/> Move the graph so that the element is aligned to the center of the viewport
1029
+ * @param id - <zh/> 元素 ID | <en/> element ID
1030
+ * @param animation - <zh/> 动画配置 | <en/> animation configuration
1031
+ * @apiCategory viewport
1032
+ */
639
1033
  public async focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void> {
640
1034
  await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
641
1035
  }
@@ -647,13 +1041,15 @@ export class Graph extends EventEmitter {
647
1041
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
648
1042
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
649
1043
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
650
- * @description
1044
+ * @remarks
651
1045
  * <zh/>
652
1046
  * - ratio > 1 放大
653
1047
  * - ratio < 1 缩小
1048
+ *
654
1049
  * <en/>
655
1050
  * - ratio > 1 zoom in
656
1051
  * - ratio < 1 zoom out
1052
+ * @apiCategory viewport
657
1053
  */
658
1054
  public async zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
659
1055
  await this.context.viewport!.transform({ mode: 'relative', scale: ratio, origin }, animation);
@@ -666,15 +1062,17 @@ export class Graph extends EventEmitter {
666
1062
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
667
1063
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
668
1064
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
669
- * @description
1065
+ * @remarks
670
1066
  * <zh/>
671
1067
  * - zoom = 1 默认大小
672
1068
  * - zoom > 1 放大
673
1069
  * - zoom < 1 缩小
1070
+ *
674
1071
  * <en/>
675
1072
  * - zoom = 1 default size
676
1073
  * - zoom > 1 zoom in
677
1074
  * - zoom < 1 zoom out
1075
+ * @apiCategory viewport
678
1076
  */
679
1077
  public async zoomTo(zoom: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
680
1078
  this.context.viewport!.transform({ mode: 'absolute', scale: zoom, origin }, animation);
@@ -685,6 +1083,7 @@ export class Graph extends EventEmitter {
685
1083
  *
686
1084
  * <en/> Get the current zoom ratio
687
1085
  * @returns <zh/> 缩放比例 | <en/> zoom ratio
1086
+ * @apiCategory viewport
688
1087
  */
689
1088
  public getZoom(): number {
690
1089
  return this.context.viewport!.getZoom();
@@ -697,6 +1096,7 @@ export class Graph extends EventEmitter {
697
1096
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
698
1097
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
699
1098
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
1099
+ * @apiCategory viewport
700
1100
  */
701
1101
  public async rotateBy(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
702
1102
  await this.context.viewport!.transform({ mode: 'relative', rotate: angle, origin }, animation);
@@ -709,6 +1109,7 @@ export class Graph extends EventEmitter {
709
1109
  * @param angle - <zh/> 目标角度 | <en/> target angle
710
1110
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
711
1111
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
1112
+ * @apiCategory viewport
712
1113
  */
713
1114
  public async rotateTo(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
714
1115
  await this.context.viewport!.transform({ mode: 'absolute', rotate: angle, origin }, animation);
@@ -719,6 +1120,7 @@ export class Graph extends EventEmitter {
719
1120
  *
720
1121
  * <en/> Get the current rotation angle
721
1122
  * @returns <zh/> 旋转角度 | <en/> rotation angle
1123
+ * @apiCategory viewport
722
1124
  */
723
1125
  public getRotation(): number {
724
1126
  return this.context.viewport!.getRotation();
@@ -730,6 +1132,7 @@ export class Graph extends EventEmitter {
730
1132
  * <en/> Translate the graph by the specified distance
731
1133
  * @param offset - <zh/> 偏移量 | <en/> offset
732
1134
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1135
+ * @apiCategory viewport
733
1136
  */
734
1137
  public async translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
735
1138
  await this.context.viewport!.transform({ mode: 'relative', translate: offset }, animation);
@@ -741,7 +1144,7 @@ export class Graph extends EventEmitter {
741
1144
  * <en/> Translate the graph to the specified position
742
1145
  * @param position - <zh/> 指定位置 | <en/> specified position
743
1146
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
744
- * @description
1147
+ * @apiCategory viewport
745
1148
  */
746
1149
  public async translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
747
1150
  await this.context.viewport!.transform({ mode: 'absolute', translate: position }, animation);
@@ -752,10 +1155,11 @@ export class Graph extends EventEmitter {
752
1155
  *
753
1156
  * <en/> Get the position of the graph
754
1157
  * @returns <zh/> 图的位置 | <en/> position of the graph
755
- * @description
1158
+ * @remarks
756
1159
  * <zh/> 默认状态下,图的位置为 [0, 0]
757
1160
  *
758
1161
  * <en/> By default, the position of the graph is [0, 0]
1162
+ * @apiCategory viewport
759
1163
  */
760
1164
  public getPosition(): Point {
761
1165
  return subtract([0, 0], this.getCanvasByViewport([0, 0]));
@@ -767,7 +1171,8 @@ export class Graph extends EventEmitter {
767
1171
  * <en/> Translate the element by the specified distance
768
1172
  * @param id - <zh/> 元素 ID | <en/> element ID
769
1173
  * @param offset - <zh/> 偏移量 | <en/> offset
770
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1174
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1175
+ * @apiCategory element
771
1176
  */
772
1177
  public async translateElementBy(id: ID, offset: Position, animation?: boolean): Promise<void>;
773
1178
  /**
@@ -775,7 +1180,8 @@ export class Graph extends EventEmitter {
775
1180
  *
776
1181
  * <en/> Batch translate elements by the specified distance
777
1182
  * @param offsets - <zh/> 偏移量配置 | <en/> offset configuration
778
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1183
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1184
+ * @apiCategory element
779
1185
  */
780
1186
  public async translateElementBy(offsets: Record<ID, Position>, animation?: boolean): Promise<void>;
781
1187
  public async translateElementBy(
@@ -797,7 +1203,8 @@ export class Graph extends EventEmitter {
797
1203
  * <en/> Translate the element to the specified position
798
1204
  * @param id - <zh/> 元素 ID | <en/> element ID
799
1205
  * @param position - <zh/> 指定位置 | <en/> specified position
800
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1206
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1207
+ * @apiCategory element
801
1208
  */
802
1209
  public async translateElementTo(id: ID, position: Position, animation?: boolean): Promise<void>;
803
1210
  /**
@@ -805,7 +1212,8 @@ export class Graph extends EventEmitter {
805
1212
  *
806
1213
  * <en/> Batch translate elements to the specified position
807
1214
  * @param positions - <zh/> 位置配置 | <en/> position configuration
808
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1215
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1216
+ * @apiCategory element
809
1217
  */
810
1218
  public async translateElementTo(positions: Record<ID, Position>, animation?: boolean): Promise<void>;
811
1219
  public async translateElementTo(
@@ -821,10 +1229,26 @@ export class Graph extends EventEmitter {
821
1229
  await this.context.element!.draw({ animation });
822
1230
  }
823
1231
 
1232
+ /**
1233
+ * <zh/> 获取元素位置
1234
+ *
1235
+ * <en/> Get element position
1236
+ * @param id - <zh/> 元素 ID | <en/> element ID
1237
+ * @returns <zh/> 元素位置 | <en/> element position
1238
+ * @apiCategory element
1239
+ */
824
1240
  public getElementPosition(id: ID): Position {
825
1241
  return this.context.model.getElementPosition(id);
826
1242
  }
827
1243
 
1244
+ /**
1245
+ * <zh/> 获取元素渲染样式
1246
+ *
1247
+ * <en/> Get element rendering style
1248
+ * @param id - <zh/> 元素 ID | <en/> element ID
1249
+ * @returns <zh/> 元素渲染样式 | <en/> element rendering style
1250
+ * @apiCategory element
1251
+ */
828
1252
  public getElementRenderStyle(id: ID) {
829
1253
  return omit(this.context.element!.getElement(id)!.attributes, ['context']);
830
1254
  }
@@ -836,6 +1260,7 @@ export class Graph extends EventEmitter {
836
1260
  * @param id - <zh/> 元素 ID | <en/> element ID
837
1261
  * @param visibility - <zh/> 可见性 | <en/> visibility
838
1262
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1263
+ * @apiCategory element
839
1264
  */
840
1265
  public async setElementVisibility(
841
1266
  id: ID,
@@ -848,6 +1273,7 @@ export class Graph extends EventEmitter {
848
1273
  * <en/> Batch set element visibility
849
1274
  * @param visibility - <zh/> 可见性配置 | <en/> visibility configuration
850
1275
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1276
+ * @apiCategory element
851
1277
  */
852
1278
  public async setElementVisibility(
853
1279
  visibility: Record<ID, BaseStyleProps['visibility']>,
@@ -877,7 +1303,8 @@ export class Graph extends EventEmitter {
877
1303
  *
878
1304
  * <en/> Show element
879
1305
  * @param id - <zh/> 元素 ID | <en/> element ID
880
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1306
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1307
+ * @apiCategory element
881
1308
  */
882
1309
  public async showElement(id: ID | ID[], animation?: boolean): Promise<void> {
883
1310
  const ids = Array.isArray(id) ? id : [id];
@@ -892,7 +1319,8 @@ export class Graph extends EventEmitter {
892
1319
  *
893
1320
  * <en/> Hide element
894
1321
  * @param id - <zh/> 元素 ID | <en/> element ID
895
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1322
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1323
+ * @apiCategory element
896
1324
  */
897
1325
  public async hideElement(id: ID | ID[], animation?: boolean): Promise<void> {
898
1326
  const ids = Array.isArray(id) ? id : [id];
@@ -908,6 +1336,7 @@ export class Graph extends EventEmitter {
908
1336
  * <en/> Get element visibility
909
1337
  * @param id - <zh/> 元素 ID | <en/> element ID
910
1338
  * @returns <zh/> 元素可见性 | <en/> element visibility
1339
+ * @apiCategory element
911
1340
  */
912
1341
  public getElementVisibility(id: ID): BaseStyleProps['visibility'] {
913
1342
  const element = this.context.element!.getElement(id)!;
@@ -920,6 +1349,7 @@ export class Graph extends EventEmitter {
920
1349
  * <en/> Set element z-index
921
1350
  * @param id - <zh/> 元素 ID | <en/> element ID
922
1351
  * @param zIndex - <zh/> 层级 | <en/> z-index
1352
+ * @apiCategory element
923
1353
  */
924
1354
  public async setElementZIndex(id: ID, zIndex: number): Promise<void>;
925
1355
  /**
@@ -927,6 +1357,7 @@ export class Graph extends EventEmitter {
927
1357
  *
928
1358
  * <en/> Batch set element z-index
929
1359
  * @param zIndex - <zh/> 层级配置 | <en/> z-index configuration
1360
+ * @apiCategory element
930
1361
  */
931
1362
  public async setElementZIndex(zIndex: Record<ID, number>): Promise<void>;
932
1363
  public async setElementZIndex(args1: ID | Record<ID, number>, args2?: number): Promise<void> {
@@ -948,6 +1379,7 @@ export class Graph extends EventEmitter {
948
1379
  *
949
1380
  * <en/> Bring the element to the front
950
1381
  * @param id - <zh/> 元素 ID | <en/> element ID
1382
+ * @apiCategory element
951
1383
  */
952
1384
  public async frontElement(id: ID | ID[]): Promise<void> {
953
1385
  const ids = Array.isArray(id) ? id : [id];
@@ -978,6 +1410,7 @@ export class Graph extends EventEmitter {
978
1410
  * <en/> Get element z-index
979
1411
  * @param id - <zh/> 元素 ID | <en/> element ID
980
1412
  * @returns <zh/> 元素层级 | <en/> element z-index
1413
+ * @apiCategory element
981
1414
  */
982
1415
  public getElementZIndex(id: ID): number {
983
1416
  return zIndexOf(this.context.model.getElementsData([id])[0]);
@@ -990,6 +1423,7 @@ export class Graph extends EventEmitter {
990
1423
  * @param id - <zh/> 元素 ID | <en/> element ID
991
1424
  * @param state - <zh/> 状态 | <en/> state
992
1425
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1426
+ * @apiCategory element
993
1427
  */
994
1428
  public async setElementState(id: ID, state: State | State[], animation?: boolean): Promise<void>;
995
1429
  /**
@@ -998,6 +1432,7 @@ export class Graph extends EventEmitter {
998
1432
  * <en/> Batch set element state
999
1433
  * @param state - <zh/> 状态配置 | <en/> state configuration
1000
1434
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
1435
+ * @apiCategory element
1001
1436
  */
1002
1437
  public async setElementState(state: Record<ID, State | State[]>, animation?: boolean): Promise<void>;
1003
1438
  public async setElementState(
@@ -1030,21 +1465,46 @@ export class Graph extends EventEmitter {
1030
1465
  * <en/> Get element state
1031
1466
  * @param id - <zh/> 元素 ID | <en/> element ID
1032
1467
  * @returns <zh/> 元素状态 | <en/> element state
1468
+ * @apiCategory element
1033
1469
  */
1034
1470
  public getElementState(id: ID): State[] {
1035
1471
  return this.context.model.getElementState(id);
1036
1472
  }
1037
1473
 
1474
+ /**
1475
+ * <zh/> 获取元素自身以及子节点在世界坐标系下的渲染包围盒
1476
+ *
1477
+ * <en/> Get the rendering bounding box of the element itself and its child nodes in the world coordinate system
1478
+ * @param id - <zh/> 元素 ID | <en/> element ID
1479
+ * @returns <zh/> 渲染包围盒 | <en/> render bounding box
1480
+ * @apiCategory element
1481
+ */
1038
1482
  public getElementRenderBounds(id: ID): AABB {
1039
1483
  return this.context.element!.getElement(id)!.getRenderBounds();
1040
1484
  }
1041
1485
 
1042
- public async collapse(id: ID, animation: boolean = true): Promise<void> {
1486
+ /**
1487
+ * <zh/> 收起 Combo
1488
+ *
1489
+ * <en/> Collapse Combo
1490
+ * @param id - <zh/> 元素 ID | <en/> element ID
1491
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1492
+ * @apiCategory element
1493
+ */
1494
+ public async collapseElement(id: ID, animation: boolean = true): Promise<void> {
1043
1495
  this.setElementCollapsibility(id, true);
1044
1496
  await this.context.element!.draw({ animation, stage: 'collapse' });
1045
1497
  }
1046
1498
 
1047
- public async expand(id: ID, animation: boolean = true): Promise<void> {
1499
+ /**
1500
+ * <zh/> 展开 Combo
1501
+ *
1502
+ * <en/> Expand Combo
1503
+ * @param id - <zh/> 元素 ID | <en/> element ID
1504
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1505
+ * @apiCategory element
1506
+ */
1507
+ public async expandElement(id: ID, animation: boolean = true): Promise<void> {
1048
1508
  this.setElementCollapsibility(id, false);
1049
1509
  await this.context.element!.draw({ animation, stage: 'expand' });
1050
1510
  }
@@ -1060,33 +1520,58 @@ export class Graph extends EventEmitter {
1060
1520
  *
1061
1521
  * <en/> Export canvas content as DataURL
1062
1522
  * @param options - <zh/> 导出配置 | <en/> export configuration
1063
- * @param mode
1064
- * <zh/> 导出模式
1065
- * - viewport: 导出视口内容
1066
- * - overall: 导出整个画布
1067
- *
1068
- * <en/> export mode
1069
- * - viewport: export the content of the viewport
1070
- * - overall: export the entire canvas
1071
1523
  * @returns <zh/> DataURL | <en/> DataURL
1524
+ * @apiCategory exportImage
1072
1525
  */
1073
1526
  public async toDataURL(options: Partial<DataURLOptions> = {}): Promise<string> {
1074
1527
  return this.context.canvas!.toDataURL(options);
1075
1528
  }
1076
1529
 
1530
+ /**
1531
+ * <zh/> 给定的视窗 DOM 坐标,转换为画布上的绘制坐标
1532
+ *
1533
+ * <en/> Convert the given viewport DOM coordinates to the drawing coordinates on the canvas
1534
+ * @param point - <zh/> 视窗坐标 | <en/> viewport coordinates
1535
+ * @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
1536
+ * @apiCategory viewport
1537
+ */
1077
1538
  public getCanvasByViewport(point: Point): Point {
1078
1539
  return parsePoint(this.context.canvas!.viewport2Canvas(toPointObject(point)));
1079
1540
  }
1080
1541
 
1542
+ /**
1543
+ * <zh/> 给定画布上的绘制坐标,转换为视窗 DOM 的坐标
1544
+ *
1545
+ * <en/> Convert the given drawing coordinates on the canvas to the coordinates of the viewport DOM
1546
+ * @param point - <zh/> 画布坐标 | <en/> canvas coordinates
1547
+ * @returns <zh/> 视窗 DOM 的坐标 | <en/> coordinates of the viewport DOM
1548
+ * @apiCategory viewport
1549
+ */
1081
1550
  public getViewportByCanvas(point: Point): Point {
1082
1551
  return parsePoint(this.context.canvas.canvas2Viewport(toPointObject(point)));
1083
1552
  }
1084
1553
 
1554
+ /**
1555
+ * <zh/> 给定画布上的绘制坐标,转换为浏览器坐标
1556
+ *
1557
+ * <en/> Convert the given drawing coordinates on the canvas to browser coordinates
1558
+ * @param point - <zh/> 画布坐标 | <en/> canvas coordinates
1559
+ * @returns <zh/> 浏览器坐标 | <en/> browser coordinates
1560
+ * @apiCategory viewport
1561
+ */
1085
1562
  public getClientByCanvas(point: Point): Point {
1086
1563
  const viewportPoint = this.context.canvas.canvas2Viewport(toPointObject(point));
1087
1564
  return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
1088
1565
  }
1089
1566
 
1567
+ /**
1568
+ * <zh/> 给定的浏览器坐标,转换为画布上的绘制坐标
1569
+ *
1570
+ * <en/> Convert the given browser coordinates to drawing coordinates on the canvas
1571
+ * @param point - <zh/> 浏览器坐标 | <en/> browser coordinates
1572
+ * @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
1573
+ * @apiCategory viewport
1574
+ */
1090
1575
  public getCanvasByClient(point: Point): Point {
1091
1576
  const viewportPoint = this.context.canvas.client2Viewport(toPointObject(point));
1092
1577
  return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
@@ -1097,11 +1582,19 @@ export class Graph extends EventEmitter {
1097
1582
  *
1098
1583
  * <en/> Get the canvas coordinates of the viewport center
1099
1584
  * @returns <zh/> 视口中心的画布坐标 | <en/> Canvas coordinates of the viewport center
1585
+ * @apiCategory viewport
1100
1586
  */
1101
1587
  public getViewportCenter(): Point {
1102
1588
  return this.context.viewport!.getViewportCenter();
1103
1589
  }
1104
1590
 
1591
+ /**
1592
+ * <zh/> 获取画布中心的画布坐标
1593
+ *
1594
+ * <en/> Get the canvas coordinates of the canvas center
1595
+ * @returns <zh/> 画布中心的画布坐标 | <en/> Canvas coordinates of the canvas center
1596
+ * @apiCategory viewport
1597
+ */
1105
1598
  public getCanvasCenter(): Point {
1106
1599
  return this.context.viewport!.getCanvasCenter();
1107
1600
  }
@@ -1117,6 +1610,7 @@ export class Graph extends EventEmitter {
1117
1610
  * @param eventName - <zh/> 事件名称 | <en/> event name
1118
1611
  * @param callback - <zh/> 回调函数 | <en/> callback function
1119
1612
  * @returns <zh/> Graph 实例 | <en/> Graph instance
1613
+ * @apiCategory event
1120
1614
  */
1121
1615
  public on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
1122
1616
  return super.on(eventName, callback);
@@ -1129,6 +1623,7 @@ export class Graph extends EventEmitter {
1129
1623
  * @param eventName - <zh/> 事件名称 | <en/> event name
1130
1624
  * @param callback - <zh/> 回调函数 | <en/> callback function
1131
1625
  * @returns <zh/> Graph 实例 | <en/> Graph instance
1626
+ * @apiCategory event
1132
1627
  */
1133
1628
  public once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
1134
1629
  return super.once(eventName, callback);