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