@antv/g6 5.0.1 → 5.0.2

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 (281) 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/elements/base-element.d.ts +1 -22
  4. package/dist/lib/elements/combos/base-combo.d.ts +4 -4
  5. package/dist/lib/elements/edges/base-edge.d.ts +4 -2
  6. package/dist/lib/elements/effect.d.ts +17 -0
  7. package/dist/lib/elements/nodes/base-node.d.ts +5 -4
  8. package/dist/lib/elements/nodes/diamond.d.ts +0 -1
  9. package/dist/lib/elements/shapes/badge.d.ts +17 -6
  10. package/dist/lib/elements/shapes/base-shape.d.ts +9 -3
  11. package/dist/lib/elements/shapes/icon.d.ts +15 -3
  12. package/dist/lib/elements/shapes/label.d.ts +18 -7
  13. package/dist/lib/exports.d.ts +3 -2
  14. package/dist/lib/index.d.ts +5 -1
  15. package/dist/lib/layouts/base-layout.d.ts +3 -1
  16. package/dist/lib/plugins/bubble-sets.d.ts +2 -2
  17. package/dist/lib/plugins/hull/index.d.ts +2 -2
  18. package/dist/lib/runtime/canvas.d.ts +15 -2
  19. package/dist/lib/runtime/data.d.ts +7 -16
  20. package/dist/lib/runtime/element.d.ts +18 -2
  21. package/dist/lib/runtime/graph.d.ts +372 -108
  22. package/dist/lib/spec/element/edge.d.ts +1 -1
  23. package/dist/lib/spec/element/node.d.ts +1 -1
  24. package/dist/lib/transforms/process-parallel-edges.d.ts +2 -2
  25. package/dist/lib/types/callable.d.ts +0 -11
  26. package/dist/lib/types/data.d.ts +12 -0
  27. package/dist/lib/types/edge.d.ts +11 -0
  28. package/dist/lib/types/element.d.ts +100 -9
  29. package/dist/lib/types/index.d.ts +0 -1
  30. package/dist/lib/types/point.d.ts +0 -1
  31. package/dist/lib/utils/element.d.ts +2 -2
  32. package/dist/lib/utils/layout.d.ts +2 -2
  33. package/dist/lib/utils/path.d.ts +3 -3
  34. package/dist/lib/utils/position.d.ts +8 -8
  35. package/dist/lib/utils/style.d.ts +13 -8
  36. package/esm/behaviors/click-select.d.ts +4 -5
  37. package/esm/behaviors/click-select.js +59 -50
  38. package/esm/behaviors/click-select.js.map +1 -1
  39. package/esm/behaviors/lasso-select.js.map +1 -1
  40. package/esm/elements/base-element.d.ts +1 -22
  41. package/esm/elements/base-element.js +0 -21
  42. package/esm/elements/base-element.js.map +1 -1
  43. package/esm/elements/combos/base-combo.d.ts +4 -4
  44. package/esm/elements/combos/base-combo.js +27 -4
  45. package/esm/elements/combos/base-combo.js.map +1 -1
  46. package/esm/elements/edges/base-edge.d.ts +4 -2
  47. package/esm/elements/edges/base-edge.js +41 -7
  48. package/esm/elements/edges/base-edge.js.map +1 -1
  49. package/esm/elements/effect.d.ts +17 -0
  50. package/esm/elements/effect.js +70 -0
  51. package/esm/elements/effect.js.map +1 -0
  52. package/esm/elements/nodes/base-node.d.ts +5 -4
  53. package/esm/elements/nodes/base-node.js +33 -14
  54. package/esm/elements/nodes/base-node.js.map +1 -1
  55. package/esm/elements/nodes/circle.js +1 -1
  56. package/esm/elements/nodes/circle.js.map +1 -1
  57. package/esm/elements/nodes/diamond.d.ts +0 -1
  58. package/esm/elements/nodes/diamond.js +0 -6
  59. package/esm/elements/nodes/diamond.js.map +1 -1
  60. package/esm/elements/nodes/ellipse.js +1 -1
  61. package/esm/elements/nodes/ellipse.js.map +1 -1
  62. package/esm/elements/nodes/image.js +2 -2
  63. package/esm/elements/nodes/image.js.map +1 -1
  64. package/esm/elements/nodes/rect.js +1 -1
  65. package/esm/elements/nodes/rect.js.map +1 -1
  66. package/esm/elements/shapes/badge.d.ts +17 -6
  67. package/esm/elements/shapes/badge.js +9 -0
  68. package/esm/elements/shapes/badge.js.map +1 -1
  69. package/esm/elements/shapes/base-shape.d.ts +9 -3
  70. package/esm/elements/shapes/base-shape.js +33 -15
  71. package/esm/elements/shapes/base-shape.js.map +1 -1
  72. package/esm/elements/shapes/icon.d.ts +15 -3
  73. package/esm/elements/shapes/icon.js +12 -4
  74. package/esm/elements/shapes/icon.js.map +1 -1
  75. package/esm/elements/shapes/label.d.ts +18 -7
  76. package/esm/elements/shapes/label.js +10 -0
  77. package/esm/elements/shapes/label.js.map +1 -1
  78. package/esm/elements/shapes/polygon.js +1 -1
  79. package/esm/elements/shapes/polygon.js.map +1 -1
  80. package/esm/exports.d.ts +3 -2
  81. package/esm/exports.js +1 -1
  82. package/esm/exports.js.map +1 -1
  83. package/esm/index.d.ts +5 -1
  84. package/esm/index.js +5 -1
  85. package/esm/index.js.map +1 -1
  86. package/esm/layouts/base-layout.d.ts +3 -1
  87. package/esm/layouts/base-layout.js +3 -1
  88. package/esm/layouts/base-layout.js.map +1 -1
  89. package/esm/plugins/bubble-sets.d.ts +2 -2
  90. package/esm/plugins/bubble-sets.js.map +1 -1
  91. package/esm/plugins/hull/index.d.ts +2 -2
  92. package/esm/plugins/hull/index.js.map +1 -1
  93. package/esm/runtime/canvas.d.ts +15 -2
  94. package/esm/runtime/canvas.js.map +1 -1
  95. package/esm/runtime/data.d.ts +7 -16
  96. package/esm/runtime/data.js +14 -34
  97. package/esm/runtime/data.js.map +1 -1
  98. package/esm/runtime/element.d.ts +18 -2
  99. package/esm/runtime/element.js +68 -20
  100. package/esm/runtime/element.js.map +1 -1
  101. package/esm/runtime/graph.d.ts +372 -108
  102. package/esm/runtime/graph.js +271 -76
  103. package/esm/runtime/graph.js.map +1 -1
  104. package/esm/runtime/layout.js +1 -1
  105. package/esm/runtime/layout.js.map +1 -1
  106. package/esm/spec/element/edge.d.ts +1 -1
  107. package/esm/spec/element/node.d.ts +1 -1
  108. package/esm/themes/base.js +2 -0
  109. package/esm/themes/base.js.map +1 -1
  110. package/esm/transforms/collapse-expand-node.js +14 -4
  111. package/esm/transforms/collapse-expand-node.js.map +1 -1
  112. package/esm/transforms/process-parallel-edges.d.ts +2 -2
  113. package/esm/types/callable.d.ts +0 -11
  114. package/esm/types/data.d.ts +12 -0
  115. package/esm/types/edge.d.ts +11 -0
  116. package/esm/types/element.d.ts +100 -9
  117. package/esm/types/index.d.ts +0 -1
  118. package/esm/types/point.d.ts +0 -1
  119. package/esm/utils/element.d.ts +2 -2
  120. package/esm/utils/element.js.map +1 -1
  121. package/esm/utils/layout.d.ts +2 -2
  122. package/esm/utils/layout.js +4 -4
  123. package/esm/utils/layout.js.map +1 -1
  124. package/esm/utils/path.d.ts +3 -3
  125. package/esm/utils/path.js +1 -1
  126. package/esm/utils/path.js.map +1 -1
  127. package/esm/utils/position.d.ts +8 -8
  128. package/esm/utils/position.js +2 -2
  129. package/esm/utils/position.js.map +1 -1
  130. package/esm/utils/style.d.ts +13 -8
  131. package/esm/utils/style.js +16 -11
  132. package/esm/utils/style.js.map +1 -1
  133. package/lib/behaviors/click-select.d.ts +4 -5
  134. package/lib/behaviors/click-select.js +59 -50
  135. package/lib/behaviors/click-select.js.map +1 -1
  136. package/lib/behaviors/lasso-select.js.map +1 -1
  137. package/lib/elements/base-element.d.ts +1 -22
  138. package/lib/elements/base-element.js +0 -21
  139. package/lib/elements/base-element.js.map +1 -1
  140. package/lib/elements/combos/base-combo.d.ts +4 -4
  141. package/lib/elements/combos/base-combo.js +27 -4
  142. package/lib/elements/combos/base-combo.js.map +1 -1
  143. package/lib/elements/edges/base-edge.d.ts +4 -2
  144. package/lib/elements/edges/base-edge.js +41 -7
  145. package/lib/elements/edges/base-edge.js.map +1 -1
  146. package/lib/elements/effect.d.ts +17 -0
  147. package/lib/elements/effect.js +74 -0
  148. package/lib/elements/effect.js.map +1 -0
  149. package/lib/elements/nodes/base-node.d.ts +5 -4
  150. package/lib/elements/nodes/base-node.js +33 -14
  151. package/lib/elements/nodes/base-node.js.map +1 -1
  152. package/lib/elements/nodes/circle.js +1 -1
  153. package/lib/elements/nodes/circle.js.map +1 -1
  154. package/lib/elements/nodes/diamond.d.ts +0 -1
  155. package/lib/elements/nodes/diamond.js +0 -6
  156. package/lib/elements/nodes/diamond.js.map +1 -1
  157. package/lib/elements/nodes/ellipse.js +1 -1
  158. package/lib/elements/nodes/ellipse.js.map +1 -1
  159. package/lib/elements/nodes/image.js +2 -2
  160. package/lib/elements/nodes/image.js.map +1 -1
  161. package/lib/elements/nodes/rect.js +1 -1
  162. package/lib/elements/nodes/rect.js.map +1 -1
  163. package/lib/elements/shapes/badge.d.ts +17 -6
  164. package/lib/elements/shapes/badge.js +9 -0
  165. package/lib/elements/shapes/badge.js.map +1 -1
  166. package/lib/elements/shapes/base-shape.d.ts +9 -3
  167. package/lib/elements/shapes/base-shape.js +33 -15
  168. package/lib/elements/shapes/base-shape.js.map +1 -1
  169. package/lib/elements/shapes/icon.d.ts +15 -3
  170. package/lib/elements/shapes/icon.js +12 -4
  171. package/lib/elements/shapes/icon.js.map +1 -1
  172. package/lib/elements/shapes/label.d.ts +18 -7
  173. package/lib/elements/shapes/label.js +10 -0
  174. package/lib/elements/shapes/label.js.map +1 -1
  175. package/lib/elements/shapes/polygon.js +1 -1
  176. package/lib/elements/shapes/polygon.js.map +1 -1
  177. package/lib/exports.d.ts +3 -2
  178. package/lib/exports.js +5 -2
  179. package/lib/exports.js.map +1 -1
  180. package/lib/index.d.ts +5 -1
  181. package/lib/index.js +6 -2
  182. package/lib/index.js.map +1 -1
  183. package/lib/layouts/base-layout.d.ts +3 -1
  184. package/lib/layouts/base-layout.js +3 -1
  185. package/lib/layouts/base-layout.js.map +1 -1
  186. package/lib/plugins/bubble-sets.d.ts +2 -2
  187. package/lib/plugins/bubble-sets.js.map +1 -1
  188. package/lib/plugins/hull/index.d.ts +2 -2
  189. package/lib/plugins/hull/index.js.map +1 -1
  190. package/lib/runtime/canvas.d.ts +15 -2
  191. package/lib/runtime/canvas.js.map +1 -1
  192. package/lib/runtime/data.d.ts +7 -16
  193. package/lib/runtime/data.js +14 -34
  194. package/lib/runtime/data.js.map +1 -1
  195. package/lib/runtime/element.d.ts +18 -2
  196. package/lib/runtime/element.js +68 -20
  197. package/lib/runtime/element.js.map +1 -1
  198. package/lib/runtime/graph.d.ts +372 -108
  199. package/lib/runtime/graph.js +271 -76
  200. package/lib/runtime/graph.js.map +1 -1
  201. package/lib/runtime/layout.js +1 -1
  202. package/lib/runtime/layout.js.map +1 -1
  203. package/lib/spec/element/edge.d.ts +1 -1
  204. package/lib/spec/element/node.d.ts +1 -1
  205. package/lib/themes/base.js +2 -0
  206. package/lib/themes/base.js.map +1 -1
  207. package/lib/transforms/collapse-expand-node.js +14 -4
  208. package/lib/transforms/collapse-expand-node.js.map +1 -1
  209. package/lib/transforms/process-parallel-edges.d.ts +2 -2
  210. package/lib/types/callable.d.ts +0 -11
  211. package/lib/types/data.d.ts +12 -0
  212. package/lib/types/edge.d.ts +11 -0
  213. package/lib/types/element.d.ts +100 -9
  214. package/lib/types/index.d.ts +0 -1
  215. package/lib/types/point.d.ts +0 -1
  216. package/lib/utils/element.d.ts +2 -2
  217. package/lib/utils/element.js.map +1 -1
  218. package/lib/utils/layout.d.ts +2 -2
  219. package/lib/utils/layout.js +4 -4
  220. package/lib/utils/layout.js.map +1 -1
  221. package/lib/utils/path.d.ts +3 -3
  222. package/lib/utils/path.js +1 -1
  223. package/lib/utils/path.js.map +1 -1
  224. package/lib/utils/position.d.ts +8 -8
  225. package/lib/utils/position.js +2 -2
  226. package/lib/utils/position.js.map +1 -1
  227. package/lib/utils/style.d.ts +13 -8
  228. package/lib/utils/style.js +18 -13
  229. package/lib/utils/style.js.map +1 -1
  230. package/package.json +9 -9
  231. package/src/behaviors/click-select.ts +59 -60
  232. package/src/behaviors/lasso-select.ts +2 -2
  233. package/src/elements/base-element.ts +1 -25
  234. package/src/elements/combos/base-combo.ts +27 -11
  235. package/src/elements/edges/base-edge.ts +28 -8
  236. package/src/elements/effect.ts +74 -0
  237. package/src/elements/nodes/base-node.ts +23 -18
  238. package/src/elements/nodes/circle.ts +1 -1
  239. package/src/elements/nodes/diamond.ts +0 -7
  240. package/src/elements/nodes/ellipse.ts +1 -1
  241. package/src/elements/nodes/image.ts +2 -2
  242. package/src/elements/nodes/rect.ts +1 -1
  243. package/src/elements/shapes/badge.ts +17 -5
  244. package/src/elements/shapes/base-shape.ts +35 -15
  245. package/src/elements/shapes/icon.ts +18 -7
  246. package/src/elements/shapes/label.ts +19 -6
  247. package/src/elements/shapes/polygon.ts +1 -1
  248. package/src/exports.ts +6 -2
  249. package/src/index.ts +6 -2
  250. package/src/layouts/base-layout.ts +5 -1
  251. package/src/plugins/bubble-sets.ts +2 -2
  252. package/src/plugins/hull/index.ts +2 -2
  253. package/src/runtime/canvas.ts +15 -10
  254. package/src/runtime/data.ts +22 -44
  255. package/src/runtime/element.ts +80 -26
  256. package/src/runtime/graph.ts +398 -126
  257. package/src/runtime/layout.ts +2 -2
  258. package/src/spec/element/edge.ts +1 -1
  259. package/src/spec/element/node.ts +1 -1
  260. package/src/themes/base.ts +2 -0
  261. package/src/transforms/collapse-expand-node.ts +13 -4
  262. package/src/transforms/process-parallel-edges.ts +2 -2
  263. package/src/types/callable.ts +0 -12
  264. package/src/types/data.ts +13 -0
  265. package/src/types/edge.ts +11 -0
  266. package/src/types/element.ts +106 -10
  267. package/src/types/index.ts +0 -1
  268. package/src/types/point.ts +0 -1
  269. package/src/utils/element.ts +3 -13
  270. package/src/utils/layout.ts +6 -6
  271. package/src/utils/path.ts +3 -3
  272. package/src/utils/position.ts +8 -8
  273. package/src/utils/style.ts +19 -12
  274. package/dist/lib/types/position.d.ts +0 -2
  275. package/esm/types/position.d.ts +0 -2
  276. package/esm/types/position.js +0 -2
  277. package/esm/types/position.js.map +0 -1
  278. package/lib/types/position.d.ts +0 -2
  279. package/lib/types/position.js +0 -3
  280. package/lib/types/position.js.map +0 -1
  281. 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
@@ -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/> 更新指定的交互配置
190
+ *
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
+ * }
161
201
  *
162
- * <en/> Update behavior
163
- * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
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/> 设置插件配置
177
217
  *
178
- * <en/> Set plugins
179
- * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
218
+ * <en/> Set plugins options
219
+ * @param plugins - <zh/> 插件配置 | <en/> plugin options
220
+ * @remarks
221
+ * <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
222
+ *
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/> 更新插件配置
232
+ *
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
+ * }
185
243
  *
186
- * <en/> Update plugin
187
- * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
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/> 获取图数据
234
307
  *
235
- * <en/> Get data
236
- * @returns <zh/> 数据 | <en/> data
308
+ * <en/> Get graph data
309
+ * @returns <zh/> 图数据 | <en/> Graph data
310
+ * <zh/> 获取当前图的数据,包括节点、边、组合数据
311
+ *
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,195 @@ 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
+ * ```
372
503
  * @apiCategory data
373
504
  */
374
- addComboData(data: CallableValue<ComboData[]>): void;
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
516
+ */
517
+ addChildrenData(parentId: ID, childrenData: NodeData[]): void;
375
518
  /**
376
519
  * <zh/> 更新元素数据
377
520
  *
378
521
  * <en/> Update element data
379
522
  * @param data - <zh/> 元素数据 | <en/> element data
523
+ * @remarks
524
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
525
+ *
526
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
527
+ * @example
528
+ * ```ts
529
+ * graph.updateData({
530
+ * nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
531
+ * edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
532
+ * });
533
+ * ```
380
534
  * @apiCategory data
381
535
  */
382
- updateData(data: CallableValue<PartialGraphData>): void;
536
+ updateData(data: PartialGraphData | ((prev: GraphData) => PartialGraphData)): void;
383
537
  /**
384
538
  * <zh/> 更新节点数据
385
539
  *
386
540
  * <en/> Update node data
387
541
  * @param data - <zh/> 节点数据 | <en/> node data
542
+ * @remarks
543
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
544
+ *
545
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
546
+ * @example
547
+ * ```ts
548
+ * graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
549
+ * ```
388
550
  * @apiCategory data
389
551
  */
390
- updateNodeData(data: CallableValue<PartialNodeLikeData<NodeData>[]>): void;
552
+ updateNodeData(data: PartialNodeLikeData<NodeData>[] | ((prev: NodeData[]) => PartialNodeLikeData<NodeData>[])): void;
391
553
  /**
392
554
  * <zh/> 更新边数据
393
555
  *
394
556
  * <en/> Update edge data
395
557
  * @param data - <zh/> 边数据 | <en/> edge data
558
+ * @remarks
559
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
560
+ *
561
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
562
+ * @example
563
+ * ```ts
564
+ * graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
565
+ * ```
396
566
  * @apiCategory data
397
567
  */
398
- updateEdgeData(data: CallableValue<PartialEdgeData<EdgeData>[]>): void;
568
+ updateEdgeData(data: PartialEdgeData<EdgeData>[] | ((prev: EdgeData[]) => PartialEdgeData<EdgeData>[])): void;
399
569
  /**
400
570
  * <zh/> 更新组合数据
401
571
  *
402
572
  * <en/> Update combo data
403
573
  * @param data - <zh/> 组合数据 | <en/> combo data
574
+ * @remarks
575
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
576
+ *
577
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
578
+ * @example
579
+ * ```ts
580
+ * graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
581
+ * ```
404
582
  * @apiCategory data
405
583
  */
406
- updateComboData(data: CallableValue<PartialNodeLikeData<ComboData>[]>): void;
584
+ updateComboData(data: PartialNodeLikeData<ComboData>[] | ((prev: ComboData[]) => PartialNodeLikeData<ComboData>[])): void;
407
585
  /**
408
- * <zh/> 删除多条元素数据
586
+ * <zh/> 删除元素数据
409
587
  *
410
- * <en/> Remove multiple element data
588
+ * <en/> Remove element data
411
589
  * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
590
+ * @example
591
+ * ```ts
592
+ * graph.removeData({
593
+ * nodes: ['node-1', 'node-2'],
594
+ * edges: ['edge-1'],
595
+ * });
596
+ * ```
412
597
  * @apiCategory data
413
598
  */
414
599
  removeData(ids: DataID | ((data: GraphData) => DataID)): void;
415
600
  /**
416
- * <zh/> 删除多条节点数据
601
+ * <zh/> 删除节点数据
417
602
  *
418
- * <en/> Remove multiple node data
603
+ * <en/> Remove node data
419
604
  * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
605
+ * @example
606
+ * ```ts
607
+ * graph.removeNodeData(['node-1', 'node-2']);
608
+ * ```
420
609
  * @apiCategory data
421
610
  */
422
611
  removeNodeData(ids: ID[] | ((data: NodeData[]) => ID[])): void;
423
612
  /**
424
- * <zh/> 删除多条边数据
613
+ * <zh/> 删除边数据
425
614
  *
426
- * <en/> Remove multiple edge data
615
+ * <en/> Remove edge data
427
616
  * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
617
+ * @remarks
618
+ * <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
619
+ *
620
+ * <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
621
+ * @example
622
+ * ```ts
623
+ * graph.removeEdgeData(['edge-1']);
624
+ * ```
428
625
  * @apiCategory data
429
626
  */
430
627
  removeEdgeData(ids: ID[] | ((data: EdgeData[]) => ID[])): void;
431
628
  /**
432
- * <zh/> 删除多条组合数据
629
+ * <zh/> 删除组合数据
433
630
  *
434
- * <en/> Remove multiple combo data
631
+ * <en/> Remove combo data
435
632
  * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
633
+ * @example
634
+ * ```ts
635
+ * graph.removeComboData(['combo-1']);
636
+ * ```
436
637
  * @apiCategory data
437
638
  */
438
639
  removeComboData(ids: ID[] | ((data: ComboData[]) => ID[])): void;
@@ -503,6 +704,10 @@ export declare class Graph extends EventEmitter {
503
704
  * <en/> Get node data in a specific state
504
705
  * @param state - <zh/> 状态 | <en/> state
505
706
  * @returns <zh/> 节点数据 | <en/> node data
707
+ * @example
708
+ * ```ts
709
+ * const nodes = graph.getElementDataByState('node', 'selected');
710
+ * ```
506
711
  * @apiCategory data
507
712
  */
508
713
  getElementDataByState(elementType: 'node', state: State): NodeData[];
@@ -512,6 +717,10 @@ export declare class Graph extends EventEmitter {
512
717
  * <en/> Get edge data in a specific state
513
718
  * @param state - <zh/> 状态 | <en/> state
514
719
  * @returns <zh/> 边数据 | <en/> edge data
720
+ * @example
721
+ * ```ts
722
+ * const nodes = graph.getElementDataByState('edge', 'selected');
723
+ * ```
515
724
  * @apiCategory data
516
725
  */
517
726
  getElementDataByState(elementType: 'edge', state: State): EdgeData[];
@@ -521,6 +730,10 @@ export declare class Graph extends EventEmitter {
521
730
  * <en/> Get combo data in a specific state
522
731
  * @param state - <zh/> 状态 | <en/> state
523
732
  * @returns <zh/> 组合数据 | <en/> combo data
733
+ * @example
734
+ * ```ts
735
+ * const nodes = graph.getElementDataByState('node', 'selected');
736
+ * ```
524
737
  * @apiCategory data
525
738
  */
526
739
  getElementDataByState(elementType: 'combo', state: State): ComboData[];
@@ -534,7 +747,11 @@ export declare class Graph extends EventEmitter {
534
747
  * @remarks
535
748
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
536
749
  *
750
+ * > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
751
+ *
537
752
  * <en/> This process will execute data update, element rendering, and layout execution
753
+ *
754
+ * > ⚠️ 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
755
  * @apiCategory render
539
756
  */
540
757
  render(): Promise<void>;
@@ -543,7 +760,15 @@ export declare class Graph extends EventEmitter {
543
760
  *
544
761
  * <en/> Draw elements
545
762
  * @returns <zh/> 渲染结果 | <en/> draw result
546
- * @apiCategory element
763
+ * @remarks
764
+ * <zh/> 仅执行元素绘制,不会重新布局
765
+ *
766
+ * <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
767
+ *
768
+ * <en/> Only execute element drawing, no re-layout
769
+ *
770
+ * <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
771
+ * @apiCategory render
547
772
  */
548
773
  draw(): Promise<void>;
549
774
  /**
@@ -575,6 +800,10 @@ export declare class Graph extends EventEmitter {
575
800
  * <zh/> 销毁当前图实例
576
801
  *
577
802
  * <en/> Destroy the current graph instance
803
+ * @remarks
804
+ * <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
805
+ *
806
+ * <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
578
807
  * @apiCategory instance
579
808
  */
580
809
  destroy(): void;
@@ -607,7 +836,7 @@ export declare class Graph extends EventEmitter {
607
836
  *
608
837
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
609
838
  * @param options - <zh/> 适配配置 | <en/> fit options
610
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
839
+ * @param animation - <zh/> 动画配置 | <en/> animation options
611
840
  * @apiCategory viewport
612
841
  */
613
842
  fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void>;
@@ -615,26 +844,30 @@ export declare class Graph extends EventEmitter {
615
844
  * <zh/> 将图平移至视口中心
616
845
  *
617
846
  * <en/> Move the graph to the center of the viewport
618
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
847
+ * @param animation - <zh/> 动画配置 | <en/> animation options
619
848
  * @apiCategory viewport
620
849
  */
621
850
  fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void>;
622
851
  private autoFit;
623
852
  /**
853
+ * <zh/> 聚焦元素
854
+ *
855
+ * <en/> Focus on element
856
+ * @param id - <zh/> 元素 ID | <en/> element ID
857
+ * @param animation - <zh/> 动画配置 | <en/> animation options
858
+ * @remarks
624
859
  * <zh/> 移动图,使得元素对齐到视口中心
625
860
  *
626
861
  * <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
862
  * @apiCategory viewport
630
863
  */
631
864
  focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void>;
632
865
  /**
633
- * <zh/> 基于当前缩放比例进行缩放
866
+ * <zh/> 基于当前缩放比例进行缩放(相对缩放)
634
867
  *
635
- * <en/> Zoom based on the current zoom ratio
868
+ * <en/> Zoom based on the current zoom ratio (relative zoom)
636
869
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
637
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
870
+ * @param animation - <zh/> 动画配置 | <en/> animation options
638
871
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
639
872
  * @remarks
640
873
  * <zh/>
@@ -648,11 +881,11 @@ export declare class Graph extends EventEmitter {
648
881
  */
649
882
  zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
650
883
  /**
651
- * <zh/> 缩放画布至指定比例
884
+ * <zh/> 缩放画布至指定比例(绝对缩放)
652
885
  *
653
- * <en/> Zoom the canvas to the specified ratio
886
+ * <en/> Zoom the canvas to the specified ratio (absolute zoom)
654
887
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
655
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
888
+ * @param animation - <zh/> 动画配置 | <en/> animation options
656
889
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
657
890
  * @remarks
658
891
  * <zh/>
@@ -676,21 +909,21 @@ export declare class Graph extends EventEmitter {
676
909
  */
677
910
  getZoom(): number;
678
911
  /**
679
- * <zh/> 基于当前旋转角度进行旋转
912
+ * <zh/> 基于当前旋转角度进行旋转(相对旋转)
680
913
  *
681
- * <en/> Rotate based on the current rotation angle
914
+ * <en/> Rotate based on the current rotation angle (relative rotation)
682
915
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
683
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
916
+ * @param animation - <zh/> 动画配置 | <en/> animation options
684
917
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
685
918
  * @apiCategory viewport
686
919
  */
687
920
  rotateBy(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
688
921
  /**
689
- * <zh/> 旋转画布至指定角度
922
+ * <zh/> 旋转画布至指定角度 (绝对旋转)
690
923
  *
691
- * <en/> Rotate the canvas to the specified angle
924
+ * <en/> Rotate the canvas to the specified angle (absolute rotation)
692
925
  * @param angle - <zh/> 目标角度 | <en/> target angle
693
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
926
+ * @param animation - <zh/> 动画配置 | <en/> animation options
694
927
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
695
928
  * @apiCategory viewport
696
929
  */
@@ -704,20 +937,20 @@ export declare class Graph extends EventEmitter {
704
937
  */
705
938
  getRotation(): number;
706
939
  /**
707
- * <zh/> 将图平移指定距离
940
+ * <zh/> 将图平移指定距离 (相对平移)
708
941
  *
709
- * <en/> Translate the graph by the specified distance
942
+ * <en/> Translate the graph by the specified distance (relative translation)
710
943
  * @param offset - <zh/> 偏移量 | <en/> offset
711
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
944
+ * @param animation - <zh/> 动画配置 | <en/> animation options
712
945
  * @apiCategory viewport
713
946
  */
714
947
  translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
715
948
  /**
716
- * <zh/> 将图平移至指定位置
949
+ * <zh/> 将图平移至指定位置 (绝对平移)
717
950
  *
718
- * <en/> Translate the graph to the specified position
951
+ * <en/> Translate the graph to the specified position (absolute translation)
719
952
  * @param position - <zh/> 指定位置 | <en/> specified position
720
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
953
+ * @param animation - <zh/> 动画配置 | <en/> animation options
721
954
  * @apiCategory viewport
722
955
  */
723
956
  translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
@@ -734,43 +967,43 @@ export declare class Graph extends EventEmitter {
734
967
  */
735
968
  getPosition(): Point;
736
969
  /**
737
- * <zh/> 将元素平移指定距离
970
+ * <zh/> 将元素平移指定距离 (相对平移)
738
971
  *
739
- * <en/> Translate the element by the specified distance
972
+ * <en/> Translate the element by the specified distance (relative translation)
740
973
  * @param id - <zh/> 元素 ID | <en/> element ID
741
974
  * @param offset - <zh/> 偏移量 | <en/> offset
742
975
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
743
976
  * @apiCategory element
744
977
  */
745
- translateElementBy(id: ID, offset: Position, animation?: boolean): Promise<void>;
978
+ translateElementBy(id: ID, offset: Point, animation?: boolean): Promise<void>;
746
979
  /**
747
- * <zh/> 批量将元素平移指定距离
980
+ * <zh/> 批量将元素平移指定距离 (相对平移)
748
981
  *
749
- * <en/> Batch translate elements by the specified distance
750
- * @param offsets - <zh/> 偏移量配置 | <en/> offset configuration
982
+ * <en/> Batch translate elements by the specified distance (relative translation)
983
+ * @param offsets - <zh/> 偏移量配置 | <en/> offset options
751
984
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
752
985
  * @apiCategory element
753
986
  */
754
- translateElementBy(offsets: Record<ID, Position>, animation?: boolean): Promise<void>;
987
+ translateElementBy(offsets: Record<ID, Point>, animation?: boolean): Promise<void>;
755
988
  /**
756
- * <zh/> 将元素平移至指定位置
989
+ * <zh/> 将元素平移至指定位置 (绝对平移)
757
990
  *
758
- * <en/> Translate the element to the specified position
991
+ * <en/> Translate the element to the specified position (absolute translation)
759
992
  * @param id - <zh/> 元素 ID | <en/> element ID
760
993
  * @param position - <zh/> 指定位置 | <en/> specified position
761
994
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
762
995
  * @apiCategory element
763
996
  */
764
- translateElementTo(id: ID, position: Position, animation?: boolean): Promise<void>;
997
+ translateElementTo(id: ID, position: Point, animation?: boolean): Promise<void>;
765
998
  /**
766
- * <zh/> 批量将元素平移至指定位置
999
+ * <zh/> 批量将元素平移至指定位置 (绝对平移)
767
1000
  *
768
- * <en/> Batch translate elements to the specified position
769
- * @param positions - <zh/> 位置配置 | <en/> position configuration
1001
+ * <en/> Batch translate elements to the specified position (absolute translation)
1002
+ * @param positions - <zh/> 位置配置 | <en/> position options
770
1003
  * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
771
1004
  * @apiCategory element
772
1005
  */
773
- translateElementTo(positions: Record<ID, Position>, animation?: boolean): Promise<void>;
1006
+ translateElementTo(positions: Record<ID, Point>, animation?: boolean): Promise<void>;
774
1007
  /**
775
1008
  * <zh/> 获取元素位置
776
1009
  *
@@ -779,7 +1012,7 @@ export declare class Graph extends EventEmitter {
779
1012
  * @returns <zh/> 元素位置 | <en/> element position
780
1013
  * @apiCategory element
781
1014
  */
782
- getElementPosition(id: ID): Position;
1015
+ getElementPosition(id: ID): Point;
783
1016
  /**
784
1017
  * <zh/> 获取元素渲染样式
785
1018
  *
@@ -788,14 +1021,18 @@ export declare class Graph extends EventEmitter {
788
1021
  * @returns <zh/> 元素渲染样式 | <en/> element rendering style
789
1022
  * @apiCategory element
790
1023
  */
791
- getElementRenderStyle(id: ID): import("@antv/util/lib/lodash/types").ObjectType<unknown>;
1024
+ getElementRenderStyle(id: ID): Record<string, any>;
792
1025
  /**
793
1026
  * <zh/> 设置元素可见性
794
1027
  *
795
1028
  * <en/> Set element visibility
796
1029
  * @param id - <zh/> 元素 ID | <en/> element ID
797
1030
  * @param visibility - <zh/> 可见性 | <en/> visibility
798
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1031
+ * @param animation - <zh/> 动画配置 | <en/> animation options
1032
+ * @remarks
1033
+ * <zh/> 可见性配置包括 `visible` 和 `hidden` 两种状态
1034
+ *
1035
+ * <en/> Visibility configuration includes two states: `visible` and `hidden`
799
1036
  * @apiCategory element
800
1037
  */
801
1038
  setElementVisibility(id: ID, visibility: BaseStyleProps['visibility'], animation?: boolean): Promise<void>;
@@ -803,8 +1040,8 @@ export declare class Graph extends EventEmitter {
803
1040
  * <zh/> 批量设置元素可见性
804
1041
  *
805
1042
  * <en/> Batch set element visibility
806
- * @param visibility - <zh/> 可见性配置 | <en/> visibility configuration
807
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1043
+ * @param visibility - <zh/> 可见性配置 | <en/> visibility options
1044
+ * @param animation - <zh/> 动画配置 | <en/> animation options
808
1045
  * @apiCategory element
809
1046
  */
810
1047
  setElementVisibility(visibility: Record<ID, BaseStyleProps['visibility']>, animation?: boolean): Promise<void>;
@@ -848,7 +1085,7 @@ export declare class Graph extends EventEmitter {
848
1085
  * <zh/> 批量设置元素层级
849
1086
  *
850
1087
  * <en/> Batch set element z-index
851
- * @param zIndex - <zh/> 层级配置 | <en/> z-index configuration
1088
+ * @param zIndex - <zh/> 层级配置 | <en/> z-index options
852
1089
  * @apiCategory element
853
1090
  */
854
1091
  setElementZIndex(zIndex: Record<ID, number>): Promise<void>;
@@ -875,7 +1112,7 @@ export declare class Graph extends EventEmitter {
875
1112
  * <en/> Set element state
876
1113
  * @param id - <zh/> 元素 ID | <en/> element ID
877
1114
  * @param state - <zh/> 状态 | <en/> state
878
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1115
+ * @param animation - <zh/> 动画配置 | <en/> animation options
879
1116
  * @apiCategory element
880
1117
  */
881
1118
  setElementState(id: ID, state: State | State[], animation?: boolean): Promise<void>;
@@ -883,8 +1120,8 @@ export declare class Graph extends EventEmitter {
883
1120
  * <zh/> 批量设置元素状态
884
1121
  *
885
1122
  * <en/> Batch set element state
886
- * @param state - <zh/> 状态配置 | <en/> state configuration
887
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1123
+ * @param state - <zh/> 状态配置 | <en/> state options
1124
+ * @param animation - <zh/> 动画配置 | <en/> animation options
888
1125
  * @apiCategory element
889
1126
  */
890
1127
  setElementState(state: Record<ID, State | State[]>, animation?: boolean): Promise<void>;
@@ -908,7 +1145,7 @@ export declare class Graph extends EventEmitter {
908
1145
  getElementRenderBounds(id: ID): AABB;
909
1146
  private isCollapsingExpanding;
910
1147
  /**
911
- * <zh/> 收起 Combo
1148
+ * <zh/> 收起组合
912
1149
  *
913
1150
  * <en/> Collapse Combo
914
1151
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -917,7 +1154,7 @@ export declare class Graph extends EventEmitter {
917
1154
  */
918
1155
  collapseElement(id: ID, animation?: boolean): Promise<void>;
919
1156
  /**
920
- * <zh/> 展开 Combo
1157
+ * <zh/> 展开组合
921
1158
  *
922
1159
  * <en/> Expand Combo
923
1160
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -930,7 +1167,7 @@ export declare class Graph extends EventEmitter {
930
1167
  * <zh/> 导出画布内容为 DataURL
931
1168
  *
932
1169
  * <en/> Export canvas content as DataURL
933
- * @param options - <zh/> 导出配置 | <en/> export configuration
1170
+ * @param options - <zh/> 导出配置 | <en/> export options
934
1171
  * @returns <zh/> DataURL | <en/> DataURL
935
1172
  * @apiCategory exportImage
936
1173
  */
@@ -1008,4 +1245,31 @@ export declare class Graph extends EventEmitter {
1008
1245
  * @apiCategory event
1009
1246
  */
1010
1247
  once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this;
1248
+ /**
1249
+ * <zh/> 移除全部事件监听
1250
+ *
1251
+ * <en/> Remove all event listeners
1252
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1253
+ * @apiCategory event
1254
+ */
1255
+ off(): this;
1256
+ /**
1257
+ * <zh/> 移除指定事件的全部监听
1258
+ *
1259
+ * <en/> Remove all listeners for the specified event
1260
+ * @param eventName - <zh/> 事件名称 | <en/> event name
1261
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1262
+ * @apiCategory event
1263
+ */
1264
+ off(eventName: string): this;
1265
+ /**
1266
+ * <zh/> 移除事件监听
1267
+ *
1268
+ * <en/> Remove event listener
1269
+ * @param eventName - <zh/> 事件名称 | <en/> event name
1270
+ * @param callback - <zh/> 回调函数 | <en/> callback function
1271
+ * @returns <zh/> Graph 实例 | <en/> Graph instance
1272
+ * @apiCategory event
1273
+ */
1274
+ off(eventName: string, callback: (...args: any[]) => void): this;
1011
1275
  }