@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
@@ -19,6 +19,9 @@ import { TransformController } from './transform';
19
19
  import { ViewportController } from './viewport';
20
20
  export class Graph extends EventEmitter {
21
21
  options;
22
+ /**
23
+ * @internal
24
+ */
22
25
  static defaultOptions = {
23
26
  autoResize: false,
24
27
  theme: 'light',
@@ -26,6 +29,11 @@ export class Graph extends EventEmitter {
26
29
  zoom: 1,
27
30
  zoomRange: [0.01, 10],
28
31
  };
32
+ /**
33
+ * <zh/> 当前图实例是否已经被销毁
34
+ *
35
+ * <en/> Whether the current graph instance has been destroyed
36
+ */
29
37
  destroyed = false;
30
38
  // @ts-expect-error will be initialized in createRuntime
31
39
  context = {
@@ -44,6 +52,7 @@ export class Graph extends EventEmitter {
44
52
  *
45
53
  * <en/> Get options
46
54
  * @returns <zh/> 配置项 | <en/> options
55
+ * @apiCategory option
47
56
  */
48
57
  getOptions() {
49
58
  return this.options;
@@ -53,10 +62,11 @@ export class Graph extends EventEmitter {
53
62
  *
54
63
  * <en/> Set options
55
64
  * @param options - <zh/> 配置项 | <en/> options
56
- * @description
65
+ * @remarks
57
66
  * <zh/> 要更新 devicePixelRatio、container 属性请销毁后重新创建实例
58
67
  *
59
68
  * <en/> To update devicePixelRatio and container properties, please destroy and recreate the instance
69
+ * @apiCategory option
60
70
  */
61
71
  setOptions(options) {
62
72
  const { animation, background, behaviors, combo, container, data, edge, height, layout, node, padding, plugins, theme, transforms, width, zoom, zoomRange, } = options;
@@ -89,40 +99,121 @@ export class Graph extends EventEmitter {
89
99
  if (isNumber(padding) || isArray(padding))
90
100
  this.options.padding = padding;
91
101
  }
102
+ /**
103
+ * <zh/> 设置画布背景色
104
+ *
105
+ * <en/> Set canvas background color
106
+ * @param background - <zh/> 背景色 | <en/> background color
107
+ * @apiCategory canvas
108
+ */
92
109
  setBackground(background) {
93
110
  this.options.background = background;
94
111
  this.context.canvas?.setBackground(background);
95
112
  }
113
+ /**
114
+ * <zh/> 获取画布背景色
115
+ *
116
+ * <en/> Get canvas background color
117
+ * @returns <zh/> 背景色 | <en/> background color
118
+ * @apiCategory canvas
119
+ */
96
120
  getBackground() {
97
121
  return this.options.background;
98
122
  }
123
+ /**
124
+ * <zh/> 获取当前图容器的大小
125
+ *
126
+ * <en/> Get the size of the current canvas container
127
+ * @returns <zh/> 画布尺寸 | <en/> canvas size
128
+ * @apiCategory canvas
129
+ */
99
130
  getSize() {
100
131
  if (this.context.canvas)
101
132
  return this.context.canvas.getSize();
102
133
  return [this.options.width || 0, this.options.height || 0];
103
134
  }
135
+ /**
136
+ * <zh/> 获取当前图容器的大小
137
+ *
138
+ * <en/> Get the size of the current canvas container
139
+ * @param width - <zh/> 画布宽度 | <en/> canvas width
140
+ * @param height - <zh/> 画布高度 | <en/> canvas height
141
+ * @apiCategory canvas
142
+ */
104
143
  setSize(width, height) {
105
144
  this.options.width = width;
106
145
  this.options.height = height;
107
146
  }
147
+ /**
148
+ * <zh/> 获取当前图的缩放区间
149
+ *
150
+ * <en/> Get the zoom range of the current graph
151
+ * @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
152
+ * @apiCategory viewport
153
+ */
108
154
  setZoomRange(zoomRange) {
109
155
  this.options.zoomRange = zoomRange;
110
156
  }
157
+ /**
158
+ * <zh/> 获取当前图的缩放区间
159
+ *
160
+ * <en/> Get the zoom range of the current graph
161
+ * @returns <zh/> 缩放区间 | <en/> zoom range
162
+ * @apiCategory viewport
163
+ */
111
164
  getZoomRange() {
112
165
  return this.options.zoomRange;
113
166
  }
167
+ /**
168
+ * <zh/> 设置节点样式映射
169
+ *
170
+ * <en/> Set node mapper
171
+ * @param node - <zh/> 节点配置 | <en/> node configuration
172
+ * @apiCategory element
173
+ */
114
174
  setNode(node) {
115
175
  this.options.node = node;
176
+ this.context.model.refreshData();
116
177
  }
178
+ /**
179
+ * <zh/> 设置边样式映射
180
+ *
181
+ * <en/> Set edge mapper
182
+ * @param edge - <zh/> 边配置 | <en/> edge configuration
183
+ * @apiCategory element
184
+ */
117
185
  setEdge(edge) {
118
186
  this.options.edge = edge;
187
+ this.context.model.refreshData();
119
188
  }
189
+ /**
190
+ * <zh/> 设置组合样式映射
191
+ *
192
+ * <en/> Set combo mapper
193
+ * @param combo - <zh/> 组合配置 | <en/> combo configuration
194
+ * @apiCategory element
195
+ */
120
196
  setCombo(combo) {
121
197
  this.options.combo = combo;
198
+ this.context.model.refreshData();
122
199
  }
200
+ /**
201
+ * <zh/> 获取主题
202
+ *
203
+ * <en/> Get theme
204
+ * @returns <zh/> 主题配置 | <en/> theme configuration
205
+ * @apiCategory theme
206
+ */
123
207
  getTheme() {
124
208
  return this.options.theme;
125
209
  }
210
+ /**
211
+ * <zh/> 设置主题
212
+ *
213
+ * <en/> Set theme
214
+ * @param theme - <zh/> 主题配置 | <en/> theme configuration
215
+ * @apiCategory theme
216
+ */
126
217
  setTheme(theme) {
127
218
  this.options.theme = isFunction(theme) ? theme(this.getTheme()) : theme;
128
219
  const { background } = getExtension('theme', this.options.theme) || {};
@@ -130,9 +221,23 @@ export class Graph extends EventEmitter {
130
221
  this.setBackground(background);
131
222
  }
132
223
  }
224
+ /**
225
+ * <zh/> 设置布局
226
+ *
227
+ * <en/> Set layout
228
+ * @param layout - <zh/> 布局配置 | <en/> layout configuration
229
+ * @apiCategory layout
230
+ */
133
231
  setLayout(layout) {
134
232
  this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
135
233
  }
234
+ /**
235
+ * <zh/> 获取布局
236
+ *
237
+ * <en/> Get layout
238
+ * @returns <zh/> 布局配置 | <en/> layout configuration
239
+ * @apiCategory layout
240
+ */
136
241
  getLayout() {
137
242
  return this.options.layout;
138
243
  }
@@ -141,6 +246,7 @@ export class Graph extends EventEmitter {
141
246
  *
142
247
  * <en/> Set behaviors
143
248
  * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
249
+ * @apiCategory behavior
144
250
  */
145
251
  setBehaviors(behaviors) {
146
252
  this.options.behaviors = isFunction(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
@@ -151,6 +257,7 @@ export class Graph extends EventEmitter {
151
257
  *
152
258
  * <en/> Update behavior
153
259
  * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
260
+ * @apiCategory behavior
154
261
  */
155
262
  updateBehavior(behavior) {
156
263
  this.setBehaviors((behaviors) => behaviors.map((_behavior) => {
@@ -165,6 +272,7 @@ export class Graph extends EventEmitter {
165
272
  *
166
273
  * <en/> Get behaviors
167
274
  * @returns <zh/> 交互配置 | <en/> behavior configuration
275
+ * @apiCategory behavior
168
276
  */
169
277
  getBehaviors() {
170
278
  return this.options.behaviors || [];
@@ -174,6 +282,7 @@ export class Graph extends EventEmitter {
174
282
  *
175
283
  * <en/> Set plugins
176
284
  * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
285
+ * @apiCategory plugin
177
286
  */
178
287
  setPlugins(plugins) {
179
288
  this.options.plugins = isFunction(plugins) ? plugins(this.getPlugins()) : plugins;
@@ -184,6 +293,7 @@ export class Graph extends EventEmitter {
184
293
  *
185
294
  * <en/> Update plugin
186
295
  * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
296
+ * @apiCategory plugin
187
297
  */
188
298
  updatePlugin(plugin) {
189
299
  this.setPlugins((plugins) => plugins.map((_plugin) => {
@@ -198,6 +308,7 @@ export class Graph extends EventEmitter {
198
308
  *
199
309
  * <en/> Get plugins
200
310
  * @returns <zh/> 插件配置 | <en/> plugin configuration
311
+ * @apiCategory plugin
201
312
  */
202
313
  getPlugins() {
203
314
  return this.options.plugins || [];
@@ -208,6 +319,7 @@ export class Graph extends EventEmitter {
208
319
  * <en/> Get plugin instance
209
320
  * @param key - <zh/> 插件 key | <en/> plugin key
210
321
  * @returns <zh/> 插件实例 | <en/> plugin instance
322
+ * @apiCategory plugin
211
323
  */
212
324
  getPluginInstance(key) {
213
325
  return this.context.plugin.getPluginInstance(key);
@@ -217,6 +329,7 @@ export class Graph extends EventEmitter {
217
329
  *
218
330
  * <en/> Set data transforms
219
331
  * @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
332
+ * @apiCategory transform
220
333
  */
221
334
  setTransforms(transforms) {
222
335
  this.options.transforms = isFunction(transforms) ? transforms(this.getTransforms()) : transforms;
@@ -227,6 +340,7 @@ export class Graph extends EventEmitter {
227
340
  *
228
341
  * <en/> Update data transform
229
342
  * @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
343
+ * @apiCategory transform
230
344
  */
231
345
  updateTransform(transform) {
232
346
  this.setTransforms((transforms) => transforms.map((_transform) => {
@@ -241,10 +355,18 @@ export class Graph extends EventEmitter {
241
355
  *
242
356
  * <en/> Get data transforms
243
357
  * @returns <zh/> 数据转换器实例 | <en/> data transform instance
358
+ * @apiCategory transform
244
359
  */
245
360
  getTransforms() {
246
361
  return this.options.transforms || [];
247
362
  }
363
+ /**
364
+ * <zh/> 获取数据
365
+ *
366
+ * <en/> Get data
367
+ * @returns <zh/> 数据 | <en/> data
368
+ * @apiCategory data
369
+ */
248
370
  getData() {
249
371
  return this.context.model.getData();
250
372
  }
@@ -269,86 +391,205 @@ export class Graph extends EventEmitter {
269
391
  return this.context.model.getComboData(id);
270
392
  return this.context.model.getComboData([id])?.[0];
271
393
  }
394
+ /**
395
+ * <zh/> 设置全量数据
396
+ *
397
+ * <en/> Set full data
398
+ * @param data - <zh/> 数据 | <en/> data
399
+ * @apiCategory data
400
+ */
272
401
  setData(data) {
273
402
  this.context.model.setData(isFunction(data) ? data(this.getData()) : data);
274
403
  }
404
+ /**
405
+ * <zh/> 新增元素数据
406
+ *
407
+ * <en/> Add element data
408
+ * @param data - <zh/> 元素数据 | <en/> element data
409
+ * @apiCategory data
410
+ */
275
411
  addData(data) {
276
412
  this.context.model.addData(isFunction(data) ? data(this.getData()) : data);
277
413
  }
414
+ /**
415
+ * <zh/> 新增节点数据
416
+ *
417
+ * <en/> Add node data
418
+ * @param data - <zh/> 节点数据 | <en/> node data
419
+ * @apiCategory data
420
+ */
278
421
  addNodeData(data) {
279
422
  this.context.model.addNodeData(isFunction(data) ? data(this.getNodeData()) : data);
280
423
  }
424
+ /**
425
+ * <zh/> 新增边数据
426
+ *
427
+ * <en/> Add edge data
428
+ * @param data - <zh/> 边数据 | <en/> edge data
429
+ * @apiCategory data
430
+ */
281
431
  addEdgeData(data) {
282
432
  this.context.model.addEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
283
433
  }
434
+ /**
435
+ * <zh/> 新增组合数据
436
+ *
437
+ * <en/> Add combo data
438
+ * @param data - <zh/> 组合数据 | <en/> combo data
439
+ * @apiCategory data
440
+ */
284
441
  addComboData(data) {
285
442
  this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
286
443
  }
444
+ /**
445
+ * <zh/> 更新元素数据
446
+ *
447
+ * <en/> Update element data
448
+ * @param data - <zh/> 元素数据 | <en/> element data
449
+ * @apiCategory data
450
+ */
287
451
  updateData(data) {
288
452
  this.context.model.updateData(isFunction(data) ? data(this.getData()) : data);
289
453
  }
454
+ /**
455
+ * <zh/> 更新节点数据
456
+ *
457
+ * <en/> Update node data
458
+ * @param data - <zh/> 节点数据 | <en/> node data
459
+ * @apiCategory data
460
+ */
290
461
  updateNodeData(data) {
291
462
  this.context.model.updateNodeData(isFunction(data) ? data(this.getNodeData()) : data);
292
463
  }
464
+ /**
465
+ * <zh/> 更新边数据
466
+ *
467
+ * <en/> Update edge data
468
+ * @param data - <zh/> 边数据 | <en/> edge data
469
+ * @apiCategory data
470
+ */
293
471
  updateEdgeData(data) {
294
472
  this.context.model.updateEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
295
473
  }
474
+ /**
475
+ * <zh/> 更新 组合数据
476
+ *
477
+ * <en/> Update combo data
478
+ * @param data - <zh/> 组合数据 | <en/> combo data
479
+ * @apiCategory data
480
+ */
296
481
  updateComboData(data) {
297
482
  this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
298
483
  }
299
- removeData(id) {
300
- this.context.model.removeData(isFunction(id) ? id(this.getData()) : id);
484
+ /**
485
+ * <zh/> 删除多条元素数据
486
+ *
487
+ * <en/> Remove multiple element data
488
+ * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
489
+ * @apiCategory data
490
+ */
491
+ removeData(ids) {
492
+ this.context.model.removeData(isFunction(ids) ? ids(this.getData()) : ids);
301
493
  }
494
+ /**
495
+ * <zh/> 删除多条节点数据
496
+ *
497
+ * <en/> Remove multiple node data
498
+ * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
499
+ * @apiCategory data
500
+ */
302
501
  removeNodeData(ids) {
303
502
  this.context.model.removeNodeData(isFunction(ids) ? ids(this.getNodeData()) : ids);
304
503
  }
504
+ /**
505
+ * <zh/> 删除多条边数据
506
+ *
507
+ * <en/> Remove multiple edge data
508
+ * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
509
+ * @apiCategory data
510
+ */
305
511
  removeEdgeData(ids) {
306
512
  this.context.model.removeEdgeData(isFunction(ids) ? ids(this.getEdgeData()) : ids);
307
513
  }
514
+ /**
515
+ * <zh/> 删除多条组合数据
516
+ *
517
+ * <en/> Remove multiple combo data
518
+ * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
519
+ * @apiCategory data
520
+ */
308
521
  removeComboData(ids) {
309
522
  this.context.model.removeComboData(isFunction(ids) ? ids(this.getComboData()) : ids);
310
523
  }
524
+ /**
525
+ * <zh/> 获取元素类型
526
+ *
527
+ * <en/> Get element type
528
+ * @param id - <zh/> 元素 ID | <en/> element ID
529
+ * @returns <zh/> 元素类型 | <en/> element type
530
+ * @apiCategory element
531
+ */
311
532
  getElementType(id) {
312
533
  return this.context.model.getElementType(id);
313
534
  }
535
+ /**
536
+ * <zh/> 获取节点或组合相关的边数据
537
+ *
538
+ * <en/> Get the edge data related to the node or combo
539
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
540
+ * @param direction - <zh/> 边的方向 | <en/> edge direction
541
+ * @returns <zh/> 边数据 | <en/> edge data
542
+ * @apiCategory data
543
+ */
314
544
  getRelatedEdgesData(id, direction = 'both') {
315
545
  return this.context.model.getRelatedEdgesData(id, direction);
316
546
  }
547
+ /**
548
+ * <zh/> 获取节点或组合的一跳邻居节点数据
549
+ *
550
+ * <en/> Get the one-hop neighbor node data of the node or combo
551
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
552
+ * @returns <zh/> 邻居节点数据 | <en/> neighbor node data
553
+ * @apiCategory data
554
+ */
317
555
  getNeighborNodesData(id) {
318
556
  return this.context.model.getNeighborNodesData(id);
319
557
  }
320
558
  /**
321
- * <zh/> 获取节点或 combo 的祖先元素数据
559
+ * <zh/> 获取节点或组合的祖先元素数据
322
560
  *
323
561
  * <en/> Get the ancestor element data of the node or combo
324
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
325
- * @param hierarchy - <zh/> 指定树图层级关系还是 combo 层级关系 | <en/> specify tree or combo hierarchy relationship
562
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
563
+ * @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
326
564
  * @returns <zh/> 祖先元素数据 | <en/> ancestor element data
327
- * @description
565
+ * @remarks
328
566
  * <zh/> 数组中的顺序是从父节点到祖先节点
329
567
  *
330
568
  * <en/> The order in the array is from the parent node to the ancestor node
569
+ * @apiCategory data
331
570
  */
332
571
  getAncestorsData(id, hierarchy) {
333
572
  return this.context.model.getAncestorsData(id, hierarchy);
334
573
  }
335
574
  /**
336
- * <zh/> 获取节点或 combo 的父元素数据
575
+ * <zh/> 获取节点或组合的父元素数据
337
576
  *
338
577
  * <en/> Get the parent element data of the node or combo
339
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
340
- * @param hierarchy - <zh/> 指定树图层级关系还是 combo 层级关系 | <en/> specify tree or combo hierarchy relationship
578
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
579
+ * @param hierarchy - <zh/> 指定树图层级关系还是组合层级关系 | <en/> specify tree or combo hierarchy relationship
341
580
  * @returns <zh/> 父元素数据 | <en/> parent element data
581
+ * @apiCategory data
342
582
  */
343
583
  getParentData(id, hierarchy) {
344
584
  return this.context.model.getParentData(id, hierarchy);
345
585
  }
346
586
  /**
347
- * <zh/> 获取节点或 combo 的子元素数据
587
+ * <zh/> 获取节点或组合的子元素数据
348
588
  *
349
589
  * <en/> Get the child element data of the node or combo
350
- * @param id - <zh/> 节点或 combo ID | <en/> node or combo ID
590
+ * @param id - <zh/> 节点或组合ID | <en/> node or combo ID
351
591
  * @returns <zh/> 子元素数据 | <en/> child element data
592
+ * @apiCategory data
352
593
  */
353
594
  getChildrenData(id) {
354
595
  return this.context.model.getChildrenData(id);
@@ -371,8 +612,8 @@ export class Graph extends EventEmitter {
371
612
  this.emit(GraphEvent.BEFORE_CANVAS_INIT, { container: $container, width, height });
372
613
  const canvas = new Canvas({
373
614
  container: $container,
374
- width: width ?? containerSize[0],
375
- height: height ?? containerSize[1],
615
+ width: width || containerSize[0],
616
+ height: height || containerSize[1],
376
617
  renderer,
377
618
  });
378
619
  this.context.canvas = canvas;
@@ -410,10 +651,11 @@ export class Graph extends EventEmitter {
410
651
  * <zh/> 执行渲染
411
652
  *
412
653
  * <en/> Render
413
- * @description
654
+ * @remarks
414
655
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
415
656
  *
416
657
  * <en/> This process will execute data update, element rendering, and layout execution
658
+ * @apiCategory render
417
659
  */
418
660
  async render() {
419
661
  await this.prepare();
@@ -427,27 +669,52 @@ export class Graph extends EventEmitter {
427
669
  *
428
670
  * <en/> Draw elements
429
671
  * @returns <zh/> 渲染结果 | <en/> draw result
672
+ * @apiCategory element
430
673
  */
431
674
  async draw() {
432
675
  await this.prepare();
433
676
  return this.context.element.draw();
434
677
  }
678
+ /**
679
+ * <zh/> 执行布局
680
+ *
681
+ * <en/> Execute layout
682
+ * @apiCategory layout
683
+ */
435
684
  layout() {
436
- return this.context.layout.layout();
685
+ this.context.layout.layout();
437
686
  }
687
+ /**
688
+ * <zh/> 停止布局
689
+ *
690
+ * <en/> Stop layout
691
+ * @remarks
692
+ * <zh/> 适用于带有迭代动画的布局,目前有 `force` 属于此类布局,即停止力导布局的迭代,一般用于布局迭代时间过长情况下的手动停止迭代动画,例如在点击画布/节点的监听中调用
693
+ *
694
+ * <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
695
+ * @apiCategory layout
696
+ */
438
697
  stopLayout() {
439
- return this.context.layout.stopLayout();
698
+ this.context.layout.stopLayout();
440
699
  }
441
700
  /**
442
701
  * <zh/> 清空画布元素
443
702
  *
444
703
  * <en/> Clear canvas elements
704
+ * @apiCategory canvas
445
705
  */
446
706
  async clear() {
447
707
  this.context.model.setData({});
448
708
  await this.draw();
449
709
  }
710
+ /**
711
+ * <zh/> 销毁当前图实例
712
+ *
713
+ * <en/> Destroy the current graph instance
714
+ * @apiCategory instance
715
+ */
450
716
  destroy() {
717
+ emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_DESTROY));
451
718
  const { layout, element, model, canvas, behavior, plugin } = this.context;
452
719
  plugin?.destroy();
453
720
  behavior?.destroy();
@@ -461,7 +728,15 @@ export class Graph extends EventEmitter {
461
728
  this.off();
462
729
  window.removeEventListener('resize', this.onResize);
463
730
  this.destroyed = true;
731
+ emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_DESTROY));
464
732
  }
733
+ /**
734
+ * <zh/> 获取画布实例
735
+ *
736
+ * <en/> Get canvas instance
737
+ * @returns - <zh/> 画布实例 | <en/> canvas instance
738
+ * @apiCategory canvas
739
+ */
465
740
  getCanvas() {
466
741
  return this.context.canvas;
467
742
  }
@@ -479,6 +754,7 @@ export class Graph extends EventEmitter {
479
754
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
480
755
  * @param options - <zh/> 适配配置 | <en/> fit options
481
756
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
757
+ * @apiCategory viewport
482
758
  */
483
759
  async fitView(options, animation) {
484
760
  await this.context.viewport?.fitView(options, animation);
@@ -488,6 +764,7 @@ export class Graph extends EventEmitter {
488
764
  *
489
765
  * <en/> Move the graph to the center of the viewport
490
766
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
767
+ * @apiCategory viewport
491
768
  */
492
769
  async fitCenter(animation) {
493
770
  await this.context.viewport?.fitCenter(animation);
@@ -510,6 +787,14 @@ export class Graph extends EventEmitter {
510
787
  await this.fitCenter(animation);
511
788
  }
512
789
  }
790
+ /**
791
+ * <zh/> 移动图,使得元素对齐到视口中心
792
+ *
793
+ * <en/> Move the graph so that the element is aligned to the center of the viewport
794
+ * @param id - <zh/> 元素 ID | <en/> element ID
795
+ * @param animation - <zh/> 动画配置 | <en/> animation configuration
796
+ * @apiCategory viewport
797
+ */
513
798
  async focusElement(id, animation) {
514
799
  await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
515
800
  }
@@ -520,13 +805,15 @@ export class Graph extends EventEmitter {
520
805
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
521
806
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
522
807
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
523
- * @description
808
+ * @remarks
524
809
  * <zh/>
525
810
  * - ratio > 1 放大
526
811
  * - ratio < 1 缩小
812
+ *
527
813
  * <en/>
528
814
  * - ratio > 1 zoom in
529
815
  * - ratio < 1 zoom out
816
+ * @apiCategory viewport
530
817
  */
531
818
  async zoomBy(ratio, animation, origin) {
532
819
  await this.context.viewport.transform({ mode: 'relative', scale: ratio, origin }, animation);
@@ -538,15 +825,17 @@ export class Graph extends EventEmitter {
538
825
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
539
826
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
540
827
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
541
- * @description
828
+ * @remarks
542
829
  * <zh/>
543
830
  * - zoom = 1 默认大小
544
831
  * - zoom > 1 放大
545
832
  * - zoom < 1 缩小
833
+ *
546
834
  * <en/>
547
835
  * - zoom = 1 default size
548
836
  * - zoom > 1 zoom in
549
837
  * - zoom < 1 zoom out
838
+ * @apiCategory viewport
550
839
  */
551
840
  async zoomTo(zoom, animation, origin) {
552
841
  this.context.viewport.transform({ mode: 'absolute', scale: zoom, origin }, animation);
@@ -556,6 +845,7 @@ export class Graph extends EventEmitter {
556
845
  *
557
846
  * <en/> Get the current zoom ratio
558
847
  * @returns <zh/> 缩放比例 | <en/> zoom ratio
848
+ * @apiCategory viewport
559
849
  */
560
850
  getZoom() {
561
851
  return this.context.viewport.getZoom();
@@ -567,6 +857,7 @@ export class Graph extends EventEmitter {
567
857
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
568
858
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
569
859
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
860
+ * @apiCategory viewport
570
861
  */
571
862
  async rotateBy(angle, animation, origin) {
572
863
  await this.context.viewport.transform({ mode: 'relative', rotate: angle, origin }, animation);
@@ -578,6 +869,7 @@ export class Graph extends EventEmitter {
578
869
  * @param angle - <zh/> 目标角度 | <en/> target angle
579
870
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
580
871
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
872
+ * @apiCategory viewport
581
873
  */
582
874
  async rotateTo(angle, animation, origin) {
583
875
  await this.context.viewport.transform({ mode: 'absolute', rotate: angle, origin }, animation);
@@ -587,6 +879,7 @@ export class Graph extends EventEmitter {
587
879
  *
588
880
  * <en/> Get the current rotation angle
589
881
  * @returns <zh/> 旋转角度 | <en/> rotation angle
882
+ * @apiCategory viewport
590
883
  */
591
884
  getRotation() {
592
885
  return this.context.viewport.getRotation();
@@ -597,6 +890,7 @@ export class Graph extends EventEmitter {
597
890
  * <en/> Translate the graph by the specified distance
598
891
  * @param offset - <zh/> 偏移量 | <en/> offset
599
892
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
893
+ * @apiCategory viewport
600
894
  */
601
895
  async translateBy(offset, animation) {
602
896
  await this.context.viewport.transform({ mode: 'relative', translate: offset }, animation);
@@ -607,7 +901,7 @@ export class Graph extends EventEmitter {
607
901
  * <en/> Translate the graph to the specified position
608
902
  * @param position - <zh/> 指定位置 | <en/> specified position
609
903
  * @param animation - <zh/> 动画配置 | <en/> animation configuration
610
- * @description
904
+ * @apiCategory viewport
611
905
  */
612
906
  async translateTo(position, animation) {
613
907
  await this.context.viewport.transform({ mode: 'absolute', translate: position }, animation);
@@ -617,10 +911,11 @@ export class Graph extends EventEmitter {
617
911
  *
618
912
  * <en/> Get the position of the graph
619
913
  * @returns <zh/> 图的位置 | <en/> position of the graph
620
- * @description
914
+ * @remarks
621
915
  * <zh/> 默认状态下,图的位置为 [0, 0]
622
916
  *
623
917
  * <en/> By default, the position of the graph is [0, 0]
918
+ * @apiCategory viewport
624
919
  */
625
920
  getPosition() {
626
921
  return subtract([0, 0], this.getCanvasByViewport([0, 0]));
@@ -639,9 +934,25 @@ export class Graph extends EventEmitter {
639
934
  Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
640
935
  await this.context.element.draw({ animation });
641
936
  }
937
+ /**
938
+ * <zh/> 获取元素位置
939
+ *
940
+ * <en/> Get element position
941
+ * @param id - <zh/> 元素 ID | <en/> element ID
942
+ * @returns <zh/> 元素位置 | <en/> element position
943
+ * @apiCategory element
944
+ */
642
945
  getElementPosition(id) {
643
946
  return this.context.model.getElementPosition(id);
644
947
  }
948
+ /**
949
+ * <zh/> 获取元素渲染样式
950
+ *
951
+ * <en/> Get element rendering style
952
+ * @param id - <zh/> 元素 ID | <en/> element ID
953
+ * @returns <zh/> 元素渲染样式 | <en/> element rendering style
954
+ * @apiCategory element
955
+ */
645
956
  getElementRenderStyle(id) {
646
957
  return omit(this.context.element.getElement(id).attributes, ['context']);
647
958
  }
@@ -662,7 +973,8 @@ export class Graph extends EventEmitter {
662
973
  *
663
974
  * <en/> Show element
664
975
  * @param id - <zh/> 元素 ID | <en/> element ID
665
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
976
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
977
+ * @apiCategory element
666
978
  */
667
979
  async showElement(id, animation) {
668
980
  const ids = Array.isArray(id) ? id : [id];
@@ -673,7 +985,8 @@ export class Graph extends EventEmitter {
673
985
  *
674
986
  * <en/> Hide element
675
987
  * @param id - <zh/> 元素 ID | <en/> element ID
676
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
988
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
989
+ * @apiCategory element
677
990
  */
678
991
  async hideElement(id, animation) {
679
992
  const ids = Array.isArray(id) ? id : [id];
@@ -685,6 +998,7 @@ export class Graph extends EventEmitter {
685
998
  * <en/> Get element visibility
686
999
  * @param id - <zh/> 元素 ID | <en/> element ID
687
1000
  * @returns <zh/> 元素可见性 | <en/> element visibility
1001
+ * @apiCategory element
688
1002
  */
689
1003
  getElementVisibility(id) {
690
1004
  const element = this.context.element.getElement(id);
@@ -706,6 +1020,7 @@ export class Graph extends EventEmitter {
706
1020
  *
707
1021
  * <en/> Bring the element to the front
708
1022
  * @param id - <zh/> 元素 ID | <en/> element ID
1023
+ * @apiCategory element
709
1024
  */
710
1025
  async frontElement(id) {
711
1026
  const ids = Array.isArray(id) ? id : [id];
@@ -733,6 +1048,7 @@ export class Graph extends EventEmitter {
733
1048
  * <en/> Get element z-index
734
1049
  * @param id - <zh/> 元素 ID | <en/> element ID
735
1050
  * @returns <zh/> 元素层级 | <en/> element z-index
1051
+ * @apiCategory element
736
1052
  */
737
1053
  getElementZIndex(id) {
738
1054
  return zIndexOf(this.context.model.getElementsData([id])[0]);
@@ -760,18 +1076,43 @@ export class Graph extends EventEmitter {
760
1076
  * <en/> Get element state
761
1077
  * @param id - <zh/> 元素 ID | <en/> element ID
762
1078
  * @returns <zh/> 元素状态 | <en/> element state
1079
+ * @apiCategory element
763
1080
  */
764
1081
  getElementState(id) {
765
1082
  return this.context.model.getElementState(id);
766
1083
  }
1084
+ /**
1085
+ * <zh/> 获取元素自身以及子节点在世界坐标系下的渲染包围盒
1086
+ *
1087
+ * <en/> Get the rendering bounding box of the element itself and its child nodes in the world coordinate system
1088
+ * @param id - <zh/> 元素 ID | <en/> element ID
1089
+ * @returns <zh/> 渲染包围盒 | <en/> render bounding box
1090
+ * @apiCategory element
1091
+ */
767
1092
  getElementRenderBounds(id) {
768
1093
  return this.context.element.getElement(id).getRenderBounds();
769
1094
  }
770
- async collapse(id, animation = true) {
1095
+ /**
1096
+ * <zh/> 收起 Combo
1097
+ *
1098
+ * <en/> Collapse Combo
1099
+ * @param id - <zh/> 元素 ID | <en/> element ID
1100
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1101
+ * @apiCategory element
1102
+ */
1103
+ async collapseElement(id, animation = true) {
771
1104
  this.setElementCollapsibility(id, true);
772
1105
  await this.context.element.draw({ animation, stage: 'collapse' });
773
1106
  }
774
- async expand(id, animation = true) {
1107
+ /**
1108
+ * <zh/> 展开 Combo
1109
+ *
1110
+ * <en/> Expand Combo
1111
+ * @param id - <zh/> 元素 ID | <en/> element ID
1112
+ * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1113
+ * @apiCategory element
1114
+ */
1115
+ async expandElement(id, animation = true) {
775
1116
  this.setElementCollapsibility(id, false);
776
1117
  await this.context.element.draw({ animation, stage: 'expand' });
777
1118
  }
@@ -787,29 +1128,54 @@ export class Graph extends EventEmitter {
787
1128
  *
788
1129
  * <en/> Export canvas content as DataURL
789
1130
  * @param options - <zh/> 导出配置 | <en/> export configuration
790
- * @param mode
791
- * <zh/> 导出模式
792
- * - viewport: 导出视口内容
793
- * - overall: 导出整个画布
794
- *
795
- * <en/> export mode
796
- * - viewport: export the content of the viewport
797
- * - overall: export the entire canvas
798
1131
  * @returns <zh/> DataURL | <en/> DataURL
1132
+ * @apiCategory exportImage
799
1133
  */
800
1134
  async toDataURL(options = {}) {
801
1135
  return this.context.canvas.toDataURL(options);
802
1136
  }
1137
+ /**
1138
+ * <zh/> 给定的视窗 DOM 坐标,转换为画布上的绘制坐标
1139
+ *
1140
+ * <en/> Convert the given viewport DOM coordinates to the drawing coordinates on the canvas
1141
+ * @param point - <zh/> 视窗坐标 | <en/> viewport coordinates
1142
+ * @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
1143
+ * @apiCategory viewport
1144
+ */
803
1145
  getCanvasByViewport(point) {
804
1146
  return parsePoint(this.context.canvas.viewport2Canvas(toPointObject(point)));
805
1147
  }
1148
+ /**
1149
+ * <zh/> 给定画布上的绘制坐标,转换为视窗 DOM 的坐标
1150
+ *
1151
+ * <en/> Convert the given drawing coordinates on the canvas to the coordinates of the viewport DOM
1152
+ * @param point - <zh/> 画布坐标 | <en/> canvas coordinates
1153
+ * @returns <zh/> 视窗 DOM 的坐标 | <en/> coordinates of the viewport DOM
1154
+ * @apiCategory viewport
1155
+ */
806
1156
  getViewportByCanvas(point) {
807
1157
  return parsePoint(this.context.canvas.canvas2Viewport(toPointObject(point)));
808
1158
  }
1159
+ /**
1160
+ * <zh/> 给定画布上的绘制坐标,转换为浏览器坐标
1161
+ *
1162
+ * <en/> Convert the given drawing coordinates on the canvas to browser coordinates
1163
+ * @param point - <zh/> 画布坐标 | <en/> canvas coordinates
1164
+ * @returns <zh/> 浏览器坐标 | <en/> browser coordinates
1165
+ * @apiCategory viewport
1166
+ */
809
1167
  getClientByCanvas(point) {
810
1168
  const viewportPoint = this.context.canvas.canvas2Viewport(toPointObject(point));
811
1169
  return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
812
1170
  }
1171
+ /**
1172
+ * <zh/> 给定的浏览器坐标,转换为画布上的绘制坐标
1173
+ *
1174
+ * <en/> Convert the given browser coordinates to drawing coordinates on the canvas
1175
+ * @param point - <zh/> 浏览器坐标 | <en/> browser coordinates
1176
+ * @returns <zh/> 画布上的绘制坐标 | <en/> drawing coordinates on the canvas
1177
+ * @apiCategory viewport
1178
+ */
813
1179
  getCanvasByClient(point) {
814
1180
  const viewportPoint = this.context.canvas.client2Viewport(toPointObject(point));
815
1181
  return parsePoint(this.context.canvas.viewport2Canvas(viewportPoint));
@@ -819,10 +1185,18 @@ export class Graph extends EventEmitter {
819
1185
  *
820
1186
  * <en/> Get the canvas coordinates of the viewport center
821
1187
  * @returns <zh/> 视口中心的画布坐标 | <en/> Canvas coordinates of the viewport center
1188
+ * @apiCategory viewport
822
1189
  */
823
1190
  getViewportCenter() {
824
1191
  return this.context.viewport.getViewportCenter();
825
1192
  }
1193
+ /**
1194
+ * <zh/> 获取画布中心的画布坐标
1195
+ *
1196
+ * <en/> Get the canvas coordinates of the canvas center
1197
+ * @returns <zh/> 画布中心的画布坐标 | <en/> Canvas coordinates of the canvas center
1198
+ * @apiCategory viewport
1199
+ */
826
1200
  getCanvasCenter() {
827
1201
  return this.context.viewport.getCanvasCenter();
828
1202
  }
@@ -836,6 +1210,7 @@ export class Graph extends EventEmitter {
836
1210
  * @param eventName - <zh/> 事件名称 | <en/> event name
837
1211
  * @param callback - <zh/> 回调函数 | <en/> callback function
838
1212
  * @returns <zh/> Graph 实例 | <en/> Graph instance
1213
+ * @apiCategory event
839
1214
  */
840
1215
  on(eventName, callback) {
841
1216
  return super.on(eventName, callback);
@@ -847,6 +1222,7 @@ export class Graph extends EventEmitter {
847
1222
  * @param eventName - <zh/> 事件名称 | <en/> event name
848
1223
  * @param callback - <zh/> 回调函数 | <en/> callback function
849
1224
  * @returns <zh/> Graph 实例 | <en/> Graph instance
1225
+ * @apiCategory event
850
1226
  */
851
1227
  once(eventName, callback) {
852
1228
  return super.once(eventName, callback);