@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
@@ -13,7 +13,6 @@ const dom_1 = require("../utils/dom");
13
13
  const event_1 = require("../utils/event");
14
14
  const id_1 = require("../utils/id");
15
15
  const point_1 = require("../utils/point");
16
- const style_1 = require("../utils/style");
17
16
  const vector_1 = require("../utils/vector");
18
17
  const animation_1 = require("./animation");
19
18
  const batch_1 = require("./batch");
@@ -124,7 +123,7 @@ class Graph extends event_emitter_1.default {
124
123
  return this.options.background;
125
124
  }
126
125
  /**
127
- * <zh/> 获取当前图容器的大小
126
+ * <zh/> 获取当前画布容器的尺寸
128
127
  *
129
128
  * <en/> Get the size of the current canvas container
130
129
  * @returns <zh/> 画布尺寸 | <en/> canvas size
@@ -136,7 +135,7 @@ class Graph extends event_emitter_1.default {
136
135
  return [this.options.width || 0, this.options.height || 0];
137
136
  }
138
137
  /**
139
- * <zh/> 获取当前图容器的大小
138
+ * <zh/> 获取当前画布容器的尺寸
140
139
  *
141
140
  * <en/> Get the size of the current canvas container
142
141
  * @param width - <zh/> 画布宽度 | <en/> canvas width
@@ -148,7 +147,7 @@ class Graph extends event_emitter_1.default {
148
147
  this.context.canvas?.resize(width, height);
149
148
  }
150
149
  /**
151
- * <zh/> 获取当前图的缩放区间
150
+ * <zh/> 设置当前图的缩放区间
152
151
  *
153
152
  * <en/> Get the zoom range of the current graph
154
153
  * @param zoomRange - <zh/> 缩放区间 | <en/> zoom range
@@ -171,7 +170,11 @@ class Graph extends event_emitter_1.default {
171
170
  * <zh/> 设置节点样式映射
172
171
  *
173
172
  * <en/> Set node mapper
174
- * @param node - <zh/> 节点配置 | <en/> node configuration
173
+ * @param node - <zh/> 节点配置 | <en/> node options
174
+ * @remarks
175
+ * <zh/> 即 `options.node` 的值
176
+ *
177
+ * <en/> The value of `options.node`
175
178
  * @apiCategory element
176
179
  */
177
180
  setNode(node) {
@@ -182,7 +185,11 @@ class Graph extends event_emitter_1.default {
182
185
  * <zh/> 设置边样式映射
183
186
  *
184
187
  * <en/> Set edge mapper
185
- * @param edge - <zh/> 边配置 | <en/> edge configuration
188
+ * @param edge - <zh/> 边配置 | <en/> edge options
189
+ * @remarks
190
+ * <zh/> 即 `options.edge` 的值
191
+ *
192
+ * <en/> The value of `options.edge`
186
193
  * @apiCategory element
187
194
  */
188
195
  setEdge(edge) {
@@ -193,7 +200,11 @@ class Graph extends event_emitter_1.default {
193
200
  * <zh/> 设置组合样式映射
194
201
  *
195
202
  * <en/> Set combo mapper
196
- * @param combo - <zh/> 组合配置 | <en/> combo configuration
203
+ * @param combo - <zh/> 组合配置 | <en/> combo options
204
+ * @remarks
205
+ * <zh/> 即 `options.combo` 的值
206
+ *
207
+ * <en/> The value of `options.combo`
197
208
  * @apiCategory element
198
209
  */
199
210
  setCombo(combo) {
@@ -204,7 +215,7 @@ class Graph extends event_emitter_1.default {
204
215
  * <zh/> 获取主题
205
216
  *
206
217
  * <en/> Get theme
207
- * @returns <zh/> 主题配置 | <en/> theme configuration
218
+ * @returns <zh/> 当前主题 | <en/> current theme
208
219
  * @apiCategory theme
209
220
  */
210
221
  getTheme() {
@@ -214,7 +225,11 @@ class Graph extends event_emitter_1.default {
214
225
  * <zh/> 设置主题
215
226
  *
216
227
  * <en/> Set theme
217
- * @param theme - <zh/> 主题配置 | <en/> theme configuration
228
+ * @param theme - <zh/> 主题名 | <en/> theme name
229
+ * @example
230
+ * ```ts
231
+ * graph.setTheme('dark');
232
+ * ```
218
233
  * @apiCategory theme
219
234
  */
220
235
  setTheme(theme) {
@@ -228,17 +243,23 @@ class Graph extends event_emitter_1.default {
228
243
  * <zh/> 设置布局
229
244
  *
230
245
  * <en/> Set layout
231
- * @param layout - <zh/> 布局配置 | <en/> layout configuration
246
+ * @param layout - <zh/> 布局配置 | <en/> layout options
247
+ * @example
248
+ * ```ts
249
+ * graph.setLayout({
250
+ * type: 'dagre',
251
+ * })
252
+ * ```
232
253
  * @apiCategory layout
233
254
  */
234
255
  setLayout(layout) {
235
256
  this.options.layout = (0, util_1.isFunction)(layout) ? layout(this.getLayout()) : layout;
236
257
  }
237
258
  /**
238
- * <zh/> 获取布局
259
+ * <zh/> 获取布局配置
239
260
  *
240
- * <en/> Get layout
241
- * @returns <zh/> 布局配置 | <en/> layout configuration
261
+ * <en/> Get layout options
262
+ * @returns <zh/> 布局配置 | <en/> layout options
242
263
  * @apiCategory layout
243
264
  */
244
265
  getLayout() {
@@ -248,7 +269,15 @@ class Graph extends event_emitter_1.default {
248
269
  * <zh/> 设置交互
249
270
  *
250
271
  * <en/> Set behaviors
251
- * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
272
+ * @param behaviors - <zh/> 交互配置 | <en/> behavior options
273
+ * @remarks
274
+ * <zh/> 设置的交互会全量替换原有的交互,如果需要新增交互可以使用如下方式:
275
+ *
276
+ * <en/> The set behavior will completely replace the original behavior. If you need to add behavior, you can use the following method:
277
+ *
278
+ * ```ts
279
+ * graph.setBehaviors((behaviors) => [...behaviors, { type: 'zoom-canvas' }])
280
+ * ```
252
281
  * @apiCategory behavior
253
282
  */
254
283
  setBehaviors(behaviors) {
@@ -256,10 +285,21 @@ class Graph extends event_emitter_1.default {
256
285
  this.context.behavior?.setBehaviors(this.options.behaviors);
257
286
  }
258
287
  /**
259
- * <zh/> 更新交互
288
+ * <zh/> 更新指定的交互配置
289
+ *
290
+ * <en/> Update specified behavior options
291
+ * @param behavior - <zh/> 交互配置 | <en/> behavior options
292
+ * @remarks
293
+ * <zh/> 如果要更新一个交互,那么必须在交互配置中指定 key 字段,例如:
260
294
  *
261
- * <en/> Update behavior
262
- * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
295
+ * <en/> If you want to update a behavior, you must specify the key field in the behavior options, for example:
296
+ * ```ts
297
+ * {
298
+ * behaviors: [{ type: 'zoom-canvas', key: 'zoom-canvas' }]
299
+ * }
300
+ *
301
+ * graph.updateBehavior({ key: 'zoom-canvas', enable: false })
302
+ * ```
263
303
  * @apiCategory behavior
264
304
  */
265
305
  updateBehavior(behavior) {
@@ -271,20 +311,27 @@ class Graph extends event_emitter_1.default {
271
311
  }));
272
312
  }
273
313
  /**
274
- * <zh/> 获取交互
314
+ * <zh/> 获取交互配置
275
315
  *
276
- * <en/> Get behaviors
277
- * @returns <zh/> 交互配置 | <en/> behavior configuration
316
+ * <en/> Get behaviors options
317
+ * @returns <zh/> 交互配置 | <en/> behavior options
278
318
  * @apiCategory behavior
279
319
  */
280
320
  getBehaviors() {
281
321
  return this.options.behaviors || [];
282
322
  }
283
323
  /**
284
- * <zh/> 设置插件
324
+ * <zh/> 设置插件配置
325
+ *
326
+ * <en/> Set plugins options
327
+ * @param plugins - <zh/> 插件配置 | <en/> plugin options
328
+ * @remarks
329
+ * <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
285
330
  *
286
- * <en/> Set plugins
287
- * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
331
+ * <en/> The set plugin will completely replace the original plugin configuration. If you need to add a plugin, you can use the following method:
332
+ * ```ts
333
+ * graph.setPlugins((plugins) => [...plugins, { key: 'grid-line' }])
334
+ * ```
288
335
  * @apiCategory plugin
289
336
  */
290
337
  setPlugins(plugins) {
@@ -292,10 +339,21 @@ class Graph extends event_emitter_1.default {
292
339
  this.context.plugin?.setPlugins(this.options.plugins);
293
340
  }
294
341
  /**
295
- * <zh/> 更新插件
342
+ * <zh/> 更新插件配置
296
343
  *
297
- * <en/> Update plugin
298
- * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
344
+ * <en/> Update plugin options
345
+ * @param plugin - <zh/> 插件配置 | <en/> plugin options
346
+ * @remarks
347
+ * <zh/> 如果要更新一个插件,那么必须在插件配置中指定 key 字段,例如:
348
+ *
349
+ * <en/> If you want to update a plugin, you must specify the key field in the plugin options, for example:
350
+ * ```ts
351
+ * {
352
+ * plugins: [{ key: 'grid-line' }]
353
+ * }
354
+ *
355
+ * graph.updatePlugin({ key: 'grid-line', follow: true })
356
+ * ```
299
357
  * @apiCategory plugin
300
358
  */
301
359
  updatePlugin(plugin) {
@@ -307,10 +365,10 @@ class Graph extends event_emitter_1.default {
307
365
  }));
308
366
  }
309
367
  /**
310
- * <zh/> 获取插件
368
+ * <zh/> 获取插件配置
311
369
  *
312
- * <en/> Get plugins
313
- * @returns <zh/> 插件配置 | <en/> plugin configuration
370
+ * <en/> Get plugins options
371
+ * @returns <zh/> 插件配置 | <en/> plugin options
314
372
  * @apiCategory plugin
315
373
  */
316
374
  getPlugins() {
@@ -322,6 +380,17 @@ class Graph extends event_emitter_1.default {
322
380
  * <en/> Get plugin instance
323
381
  * @param key - <zh/> 插件 key | <en/> plugin key
324
382
  * @returns <zh/> 插件实例 | <en/> plugin instance
383
+ * @remarks
384
+ * <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
385
+ *
386
+ * <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
387
+ * ```ts
388
+ * const fullscreen = graph.getPluginInstance('fullscreen');
389
+ *
390
+ * fullscreen.request();
391
+ *
392
+ * fullscreen.exit();
393
+ * ```
325
394
  * @apiCategory plugin
326
395
  */
327
396
  getPluginInstance(key) {
@@ -331,7 +400,11 @@ class Graph extends event_emitter_1.default {
331
400
  * <zh/> 设置数据转换器
332
401
  *
333
402
  * <en/> Set data transforms
334
- * @param transforms - <zh/> 数据转换配置 | <en/> data transform configuration
403
+ * @param transforms - <zh/> 数据转换配置 | <en/> data transform options
404
+ * @remarks
405
+ * <zh/> 数据转换器能够在图渲染过程中执行数据转换,目前支持在渲染前对绘制数据进行转化。
406
+ *
407
+ * <en/> Data transforms can perform data transformation during the rendering process of the graph. Currently, it supports transforming the drawing data before rendering.
335
408
  * @apiCategory transform
336
409
  */
337
410
  setTransforms(transforms) {
@@ -342,7 +415,7 @@ class Graph extends event_emitter_1.default {
342
415
  * <zh/> 更新数据转换器
343
416
  *
344
417
  * <en/> Update data transform
345
- * @param transform - <zh/> 数据转换配置 | <en/> data transform configuration
418
+ * @param transform - <zh/> 数据转换器配置 | <en/> data transform options
346
419
  * @apiCategory transform
347
420
  */
348
421
  updateTransform(transform) {
@@ -355,20 +428,23 @@ class Graph extends event_emitter_1.default {
355
428
  this.context.model.refreshData();
356
429
  }
357
430
  /**
358
- * <zh/> 获取数据转换器
431
+ * <zh/> 获取数据转换器配置
359
432
  *
360
- * <en/> Get data transforms
361
- * @returns <zh/> 数据转换器实例 | <en/> data transform instance
433
+ * <en/> Get data transforms options
434
+ * @returns <zh/> 数据转换配置 | <en/> data transform options
362
435
  * @apiCategory transform
363
436
  */
364
437
  getTransforms() {
365
438
  return this.options.transforms || [];
366
439
  }
367
440
  /**
368
- * <zh/> 获取数据
441
+ * <zh/> 获取图数据
369
442
  *
370
- * <en/> Get data
371
- * @returns <zh/> 数据 | <en/> data
443
+ * <en/> Get graph data
444
+ * @returns <zh/> 图数据 | <en/> Graph data
445
+ * <zh/> 获取当前图的数据,包括节点、边、组合数据
446
+ *
447
+ * <en/> Get the data of the current graph, including node, edge, and combo data
372
448
  * @apiCategory data
373
449
  */
374
450
  getData() {
@@ -405,6 +481,10 @@ class Graph extends event_emitter_1.default {
405
481
  *
406
482
  * <en/> Set full data
407
483
  * @param data - <zh/> 数据 | <en/> data
484
+ * @remarks
485
+ * <zh/> 设置全量数据会替换当前图中的所有数据,G6 会自动进行数据差异计算
486
+ *
487
+ * <en/> Setting full data will replace all data in the current graph, and G6 will automatically calculate the data difference
408
488
  * @apiCategory data
409
489
  */
410
490
  setData(data) {
@@ -415,6 +495,13 @@ class Graph extends event_emitter_1.default {
415
495
  *
416
496
  * <en/> Add element data
417
497
  * @param data - <zh/> 元素数据 | <en/> element data
498
+ * @example
499
+ * ```ts
500
+ * graph.addData({
501
+ * nodes: [{ id: 'node-1' }, { id: 'node-2' }],
502
+ * edges: [{ source: 'node-1', target: 'node-2' }],
503
+ * });
504
+ * ```
418
505
  * @apiCategory data
419
506
  */
420
507
  addData(data) {
@@ -425,6 +512,10 @@ class Graph extends event_emitter_1.default {
425
512
  *
426
513
  * <en/> Add node data
427
514
  * @param data - <zh/> 节点数据 | <en/> node data
515
+ * @example
516
+ * ```ts
517
+ * graph.addNodeData([{ id: 'node-1' }, { id: 'node-2' }]);
518
+ * ```
428
519
  * @apiCategory data
429
520
  */
430
521
  addNodeData(data) {
@@ -435,6 +526,10 @@ class Graph extends event_emitter_1.default {
435
526
  *
436
527
  * <en/> Add edge data
437
528
  * @param data - <zh/> 边数据 | <en/> edge data
529
+ * @example
530
+ * ```ts
531
+ * graph.addEdgeData([{ source: 'node-1', target: 'node-2' }]);
532
+ * ```
438
533
  * @apiCategory data
439
534
  */
440
535
  addEdgeData(data) {
@@ -445,16 +540,46 @@ class Graph extends event_emitter_1.default {
445
540
  *
446
541
  * <en/> Add combo data
447
542
  * @param data - <zh/> 组合数据 | <en/> combo data
543
+ * @example
544
+ * ```ts
545
+ * graph.addComboData([{ id: 'combo-1' }]);
546
+ * ```
448
547
  * @apiCategory data
449
548
  */
450
549
  addComboData(data) {
451
550
  this.context.model.addComboData((0, util_1.isFunction)(data) ? data(this.getComboData()) : data);
452
551
  }
552
+ /**
553
+ * <zh/> 为树图节点添加子节点数据
554
+ *
555
+ * <en/> Add child node data to the tree node
556
+ * @param parentId - <zh/> 父节点 ID | <en/> parent node ID
557
+ * @param childrenData - <zh/> 子节点数据 | <en/> child node data
558
+ * @remarks
559
+ * <zh/> 为组合添加子节点使用 addNodeData / addComboData 方法
560
+ *
561
+ * <en/> Use addNodeData / addComboData method to add child nodes to the combo
562
+ * @apiCategory data
563
+ */
564
+ addChildrenData(parentId, childrenData) {
565
+ this.context.model.addChildrenData(parentId, childrenData);
566
+ }
453
567
  /**
454
568
  * <zh/> 更新元素数据
455
569
  *
456
570
  * <en/> Update element data
457
571
  * @param data - <zh/> 元素数据 | <en/> element data
572
+ * @remarks
573
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
574
+ *
575
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
576
+ * @example
577
+ * ```ts
578
+ * graph.updateData({
579
+ * nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
580
+ * edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
581
+ * });
582
+ * ```
458
583
  * @apiCategory data
459
584
  */
460
585
  updateData(data) {
@@ -465,6 +590,14 @@ class Graph extends event_emitter_1.default {
465
590
  *
466
591
  * <en/> Update node data
467
592
  * @param data - <zh/> 节点数据 | <en/> node data
593
+ * @remarks
594
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
595
+ *
596
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
597
+ * @example
598
+ * ```ts
599
+ * graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
600
+ * ```
468
601
  * @apiCategory data
469
602
  */
470
603
  updateNodeData(data) {
@@ -475,6 +608,14 @@ class Graph extends event_emitter_1.default {
475
608
  *
476
609
  * <en/> Update edge data
477
610
  * @param data - <zh/> 边数据 | <en/> edge data
611
+ * @remarks
612
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
613
+ *
614
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
615
+ * @example
616
+ * ```ts
617
+ * graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
618
+ * ```
478
619
  * @apiCategory data
479
620
  */
480
621
  updateEdgeData(data) {
@@ -485,46 +626,77 @@ class Graph extends event_emitter_1.default {
485
626
  *
486
627
  * <en/> Update combo data
487
628
  * @param data - <zh/> 组合数据 | <en/> combo data
629
+ * @remarks
630
+ * <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
631
+ *
632
+ * <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
633
+ * @example
634
+ * ```ts
635
+ * graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
636
+ * ```
488
637
  * @apiCategory data
489
638
  */
490
639
  updateComboData(data) {
491
640
  this.context.model.updateComboData((0, util_1.isFunction)(data) ? data(this.getComboData()) : data);
492
641
  }
493
642
  /**
494
- * <zh/> 删除多条元素数据
643
+ * <zh/> 删除元素数据
495
644
  *
496
- * <en/> Remove multiple element data
645
+ * <en/> Remove element data
497
646
  * @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
647
+ * @example
648
+ * ```ts
649
+ * graph.removeData({
650
+ * nodes: ['node-1', 'node-2'],
651
+ * edges: ['edge-1'],
652
+ * });
653
+ * ```
498
654
  * @apiCategory data
499
655
  */
500
656
  removeData(ids) {
501
657
  this.context.model.removeData((0, util_1.isFunction)(ids) ? ids(this.getData()) : ids);
502
658
  }
503
659
  /**
504
- * <zh/> 删除多条节点数据
660
+ * <zh/> 删除节点数据
505
661
  *
506
- * <en/> Remove multiple node data
662
+ * <en/> Remove node data
507
663
  * @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
664
+ * @example
665
+ * ```ts
666
+ * graph.removeNodeData(['node-1', 'node-2']);
667
+ * ```
508
668
  * @apiCategory data
509
669
  */
510
670
  removeNodeData(ids) {
511
671
  this.context.model.removeNodeData((0, util_1.isFunction)(ids) ? ids(this.getNodeData()) : ids);
512
672
  }
513
673
  /**
514
- * <zh/> 删除多条边数据
674
+ * <zh/> 删除边数据
515
675
  *
516
- * <en/> Remove multiple edge data
676
+ * <en/> Remove edge data
517
677
  * @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
678
+ * @remarks
679
+ * <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
680
+ *
681
+ * <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
682
+ * @example
683
+ * ```ts
684
+ * graph.removeEdgeData(['edge-1']);
685
+ * ```
518
686
  * @apiCategory data
519
687
  */
520
688
  removeEdgeData(ids) {
521
689
  this.context.model.removeEdgeData((0, util_1.isFunction)(ids) ? ids(this.getEdgeData()) : ids);
522
690
  }
523
691
  /**
524
- * <zh/> 删除多条组合数据
692
+ * <zh/> 删除组合数据
525
693
  *
526
- * <en/> Remove multiple combo data
694
+ * <en/> Remove combo data
527
695
  * @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
696
+ * @example
697
+ * ```ts
698
+ * graph.removeComboData(['combo-1']);
699
+ * ```
528
700
  * @apiCategory data
529
701
  */
530
702
  removeComboData(ids) {
@@ -666,7 +838,11 @@ class Graph extends event_emitter_1.default {
666
838
  * @remarks
667
839
  * <zh/> 此过程会执行数据更新、绘制元素、执行布局
668
840
  *
841
+ * > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
842
+ *
669
843
  * <en/> This process will execute data update, element rendering, and layout execution
844
+ *
845
+ * > ⚠️ 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
670
846
  * @apiCategory render
671
847
  */
672
848
  async render() {
@@ -682,7 +858,15 @@ class Graph extends event_emitter_1.default {
682
858
  *
683
859
  * <en/> Draw elements
684
860
  * @returns <zh/> 渲染结果 | <en/> draw result
685
- * @apiCategory element
861
+ * @remarks
862
+ * <zh/> 仅执行元素绘制,不会重新布局
863
+ *
864
+ * <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
865
+ *
866
+ * <en/> Only execute element drawing, no re-layout
867
+ *
868
+ * <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
869
+ * @apiCategory render
686
870
  */
687
871
  async draw() {
688
872
  await this.prepare();
@@ -725,6 +909,10 @@ class Graph extends event_emitter_1.default {
725
909
  * <zh/> 销毁当前图实例
726
910
  *
727
911
  * <en/> Destroy the current graph instance
912
+ * @remarks
913
+ * <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
914
+ *
915
+ * <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
728
916
  * @apiCategory instance
729
917
  */
730
918
  destroy() {
@@ -768,7 +956,7 @@ class Graph extends event_emitter_1.default {
768
956
  *
769
957
  * <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
770
958
  * @param options - <zh/> 适配配置 | <en/> fit options
771
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
959
+ * @param animation - <zh/> 动画配置 | <en/> animation options
772
960
  * @apiCategory viewport
773
961
  */
774
962
  async fitView(options, animation) {
@@ -778,7 +966,7 @@ class Graph extends event_emitter_1.default {
778
966
  * <zh/> 将图平移至视口中心
779
967
  *
780
968
  * <en/> Move the graph to the center of the viewport
781
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
969
+ * @param animation - <zh/> 动画配置 | <en/> animation options
782
970
  * @apiCategory viewport
783
971
  */
784
972
  async fitCenter(animation) {
@@ -803,22 +991,26 @@ class Graph extends event_emitter_1.default {
803
991
  }
804
992
  }
805
993
  /**
994
+ * <zh/> 聚焦元素
995
+ *
996
+ * <en/> Focus on element
997
+ * @param id - <zh/> 元素 ID | <en/> element ID
998
+ * @param animation - <zh/> 动画配置 | <en/> animation options
999
+ * @remarks
806
1000
  * <zh/> 移动图,使得元素对齐到视口中心
807
1001
  *
808
1002
  * <en/> Move the graph so that the element is aligned to the center of the viewport
809
- * @param id - <zh/> 元素 ID | <en/> element ID
810
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
811
1003
  * @apiCategory viewport
812
1004
  */
813
1005
  async focusElement(id, animation) {
814
1006
  await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
815
1007
  }
816
1008
  /**
817
- * <zh/> 基于当前缩放比例进行缩放
1009
+ * <zh/> 基于当前缩放比例进行缩放(相对缩放)
818
1010
  *
819
- * <en/> Zoom based on the current zoom ratio
1011
+ * <en/> Zoom based on the current zoom ratio (relative zoom)
820
1012
  * @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
821
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1013
+ * @param animation - <zh/> 动画配置 | <en/> animation options
822
1014
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
823
1015
  * @remarks
824
1016
  * <zh/>
@@ -834,11 +1026,11 @@ class Graph extends event_emitter_1.default {
834
1026
  await this.context.viewport.transform({ mode: 'relative', scale: ratio, origin }, animation);
835
1027
  }
836
1028
  /**
837
- * <zh/> 缩放画布至指定比例
1029
+ * <zh/> 缩放画布至指定比例(绝对缩放)
838
1030
  *
839
- * <en/> Zoom the canvas to the specified ratio
1031
+ * <en/> Zoom the canvas to the specified ratio (absolute zoom)
840
1032
  * @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
841
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1033
+ * @param animation - <zh/> 动画配置 | <en/> animation options
842
1034
  * @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
843
1035
  * @remarks
844
1036
  * <zh/>
@@ -866,11 +1058,11 @@ class Graph extends event_emitter_1.default {
866
1058
  return this.context.viewport.getZoom();
867
1059
  }
868
1060
  /**
869
- * <zh/> 基于当前旋转角度进行旋转
1061
+ * <zh/> 基于当前旋转角度进行旋转(相对旋转)
870
1062
  *
871
- * <en/> Rotate based on the current rotation angle
1063
+ * <en/> Rotate based on the current rotation angle (relative rotation)
872
1064
  * @param angle - <zh/> 旋转角度 | <en/> rotation angle
873
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1065
+ * @param animation - <zh/> 动画配置 | <en/> animation options
874
1066
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
875
1067
  * @apiCategory viewport
876
1068
  */
@@ -878,11 +1070,11 @@ class Graph extends event_emitter_1.default {
878
1070
  await this.context.viewport.transform({ mode: 'relative', rotate: angle, origin }, animation);
879
1071
  }
880
1072
  /**
881
- * <zh/> 旋转画布至指定角度
1073
+ * <zh/> 旋转画布至指定角度 (绝对旋转)
882
1074
  *
883
- * <en/> Rotate the canvas to the specified angle
1075
+ * <en/> Rotate the canvas to the specified angle (absolute rotation)
884
1076
  * @param angle - <zh/> 目标角度 | <en/> target angle
885
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1077
+ * @param animation - <zh/> 动画配置 | <en/> animation options
886
1078
  * @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
887
1079
  * @apiCategory viewport
888
1080
  */
@@ -900,22 +1092,22 @@ class Graph extends event_emitter_1.default {
900
1092
  return this.context.viewport.getRotation();
901
1093
  }
902
1094
  /**
903
- * <zh/> 将图平移指定距离
1095
+ * <zh/> 将图平移指定距离 (相对平移)
904
1096
  *
905
- * <en/> Translate the graph by the specified distance
1097
+ * <en/> Translate the graph by the specified distance (relative translation)
906
1098
  * @param offset - <zh/> 偏移量 | <en/> offset
907
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1099
+ * @param animation - <zh/> 动画配置 | <en/> animation options
908
1100
  * @apiCategory viewport
909
1101
  */
910
1102
  async translateBy(offset, animation) {
911
1103
  await this.context.viewport.transform({ mode: 'relative', translate: offset }, animation);
912
1104
  }
913
1105
  /**
914
- * <zh/> 将图平移至指定位置
1106
+ * <zh/> 将图平移至指定位置 (绝对平移)
915
1107
  *
916
- * <en/> Translate the graph to the specified position
1108
+ * <en/> Translate the graph to the specified position (absolute translation)
917
1109
  * @param position - <zh/> 指定位置 | <en/> specified position
918
- * @param animation - <zh/> 动画配置 | <en/> animation configuration
1110
+ * @param animation - <zh/> 动画配置 | <en/> animation options
919
1111
  * @apiCategory viewport
920
1112
  */
921
1113
  async translateTo(position, animation) {
@@ -939,15 +1131,15 @@ class Graph extends event_emitter_1.default {
939
1131
  const [config, animation] = (0, util_1.isObject)(args1)
940
1132
  ? [args1, args2 ?? true]
941
1133
  : [{ [args1]: args2 }, args3];
942
- Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeBy(id, offset));
943
- await this.context.element.draw({ animation })?.finished;
1134
+ Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeLikeBy(id, offset));
1135
+ await this.context.element.draw({ animation, stage: 'translate' })?.finished;
944
1136
  }
945
1137
  async translateElementTo(args1, args2, args3 = true) {
946
1138
  const [config, animation] = (0, util_1.isObject)(args1)
947
1139
  ? [args1, args2 ?? true]
948
1140
  : [{ [args1]: args2 }, args3];
949
- Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
950
- await this.context.element.draw({ animation })?.finished;
1141
+ Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeLikeTo(id, position));
1142
+ await this.context.element.draw({ animation, stage: 'translate' })?.finished;
951
1143
  }
952
1144
  /**
953
1145
  * <zh/> 获取元素位置
@@ -1031,7 +1223,7 @@ class Graph extends event_emitter_1.default {
1031
1223
  });
1032
1224
  const { model, element } = this.context;
1033
1225
  model.preventUpdateNodeLikeHierarchy(() => model.updateData(dataToUpdate));
1034
- await element.draw({ animation: false })?.finished;
1226
+ await element.draw({ animation: false, stage: 'zIndex' })?.finished;
1035
1227
  }
1036
1228
  /**
1037
1229
  * <zh/> 将元素置于最顶层
@@ -1042,17 +1234,17 @@ class Graph extends event_emitter_1.default {
1042
1234
  */
1043
1235
  async frontElement(id) {
1044
1236
  const ids = Array.isArray(id) ? id : [id];
1045
- const { model } = this.context;
1237
+ const { model, element } = this.context;
1046
1238
  const config = {};
1047
1239
  ids.map((_id) => {
1048
- const zIndex = model.getFrontZIndex(_id);
1240
+ const zIndex = element.getFrontZIndex(_id);
1049
1241
  const elementType = model.getElementType(_id);
1050
1242
  if (elementType === 'combo') {
1051
1243
  const ancestor = model.getAncestorsData(_id, constants_1.COMBO_KEY).at(-1) || this.getComboData(_id);
1052
- const combos = [ancestor, ...model.getDescendantsData((0, id_1.idOf)(ancestor))].filter((datum) => model.isCombo((0, id_1.idOf)(datum)));
1053
- const delta = zIndex - (0, style_1.zIndexOf)(ancestor);
1244
+ const combos = [ancestor, ...model.getDescendantsData((0, id_1.idOf)(ancestor))];
1245
+ const delta = zIndex - element.getElementZIndex(_id);
1054
1246
  combos.forEach((combo) => {
1055
- config[(0, id_1.idOf)(combo)] = (0, style_1.zIndexOf)(combo) + delta;
1247
+ config[(0, id_1.idOf)(combo)] = this.getElementZIndex((0, id_1.idOf)(combo)) + delta;
1056
1248
  });
1057
1249
  }
1058
1250
  else
@@ -1069,7 +1261,8 @@ class Graph extends event_emitter_1.default {
1069
1261
  * @apiCategory element
1070
1262
  */
1071
1263
  getElementZIndex(id) {
1072
- return (0, style_1.zIndexOf)(this.context.model.getElementDataById(id));
1264
+ const { model, element } = this.context;
1265
+ return model.getElementDataById(id)?.style?.zIndex ?? element.getElementZIndex(id);
1073
1266
  }
1074
1267
  async setElementState(args1, args2, args3 = true) {
1075
1268
  const [config, animation] = (0, util_1.isObject)(args1)
@@ -1112,7 +1305,7 @@ class Graph extends event_emitter_1.default {
1112
1305
  }
1113
1306
  isCollapsingExpanding = false;
1114
1307
  /**
1115
- * <zh/> 收起 Combo
1308
+ * <zh/> 收起组合
1116
1309
  *
1117
1310
  * <en/> Collapse Combo
1118
1311
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -1135,7 +1328,7 @@ class Graph extends event_emitter_1.default {
1135
1328
  this.isCollapsingExpanding = false;
1136
1329
  }
1137
1330
  /**
1138
- * <zh/> 展开 Combo
1331
+ * <zh/> 展开组合
1139
1332
  *
1140
1333
  * <en/> Expand Combo
1141
1334
  * @param id - <zh/> 元素 ID | <en/> element ID
@@ -1168,7 +1361,7 @@ class Graph extends event_emitter_1.default {
1168
1361
  * <zh/> 导出画布内容为 DataURL
1169
1362
  *
1170
1363
  * <en/> Export canvas content as DataURL
1171
- * @param options - <zh/> 导出配置 | <en/> export configuration
1364
+ * @param options - <zh/> 导出配置 | <en/> export options
1172
1365
  * @returns <zh/> DataURL | <en/> DataURL
1173
1366
  * @apiCategory exportImage
1174
1367
  */
@@ -1268,6 +1461,9 @@ class Graph extends event_emitter_1.default {
1268
1461
  once(eventName, callback) {
1269
1462
  return super.once(eventName, callback);
1270
1463
  }
1464
+ off(eventName, callback) {
1465
+ return super.off(eventName, callback);
1466
+ }
1271
1467
  }
1272
1468
  exports.Graph = Graph;
1273
1469
  //# sourceMappingURL=graph.js.map