@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
@@ -7,7 +7,6 @@ import { sizeOf } from '../utils/dom';
7
7
  import { GraphLifeCycleEvent, emit } from '../utils/event';
8
8
  import { idOf } from '../utils/id';
9
9
  import { parsePoint, toPointObject } from '../utils/point';
10
- import { zIndexOf } from '../utils/style';
11
10
  import { subtract } from '../utils/vector';
12
11
  import { Animation } from './animation';
13
12
  import { BatchController } from './batch';
@@ -118,7 +117,7 @@ export class Graph extends EventEmitter {
118
117
  return this.options.background;
119
118
  }
120
119
  /**
121
- * <zh/> 获取当前图容器的大小
120
+ * <zh/> 获取当前画布容器的尺寸
122
121
  *
123
122
  * <en/> Get the size of the current canvas container
124
123
  * @returns <zh/> 画布尺寸 | <en/> canvas size
@@ -130,7 +129,7 @@ export class Graph extends EventEmitter {
130
129
  return [this.options.width || 0, this.options.height || 0];
131
130
  }
132
131
  /**
133
- * <zh/> 获取当前图容器的大小
132
+ * <zh/> 获取当前画布容器的尺寸
134
133
  *
135
134
  * <en/> Get the size of the current canvas container
136
135
  * @param width - <zh/> 画布宽度 | <en/> canvas width
@@ -142,7 +141,7 @@ export class Graph extends EventEmitter {
142
141
  this.context.canvas?.resize(width, height);
143
142
  }
144
143
  /**
145
- * <zh/> 获取当前图的缩放区间
144
+ * <zh/> 设置当前图的缩放区间
146
145
  *
147
146
  * <en/> Get the zoom range of the current graph
148
147
  * @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
@@ -165,7 +164,11 @@ export class Graph extends EventEmitter {
165
164
  * <zh/> 设置节点样式映射
166
165
  *
167
166
  * <en/> Set node mapper
168
- * @param node - <zh/> 节点配置 | <en/> node configuration
167
+ * @param node - <zh/> 节点配置 | <en/> node options
168
+ * @remarks
169
+ * <zh/> 即 `options.node` 的值
170
+ *
171
+ * <en/> The value of `options.node`
169
172
  * @apiCategory element
170
173
  */
171
174
  setNode(node) {
@@ -176,7 +179,11 @@ export class Graph extends EventEmitter {
176
179
  * <zh/> 设置边样式映射
177
180
  *
178
181
  * <en/> Set edge mapper
179
- * @param edge - <zh/> 边配置 | <en/> edge configuration
182
+ * @param edge - <zh/> 边配置 | <en/> edge options
183
+ * @remarks
184
+ * <zh/> 即 `options.edge` 的值
185
+ *
186
+ * <en/> The value of `options.edge`
180
187
  * @apiCategory element
181
188
  */
182
189
  setEdge(edge) {
@@ -187,7 +194,11 @@ export class Graph extends EventEmitter {
187
194
  * <zh/> 设置组合样式映射
188
195
  *
189
196
  * <en/> Set combo mapper
190
- * @param combo - <zh/> 组合配置 | <en/> combo configuration
197
+ * @param combo - <zh/> 组合配置 | <en/> combo options
198
+ * @remarks
199
+ * <zh/> 即 `options.combo` 的值
200
+ *
201
+ * <en/> The value of `options.combo`
191
202
  * @apiCategory element
192
203
  */
193
204
  setCombo(combo) {
@@ -198,7 +209,7 @@ export class Graph extends EventEmitter {
198
209
  * <zh/> 获取主题
199
210
  *
200
211
  * <en/> Get theme
201
- * @returns <zh/> 主题配置 | <en/> theme configuration
212
+ * @returns <zh/> 当前主题 | <en/> current theme
202
213
  * @apiCategory theme
203
214
  */
204
215
  getTheme() {
@@ -208,7 +219,11 @@ export class Graph extends EventEmitter {
208
219
  * <zh/> 设置主题
209
220
  *
210
221
  * <en/> Set theme
211
- * @param theme - <zh/> 主题配置 | <en/> theme configuration
222
+ * @param theme - <zh/> 主题名 | <en/> theme name
223
+ * @example
224
+ * ```ts
225
+ * graph.setTheme('dark');
226
+ * ```
212
227
  * @apiCategory theme
213
228
  */
214
229
  setTheme(theme) {
@@ -222,17 +237,23 @@ export class Graph extends EventEmitter {
222
237
  * <zh/> 设置布局
223
238
  *
224
239
  * <en/> Set layout
225
- * @param layout - <zh/> 布局配置 | <en/> layout configuration
240
+ * @param layout - <zh/> 布局配置 | <en/> layout options
241
+ * @example
242
+ * ```ts
243
+ * graph.setLayout({
244
+ * type: 'dagre',
245
+ * })
246
+ * ```
226
247
  * @apiCategory layout
227
248
  */
228
249
  setLayout(layout) {
229
250
  this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
230
251
  }
231
252
  /**
232
- * <zh/> 获取布局
253
+ * <zh/> 获取布局配置
233
254
  *
234
- * <en/> Get layout
235
- * @returns <zh/> 布局配置 | <en/> layout configuration
255
+ * <en/> Get layout options
256
+ * @returns <zh/> 布局配置 | <en/> layout options
236
257
  * @apiCategory layout
237
258
  */
238
259
  getLayout() {
@@ -242,7 +263,15 @@ export class Graph extends EventEmitter {
242
263
  * <zh/> 设置交互
243
264
  *
244
265
  * <en/> Set behaviors
245
- * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
266
+ * @param behaviors - <zh/> 交互配置 | <en/> behavior options
267
+ * @remarks
268
+ * <zh/> 设置的交互会全量替换原有的交互,如果需要新增交互可以使用如下方式:
269
+ *
270
+ * <en/> The set behavior will completely replace the original behavior. If you need to add behavior, you can use the following method:
271
+ *
272
+ * ```ts
273
+ * graph.setBehaviors((behaviors) => [...behaviors, { type: 'zoom-canvas' }])
274
+ * ```
246
275
  * @apiCategory behavior
247
276
  */
248
277
  setBehaviors(behaviors) {
@@ -250,10 +279,21 @@ export class Graph extends EventEmitter {
250
279
  this.context.behavior?.setBehaviors(this.options.behaviors);
251
280
  }
252
281
  /**
253
- * <zh/> 更新交互
282
+ * <zh/> 更新指定的交互配置
283
+ *
284
+ * <en/> Update specified behavior options
285
+ * @param behavior - <zh/> 交互配置 | <en/> behavior options
286
+ * @remarks
287
+ * <zh/> 如果要更新一个交互,那么必须在交互配置中指定 key 字段,例如:
254
288
  *
255
- * <en/> Update behavior
256
- * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
289
+ * <en/> If you want to update a behavior, you must specify the key field in the behavior options, for example:
290
+ * ```ts
291
+ * {
292
+ * behaviors: [{ type: 'zoom-canvas', key: 'zoom-canvas' }]
293
+ * }
294
+ *
295
+ * graph.updateBehavior({ key: 'zoom-canvas', enable: false })
296
+ * ```
257
297
  * @apiCategory behavior
258
298
  */
259
299
  updateBehavior(behavior) {
@@ -265,20 +305,27 @@ export class Graph extends EventEmitter {
265
305
  }));
266
306
  }
267
307
  /**
268
- * <zh/> 获取交互
308
+ * <zh/> 获取交互配置
269
309
  *
270
- * <en/> Get behaviors
271
- * @returns <zh/> 交互配置 | <en/> behavior configuration
310
+ * <en/> Get behaviors options
311
+ * @returns <zh/> 交互配置 | <en/> behavior options
272
312
  * @apiCategory behavior
273
313
  */
274
314
  getBehaviors() {
275
315
  return this.options.behaviors || [];
276
316
  }
277
317
  /**
278
- * <zh/> 设置插件
318
+ * <zh/> 设置插件配置
319
+ *
320
+ * <en/> Set plugins options
321
+ * @param plugins - <zh/> 插件配置 | <en/> plugin options
322
+ * @remarks
323
+ * <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
279
324
  *
280
- * <en/> Set plugins
281
- * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
325
+ * <en/> The set plugin will completely replace the original plugin configuration. If you need to add a plugin, you can use the following method:
326
+ * ```ts
327
+ * graph.setPlugins((plugins) => [...plugins, { key: 'grid-line' }])
328
+ * ```
282
329
  * @apiCategory plugin
283
330
  */
284
331
  setPlugins(plugins) {
@@ -286,10 +333,21 @@ export class Graph extends EventEmitter {
286
333
  this.context.plugin?.setPlugins(this.options.plugins);
287
334
  }
288
335
  /**
289
- * <zh/> 更新插件
336
+ * <zh/> 更新插件配置
290
337
  *
291
- * <en/> Update plugin
292
- * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
338
+ * <en/> Update plugin options
339
+ * @param plugin - <zh/> 插件配置 | <en/> plugin options
340
+ * @remarks
341
+ * <zh/> 如果要更新一个插件,那么必须在插件配置中指定 key 字段,例如:
342
+ *
343
+ * <en/> If you want to update a plugin, you must specify the key field in the plugin options, for example:
344
+ * ```ts
345
+ * {
346
+ * plugins: [{ key: 'grid-line' }]
347
+ * }
348
+ *
349
+ * graph.updatePlugin({ key: 'grid-line', follow: true })
350
+ * ```
293
351
  * @apiCategory plugin
294
352
  */
295
353
  updatePlugin(plugin) {
@@ -301,10 +359,10 @@ export class Graph extends EventEmitter {
301
359
  }));
302
360
  }
303
361
  /**
304
- * <zh/> 获取插件
362
+ * <zh/> 获取插件配置
305
363
  *
306
- * <en/> Get plugins
307
- * @returns <zh/> 插件配置 | <en/> plugin configuration
364
+ * <en/> Get plugins options
365
+ * @returns <zh/> 插件配置 | <en/> plugin options
308
366
  * @apiCategory plugin
309
367
  */
310
368
  getPlugins() {
@@ -316,6 +374,17 @@ export class Graph extends EventEmitter {
316
374
  * <en/> Get plugin instance
317
375
  * @param key - <zh/> 插件 key | <en/> plugin key
318
376
  * @returns <zh/> 插件实例 | <en/> plugin instance
377
+ * @remarks
378
+ * <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
379
+ *
380
+ * <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
381
+ * ```ts
382
+ * const fullscreen = graph.getPluginInstance('fullscreen');
383
+ *
384
+ * fullscreen.request();
385
+ *
386
+ * fullscreen.exit();
387
+ * ```
319
388
  * @apiCategory plugin
320
389
  */
321
390
  getPluginInstance(key) {
@@ -325,7 +394,11 @@ export class Graph extends EventEmitter {
325
394
  * <zh/> 设置数据转换器
326
395
  *
327
396
  * <en/> Set data transforms
328
- * @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
397
+ * @param transforms - <zh/> 数据转换配置 | <en/> data transform options
398
+ * @remarks
399
+ * <zh/> 数据转换器能够在图渲染过程中执行数据转换,目前支持在渲染前对绘制数据进行转化。
400
+ *
401
+ * <en/> Data transforms can perform data transformation during the rendering process of the graph. Currently, it supports transforming the drawing data before rendering.
329
402
  * @apiCategory transform
330
403
  */
331
404
  setTransforms(transforms) {
@@ -336,7 +409,7 @@ export class Graph extends EventEmitter {
336
409
  * <zh/> 更新数据转换器
337
410
  *
338
411
  * <en/> Update data transform
339
- * @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
412
+ * @param transform - <zh/> 数据转换器配置 | <en/> data transform options
340
413
  * @apiCategory transform
341
414
  */
342
415
  updateTransform(transform) {
@@ -349,20 +422,23 @@ export class Graph extends EventEmitter {
349
422
  this.context.model.refreshData();
350
423
  }
351
424
  /**
352
- * <zh/> 获取数据转换器
425
+ * <zh/> 获取数据转换器配置
353
426
  *
354
- * <en/> Get data transforms
355
- * @returns <zh/> 数据转换器实例 | <en/> data transform instance
427
+ * <en/> Get data transforms options
428
+ * @returns <zh/> 数据转换配置 | <en/> data transform options
356
429
  * @apiCategory transform
357
430
  */
358
431
  getTransforms() {
359
432
  return this.options.transforms || [];
360
433
  }
361
434
  /**
362
- * <zh/> 获取数据
435
+ * <zh/> 获取图数据
363
436
  *
364
- * <en/> Get data
365
- * @returns <zh/> 数据 | <en/> data
437
+ * <en/> Get graph data
438
+ * @returns <zh/> 图数据 | <en/> Graph data
439
+ * <zh/> 获取当前图的数据,包括节点、边、组合数据
440
+ *
441
+ * <en/> Get the data of the current graph, including node, edge, and combo data
366
442
  * @apiCategory data
367
443
  */
368
444
  getData() {
@@ -399,6 +475,10 @@ export class Graph extends EventEmitter {
399
475
  *
400
476
  * <en/> Set full data
401
477
  * @param data - <zh/> 数据 | <en/> data
478
+ * @remarks
479
+ * <zh/> 设置全量数据会替换当前图中的所有数据,G6 会自动进行数据差异计算
480
+ *
481
+ * <en/> Setting full data will replace all data in the current graph, and G6 will automatically calculate the data difference
402
482
  * @apiCategory data
403
483
  */
404
484
  setData(data) {
@@ -409,6 +489,13 @@ export class Graph extends EventEmitter {
409
489
  *
410
490
  * <en/> Add element data
411
491
  * @param data - <zh/> 元素数据 | <en/> element data
492
+ * @example
493
+ * ```ts
494
+ * graph.addData({
495
+ * nodes: [{ id: 'node-1' }, { id: 'node-2' }],
496
+ * edges: [{ source: 'node-1', target: 'node-2' }],
497
+ * });
498
+ * ```
412
499
  * @apiCategory data
413
500
  */
414
501
  addData(data) {
@@ -419,6 +506,10 @@ export class Graph extends EventEmitter {
419
506
  *
420
507
  * <en/> Add node data
421
508
  * @param data - <zh/> 节点数据 | <en/> node data
509
+ * @example
510
+ * ```ts
511
+ * graph.addNodeData([{ id: 'node-1' }, { id: 'node-2' }]);
512
+ * ```
422
513
  * @apiCategory data
423
514
  */
424
515
  addNodeData(data) {
@@ -429,6 +520,10 @@ export class Graph extends EventEmitter {
429
520
  *
430
521
  * <en/> Add edge data
431
522
  * @param data - <zh/> 边数据 | <en/> edge data
523
+ * @example
524
+ * ```ts
525
+ * graph.addEdgeData([{ source: 'node-1', target: 'node-2' }]);
526
+ * ```
432
527
  * @apiCategory data
433
528
  */
434
529
  addEdgeData(data) {
@@ -439,16 +534,46 @@ export class Graph extends EventEmitter {
439
534
  *
440
535
  * <en/> Add combo data
441
536
  * @param data - <zh/> 组合数据 | <en/> combo data
537
+ * @example
538
+ * ```ts
539
+ * graph.addComboData([{ id: 'combo-1' }]);
540
+ * ```
442
541
  * @apiCategory data
443
542
  */
444
543
  addComboData(data) {
445
544
  this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
446
545
  }
546
+ /**
547
+ * <zh/> 为树图节点添加子节点数据
548
+ *
549
+ * <en/> Add child node data to the tree node
550
+ * @param parentId - <zh/> 父节点 ID | <en/> parent node ID
551
+ * @param childrenData - <zh/> 子节点数据 | <en/> child node data
552
+ * @remarks
553
+ * <zh/> 为组合添加子节点使用 addNodeData / addComboData 方法
554
+ *
555
+ * <en/> Use addNodeData / addComboData method to add child nodes to the combo
556
+ * @apiCategory data
557
+ */
558
+ addChildrenData(parentId, childrenData) {
559
+ this.context.model.addChildrenData(parentId, childrenData);
560
+ }
447
561
  /**
448
562
  * <zh/> 更新元素数据
449
563
  *
450
564
  * <en/> Update element data
451
565
  * @param data - <zh/> 元素数据 | <en/> element data
566
+ * @remarks
567
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
568
+ *
569
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
570
+ * @example
571
+ * ```ts
572
+ * graph.updateData({
573
+ * nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
574
+ * edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
575
+ * });
576
+ * ```
452
577
  * @apiCategory data
453
578
  */
454
579
  updateData(data) {
@@ -459,6 +584,14 @@ export class Graph extends EventEmitter {
459
584
  *
460
585
  * <en/> Update node data
461
586
  * @param data - <zh/> 节点数据 | <en/> node data
587
+ * @remarks
588
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
589
+ *
590
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
591
+ * @example
592
+ * ```ts
593
+ * graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
594
+ * ```
462
595
  * @apiCategory data
463
596
  */
464
597
  updateNodeData(data) {
@@ -469,6 +602,14 @@ export class Graph extends EventEmitter {
469
602
  *
470
603
  * <en/> Update edge data
471
604
  * @param data - <zh/> 边数据 | <en/> edge data
605
+ * @remarks
606
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
607
+ *
608
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
609
+ * @example
610
+ * ```ts
611
+ * graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
612
+ * ```
472
613
  * @apiCategory data
473
614
  */
474
615
  updateEdgeData(data) {
@@ -479,46 +620,77 @@ export class Graph extends EventEmitter {
479
620
  *
480
621
  * <en/> Update combo data
481
622
  * @param data - <zh/> 组合数据 | <en/> combo data
623
+ * @remarks
624
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
625
+ *
626
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
627
+ * @example
628
+ * ```ts
629
+ * graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
630
+ * ```
482
631
  * @apiCategory data
483
632
  */
484
633
  updateComboData(data) {
485
634
  this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
486
635
  }
487
636
  /**
488
- * <zh/> 删除多条元素数据
637
+ * <zh/> 删除元素数据
489
638
  *
490
- * <en/> Remove multiple element data
639
+ * <en/> Remove element data
491
640
  * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
641
+ * @example
642
+ * ```ts
643
+ * graph.removeData({
644
+ * nodes: ['node-1', 'node-2'],
645
+ * edges: ['edge-1'],
646
+ * });
647
+ * ```
492
648
  * @apiCategory data
493
649
  */
494
650
  removeData(ids) {
495
651
  this.context.model.removeData(isFunction(ids) ? ids(this.getData()) : ids);
496
652
  }
497
653
  /**
498
- * <zh/> 删除多条节点数据
654
+ * <zh/> 删除节点数据
499
655
  *
500
- * <en/> Remove multiple node data
656
+ * <en/> Remove node data
501
657
  * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
658
+ * @example
659
+ * ```ts
660
+ * graph.removeNodeData(['node-1', 'node-2']);
661
+ * ```
502
662
  * @apiCategory data
503
663
  */
504
664
  removeNodeData(ids) {
505
665
  this.context.model.removeNodeData(isFunction(ids) ? ids(this.getNodeData()) : ids);
506
666
  }
507
667
  /**
508
- * <zh/> 删除多条边数据
668
+ * <zh/> 删除边数据
509
669
  *
510
- * <en/> Remove multiple edge data
670
+ * <en/> Remove edge data
511
671
  * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
672
+ * @remarks
673
+ * <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
674
+ *
675
+ * <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
676
+ * @example
677
+ * ```ts
678
+ * graph.removeEdgeData(['edge-1']);
679
+ * ```
512
680
  * @apiCategory data
513
681
  */
514
682
  removeEdgeData(ids) {
515
683
  this.context.model.removeEdgeData(isFunction(ids) ? ids(this.getEdgeData()) : ids);
516
684
  }
517
685
  /**
518
- * <zh/> 删除多条组合数据
686
+ * <zh/> 删除组合数据
519
687
  *
520
- * <en/> Remove multiple combo data
688
+ * <en/> Remove combo data
521
689
  * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
690
+ * @example
691
+ * ```ts
692
+ * graph.removeComboData(['combo-1']);
693
+ * ```
522
694
  * @apiCategory data
523
695
  */
524
696
  removeComboData(ids) {
@@ -660,7 +832,11 @@ export class Graph extends EventEmitter {
660
832
  * @remarks
661
833
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
662
834
  *
835
+ * > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
836
+ *
663
837
  * <en/> This process will execute data update, element rendering, and layout execution
838
+ *
839
+ * > ⚠️ 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
664
840
  * @apiCategory render
665
841
  */
666
842
  async render() {
@@ -676,7 +852,15 @@ export class Graph extends EventEmitter {
676
852
  *
677
853
  * <en/> Draw elements
678
854
  * @returns <zh/> 渲染结果 | <en/> draw result
679
- * @apiCategory element
855
+ * @remarks
856
+ * <zh/> 仅执行元素绘制,不会重新布局
857
+ *
858
+ * <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
859
+ *
860
+ * <en/> Only execute element drawing, no re-layout
861
+ *
862
+ * <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
863
+ * @apiCategory render
680
864
  */
681
865
  async draw() {
682
866
  await this.prepare();
@@ -719,6 +903,10 @@ export class Graph extends EventEmitter {
719
903
  * <zh/> 销毁当前图实例
720
904
  *
721
905
  * <en/> Destroy the current graph instance
906
+ * @remarks
907
+ * <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
908
+ *
909
+ * <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
722
910
  * @apiCategory instance
723
911
  */
724
912
  destroy() {
@@ -762,7 +950,7 @@ export class Graph extends EventEmitter {
762
950
  *
763
951
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
764
952
  * @param options - <zh/> 适配配置 | <en/> fit options
765
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
953
+ * @param animation - <zh/> 动画配置 | <en/> animation options
766
954
  * @apiCategory viewport
767
955
  */
768
956
  async fitView(options, animation) {
@@ -772,7 +960,7 @@ export class Graph extends EventEmitter {
772
960
  * <zh/> 将图平移至视口中心
773
961
  *
774
962
  * <en/> Move the graph to the center of the viewport
775
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
963
+ * @param animation - <zh/> 动画配置 | <en/> animation options
776
964
  * @apiCategory viewport
777
965
  */
778
966
  async fitCenter(animation) {
@@ -797,22 +985,26 @@ export class Graph extends EventEmitter {
797
985
  }
798
986
  }
799
987
  /**
988
+ * <zh/> 聚焦元素
989
+ *
990
+ * <en/> Focus on element
991
+ * @param id - <zh/> 元素 ID | <en/> element ID
992
+ * @param animation - <zh/> 动画配置 | <en/> animation options
993
+ * @remarks
800
994
  * <zh/> 移动图,使得元素对齐到视口中心
801
995
  *
802
996
  * <en/> Move the graph so that the element is aligned to the center of the viewport
803
- * @param id - <zh/> 元素 ID | <en/> element ID
804
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
805
997
  * @apiCategory viewport
806
998
  */
807
999
  async focusElement(id, animation) {
808
1000
  await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
809
1001
  }
810
1002
  /**
811
- * <zh/> 基于当前缩放比例进行缩放
1003
+ * <zh/> 基于当前缩放比例进行缩放(相对缩放)
812
1004
  *
813
- * <en/> Zoom based on the current zoom ratio
1005
+ * <en/> Zoom based on the current zoom ratio (relative zoom)
814
1006
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
815
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1007
+ * @param animation - <zh/> 动画配置 | <en/> animation options
816
1008
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
817
1009
  * @remarks
818
1010
  * <zh/>
@@ -828,11 +1020,11 @@ export class Graph extends EventEmitter {
828
1020
  await this.context.viewport.transform({ mode: 'relative', scale: ratio, origin }, animation);
829
1021
  }
830
1022
  /**
831
- * <zh/> 缩放画布至指定比例
1023
+ * <zh/> 缩放画布至指定比例(绝对缩放)
832
1024
  *
833
- * <en/> Zoom the canvas to the specified ratio
1025
+ * <en/> Zoom the canvas to the specified ratio (absolute zoom)
834
1026
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
835
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1027
+ * @param animation - <zh/> 动画配置 | <en/> animation options
836
1028
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
837
1029
  * @remarks
838
1030
  * <zh/>
@@ -860,11 +1052,11 @@ export class Graph extends EventEmitter {
860
1052
  return this.context.viewport.getZoom();
861
1053
  }
862
1054
  /**
863
- * <zh/> 基于当前旋转角度进行旋转
1055
+ * <zh/> 基于当前旋转角度进行旋转(相对旋转)
864
1056
  *
865
- * <en/> Rotate based on the current rotation angle
1057
+ * <en/> Rotate based on the current rotation angle (relative rotation)
866
1058
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
867
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1059
+ * @param animation - <zh/> 动画配置 | <en/> animation options
868
1060
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
869
1061
  * @apiCategory viewport
870
1062
  */
@@ -872,11 +1064,11 @@ export class Graph extends EventEmitter {
872
1064
  await this.context.viewport.transform({ mode: 'relative', rotate: angle, origin }, animation);
873
1065
  }
874
1066
  /**
875
- * <zh/> 旋转画布至指定角度
1067
+ * <zh/> 旋转画布至指定角度 (绝对旋转)
876
1068
  *
877
- * <en/> Rotate the canvas to the specified angle
1069
+ * <en/> Rotate the canvas to the specified angle (absolute rotation)
878
1070
  * @param angle - <zh/> 目标角度 | <en/> target angle
879
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1071
+ * @param animation - <zh/> 动画配置 | <en/> animation options
880
1072
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
881
1073
  * @apiCategory viewport
882
1074
  */
@@ -894,22 +1086,22 @@ export class Graph extends EventEmitter {
894
1086
  return this.context.viewport.getRotation();
895
1087
  }
896
1088
  /**
897
- * <zh/> 将图平移指定距离
1089
+ * <zh/> 将图平移指定距离 (相对平移)
898
1090
  *
899
- * <en/> Translate the graph by the specified distance
1091
+ * <en/> Translate the graph by the specified distance (relative translation)
900
1092
  * @param offset - <zh/> 偏移量 | <en/> offset
901
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1093
+ * @param animation - <zh/> 动画配置 | <en/> animation options
902
1094
  * @apiCategory viewport
903
1095
  */
904
1096
  async translateBy(offset, animation) {
905
1097
  await this.context.viewport.transform({ mode: 'relative', translate: offset }, animation);
906
1098
  }
907
1099
  /**
908
- * <zh/> 将图平移至指定位置
1100
+ * <zh/> 将图平移至指定位置 (绝对平移)
909
1101
  *
910
- * <en/> Translate the graph to the specified position
1102
+ * <en/> Translate the graph to the specified position (absolute translation)
911
1103
  * @param position - <zh/> 指定位置 | <en/> specified position
912
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1104
+ * @param animation - <zh/> 动画配置 | <en/> animation options
913
1105
  * @apiCategory viewport
914
1106
  */
915
1107
  async translateTo(position, animation) {
@@ -933,15 +1125,15 @@ export class Graph extends EventEmitter {
933
1125
  const [config, animation] = isObject(args1)
934
1126
  ? [args1, args2 ?? true]
935
1127
  : [{ [args1]: args2 }, args3];
936
- Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeBy(id, offset));
937
- await this.context.element.draw({ animation })?.finished;
1128
+ Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeLikeBy(id, offset));
1129
+ await this.context.element.draw({ animation, stage: 'translate' })?.finished;
938
1130
  }
939
1131
  async translateElementTo(args1, args2, args3 = true) {
940
1132
  const [config, animation] = isObject(args1)
941
1133
  ? [args1, args2 ?? true]
942
1134
  : [{ [args1]: args2 }, args3];
943
- Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
944
- await this.context.element.draw({ animation })?.finished;
1135
+ Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeLikeTo(id, position));
1136
+ await this.context.element.draw({ animation, stage: 'translate' })?.finished;
945
1137
  }
946
1138
  /**
947
1139
  * <zh/> 获取元素位置
@@ -1025,7 +1217,7 @@ export class Graph extends EventEmitter {
1025
1217
  });
1026
1218
  const { model, element } = this.context;
1027
1219
  model.preventUpdateNodeLikeHierarchy(() => model.updateData(dataToUpdate));
1028
- await element.draw({ animation: false })?.finished;
1220
+ await element.draw({ animation: false, stage: 'zIndex' })?.finished;
1029
1221
  }
1030
1222
  /**
1031
1223
  * <zh/> 将元素置于最顶层
@@ -1036,17 +1228,17 @@ export class Graph extends EventEmitter {
1036
1228
  */
1037
1229
  async frontElement(id) {
1038
1230
  const ids = Array.isArray(id) ? id : [id];
1039
- const { model } = this.context;
1231
+ const { model, element } = this.context;
1040
1232
  const config = {};
1041
1233
  ids.map((_id) => {
1042
- const zIndex = model.getFrontZIndex(_id);
1234
+ const zIndex = element.getFrontZIndex(_id);
1043
1235
  const elementType = model.getElementType(_id);
1044
1236
  if (elementType === 'combo') {
1045
1237
  const ancestor = model.getAncestorsData(_id, COMBO_KEY).at(-1) || this.getComboData(_id);
1046
- const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))].filter((datum) => model.isCombo(idOf(datum)));
1047
- const delta = zIndex - zIndexOf(ancestor);
1238
+ const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))];
1239
+ const delta = zIndex - element.getElementZIndex(_id);
1048
1240
  combos.forEach((combo) => {
1049
- config[idOf(combo)] = zIndexOf(combo) + delta;
1241
+ config[idOf(combo)] = this.getElementZIndex(idOf(combo)) + delta;
1050
1242
  });
1051
1243
  }
1052
1244
  else
@@ -1063,7 +1255,8 @@ export class Graph extends EventEmitter {
1063
1255
  * @apiCategory element
1064
1256
  */
1065
1257
  getElementZIndex(id) {
1066
- return zIndexOf(this.context.model.getElementDataById(id));
1258
+ const { model, element } = this.context;
1259
+ return model.getElementDataById(id)?.style?.zIndex ?? element.getElementZIndex(id);
1067
1260
  }
1068
1261
  async setElementState(args1, args2, args3 = true) {
1069
1262
  const [config, animation] = isObject(args1)
@@ -1106,7 +1299,7 @@ export class Graph extends EventEmitter {
1106
1299
  }
1107
1300
  isCollapsingExpanding = false;
1108
1301
  /**
1109
- * <zh/> 收起 Combo
1302
+ * <zh/> 收起组合
1110
1303
  *
1111
1304
  * <en/> Collapse Combo
1112
1305
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -1129,7 +1322,7 @@ export class Graph extends EventEmitter {
1129
1322
  this.isCollapsingExpanding = false;
1130
1323
  }
1131
1324
  /**
1132
- * <zh/> 展开 Combo
1325
+ * <zh/> 展开组合
1133
1326
  *
1134
1327
  * <en/> Expand Combo
1135
1328
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -1162,7 +1355,7 @@ export class Graph extends EventEmitter {
1162
1355
  * <zh/> 导出画布内容为 DataURL
1163
1356
  *
1164
1357
  * <en/> Export canvas content as DataURL
1165
- * @param options - <zh/> 导出配置 | <en/> export configuration
1358
+ * @param options - <zh/> 导出配置 | <en/> export options
1166
1359
  * @returns <zh/> DataURL | <en/> DataURL
1167
1360
  * @apiCategory exportImage
1168
1361
  */
@@ -1262,5 +1455,8 @@ export class Graph extends EventEmitter {
1262
1455
  once(eventName, callback) {
1263
1456
  return super.once(eventName, callback);
1264
1457
  }
1458
+ off(eventName, callback) {
1459
+ return super.off(eventName, callback);
1460
+ }
1265
1461
  }
1266
1462
  //# sourceMappingURL=graph.js.map