@antv/g6 5.0.1 → 5.0.3

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 (302) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/click-select.d.ts +4 -5
  3. package/dist/lib/behaviors/hover-activate.d.ts +0 -1
  4. package/dist/lib/elements/base-element.d.ts +1 -22
  5. package/dist/lib/elements/combos/base-combo.d.ts +4 -4
  6. package/dist/lib/elements/edges/base-edge.d.ts +4 -2
  7. package/dist/lib/elements/effect.d.ts +17 -0
  8. package/dist/lib/elements/nodes/base-node.d.ts +5 -4
  9. package/dist/lib/elements/nodes/diamond.d.ts +0 -1
  10. package/dist/lib/elements/shapes/badge.d.ts +17 -6
  11. package/dist/lib/elements/shapes/base-shape.d.ts +9 -3
  12. package/dist/lib/elements/shapes/icon.d.ts +15 -3
  13. package/dist/lib/elements/shapes/label.d.ts +18 -7
  14. package/dist/lib/exports.d.ts +3 -2
  15. package/dist/lib/index.d.ts +5 -1
  16. package/dist/lib/layouts/base-layout.d.ts +3 -1
  17. package/dist/lib/plugins/bubble-sets.d.ts +2 -2
  18. package/dist/lib/plugins/contextmenu/index.d.ts +4 -3
  19. package/dist/lib/plugins/hull/index.d.ts +2 -2
  20. package/dist/lib/runtime/canvas.d.ts +15 -2
  21. package/dist/lib/runtime/data.d.ts +9 -16
  22. package/dist/lib/runtime/element.d.ts +18 -2
  23. package/dist/lib/runtime/graph.d.ts +374 -109
  24. package/dist/lib/spec/element/edge.d.ts +1 -1
  25. package/dist/lib/spec/element/node.d.ts +1 -1
  26. package/dist/lib/transforms/process-parallel-edges.d.ts +2 -2
  27. package/dist/lib/types/callable.d.ts +0 -11
  28. package/dist/lib/types/data.d.ts +12 -0
  29. package/dist/lib/types/edge.d.ts +11 -0
  30. package/dist/lib/types/element.d.ts +100 -9
  31. package/dist/lib/types/index.d.ts +0 -1
  32. package/dist/lib/types/point.d.ts +0 -1
  33. package/dist/lib/utils/element.d.ts +2 -2
  34. package/dist/lib/utils/layout.d.ts +2 -2
  35. package/dist/lib/utils/path.d.ts +3 -3
  36. package/dist/lib/utils/position.d.ts +8 -8
  37. package/dist/lib/utils/style.d.ts +13 -8
  38. package/esm/behaviors/click-select.d.ts +4 -5
  39. package/esm/behaviors/click-select.js +62 -50
  40. package/esm/behaviors/click-select.js.map +1 -1
  41. package/esm/behaviors/drag-element.js +2 -9
  42. package/esm/behaviors/drag-element.js.map +1 -1
  43. package/esm/behaviors/hover-activate.d.ts +0 -1
  44. package/esm/behaviors/hover-activate.js +18 -16
  45. package/esm/behaviors/hover-activate.js.map +1 -1
  46. package/esm/behaviors/lasso-select.js.map +1 -1
  47. package/esm/elements/base-element.d.ts +1 -22
  48. package/esm/elements/base-element.js +0 -21
  49. package/esm/elements/base-element.js.map +1 -1
  50. package/esm/elements/combos/base-combo.d.ts +4 -4
  51. package/esm/elements/combos/base-combo.js +27 -4
  52. package/esm/elements/combos/base-combo.js.map +1 -1
  53. package/esm/elements/edges/base-edge.d.ts +4 -2
  54. package/esm/elements/edges/base-edge.js +41 -7
  55. package/esm/elements/edges/base-edge.js.map +1 -1
  56. package/esm/elements/effect.d.ts +17 -0
  57. package/esm/elements/effect.js +70 -0
  58. package/esm/elements/effect.js.map +1 -0
  59. package/esm/elements/nodes/base-node.d.ts +5 -4
  60. package/esm/elements/nodes/base-node.js +33 -14
  61. package/esm/elements/nodes/base-node.js.map +1 -1
  62. package/esm/elements/nodes/circle.js +1 -1
  63. package/esm/elements/nodes/circle.js.map +1 -1
  64. package/esm/elements/nodes/diamond.d.ts +0 -1
  65. package/esm/elements/nodes/diamond.js +0 -6
  66. package/esm/elements/nodes/diamond.js.map +1 -1
  67. package/esm/elements/nodes/ellipse.js +1 -1
  68. package/esm/elements/nodes/ellipse.js.map +1 -1
  69. package/esm/elements/nodes/image.js +2 -2
  70. package/esm/elements/nodes/image.js.map +1 -1
  71. package/esm/elements/nodes/rect.js +1 -1
  72. package/esm/elements/nodes/rect.js.map +1 -1
  73. package/esm/elements/shapes/badge.d.ts +17 -6
  74. package/esm/elements/shapes/badge.js +9 -0
  75. package/esm/elements/shapes/badge.js.map +1 -1
  76. package/esm/elements/shapes/base-shape.d.ts +9 -3
  77. package/esm/elements/shapes/base-shape.js +33 -15
  78. package/esm/elements/shapes/base-shape.js.map +1 -1
  79. package/esm/elements/shapes/icon.d.ts +15 -3
  80. package/esm/elements/shapes/icon.js +12 -4
  81. package/esm/elements/shapes/icon.js.map +1 -1
  82. package/esm/elements/shapes/label.d.ts +18 -7
  83. package/esm/elements/shapes/label.js +10 -0
  84. package/esm/elements/shapes/label.js.map +1 -1
  85. package/esm/elements/shapes/polygon.js +1 -1
  86. package/esm/elements/shapes/polygon.js.map +1 -1
  87. package/esm/exports.d.ts +3 -2
  88. package/esm/exports.js +1 -1
  89. package/esm/exports.js.map +1 -1
  90. package/esm/index.d.ts +5 -1
  91. package/esm/index.js +5 -1
  92. package/esm/index.js.map +1 -1
  93. package/esm/layouts/base-layout.d.ts +3 -1
  94. package/esm/layouts/base-layout.js +3 -1
  95. package/esm/layouts/base-layout.js.map +1 -1
  96. package/esm/plugins/bubble-sets.d.ts +2 -2
  97. package/esm/plugins/bubble-sets.js.map +1 -1
  98. package/esm/plugins/contextmenu/index.d.ts +4 -3
  99. package/esm/plugins/contextmenu/index.js +12 -10
  100. package/esm/plugins/contextmenu/index.js.map +1 -1
  101. package/esm/plugins/hull/index.d.ts +2 -2
  102. package/esm/plugins/hull/index.js.map +1 -1
  103. package/esm/runtime/canvas.d.ts +15 -2
  104. package/esm/runtime/canvas.js.map +1 -1
  105. package/esm/runtime/data.d.ts +9 -16
  106. package/esm/runtime/data.js +26 -34
  107. package/esm/runtime/data.js.map +1 -1
  108. package/esm/runtime/element.d.ts +18 -2
  109. package/esm/runtime/element.js +75 -24
  110. package/esm/runtime/element.js.map +1 -1
  111. package/esm/runtime/graph.d.ts +374 -109
  112. package/esm/runtime/graph.js +278 -82
  113. package/esm/runtime/graph.js.map +1 -1
  114. package/esm/runtime/layout.js +1 -1
  115. package/esm/runtime/layout.js.map +1 -1
  116. package/esm/spec/element/edge.d.ts +1 -1
  117. package/esm/spec/element/node.d.ts +1 -1
  118. package/esm/themes/base.js +5 -0
  119. package/esm/themes/base.js.map +1 -1
  120. package/esm/transforms/collapse-expand-node.js +14 -4
  121. package/esm/transforms/collapse-expand-node.js.map +1 -1
  122. package/esm/transforms/process-parallel-edges.d.ts +2 -2
  123. package/esm/types/callable.d.ts +0 -11
  124. package/esm/types/data.d.ts +12 -0
  125. package/esm/types/edge.d.ts +11 -0
  126. package/esm/types/element.d.ts +100 -9
  127. package/esm/types/index.d.ts +0 -1
  128. package/esm/types/point.d.ts +0 -1
  129. package/esm/utils/element.d.ts +2 -2
  130. package/esm/utils/element.js.map +1 -1
  131. package/esm/utils/layout.d.ts +2 -2
  132. package/esm/utils/layout.js +4 -4
  133. package/esm/utils/layout.js.map +1 -1
  134. package/esm/utils/path.d.ts +3 -3
  135. package/esm/utils/path.js +1 -1
  136. package/esm/utils/path.js.map +1 -1
  137. package/esm/utils/position.d.ts +8 -8
  138. package/esm/utils/position.js +2 -2
  139. package/esm/utils/position.js.map +1 -1
  140. package/esm/utils/style.d.ts +13 -8
  141. package/esm/utils/style.js +16 -11
  142. package/esm/utils/style.js.map +1 -1
  143. package/lib/behaviors/click-select.d.ts +4 -5
  144. package/lib/behaviors/click-select.js +62 -50
  145. package/lib/behaviors/click-select.js.map +1 -1
  146. package/lib/behaviors/drag-element.js +2 -9
  147. package/lib/behaviors/drag-element.js.map +1 -1
  148. package/lib/behaviors/hover-activate.d.ts +0 -1
  149. package/lib/behaviors/hover-activate.js +18 -16
  150. package/lib/behaviors/hover-activate.js.map +1 -1
  151. package/lib/behaviors/lasso-select.js.map +1 -1
  152. package/lib/elements/base-element.d.ts +1 -22
  153. package/lib/elements/base-element.js +0 -21
  154. package/lib/elements/base-element.js.map +1 -1
  155. package/lib/elements/combos/base-combo.d.ts +4 -4
  156. package/lib/elements/combos/base-combo.js +27 -4
  157. package/lib/elements/combos/base-combo.js.map +1 -1
  158. package/lib/elements/edges/base-edge.d.ts +4 -2
  159. package/lib/elements/edges/base-edge.js +41 -7
  160. package/lib/elements/edges/base-edge.js.map +1 -1
  161. package/lib/elements/effect.d.ts +17 -0
  162. package/lib/elements/effect.js +74 -0
  163. package/lib/elements/effect.js.map +1 -0
  164. package/lib/elements/nodes/base-node.d.ts +5 -4
  165. package/lib/elements/nodes/base-node.js +33 -14
  166. package/lib/elements/nodes/base-node.js.map +1 -1
  167. package/lib/elements/nodes/circle.js +1 -1
  168. package/lib/elements/nodes/circle.js.map +1 -1
  169. package/lib/elements/nodes/diamond.d.ts +0 -1
  170. package/lib/elements/nodes/diamond.js +0 -6
  171. package/lib/elements/nodes/diamond.js.map +1 -1
  172. package/lib/elements/nodes/ellipse.js +1 -1
  173. package/lib/elements/nodes/ellipse.js.map +1 -1
  174. package/lib/elements/nodes/image.js +2 -2
  175. package/lib/elements/nodes/image.js.map +1 -1
  176. package/lib/elements/nodes/rect.js +1 -1
  177. package/lib/elements/nodes/rect.js.map +1 -1
  178. package/lib/elements/shapes/badge.d.ts +17 -6
  179. package/lib/elements/shapes/badge.js +9 -0
  180. package/lib/elements/shapes/badge.js.map +1 -1
  181. package/lib/elements/shapes/base-shape.d.ts +9 -3
  182. package/lib/elements/shapes/base-shape.js +33 -15
  183. package/lib/elements/shapes/base-shape.js.map +1 -1
  184. package/lib/elements/shapes/icon.d.ts +15 -3
  185. package/lib/elements/shapes/icon.js +12 -4
  186. package/lib/elements/shapes/icon.js.map +1 -1
  187. package/lib/elements/shapes/label.d.ts +18 -7
  188. package/lib/elements/shapes/label.js +10 -0
  189. package/lib/elements/shapes/label.js.map +1 -1
  190. package/lib/elements/shapes/polygon.js +1 -1
  191. package/lib/elements/shapes/polygon.js.map +1 -1
  192. package/lib/exports.d.ts +3 -2
  193. package/lib/exports.js +5 -2
  194. package/lib/exports.js.map +1 -1
  195. package/lib/index.d.ts +5 -1
  196. package/lib/index.js +6 -2
  197. package/lib/index.js.map +1 -1
  198. package/lib/layouts/base-layout.d.ts +3 -1
  199. package/lib/layouts/base-layout.js +3 -1
  200. package/lib/layouts/base-layout.js.map +1 -1
  201. package/lib/plugins/bubble-sets.d.ts +2 -2
  202. package/lib/plugins/bubble-sets.js.map +1 -1
  203. package/lib/plugins/contextmenu/index.d.ts +4 -3
  204. package/lib/plugins/contextmenu/index.js +12 -10
  205. package/lib/plugins/contextmenu/index.js.map +1 -1
  206. package/lib/plugins/hull/index.d.ts +2 -2
  207. package/lib/plugins/hull/index.js.map +1 -1
  208. package/lib/runtime/canvas.d.ts +15 -2
  209. package/lib/runtime/canvas.js.map +1 -1
  210. package/lib/runtime/data.d.ts +9 -16
  211. package/lib/runtime/data.js +26 -34
  212. package/lib/runtime/data.js.map +1 -1
  213. package/lib/runtime/element.d.ts +18 -2
  214. package/lib/runtime/element.js +75 -24
  215. package/lib/runtime/element.js.map +1 -1
  216. package/lib/runtime/graph.d.ts +374 -109
  217. package/lib/runtime/graph.js +278 -82
  218. package/lib/runtime/graph.js.map +1 -1
  219. package/lib/runtime/layout.js +1 -1
  220. package/lib/runtime/layout.js.map +1 -1
  221. package/lib/spec/element/edge.d.ts +1 -1
  222. package/lib/spec/element/node.d.ts +1 -1
  223. package/lib/themes/base.js +5 -0
  224. package/lib/themes/base.js.map +1 -1
  225. package/lib/transforms/collapse-expand-node.js +14 -4
  226. package/lib/transforms/collapse-expand-node.js.map +1 -1
  227. package/lib/transforms/process-parallel-edges.d.ts +2 -2
  228. package/lib/types/callable.d.ts +0 -11
  229. package/lib/types/data.d.ts +12 -0
  230. package/lib/types/edge.d.ts +11 -0
  231. package/lib/types/element.d.ts +100 -9
  232. package/lib/types/index.d.ts +0 -1
  233. package/lib/types/point.d.ts +0 -1
  234. package/lib/utils/element.d.ts +2 -2
  235. package/lib/utils/element.js.map +1 -1
  236. package/lib/utils/layout.d.ts +2 -2
  237. package/lib/utils/layout.js +4 -4
  238. package/lib/utils/layout.js.map +1 -1
  239. package/lib/utils/path.d.ts +3 -3
  240. package/lib/utils/path.js +1 -1
  241. package/lib/utils/path.js.map +1 -1
  242. package/lib/utils/position.d.ts +8 -8
  243. package/lib/utils/position.js +2 -2
  244. package/lib/utils/position.js.map +1 -1
  245. package/lib/utils/style.d.ts +13 -8
  246. package/lib/utils/style.js +18 -13
  247. package/lib/utils/style.js.map +1 -1
  248. package/package.json +10 -10
  249. package/src/behaviors/click-select.ts +61 -60
  250. package/src/behaviors/drag-element.ts +2 -7
  251. package/src/behaviors/hover-activate.ts +18 -22
  252. package/src/behaviors/lasso-select.ts +2 -2
  253. package/src/elements/base-element.ts +1 -25
  254. package/src/elements/combos/base-combo.ts +27 -11
  255. package/src/elements/edges/base-edge.ts +28 -8
  256. package/src/elements/effect.ts +74 -0
  257. package/src/elements/nodes/base-node.ts +23 -18
  258. package/src/elements/nodes/circle.ts +1 -1
  259. package/src/elements/nodes/diamond.ts +0 -7
  260. package/src/elements/nodes/ellipse.ts +1 -1
  261. package/src/elements/nodes/image.ts +2 -2
  262. package/src/elements/nodes/rect.ts +1 -1
  263. package/src/elements/shapes/badge.ts +17 -5
  264. package/src/elements/shapes/base-shape.ts +35 -15
  265. package/src/elements/shapes/icon.ts +18 -7
  266. package/src/elements/shapes/label.ts +19 -6
  267. package/src/elements/shapes/polygon.ts +1 -1
  268. package/src/exports.ts +6 -2
  269. package/src/index.ts +6 -2
  270. package/src/layouts/base-layout.ts +5 -1
  271. package/src/plugins/bubble-sets.ts +2 -2
  272. package/src/plugins/contextmenu/index.ts +16 -16
  273. package/src/plugins/hull/index.ts +2 -2
  274. package/src/runtime/canvas.ts +15 -10
  275. package/src/runtime/data.ts +32 -44
  276. package/src/runtime/element.ts +87 -30
  277. package/src/runtime/graph.ts +405 -132
  278. package/src/runtime/layout.ts +2 -2
  279. package/src/spec/element/edge.ts +1 -1
  280. package/src/spec/element/node.ts +1 -1
  281. package/src/themes/base.ts +5 -0
  282. package/src/transforms/collapse-expand-node.ts +13 -4
  283. package/src/transforms/process-parallel-edges.ts +2 -2
  284. package/src/types/callable.ts +0 -12
  285. package/src/types/data.ts +13 -0
  286. package/src/types/edge.ts +11 -0
  287. package/src/types/element.ts +106 -10
  288. package/src/types/index.ts +0 -1
  289. package/src/types/point.ts +0 -1
  290. package/src/utils/element.ts +3 -13
  291. package/src/utils/layout.ts +6 -6
  292. package/src/utils/path.ts +3 -3
  293. package/src/utils/position.ts +8 -8
  294. package/src/utils/style.ts +19 -12
  295. package/dist/lib/types/position.d.ts +0 -2
  296. package/esm/types/position.d.ts +0 -2
  297. package/esm/types/position.js +0 -2
  298. package/esm/types/position.js.map +0 -1
  299. package/lib/types/position.d.ts +0 -2
  300. package/lib/types/position.js +0 -3
  301. package/lib/types/position.js.map +0 -1
  302. package/src/types/position.ts +0 -3
@@ -5,10 +5,9 @@ import type { BehaviorOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, G
5
5
  import type { UpdateBehaviorOption } from '../spec/behavior';
6
6
  import type { UpdatePluginOption } from '../spec/plugin';
7
7
  import type { UpdateTransformOption } from '../spec/transform';
8
- import type { CallableValue, DataID, EdgeDirection, ElementDatum, ElementType, FitViewOptions, ID, IEvent, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, Position, State, ViewportAnimationEffectTiming } from '../types';
8
+ import type { DataID, EdgeDirection, ElementDatum, ElementType, FitViewOptions, HierarchyKey, ID, IEvent, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, State, ViewportAnimationEffectTiming } from '../types';
9
9
  import type { DataURLOptions } from './canvas';
10
10
  import { Canvas } from './canvas';
11
- import type { HierarchyKey } from './data';
12
11
  export declare class Graph extends EventEmitter {
13
12
  private options;
14
13
  /**
@@ -60,7 +59,7 @@ export declare class Graph extends EventEmitter {
60
59
  */
61
60
  getBackground(): GraphOptions['background'];
62
61
  /**
63
- * <zh/> 获取当前图容器的大小
62
+ * <zh/> 获取当前画布容器的尺寸
64
63
  *
65
64
  * <en/> Get the size of the current canvas container
66
65
  * @returns <zh/> 画布尺寸 | <en/> canvas size
@@ -68,7 +67,7 @@ export declare class Graph extends EventEmitter {
68
67
  */
69
68
  getSize(): [number, number];
70
69
  /**
71
- * <zh/> 获取当前图容器的大小
70
+ * <zh/> 获取当前画布容器的尺寸
72
71
  *
73
72
  * <en/> Get the size of the current canvas container
74
73
  * @param width - <zh/> 画布宽度 | <en/> canvas width
@@ -77,7 +76,7 @@ export declare class Graph extends EventEmitter {
77
76
  */
78
77
  setSize(width: number, height: number): void;
79
78
  /**
80
- * <zh/> 获取当前图的缩放区间
79
+ * <zh/> 设置当前图的缩放区间
81
80
  *
82
81
  * <en/> Get the zoom range of the current graph
83
82
  * @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
@@ -96,7 +95,11 @@ export declare class Graph extends EventEmitter {
96
95
  * <zh/> 设置节点样式映射
97
96
  *
98
97
  * <en/> Set node mapper
99
- * @param node - <zh/> 节点配置 | <en/> node configuration
98
+ * @param node - <zh/> 节点配置 | <en/> node options
99
+ * @remarks
100
+ * <zh/> 即 `options.node` 的值
101
+ *
102
+ * <en/> The value of `options.node`
100
103
  * @apiCategory element
101
104
  */
102
105
  setNode(node: NodeOptions): void;
@@ -104,7 +107,11 @@ export declare class Graph extends EventEmitter {
104
107
  * <zh/> 设置边样式映射
105
108
  *
106
109
  * <en/> Set edge mapper
107
- * @param edge - <zh/> 边配置 | <en/> edge configuration
110
+ * @param edge - <zh/> 边配置 | <en/> edge options
111
+ * @remarks
112
+ * <zh/> 即 `options.edge` 的值
113
+ *
114
+ * <en/> The value of `options.edge`
108
115
  * @apiCategory element
109
116
  */
110
117
  setEdge(edge: EdgeOptions): void;
@@ -112,7 +119,11 @@ export declare class Graph extends EventEmitter {
112
119
  * <zh/> 设置组合样式映射
113
120
  *
114
121
  * <en/> Set combo mapper
115
- * @param combo - <zh/> 组合配置 | <en/> combo configuration
122
+ * @param combo - <zh/> 组合配置 | <en/> combo options
123
+ * @remarks
124
+ * <zh/> 即 `options.combo` 的值
125
+ *
126
+ * <en/> The value of `options.combo`
116
127
  * @apiCategory element
117
128
  */
118
129
  setCombo(combo: ComboOptions): void;
@@ -120,7 +131,7 @@ export declare class Graph extends EventEmitter {
120
131
  * <zh/> 获取主题
121
132
  *
122
133
  * <en/> Get theme
123
- * @returns <zh/> 主题配置 | <en/> theme configuration
134
+ * @returns <zh/> 当前主题 | <en/> current theme
124
135
  * @apiCategory theme
125
136
  */
126
137
  getTheme(): ThemeOptions;
@@ -128,23 +139,33 @@ export declare class Graph extends EventEmitter {
128
139
  * <zh/> 设置主题
129
140
  *
130
141
  * <en/> Set theme
131
- * @param theme - <zh/> 主题配置 | <en/> theme configuration
142
+ * @param theme - <zh/> 主题名 | <en/> theme name
143
+ * @example
144
+ * ```ts
145
+ * graph.setTheme('dark');
146
+ * ```
132
147
  * @apiCategory theme
133
148
  */
134
- setTheme(theme: CallableValue<ThemeOptions>): void;
149
+ setTheme(theme: ThemeOptions | ((prev: ThemeOptions) => ThemeOptions)): void;
135
150
  /**
136
151
  * <zh/> 设置布局
137
152
  *
138
153
  * <en/> Set layout
139
- * @param layout - <zh/> 布局配置 | <en/> layout configuration
154
+ * @param layout - <zh/> 布局配置 | <en/> layout options
155
+ * @example
156
+ * ```ts
157
+ * graph.setLayout({
158
+ * type: 'dagre',
159
+ * })
160
+ * ```
140
161
  * @apiCategory layout
141
162
  */
142
- setLayout(layout: CallableValue<LayoutOptions>): void;
163
+ setLayout(layout: LayoutOptions | ((prev: LayoutOptions) => LayoutOptions)): void;
143
164
  /**
144
- * <zh/> 获取布局
165
+ * <zh/> 获取布局配置
145
166
  *
146
- * <en/> Get layout
147
- * @returns <zh/> 布局配置 | <en/> layout configuration
167
+ * <en/> Get layout options
168
+ * @returns <zh/> 布局配置 | <en/> layout options
148
169
  * @apiCategory layout
149
170
  */
150
171
  getLayout(): LayoutOptions;
@@ -152,47 +173,84 @@ export declare class Graph extends EventEmitter {
152
173
  * <zh/> 设置交互
153
174
  *
154
175
  * <en/> Set behaviors
155
- * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
176
+ * @param behaviors - <zh/> 交互配置 | <en/> behavior options
177
+ * @remarks
178
+ * <zh/> 设置的交互会全量替换原有的交互,如果需要新增交互可以使用如下方式:
179
+ *
180
+ * <en/> The set behavior will completely replace the original behavior. If you need to add behavior, you can use the following method:
181
+ *
182
+ * ```ts
183
+ * graph.setBehaviors((behaviors) => [...behaviors, { type: 'zoom-canvas' }])
184
+ * ```
156
185
  * @apiCategory behavior
157
186
  */
158
- setBehaviors(behaviors: CallableValue<BehaviorOptions>): void;
187
+ setBehaviors(behaviors: BehaviorOptions | ((prev: BehaviorOptions) => BehaviorOptions)): void;
159
188
  /**
160
- * <zh/> 更新交互
189
+ * <zh/> 更新指定的交互配置
161
190
  *
162
- * <en/> Update behavior
163
- * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
191
+ * <en/> Update specified behavior options
192
+ * @param behavior - <zh/> 交互配置 | <en/> behavior options
193
+ * @remarks
194
+ * <zh/> 如果要更新一个交互,那么必须在交互配置中指定 key 字段,例如:
195
+ *
196
+ * <en/> If you want to update a behavior, you must specify the key field in the behavior options, for example:
197
+ * ```ts
198
+ * {
199
+ * behaviors: [{ type: 'zoom-canvas', key: 'zoom-canvas' }]
200
+ * }
201
+ *
202
+ * graph.updateBehavior({ key: 'zoom-canvas', enable: false })
203
+ * ```
164
204
  * @apiCategory behavior
165
205
  */
166
206
  updateBehavior(behavior: UpdateBehaviorOption): void;
167
207
  /**
168
- * <zh/> 获取交互
208
+ * <zh/> 获取交互配置
169
209
  *
170
- * <en/> Get behaviors
171
- * @returns <zh/> 交互配置 | <en/> behavior configuration
210
+ * <en/> Get behaviors options
211
+ * @returns <zh/> 交互配置 | <en/> behavior options
172
212
  * @apiCategory behavior
173
213
  */
174
214
  getBehaviors(): BehaviorOptions;
175
215
  /**
176
- * <zh/> 设置插件
216
+ * <zh/> 设置插件配置
217
+ *
218
+ * <en/> Set plugins options
219
+ * @param plugins - <zh/> 插件配置 | <en/> plugin options
220
+ * @remarks
221
+ * <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
177
222
  *
178
- * <en/> Set plugins
179
- * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
223
+ * <en/> The set plugin will completely replace the original plugin configuration. If you need to add a plugin, you can use the following method:
224
+ * ```ts
225
+ * graph.setPlugins((plugins) => [...plugins, { key: 'grid-line' }])
226
+ * ```
180
227
  * @apiCategory plugin
181
228
  */
182
- setPlugins(plugins: CallableValue<PluginOptions>): void;
229
+ setPlugins(plugins: PluginOptions | ((prev: PluginOptions) => PluginOptions)): void;
183
230
  /**
184
- * <zh/> 更新插件
231
+ * <zh/> 更新插件配置
185
232
  *
186
- * <en/> Update plugin
187
- * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
233
+ * <en/> Update plugin options
234
+ * @param plugin - <zh/> 插件配置 | <en/> plugin options
235
+ * @remarks
236
+ * <zh/> 如果要更新一个插件,那么必须在插件配置中指定 key 字段,例如:
237
+ *
238
+ * <en/> If you want to update a plugin, you must specify the key field in the plugin options, for example:
239
+ * ```ts
240
+ * {
241
+ * plugins: [{ key: 'grid-line' }]
242
+ * }
243
+ *
244
+ * graph.updatePlugin({ key: 'grid-line', follow: true })
245
+ * ```
188
246
  * @apiCategory plugin
189
247
  */
190
248
  updatePlugin(plugin: UpdatePluginOption): void;
191
249
  /**
192
- * <zh/> 获取插件
250
+ * <zh/> 获取插件配置
193
251
  *
194
- * <en/> Get plugins
195
- * @returns <zh/> 插件配置 | <en/> plugin configuration
252
+ * <en/> Get plugins options
253
+ * @returns <zh/> 插件配置 | <en/> plugin options
196
254
  * @apiCategory plugin
197
255
  */
198
256
  getPlugins(): PluginOptions;
@@ -202,6 +260,17 @@ export declare class Graph extends EventEmitter {
202
260
  * <en/> Get plugin instance
203
261
  * @param key - <zh/> 插件 key | <en/> plugin key
204
262
  * @returns <zh/> 插件实例 | <en/> plugin instance
263
+ * @remarks
264
+ * <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
265
+ *
266
+ * <en/> Some plugins provide API methods for calling, such as the full-screen plugin can call the `request` and `exit` methods to request and exit full-screen
267
+ * ```ts
268
+ * const fullscreen = graph.getPluginInstance('fullscreen');
269
+ *
270
+ * fullscreen.request();
271
+ *
272
+ * fullscreen.exit();
273
+ * ```
205
274
  * @apiCategory plugin
206
275
  */
207
276
  getPluginInstance<T extends Plugin>(key: string): T;
@@ -209,31 +278,38 @@ export declare class Graph extends EventEmitter {
209
278
  * <zh/> 设置数据转换器
210
279
  *
211
280
  * <en/> Set data transforms
212
- * @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
281
+ * @param transforms - <zh/> 数据转换配置 | <en/> data transform options
282
+ * @remarks
283
+ * <zh/> 数据转换器能够在图渲染过程中执行数据转换,目前支持在渲染前对绘制数据进行转化。
284
+ *
285
+ * <en/> Data transforms can perform data transformation during the rendering process of the graph. Currently, it supports transforming the drawing data before rendering.
213
286
  * @apiCategory transform
214
287
  */
215
- setTransforms(transforms: CallableValue<TransformOptions>): void;
288
+ setTransforms(transforms: TransformOptions | ((prev: TransformOptions) => TransformOptions)): void;
216
289
  /**
217
290
  * <zh/> 更新数据转换器
218
291
  *
219
292
  * <en/> Update data transform
220
- * @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
293
+ * @param transform - <zh/> 数据转换器配置 | <en/> data transform options
221
294
  * @apiCategory transform
222
295
  */
223
296
  updateTransform(transform: UpdateTransformOption): void;
224
297
  /**
225
- * <zh/> 获取数据转换器
298
+ * <zh/> 获取数据转换器配置
226
299
  *
227
- * <en/> Get data transforms
228
- * @returns <zh/> 数据转换器实例 | <en/> data transform instance
300
+ * <en/> Get data transforms options
301
+ * @returns <zh/> 数据转换配置 | <en/> data transform options
229
302
  * @apiCategory transform
230
303
  */
231
304
  getTransforms(): TransformOptions;
232
305
  /**
233
- * <zh/> 获取数据
306
+ * <zh/> 获取图数据
307
+ *
308
+ * <en/> Get graph data
309
+ * @returns <zh/> 图数据 | <en/> Graph data
310
+ * <zh/> 获取当前图的数据,包括节点、边、组合数据
234
311
  *
235
- * <en/> Get data
236
- * @returns <zh/> 数据 | <en/> data
312
+ * <en/> Get the data of the current graph, including node, edge, and combo data
237
313
  * @apiCategory data
238
314
  */
239
315
  getData(): GraphData;
@@ -243,6 +319,10 @@ export declare class Graph extends EventEmitter {
243
319
  * <en/> Get element data by ID
244
320
  * @param id - <zh/> 元素 ID | <en/> element ID
245
321
  * @returns <zh/> 元素数据 | <en/> element data
322
+ * @remarks
323
+ * <zh/> 直接获取元素的数据而不必考虑元素类型
324
+ *
325
+ * <en/> Get element data directly without considering the element type
246
326
  * @apiCategory data
247
327
  */
248
328
  getElementData(id: ID): ElementDatum;
@@ -251,6 +331,10 @@ export declare class Graph extends EventEmitter {
251
331
  *
252
332
  * <en/> Get multiple element data in batch
253
333
  * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
334
+ * @remarks
335
+ * <zh/> 直接获取元素的数据而不必考虑元素类型
336
+ *
337
+ * <en/> Get element data directly without considering the element type
254
338
  * @apiCategory data
255
339
  */
256
340
  getElementData(ids: ID[]): ElementDatum[];
@@ -268,6 +352,10 @@ export declare class Graph extends EventEmitter {
268
352
  * <en/> Get single node data
269
353
  * @param id - <zh/> 节点 ID | <en/> node ID
270
354
  * @returns <zh/> 节点数据 | <en/> node data
355
+ * @example
356
+ * ```ts
357
+ * const node1 = graph.getNodeData('node-1');
358
+ * ```
271
359
  * @apiCategory data
272
360
  */
273
361
  getNodeData(id: ID): NodeData;
@@ -277,6 +365,10 @@ export declare class Graph extends EventEmitter {
277
365
  * <en/> Get multiple node data in batch
278
366
  * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
279
367
  * @returns <zh/> 节点数据 | <en/> node data
368
+ * @example
369
+ * ```ts
370
+ * const [node1, node2] = graph.getNodeData(['node-1', 'node-2']);
371
+ * ```
280
372
  * @apiCategory data
281
373
  */
282
374
  getNodeData(ids: ID[]): NodeData[];
@@ -294,6 +386,10 @@ export declare class Graph extends EventEmitter {
294
386
  * <en/> Get single edge data
295
387
  * @param id - <zh/> 边 ID | <en/> edge ID
296
388
  * @returns <zh/> 边数据 | <en/> edge data
389
+ * @example
390
+ * ```ts
391
+ * const edge1 = graph.getEdgeData('edge-1');
392
+ * ```
297
393
  * @apiCategory data
298
394
  */
299
395
  getEdgeData(id: ID): EdgeData;
@@ -303,6 +399,10 @@ export declare class Graph extends EventEmitter {
303
399
  * <en/> Get multiple edge data in batch
304
400
  * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
305
401
  * @returns <zh/> 边数据 | <en/> edge data
402
+ * @example
403
+ * ```ts
404
+ * const [edge1, edge2] = graph.getEdgeData(['edge-1', 'edge-2']);
405
+ * ```
306
406
  * @apiCategory data
307
407
  */
308
408
  getEdgeData(ids: ID[]): EdgeData[];
@@ -320,6 +420,10 @@ export declare class Graph extends EventEmitter {
320
420
  * <en/> Get single combo data
321
421
  * @param id - <zh/> 组合ID | <en/> combo ID
322
422
  * @returns <zh/> 组合数据 | <en/> combo data
423
+ * @example
424
+ * ```ts
425
+ * const combo1 = graph.getComboData('combo-1');
426
+ * ```
323
427
  * @apiCategory data
324
428
  */
325
429
  getComboData(id: ID): ComboData;
@@ -329,6 +433,10 @@ export declare class Graph extends EventEmitter {
329
433
  * <en/> Get multiple combo data in batch
330
434
  * @param ids - <zh/> 组合ID 数组 | <en/> combo ID array
331
435
  * @returns <zh/> 组合数据 | <en/> combo data
436
+ * @example
437
+ * ```ts
438
+ * const [combo1, combo2] = graph.getComboData(['combo-1', 'combo-2']);
439
+ * ```
332
440
  * @apiCategory data
333
441
  */
334
442
  getComboData(ids: ID[]): ComboData[];
@@ -337,102 +445,196 @@ export declare class Graph extends EventEmitter {
337
445
  *
338
446
  * <en/> Set full data
339
447
  * @param data - <zh/> 数据 | <en/> data
448
+ * @remarks
449
+ * <zh/> 设置全量数据会替换当前图中的所有数据,G6 会自动进行数据差异计算
450
+ *
451
+ * <en/> Setting full data will replace all data in the current graph, and G6 will automatically calculate the data difference
340
452
  * @apiCategory data
341
453
  */
342
- setData(data: CallableValue<GraphData>): void;
454
+ setData(data: GraphData | ((prev: GraphData) => GraphData)): void;
343
455
  /**
344
456
  * <zh/> 新增元素数据
345
457
  *
346
458
  * <en/> Add element data
347
459
  * @param data - <zh/> 元素数据 | <en/> element data
460
+ * @example
461
+ * ```ts
462
+ * graph.addData({
463
+ * nodes: [{ id: 'node-1' }, { id: 'node-2' }],
464
+ * edges: [{ source: 'node-1', target: 'node-2' }],
465
+ * });
466
+ * ```
348
467
  * @apiCategory data
349
468
  */
350
- addData(data: CallableValue<GraphData>): void;
469
+ addData(data: GraphData | ((prev: GraphData) => GraphData)): void;
351
470
  /**
352
471
  * <zh/> 新增节点数据
353
472
  *
354
473
  * <en/> Add node data
355
474
  * @param data - <zh/> 节点数据 | <en/> node data
475
+ * @example
476
+ * ```ts
477
+ * graph.addNodeData([{ id: 'node-1' }, { id: 'node-2' }]);
478
+ * ```
356
479
  * @apiCategory data
357
480
  */
358
- addNodeData(data: CallableValue<NodeData[]>): void;
481
+ addNodeData(data: NodeData[] | ((prev: NodeData[]) => NodeData[])): void;
359
482
  /**
360
483
  * <zh/> 新增边数据
361
484
  *
362
485
  * <en/> Add edge data
363
486
  * @param data - <zh/> 边数据 | <en/> edge data
487
+ * @example
488
+ * ```ts
489
+ * graph.addEdgeData([{ source: 'node-1', target: 'node-2' }]);
490
+ * ```
364
491
  * @apiCategory data
365
492
  */
366
- addEdgeData(data: CallableValue<EdgeData[]>): void;
493
+ addEdgeData(data: EdgeData[] | ((prev: EdgeData[]) => EdgeData[])): void;
367
494
  /**
368
495
  * <zh/> 新增组合数据
369
496
  *
370
497
  * <en/> Add combo data
371
498
  * @param data - <zh/> 组合数据 | <en/> combo data
499
+ * @example
500
+ * ```ts
501
+ * graph.addComboData([{ id: 'combo-1' }]);
502
+ * ```
503
+ * @apiCategory data
504
+ */
505
+ addComboData(data: ComboData[] | ((prev: ComboData[]) => ComboData[])): void;
506
+ /**
507
+ * <zh/> 为树图节点添加子节点数据
508
+ *
509
+ * <en/> Add child node data to the tree node
510
+ * @param parentId - <zh/> 父节点 ID | <en/> parent node ID
511
+ * @param childrenData - <zh/> 子节点数据 | <en/> child node data
512
+ * @remarks
513
+ * <zh/> 为组合添加子节点使用 addNodeData / addComboData 方法
514
+ *
515
+ * <en/> Use addNodeData / addComboData method to add child nodes to the combo
372
516
  * @apiCategory data
373
517
  */
374
- addComboData(data: CallableValue<ComboData[]>): void;
518
+ addChildrenData(parentId: ID, childrenData: NodeData[]): void;
375
519
  /**
376
520
  * <zh/> 更新元素数据
377
521
  *
378
522
  * <en/> Update element data
379
523
  * @param data - <zh/> 元素数据 | <en/> element data
524
+ * @remarks
525
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
526
+ *
527
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
528
+ * @example
529
+ * ```ts
530
+ * graph.updateData({
531
+ * nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
532
+ * edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
533
+ * });
534
+ * ```
380
535
  * @apiCategory data
381
536
  */
382
- updateData(data: CallableValue<PartialGraphData>): void;
537
+ updateData(data: PartialGraphData | ((prev: GraphData) => PartialGraphData)): void;
383
538
  /**
384
539
  * <zh/> 更新节点数据
385
540
  *
386
541
  * <en/> Update node data
387
542
  * @param data - <zh/> 节点数据 | <en/> node data
543
+ * @remarks
544
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
545
+ *
546
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
547
+ * @example
548
+ * ```ts
549
+ * graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
550
+ * ```
388
551
  * @apiCategory data
389
552
  */
390
- updateNodeData(data: CallableValue<PartialNodeLikeData<NodeData>[]>): void;
553
+ updateNodeData(data: PartialNodeLikeData<NodeData>[] | ((prev: NodeData[]) => PartialNodeLikeData<NodeData>[])): void;
391
554
  /**
392
555
  * <zh/> 更新边数据
393
556
  *
394
557
  * <en/> Update edge data
395
558
  * @param data - <zh/> 边数据 | <en/> edge data
559
+ * @remarks
560
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
561
+ *
562
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
563
+ * @example
564
+ * ```ts
565
+ * graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
566
+ * ```
396
567
  * @apiCategory data
397
568
  */
398
- updateEdgeData(data: CallableValue<PartialEdgeData<EdgeData>[]>): void;
569
+ updateEdgeData(data: PartialEdgeData<EdgeData>[] | ((prev: EdgeData[]) => PartialEdgeData<EdgeData>[])): void;
399
570
  /**
400
571
  * <zh/> 更新组合数据
401
572
  *
402
573
  * <en/> Update combo data
403
574
  * @param data - <zh/> 组合数据 | <en/> combo data
575
+ * @remarks
576
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
577
+ *
578
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
579
+ * @example
580
+ * ```ts
581
+ * graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
582
+ * ```
404
583
  * @apiCategory data
405
584
  */
406
- updateComboData(data: CallableValue<PartialNodeLikeData<ComboData>[]>): void;
585
+ updateComboData(data: PartialNodeLikeData<ComboData>[] | ((prev: ComboData[]) => PartialNodeLikeData<ComboData>[])): void;
407
586
  /**
408
- * <zh/> 删除多条元素数据
587
+ * <zh/> 删除元素数据
409
588
  *
410
- * <en/> Remove multiple element data
589
+ * <en/> Remove element data
411
590
  * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
591
+ * @example
592
+ * ```ts
593
+ * graph.removeData({
594
+ * nodes: ['node-1', 'node-2'],
595
+ * edges: ['edge-1'],
596
+ * });
597
+ * ```
412
598
  * @apiCategory data
413
599
  */
414
600
  removeData(ids: DataID | ((data: GraphData) => DataID)): void;
415
601
  /**
416
- * <zh/> 删除多条节点数据
602
+ * <zh/> 删除节点数据
417
603
  *
418
- * <en/> Remove multiple node data
604
+ * <en/> Remove node data
419
605
  * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
606
+ * @example
607
+ * ```ts
608
+ * graph.removeNodeData(['node-1', 'node-2']);
609
+ * ```
420
610
  * @apiCategory data
421
611
  */
422
612
  removeNodeData(ids: ID[] | ((data: NodeData[]) => ID[])): void;
423
613
  /**
424
- * <zh/> 删除多条边数据
614
+ * <zh/> 删除边数据
425
615
  *
426
- * <en/> Remove multiple edge data
616
+ * <en/> Remove edge data
427
617
  * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
618
+ * @remarks
619
+ * <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
620
+ *
621
+ * <en/> If only the source and target are provided when passing in the edge data, you need to get the actual ID of the edge through the `idOf` method
622
+ * @example
623
+ * ```ts
624
+ * graph.removeEdgeData(['edge-1']);
625
+ * ```
428
626
  * @apiCategory data
429
627
  */
430
628
  removeEdgeData(ids: ID[] | ((data: EdgeData[]) => ID[])): void;
431
629
  /**
432
- * <zh/> 删除多条组合数据
630
+ * <zh/> 删除组合数据
433
631
  *
434
- * <en/> Remove multiple combo data
632
+ * <en/> Remove combo data
435
633
  * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
634
+ * @example
635
+ * ```ts
636
+ * graph.removeComboData(['combo-1']);
637
+ * ```
436
638
  * @apiCategory data
437
639
  */
438
640
  removeComboData(ids: ID[] | ((data: ComboData[]) => ID[])): void;
@@ -503,6 +705,10 @@ export declare class Graph extends EventEmitter {
503
705
  * <en/> Get node data in a specific state
504
706
  * @param state - <zh/> 状态 | <en/> state
505
707
  * @returns <zh/> 节点数据 | <en/> node data
708
+ * @example
709
+ * ```ts
710
+ * const nodes = graph.getElementDataByState('node', 'selected');
711
+ * ```
506
712
  * @apiCategory data
507
713
  */
508
714
  getElementDataByState(elementType: 'node', state: State): NodeData[];
@@ -512,6 +718,10 @@ export declare class Graph extends EventEmitter {
512
718
  * <en/> Get edge data in a specific state
513
719
  * @param state - <zh/> 状态 | <en/> state
514
720
  * @returns <zh/> 边数据 | <en/> edge data
721
+ * @example
722
+ * ```ts
723
+ * const nodes = graph.getElementDataByState('edge', 'selected');
724
+ * ```
515
725
  * @apiCategory data
516
726
  */
517
727
  getElementDataByState(elementType: 'edge', state: State): EdgeData[];
@@ -521,6 +731,10 @@ export declare class Graph extends EventEmitter {
521
731
  * <en/> Get combo data in a specific state
522
732
  * @param state - <zh/> 状态 | <en/> state
523
733
  * @returns <zh/> 组合数据 | <en/> combo data
734
+ * @example
735
+ * ```ts
736
+ * const nodes = graph.getElementDataByState('node', 'selected');
737
+ * ```
524
738
  * @apiCategory data
525
739
  */
526
740
  getElementDataByState(elementType: 'combo', state: State): ComboData[];
@@ -534,7 +748,11 @@ export declare class Graph extends EventEmitter {
534
748
  * @remarks
535
749
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
536
750
  *
751
+ * > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
752
+ *
537
753
  * <en/> This process will execute data update, element rendering, and layout execution
754
+ *
755
+ * > ⚠️ render is an asynchronous method. If you need to perform some operations after render, you can use `await graph.render()` or listen to the GraphEvent.AFTER_RENDER event
538
756
  * @apiCategory render
539
757
  */
540
758
  render(): Promise<void>;
@@ -543,7 +761,15 @@ export declare class Graph extends EventEmitter {
543
761
  *
544
762
  * <en/> Draw elements
545
763
  * @returns <zh/> 渲染结果 | <en/> draw result
546
- * @apiCategory element
764
+ * @remarks
765
+ * <zh/> 仅执行元素绘制,不会重新布局
766
+ *
767
+ * <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
768
+ *
769
+ * <en/> Only execute element drawing, no re-layout
770
+ *
771
+ * <en/> ⚠️ draw is an asynchronous method. If you need to perform some operations after draw, you can use `await graph.draw()` or listen to the GraphEvent.AFTER_DRAW event
772
+ * @apiCategory render
547
773
  */
548
774
  draw(): Promise<void>;
549
775
  /**
@@ -575,6 +801,10 @@ export declare class Graph extends EventEmitter {
575
801
  * <zh/> 销毁当前图实例
576
802
  *
577
803
  * <en/> Destroy the current graph instance
804
+ * @remarks
805
+ * <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
806
+ *
807
+ * <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
578
808
  * @apiCategory instance
579
809
  */
580
810
  destroy(): void;
@@ -607,7 +837,7 @@ export declare class Graph extends EventEmitter {
607
837
  *
608
838
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
609
839
  * @param options - <zh/> 适配配置 | <en/> fit options
610
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
840
+ * @param animation - <zh/> 动画配置 | <en/> animation options
611
841
  * @apiCategory viewport
612
842
  */
613
843
  fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void>;
@@ -615,26 +845,30 @@ export declare class Graph extends EventEmitter {
615
845
  * <zh/> 将图平移至视口中心
616
846
  *
617
847
  * <en/> Move the graph to the center of the viewport
618
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
848
+ * @param animation - <zh/> 动画配置 | <en/> animation options
619
849
  * @apiCategory viewport
620
850
  */
621
851
  fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void>;
622
852
  private autoFit;
623
853
  /**
854
+ * <zh/> 聚焦元素
855
+ *
856
+ * <en/> Focus on element
857
+ * @param id - <zh/> 元素 ID | <en/> element ID
858
+ * @param animation - <zh/> 动画配置 | <en/> animation options
859
+ * @remarks
624
860
  * <zh/> 移动图,使得元素对齐到视口中心
625
861
  *
626
862
  * <en/> Move the graph so that the element is aligned to the center of the viewport
627
- * @param id - <zh/> 元素 ID | <en/> element ID
628
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
629
863
  * @apiCategory viewport
630
864
  */
631
865
  focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void>;
632
866
  /**
633
- * <zh/> 基于当前缩放比例进行缩放
867
+ * <zh/> 基于当前缩放比例进行缩放(相对缩放)
634
868
  *
635
- * <en/> Zoom based on the current zoom ratio
869
+ * <en/> Zoom based on the current zoom ratio (relative zoom)
636
870
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
637
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
871
+ * @param animation - <zh/> 动画配置 | <en/> animation options
638
872
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
639
873
  * @remarks
640
874
  * <zh/>
@@ -648,11 +882,11 @@ export declare class Graph extends EventEmitter {
648
882
  */
649
883
  zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
650
884
  /**
651
- * <zh/> 缩放画布至指定比例
885
+ * <zh/> 缩放画布至指定比例(绝对缩放)
652
886
  *
653
- * <en/> Zoom the canvas to the specified ratio
887
+ * <en/> Zoom the canvas to the specified ratio (absolute zoom)
654
888
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
655
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
889
+ * @param animation - <zh/> 动画配置 | <en/> animation options
656
890
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
657
891
  * @remarks
658
892
  * <zh/>
@@ -676,21 +910,21 @@ export declare class Graph extends EventEmitter {
676
910
  */
677
911
  getZoom(): number;
678
912
  /**
679
- * <zh/> 基于当前旋转角度进行旋转
913
+ * <zh/> 基于当前旋转角度进行旋转(相对旋转)
680
914
  *
681
- * <en/> Rotate based on the current rotation angle
915
+ * <en/> Rotate based on the current rotation angle (relative rotation)
682
916
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
683
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
917
+ * @param animation - <zh/> 动画配置 | <en/> animation options
684
918
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
685
919
  * @apiCategory viewport
686
920
  */
687
921
  rotateBy(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
688
922
  /**
689
- * <zh/> 旋转画布至指定角度
923
+ * <zh/> 旋转画布至指定角度 (绝对旋转)
690
924
  *
691
- * <en/> Rotate the canvas to the specified angle
925
+ * <en/> Rotate the canvas to the specified angle (absolute rotation)
692
926
  * @param angle - <zh/> 目标角度 | <en/> target angle
693
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
927
+ * @param animation - <zh/> 动画配置 | <en/> animation options
694
928
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
695
929
  * @apiCategory viewport
696
930
  */
@@ -704,20 +938,20 @@ export declare class Graph extends EventEmitter {
704
938
  */
705
939
  getRotation(): number;
706
940
  /**
707
- * <zh/> 将图平移指定距离
941
+ * <zh/> 将图平移指定距离 (相对平移)
708
942
  *
709
- * <en/> Translate the graph by the specified distance
943
+ * <en/> Translate the graph by the specified distance (relative translation)
710
944
  * @param offset - <zh/> 偏移量 | <en/> offset
711
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
945
+ * @param animation - <zh/> 动画配置 | <en/> animation options
712
946
  * @apiCategory viewport
713
947
  */
714
948
  translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
715
949
  /**
716
- * <zh/> 将图平移至指定位置
950
+ * <zh/> 将图平移至指定位置 (绝对平移)
717
951
  *
718
- * <en/> Translate the graph to the specified position
952
+ * <en/> Translate the graph to the specified position (absolute translation)
719
953
  * @param position - <zh/> 指定位置 | <en/> specified position
720
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
954
+ * @param animation - <zh/> 动画配置 | <en/> animation options
721
955
  * @apiCategory viewport
722
956
  */
723
957
  translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
@@ -734,43 +968,43 @@ export declare class Graph extends EventEmitter {
734
968
  */
735
969
  getPosition(): Point;
736
970
  /**
737
- * <zh/> 将元素平移指定距离
971
+ * <zh/> 将元素平移指定距离 (相对平移)
738
972
  *
739
- * <en/> Translate the element by the specified distance
973
+ * <en/> Translate the element by the specified distance (relative translation)
740
974
  * @param id - <zh/> 元素 ID | <en/> element ID
741
975
  * @param offset - <zh/> 偏移量 | <en/> offset
742
976
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
743
977
  * @apiCategory element
744
978
  */
745
- translateElementBy(id: ID, offset: Position, animation?: boolean): Promise<void>;
979
+ translateElementBy(id: ID, offset: Point, animation?: boolean): Promise<void>;
746
980
  /**
747
- * <zh/> 批量将元素平移指定距离
981
+ * <zh/> 批量将元素平移指定距离 (相对平移)
748
982
  *
749
- * <en/> Batch translate elements by the specified distance
750
- * @param offsets - <zh/> 偏移量配置 | <en/> offset configuration
983
+ * <en/> Batch translate elements by the specified distance (relative translation)
984
+ * @param offsets - <zh/> 偏移量配置 | <en/> offset options
751
985
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
752
986
  * @apiCategory element
753
987
  */
754
- translateElementBy(offsets: Record<ID, Position>, animation?: boolean): Promise<void>;
988
+ translateElementBy(offsets: Record<ID, Point>, animation?: boolean): Promise<void>;
755
989
  /**
756
- * <zh/> 将元素平移至指定位置
990
+ * <zh/> 将元素平移至指定位置 (绝对平移)
757
991
  *
758
- * <en/> Translate the element to the specified position
992
+ * <en/> Translate the element to the specified position (absolute translation)
759
993
  * @param id - <zh/> 元素 ID | <en/> element ID
760
994
  * @param position - <zh/> 指定位置 | <en/> specified position
761
995
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
762
996
  * @apiCategory element
763
997
  */
764
- translateElementTo(id: ID, position: Position, animation?: boolean): Promise<void>;
998
+ translateElementTo(id: ID, position: Point, animation?: boolean): Promise<void>;
765
999
  /**
766
- * <zh/> 批量将元素平移至指定位置
1000
+ * <zh/> 批量将元素平移至指定位置 (绝对平移)
767
1001
  *
768
- * <en/> Batch translate elements to the specified position
769
- * @param positions - <zh/> 位置配置 | <en/> position configuration
1002
+ * <en/> Batch translate elements to the specified position (absolute translation)
1003
+ * @param positions - <zh/> 位置配置 | <en/> position options
770
1004
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
771
1005
  * @apiCategory element
772
1006
  */
773
- translateElementTo(positions: Record<ID, Position>, animation?: boolean): Promise<void>;
1007
+ translateElementTo(positions: Record<ID, Point>, animation?: boolean): Promise<void>;
774
1008
  /**
775
1009
  * <zh/> 获取元素位置
776
1010
  *
@@ -779,7 +1013,7 @@ export declare class Graph extends EventEmitter {
779
1013
  * @returns <zh/> 元素位置 | <en/> element position
780
1014
  * @apiCategory element
781
1015
  */
782
- getElementPosition(id: ID): Position;
1016
+ getElementPosition(id: ID): Point;
783
1017
  /**
784
1018
  * <zh/> 获取元素渲染样式
785
1019
  *
@@ -788,14 +1022,18 @@ export declare class Graph extends EventEmitter {
788
1022
  * @returns <zh/> 元素渲染样式 | <en/> element rendering style
789
1023
  * @apiCategory element
790
1024
  */
791
- getElementRenderStyle(id: ID): import("@antv/util/lib/lodash/types").ObjectType<unknown>;
1025
+ getElementRenderStyle(id: ID): Record<string, any>;
792
1026
  /**
793
1027
  * <zh/> 设置元素可见性
794
1028
  *
795
1029
  * <en/> Set element visibility
796
1030
  * @param id - <zh/> 元素 ID | <en/> element ID
797
1031
  * @param visibility - <zh/> 可见性 | <en/> visibility
798
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1032
+ * @param animation - <zh/> 动画配置 | <en/> animation options
1033
+ * @remarks
1034
+ * <zh/> 可见性配置包括 `visible` 和 `hidden` 两种状态
1035
+ *
1036
+ * <en/> Visibility configuration includes two states: `visible` and `hidden`
799
1037
  * @apiCategory element
800
1038
  */
801
1039
  setElementVisibility(id: ID, visibility: BaseStyleProps['visibility'], animation?: boolean): Promise<void>;
@@ -803,8 +1041,8 @@ export declare class Graph extends EventEmitter {
803
1041
  * <zh/> 批量设置元素可见性
804
1042
  *
805
1043
  * <en/> Batch set element visibility
806
- * @param visibility - <zh/> 可见性配置 | <en/> visibility configuration
807
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1044
+ * @param visibility - <zh/> 可见性配置 | <en/> visibility options
1045
+ * @param animation - <zh/> 动画配置 | <en/> animation options
808
1046
  * @apiCategory element
809
1047
  */
810
1048
  setElementVisibility(visibility: Record<ID, BaseStyleProps['visibility']>, animation?: boolean): Promise<void>;
@@ -848,7 +1086,7 @@ export declare class Graph extends EventEmitter {
848
1086
  * <zh/> 批量设置元素层级
849
1087
  *
850
1088
  * <en/> Batch set element z-index
851
- * @param zIndex - <zh/> 层级配置 | <en/> z-index configuration
1089
+ * @param zIndex - <zh/> 层级配置 | <en/> z-index options
852
1090
  * @apiCategory element
853
1091
  */
854
1092
  setElementZIndex(zIndex: Record<ID, number>): Promise<void>;
@@ -875,7 +1113,7 @@ export declare class Graph extends EventEmitter {
875
1113
  * <en/> Set element state
876
1114
  * @param id - <zh/> 元素 ID | <en/> element ID
877
1115
  * @param state - <zh/> 状态 | <en/> state
878
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1116
+ * @param animation - <zh/> 动画配置 | <en/> animation options
879
1117
  * @apiCategory element
880
1118
  */
881
1119
  setElementState(id: ID, state: State | State[], animation?: boolean): Promise<void>;
@@ -883,8 +1121,8 @@ export declare class Graph extends EventEmitter {
883
1121
  * <zh/> 批量设置元素状态
884
1122
  *
885
1123
  * <en/> Batch set element state
886
- * @param state - <zh/> 状态配置 | <en/> state configuration
887
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1124
+ * @param state - <zh/> 状态配置 | <en/> state options
1125
+ * @param animation - <zh/> 动画配置 | <en/> animation options
888
1126
  * @apiCategory element
889
1127
  */
890
1128
  setElementState(state: Record<ID, State | State[]>, animation?: boolean): Promise<void>;
@@ -908,7 +1146,7 @@ export declare class Graph extends EventEmitter {
908
1146
  getElementRenderBounds(id: ID): AABB;
909
1147
  private isCollapsingExpanding;
910
1148
  /**
911
- * <zh/> 收起 Combo
1149
+ * <zh/> 收起组合
912
1150
  *
913
1151
  * <en/> Collapse Combo
914
1152
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -917,7 +1155,7 @@ export declare class Graph extends EventEmitter {
917
1155
  */
918
1156
  collapseElement(id: ID, animation?: boolean): Promise<void>;
919
1157
  /**
920
- * <zh/> 展开 Combo
1158
+ * <zh/> 展开组合
921
1159
  *
922
1160
  * <en/> Expand Combo
923
1161
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -930,7 +1168,7 @@ export declare class Graph extends EventEmitter {
930
1168
  * <zh/> 导出画布内容为 DataURL
931
1169
  *
932
1170
  * <en/> Export canvas content as DataURL
933
- * @param options - <zh/> 导出配置 | <en/> export configuration
1171
+ * @param options - <zh/> 导出配置 | <en/> export options
934
1172
  * @returns <zh/> DataURL | <en/> DataURL
935
1173
  * @apiCategory exportImage
936
1174
  */
@@ -1008,4 +1246,31 @@ export declare class Graph extends EventEmitter {
1008
1246
  * @apiCategory event
1009
1247
  */
1010
1248
  once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this;
1249
+ /**
1250
+ * <zh/> 移除全部事件监听
1251
+ *
1252
+ * <en/> Remove all event listeners
1253
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1254
+ * @apiCategory event
1255
+ */
1256
+ off(): this;
1257
+ /**
1258
+ * <zh/> 移除指定事件的全部监听
1259
+ *
1260
+ * <en/> Remove all listeners for the specified event
1261
+ * @param eventName - <zh/> 事件名称 | <en/> event name
1262
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1263
+ * @apiCategory event
1264
+ */
1265
+ off(eventName: string): this;
1266
+ /**
1267
+ * <zh/> 移除事件监听
1268
+ *
1269
+ * <en/> Remove event listener
1270
+ * @param eventName - <zh/> 事件名称 | <en/> event name
1271
+ * @param callback - <zh/> 回调函数 | <en/> callback function
1272
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1273
+ * @apiCategory event
1274
+ */
1275
+ off(eventName: string, callback: (...args: any[]) => void): this;
1011
1276
  }