@antv/layout 1.2.14-beta.3 → 1.2.14-beta.5

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.
package/lib/types.d.ts CHANGED
@@ -1,11 +1,41 @@
1
1
  import { Edge as IEdge, Graph as IGraph, Node as INode } from '@antv/graphlib';
2
+ /**
3
+ * <zh/> 节点数据
4
+ *
5
+ * <en/> Node data
6
+ */
2
7
  export interface NodeData {
8
+ /**
9
+ * <zh/> 节点x轴坐标
10
+ *
11
+ * <en/> Node x coordinate
12
+ */
3
13
  x?: number;
14
+ /**
15
+ * <zh/> 节点y轴坐标
16
+ *
17
+ * <en/> Node y coordinate
18
+ */
4
19
  y?: number;
20
+ /**
21
+ * <zh/> 节点z轴坐标
22
+ *
23
+ * <en/> Node z coordinate
24
+ */
5
25
  z?: number;
26
+ /**
27
+ * <zh/> 节点大小(直径)
28
+ *
29
+ * <en/> Node size (diameter)
30
+ */
6
31
  size?: number | number[];
7
32
  [key: string]: any;
8
33
  }
34
+ /**
35
+ * <zh/> 边数据
36
+ *
37
+ * <en/> Edge data
38
+ */
9
39
  export interface EdgeData {
10
40
  weight?: number;
11
41
  [keys: string]: any;
@@ -37,19 +67,33 @@ export type LayoutMapping = {
37
67
  };
38
68
  export interface Layout<LayoutOptions> {
39
69
  /**
40
- * To directly assign the positions to the nodes.
70
+ * <zh/> 传入数据并执行布局计算,结果写入原始数据
71
+ *
72
+ * <en/> Passes in the data and performs the layout calculation, modifying the original data
73
+ * @param graph - <zh/> 规范化数据 | <en/> Normalized data
74
+ * @param options - <zh/> 布局配置 | <en/> Layout options
75
+ * @returns Promise<void>
41
76
  */
42
77
  assign(graph: Graph, options?: LayoutOptions): Promise<void>;
43
78
  /**
44
- * Return the positions of nodes and edges(if needed).
79
+ * <zh/> 传入数据并执行布局计算,且结果不写入原始数据,作为返回值
80
+ *
81
+ * <en/> Passes in the data and performs the layout calculation, and the result is not written to the original data, but returned as a value
82
+ * @param graph - <zh/> 规范化数据 | <en/> Normalized data
83
+ * @param options - <zh/> 布局配置 | <en/> Layout options
84
+ * @returns <zh/> 布局结果 | <en/> Layout result
45
85
  */
46
86
  execute(graph: Graph, options?: LayoutOptions): Promise<LayoutMapping>;
47
87
  /**
48
- * Layout options, can be changed in runtime.
88
+ * <zh/> 布局计算的配置项
89
+ *
90
+ * <en/> Layout calculation configuration item
49
91
  */
50
92
  options: LayoutOptions;
51
93
  /**
52
- * Unique ID, it will get registered and used on the webworker-side.
94
+ * <zh/> 布局id
95
+ *
96
+ * <en/> Layout id
53
97
  */
54
98
  id: string;
55
99
  }
@@ -73,107 +117,673 @@ export interface LayoutSupervisor {
73
117
  kill(): void;
74
118
  isRunning(): boolean;
75
119
  }
120
+ /**
121
+ * <zh/> 环形 Circular 布局配置
122
+ *
123
+ * <en/> Circular layout configuration
124
+ */
76
125
  export interface CircularLayoutOptions {
126
+ /**
127
+ * <zh/> 布局的中心
128
+ *
129
+ * <en/> Layout center
130
+ */
77
131
  center?: PointTuple;
132
+ /**
133
+ * <zh/> 布局的宽度
134
+ *
135
+ * <en/> Layout width
136
+ */
78
137
  width?: number;
138
+ /**
139
+ * <zh/> 布局的高度
140
+ *
141
+ * <en/> Layout height
142
+ */
79
143
  height?: number;
144
+ /**
145
+ * <zh/> 圆的半径
146
+ *
147
+ * <en/> Circle radius
148
+ * @remarks
149
+ * <zh/> 若设置了 radius,则 startRadius 与 endRadius 不生效
150
+ *
151
+ * <en/> If radius is set, startRadius and endRadius will not take effect
152
+ * @defaultVaule null
153
+ */
80
154
  radius?: number | null;
155
+ /**
156
+ * <zh/> 螺旋状布局的起始半径
157
+ *
158
+ * <en/> Spiral layout start radius
159
+ * @defaultVaule null
160
+ */
81
161
  startRadius?: number | null;
162
+ /**
163
+ * <zh/> 螺旋状布局的结束半径
164
+ *
165
+ * <en/> Spiral layout end radius
166
+ * @defaultVaule null
167
+ */
82
168
  endRadius?: number | null;
169
+ /**
170
+ * <zh/> 是否顺时针排列
171
+ *
172
+ * <en/> Whether to arrange clockwise
173
+ * @defaultVaule true
174
+ */
83
175
  clockwise?: boolean;
176
+ /**
177
+ * <zh/> 节点在环上的分段数(几个段将均匀分布)
178
+ *
179
+ * <en/> Number of segments (how many segments will be evenly distributed)
180
+ * @remarks
181
+ * <zh/> 在 endRadius - startRadius != 0 时生效
182
+ *
183
+ * <en/> It takes effect when endRadius - startRadius != 0
184
+ * @defaultVaule 1
185
+ */
84
186
  divisions?: number;
187
+ /**
188
+ * <zh/> 节点在环上排序的依据
189
+ * - null: 直接使用数据中的顺序
190
+ * - 'topology': 按照拓扑排序
191
+ * - 'topology-directed': 按照拓扑排序(有向图)
192
+ * - 'degree': 按照度数大小排序
193
+ * <en/> Sorting basis of nodes on the ring
194
+ * - null: Use the order in the data directly
195
+ * - 'topology': Sort according to topological order
196
+ * - 'topology-directed': Sort according to topological order (directed graph)
197
+ * - 'degree': Sort according to degree size
198
+ * @defaultVaule null
199
+ */
85
200
  ordering?: 'topology' | 'topology-directed' | 'degree' | null;
201
+ /**
202
+ * <zh/> 从第一个节点到最后节点之间相隔多少个 2*PI
203
+ *
204
+ * <en/> The distance between the first node and the last node is separated by how many 2*PI
205
+ * @defaultVaule 1
206
+ */
86
207
  angleRatio?: number;
208
+ /**
209
+ * <zh/> 起始角度
210
+ *
211
+ * <en/> Start angle
212
+ */
87
213
  startAngle?: number;
214
+ /**
215
+ * <zh/> 结束角度
216
+ *
217
+ * <en/> End angle
218
+ */
88
219
  endAngle?: number;
220
+ /**
221
+ * <zh/> 环与环之间最小间距,用于调整半径
222
+ *
223
+ * <en/> Minimum spacing between rings, used to adjust the radius
224
+ */
89
225
  nodeSpacing?: ((node?: Node) => number) | number;
226
+ /**
227
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
228
+ *
229
+ * <en/> Node size (diameter). Used for collision detection when nodes overlap
230
+ */
90
231
  nodeSize?: number | number[] | ((nodeData: Node) => number);
91
232
  }
92
233
  export interface GridLayoutOptions {
234
+ /**
235
+ * <zh/> 网格布局的总宽度
236
+ *
237
+ * <en/> Total width of grid layout
238
+ * @remarks
239
+ * <zh/> 在 G6 中使用当前容器的宽度作为 grid 布局 width 的默认值。单独使用此布局时默认值为 300
240
+ *
241
+ * <en/> The width of the grid layout is the default value of the current container width in G6. The default value is 300 when this layout is used alone
242
+ * @defaultVaule 300
243
+ */
93
244
  width?: number;
245
+ /**
246
+ * <zh/> 网格布局的总高度
247
+ *
248
+ * <en/> Total height of grid layout
249
+ * @remarks
250
+ * <zh/> 在 G6 中使用当前容器的高度作为 grid 布局 height 的默认值。单独使用此布局时默认值为 300
251
+ *
252
+ * <en/> The height of the grid layout is the default value of the current container height in G6. The default value is 300 when this layout is used alone
253
+ * @defaultVaule 300
254
+ */
94
255
  height?: number;
256
+ /**
257
+ * <zh/> 网格开始位置(左上角)
258
+ *
259
+ * <en/> Grid layout starting position (upper left corner)
260
+ * @defaultVaule [0, 0]
261
+ *
262
+ */
95
263
  begin?: PointTuple;
264
+ /**
265
+ * <zh/> 是否防止重叠
266
+ *
267
+ * <en/> Whether to prevent overlap
268
+ * @remarks
269
+ * <zh/> 必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
270
+ *
271
+ * <en/> Must be used with the following properties: nodeSize or data.size in the data. When data.size is set or nodeSize is configured with the same value as the current graph node size in the layout, the collision detection of node overlap can be performed
272
+ * @defaultVaule false
273
+ */
96
274
  preventOverlap?: boolean;
275
+ /**
276
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
277
+ *
278
+ * <en/> Node size (diameter). Used for collision detection when nodes overlap
279
+ */
97
280
  nodeSize?: number | number[] | ((nodeData: Node) => number);
281
+ /**
282
+ * <zh/> 避免重叠时节点的间距 padding。preventOverlap 为 true 时生效
283
+ *
284
+ * <en/> Padding between nodes to prevent overlap. It takes effect when preventOverlap is true
285
+ * @defaultVaule 10
286
+ */
98
287
  preventOverlapPadding?: number;
288
+ /**
289
+ * <zh/> 为 false 时表示利用所有可用画布空间,为 true 时表示利用最小的画布空间
290
+ *
291
+ * <en/> When false, it means to use all available canvas space. When true, it means to use the smallest canvas space
292
+ * @defaultVaule false
293
+ */
99
294
  condense?: boolean;
295
+ /**
296
+ * <zh/> 网格的行数,为 undefined 时算法根据节点数量、布局空间、cols(若指定)自动计算
297
+ *
298
+ * <en/> Number of rows in the grid. It is calculated automatically when it is undefined and the number of nodes, layout space, and cols (if specified) are specified
299
+ * @defaultVaule 10
300
+ */
100
301
  rows?: number;
302
+ /**
303
+ * <zh/> 网格的列数,为 undefined 时算法根据节点数量、布局空间、rows(若指定)自动计算
304
+ *
305
+ * <en/> Number of columns in the grid. It is calculated automatically when it is undefined and the number of nodes, layout space, and rows (if specified) are specified
306
+ * @defaultVaule undefined
307
+ */
101
308
  cols?: number;
309
+ /**
310
+ * <zh/> 指定排序的依据(节点属性名),数值越高则该节点被放置得越中心。若为 undefined,则会计算节点的度数,度数越高,节点将被放置得越中心
311
+ *
312
+ * <en/> Specify the basis for sorting (node attribute name). The higher the value, the more the node will be placed in the center. If it is undefined, the degree of the node will be calculated, and the higher the degree, the more the node will be placed in the center
313
+ * @defaultVaule undefined
314
+ */
102
315
  sortBy?: string;
316
+ /**
317
+ * <zh/> 指定每个节点所在的行和列
318
+ *
319
+ * <en/> Specify the row and column where each node is located
320
+ * @defaultVaule undefined
321
+ */
103
322
  position?: (node?: Node) => {
104
323
  row?: number;
105
324
  col?: number;
106
325
  };
326
+ /**
327
+ * <zh/> 环与环之间最小间距,用于调整半径
328
+ *
329
+ * <en/> Minimum spacing between rings, used to adjust the radius
330
+ */
107
331
  nodeSpacing?: ((node?: Node) => number) | number;
108
332
  }
333
+ /**
334
+ * <zh/> 随机布局配置
335
+ *
336
+ * <en/> Random layout configuration
337
+ */
109
338
  export interface RandomLayoutOptions {
339
+ /**
340
+ * <zh/> 布局的中心
341
+ *
342
+ * <en/> Layout center
343
+ */
110
344
  center?: PointTuple;
345
+ /**
346
+ * <zh/> 布局的宽度范围
347
+ *
348
+ * <en/> Layout width range
349
+ */
111
350
  width?: number;
351
+ /**
352
+ * <zh/> 布局的高度范围
353
+ *
354
+ * <en/> Layout height range
355
+ */
112
356
  height?: number;
113
357
  }
358
+ /**
359
+ * <zh/> MDS 高维数据降维布局配置
360
+ *
361
+ * <en/> MDS layout configuration for high-dimensional data dimensionality reduction
362
+ */
114
363
  export interface MDSLayoutOptions {
364
+ /**
365
+ * <zh/> 圆形布局的中心位置
366
+ *
367
+ * <en/> Center position of circular layout
368
+ */
115
369
  center?: PointTuple;
370
+ /**
371
+ * <zh/> 边的理想长度,可以理解为边作为弹簧在不受力下的长度
372
+ *
373
+ * <en/> Ideal length of the edge, which can be understood as the length of the edge as a spring under no force
374
+ * @defaultVaule 200
375
+ */
116
376
  linkDistance?: number;
117
377
  }
378
+ /**
379
+ * <zh/> Concentric 同心圆布局配置
380
+ *
381
+ * <en/> Concentric layout configuration
382
+ */
118
383
  export interface ConcentricLayoutOptions {
384
+ /**
385
+ * <zh/> 圆形布局的中心位置,默认为当前容器的中心位置
386
+ *
387
+ * <en/> Center position of circular layout, defaults to the center position of the current container
388
+ */
119
389
  center?: PointTuple;
390
+ /**
391
+ * <zh/> 是否防止重叠
392
+ *
393
+ * <en/> Whether to prevent overlap
394
+ * @remarks
395
+ * <zh/> 必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
396
+ *
397
+ * <en/> Must be used with the following properties, and only when the data.size property is set in the data or the nodeSize value configured with the same size as the current graph node is configured in the layout, can the node overlap collision detection be performed
398
+ * @defaultVaule false
399
+ */
120
400
  preventOverlap?: boolean;
401
+ /**
402
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
403
+ *
404
+ * <en/> Node size (diameter). Used for collision detection when preventing node overlap
405
+ */
121
406
  nodeSize?: number | PointTuple | ((nodeData: Node) => number);
407
+ /**
408
+ * <zh/> 第一个节点与最后一个节点之间的弧度差
409
+ *
410
+ * <en/> The difference in radians between the first and last nodes
411
+ * @remarks
412
+ * <zh/> 若为 undefined ,则将会被设置为 2 * Math.PI * (1 - 1 / |level.nodes|) ,其中 level.nodes 为该算法计算出的每一层的节点,|level.nodes| 代表该层节点数量
413
+ *
414
+ * <en/> If undefined, it will be set to 2 * Math.PI * (1 - 1 / |level.nodes|), where level.nodes is the number of nodes in each layer calculated by this algorithm, and |level.nodes| represents the number of nodes in this layer
415
+ * @defaultVaule undefined
416
+ */
122
417
  sweep?: number;
418
+ /**
419
+ * <zh/> 环与环之间的距离是否相等
420
+ *
421
+ * <en/> Whether the distance between rings is equal
422
+ * @defaultVaule false
423
+ */
123
424
  equidistant?: boolean;
425
+ /**
426
+ * <zh/> 开始布局节点的弧度
427
+ *
428
+ * <en/> The starting angle of the layout node
429
+ * @defaultVaule 3 / 2 * Math.PI
430
+ */
124
431
  startAngle?: number;
432
+ /**
433
+ * <zh/> 是否按照顺时针排列
434
+ *
435
+ * <en/> Whether to arrange in clockwise order
436
+ * @defaultVaule false
437
+ */
125
438
  clockwise?: boolean;
439
+ /**
440
+ * <zh/> 每一层同心值的求和
441
+ *
442
+ * <en/> The sum of the concentric values of each layer
443
+ * @remarks
444
+ * <zh/> 若为 undefined,则将会被设置为 maxValue / 4 ,其中 maxValue 为最大的排序依据的属性值。例如,若 sortBy 为 'degree',则 maxValue 为所有节点中度数最大的节点的度数
445
+ *
446
+ * <en/> If undefined, it will be set to maxValue / 4, where maxValue is the largest value of the sortBy attribute. For example, if sortBy is 'degree', maxValue is the degree of the node with the largest degree in all nodes
447
+ * @defaultVaule undefined
448
+ */
126
449
  maxLevelDiff?: number;
450
+ /**
451
+ * <zh/> 指定排序的依据(节点属性名)
452
+ *
453
+ * <en/> Specify the basis for sorting (node attribute name)
454
+ * @remarks
455
+ * <zh/> 数值越高则该节点被放置得越中心。若为 undefined,则会计算节点的度数,度数越高,节点将被放置得越中心
456
+ *
457
+ * <en/> The higher the value, the more the node will be placed in the center. If undefined, the degree of the node will be calculated, and the higher the degree, the more the node will be placed in the center
458
+ * @defaultVaule undefined
459
+ */
127
460
  sortBy?: string;
461
+ /**
462
+ * <zh/> 布局的宽度,默认使用容器宽度
463
+ *
464
+ * <en/> The width of the layout, defaults to the container width
465
+ */
128
466
  width?: number;
467
+ /**
468
+ * <zh/> 布局的高度,默认使用容器高度
469
+ *
470
+ * <en/> The height of the layout, defaults to the container height
471
+ */
129
472
  height?: number;
473
+ /**
474
+ * <zh/> 环与环之间最小间距,用于调整半径
475
+ *
476
+ * <en/> Minimum spacing between rings, used to adjust the radius
477
+ * @defaultVaule 10
478
+ */
130
479
  nodeSpacing?: number | number[] | ((node?: Node) => number);
131
480
  }
481
+ /**
482
+ * <zh/> Radial 辐射布局的配置项
483
+ *
484
+ * <en/> Configuration items for Radial layout
485
+ */
132
486
  export interface RadialLayoutOptions {
487
+ /**
488
+ * <zh/> 圆形布局的中心位置,默认为当前容器的中心位置
489
+ *
490
+ * <en/> The center position of the circular layout, defaults to the center position of the current container
491
+ */
133
492
  center?: PointTuple;
493
+ /**
494
+ * <zh/> 布局的宽度,默认使用容器宽度
495
+ *
496
+ * <en/> The width of the layout, defaults to the container width
497
+ */
134
498
  width?: number;
499
+ /**
500
+ * <zh/> 布局的高度,默认使用容器高度
501
+ *
502
+ * <en/> The height of the layout, defaults to the container height
503
+ */
135
504
  height?: number;
505
+ /**
506
+ * <zh/> 边长度
507
+ *
508
+ * <en/> Edge length
509
+ * @defaultVaule 50
510
+ */
136
511
  linkDistance?: number;
512
+ /**
513
+ * <zh/> 停止迭代到最大迭代数
514
+ *
515
+ * <en/> Stop iterating until the maximum iteration number is reached
516
+ * @defaultVaule 1000
517
+ */
137
518
  maxIteration?: number;
519
+ /**
520
+ * <zh/> 辐射的中心点
521
+ * - string: 节点 id
522
+ * - Node: 节点本身
523
+ * - null: 数据中第一个节点
524
+ * <en/> The center point of the radiation
525
+ * - string: node id
526
+ * - Node: node itself
527
+ * - null: the first node in the data
528
+ */
138
529
  focusNode?: string | Node | null;
530
+ /**
531
+ * <zh/> 每一圈距离上一圈的距离。默认填充整个画布,即根据图的大小决定
532
+ *
533
+ * <en/> The distance between each ring. Defaults to filling the entire canvas, i.e., determined by the size of the graph
534
+ * @defaultVaule 100
535
+ */
139
536
  unitRadius?: number | null;
537
+ /**
538
+ * <zh/> 是否防止重叠
539
+ *
540
+ * <en/> Whether to prevent overlap
541
+ * @remarks
542
+ * <zh/> 必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
543
+ *
544
+ * <en/> Must be used with the following properties: nodeSize or data.size in the node data. Only when data.size or nodeSize with the same value as the current graph node size is set in the layout configuration, can the collision detection of node overlap be performed
545
+ * @defaultVaule false
546
+ */
140
547
  preventOverlap?: boolean;
548
+ /**
549
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
550
+ *
551
+ * <en/> Node size (diameter). Used for collision detection when preventing node overlap
552
+ */
141
553
  nodeSize?: number | number[] | ((nodeData: Node) => number);
554
+ /**
555
+ * <zh/> preventOverlap 为 true 时生效, 防止重叠时节点边缘间距的最小值。可以是回调函数, 为不同节点设置不同的最小间距
556
+ *
557
+ * <en/> Effective when preventOverlap is true. The minimum edge spacing when preventing node overlap. It can be a callback function, and set different minimum spacing for different nodes
558
+ * @defaultVaule 10
559
+ */
142
560
  nodeSpacing?: number | Function;
561
+ /**
562
+ * <zh/> 防止重叠步骤的最大迭代次数
563
+ *
564
+ * <en/> Maximum iteration number of the prevent overlap step
565
+ * @defaultVaule 200
566
+ */
143
567
  maxPreventOverlapIteration?: number;
568
+ /**
569
+ * <zh/> 是否必须是严格的 radial 布局,及每一层的节点严格布局在一个环上。preventOverlap 为 true 时生效。
570
+ *
571
+ * <en/> Whether it must be a strict radial layout, that is, each layer of nodes strictly layout on a ring. Effective when preventOverlap is true.
572
+ * @remarks
573
+ * <zh/> 当 preventOverlap 为 true,且 strictRadial 为 false 时,有重叠的节点严格沿着所在的环展开,但在一个环上若节点过多,可能无法完全避免节点重叠 当 preventOverlap 为 true,且 strictRadial 为 true 时,允许同环上重叠的节点不严格沿着该环布局,可以在该环的前后偏移以避免重叠
574
+ *
575
+ * <en/> When preventOverlap is true and strictRadial is false, overlapping nodes are strictly laid out along the ring they are in. However, if there are too many nodes on a ring, it may not be possible to completely avoid node overlap. When preventOverlap is true and strictRadial is true, overlapping nodes on the same ring are allowed to be laid out not strictly along the ring, and can be offset before and after the ring to avoid overlap
576
+ * @defaultVaule true
577
+ */
144
578
  strictRadial?: boolean;
579
+ /**
580
+ * <zh/> 同层节点布局后相距远近的依据
581
+ *
582
+ * <en/> The basis for the distance between nodes in the same layer after layout
583
+ * @remarks
584
+ * <zh/> 默认 undefined ,表示根据数据的拓扑结构(节点间最短路径)排布,即关系越近/点对间最短路径越小的节点将会被尽可能排列在一起;'data' 表示按照节点在数据中的顺序排列,即在数据顺序上靠近的节点将会尽可能排列在一起;也可以指定为节点数据中的某个字段名,例如 'cluster'、'name' 等(必须在数据的 data 中存在)
585
+ *
586
+ * <en/> The default is undefined, which means arranging based on the topological structure of the data (the shortest path between nodes). Nodes that are closer in proximity or have a smaller shortest path between them will be arranged as close together as possible. 'data' indicates arranging based on the order of nodes in the data, so nodes that are closer in the data order will be arranged as close together as possible. You can also specify a field name in the node data, such as 'cluster' or 'name' (it must exist in the data of the graph)
587
+ * @defaultVaule undefined
588
+ */
145
589
  sortBy?: string;
590
+ /**
591
+ * <zh/> 同层节点根据 sortBy 排列的强度,数值越大,sortBy 指定的方式计算出距离越小的越靠近。sortBy 不为 undefined 时生效
592
+ *
593
+ * <en/> The strength of arranging nodes according to sortBy. The larger the value, the closer the nodes that sortBy specifies are arranged. It takes effect when sortBy is not undefined
594
+ * @defaultVaule 10
595
+ */
146
596
  sortStrength?: number;
147
597
  }
598
+ /**
599
+ * <zh/> D3 Force 力导布局配置项
600
+ *
601
+ * <en/> D3 Force layout configuration item
602
+ */
148
603
  export interface D3ForceLayoutOptions {
604
+ /**
605
+ * <zh/> 布局的中心位置,默认为当前容器的中心位置
606
+ *
607
+ * <en/> The center position of the layout, the default is the center position of the current container
608
+ */
149
609
  center?: PointTuple;
610
+ /**
611
+ * <zh/> 边长度
612
+ * - number: 边长度固定值
613
+ * - (edge: Edge) => number: 边长度回调函数,根据不同边设置不同的边长度
614
+ * <en/> Edge length
615
+ * - number: fixed edge length
616
+ * - (edge: Edge) => number: edge length callback function, set different edge lengths according to different edges
617
+ * @defaultVaule 50
618
+ */
150
619
  linkDistance?: number | ((edge?: Edge) => number);
620
+ /**
621
+ * <zh/> 边的作用力,范围是 0 到 1,默认根据节点的出入度自适应
622
+ * - number: 边的作用力固定值
623
+ * - (edge: Edge) => number: 边的作用力回调函数,根据不同边设置不同的边作用力
624
+ * <en/> Edge strength, the range is 0 to 1, and it adapts automatically according to the in-out degree of the node
625
+ * - number: fixed edge strength
626
+ * - (edge: Edge) => number: edge strength callback function, set different edge strengths according to different edges
627
+ */
151
628
  edgeStrength?: number | ((edge?: Edge) => number);
629
+ /**
630
+ * <zh/> 聚类节点作用力。负数代表斥力
631
+ * - number: 聚类节点作用力固定值
632
+ * - (node: Node) => number: 聚类节点作用力回调函数,根据不同节点设置不同的聚类节点作用力
633
+ * <en/> Cluster node strength. Negative numbers represent repulsion
634
+ * - number: fixed cluster node strength
635
+ * - (node: Node) => number: cluster node strength callback function, set different cluster node strengths according to different nodes
636
+ * @defaultVaule -1
637
+ */
152
638
  nodeStrength?: number | ((node?: Node) => number);
639
+ /**
640
+ * <zh/> 是否防止重叠
641
+ *
642
+ * <en/> Whether to prevent overlap
643
+ * @remarks
644
+ * <zh/> 必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
645
+ *
646
+ * <en/> Must be used with the following properties: nodeSize or data.size in the node data. Only when data.size or nodeSize with the same value as the current graph node size is set in the layout configuration, can the collision detection of node overlapping be performed
647
+ * @defaultVaule false
648
+ */
153
649
  preventOverlap?: boolean;
650
+ /**
651
+ * <zh/> 防止重叠的力强度,范围 [0, 1]
652
+ *
653
+ * <en/> The force strength of preventing overlap, the range is [0, 1]
654
+ * @defaultVaule 1
655
+ */
154
656
  collideStrength?: number;
657
+ /**
658
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
659
+ *
660
+ * <en/> Node size (diameter). Used for collision detection when preventing node overlapping
661
+ */
155
662
  nodeSize?: number | number[] | ((node?: Node) => number);
663
+ /**
664
+ * <zh/> preventOverlap 为 true 时生效, 防止重叠时节点边缘间距的最小值。可以是回调函数, 为不同节点设置不同的最小间距
665
+ *
666
+ * <en/> It takes effect when preventOverlap is true. The minimum spacing of the node edge when preventing node overlapping. It can be a callback function, and set different minimum spacing for different nodes
667
+ */
156
668
  nodeSpacing?: number | number[] | ((node?: Node) => number);
669
+ /**
670
+ * <zh/> 当前的迭代收敛阈值
671
+ *
672
+ * <en/> The convergence threshold of the current iteration
673
+ * @defaultVaule 0.3
674
+ */
157
675
  alpha?: number;
676
+ /**
677
+ * <zh/> 迭代阈值的衰减率。范围 [0, 1]。0.028 对应迭代数为 300
678
+ *
679
+ * <en/> The decay rate of the iteration threshold. The range is [0, 1]. 0.028 corresponds to iteration number 300
680
+ * @defaultVaule 0.028
681
+ */
158
682
  alphaDecay?: number;
683
+ /**
684
+ * <zh/> 停止迭代的阈值
685
+ *
686
+ * <en/> The threshold to stop iteration
687
+ * @defaultVaule 0.001
688
+ */
159
689
  alphaMin?: number;
690
+ /**
691
+ * <zh/> 是否按照聚类信息布局
692
+ *
693
+ * <en/> Whether to layout according to the clustering information
694
+ * @defaultVaule false
695
+ */
160
696
  clustering?: boolean;
697
+ /**
698
+ * <zh/> 聚类节点作用力。负数代表斥力
699
+ *
700
+ * <en/> Clustering node force. Negative numbers represent repulsion
701
+ * @defaultVaule -1
702
+ */
161
703
  clusterNodeStrength?: number;
704
+ /**
705
+ * <zh/> 聚类边作用力
706
+ *
707
+ * <en/> Clustering edge force
708
+ * @defaultVaule 0.1
709
+ */
162
710
  clusterEdgeStrength?: number;
711
+ /**
712
+ * <zh/> 聚类边长度
713
+ *
714
+ * <en/> Clustering edge length
715
+ * @defaultVaule 100
716
+ */
163
717
  clusterEdgeDistance?: number;
718
+ /**
719
+ * <zh/> 聚类节点大小 / 直径,直径越大,越分散
720
+ *
721
+ * <en/> Clustering node size / diameter. Diameter larger means more scattered
722
+ * @defaultVaule 10
723
+ */
164
724
  clusterNodeSize?: number;
725
+ /**
726
+ * <zh/> 用于 foci 的力
727
+ *
728
+ * <en/> Force for foci
729
+ * @defaultVaule 0.8
730
+ */
165
731
  clusterFociStrength?: number;
732
+ /**
733
+ * <zh/> 自定义 force 方法,若不指定,则使用 d3.js 的方法
734
+ *
735
+ * <en/> Custom force method, if not specified, use the method of d3.js
736
+ */
166
737
  forceSimulation?: any;
738
+ /**
739
+ * <zh/> 每一次迭代的回调函数,返回值为这一次迭代的布局结果
740
+ *
741
+ * <en/> The callback function called every iteration, and the return value is the layout result of this iteration
742
+ * @param data - <zh/> 布局结果,包含节点和边的位置信息
743
+ */
167
744
  onTick?: (data: LayoutMapping) => void;
168
745
  }
746
+ /**
747
+ * <zh/> 向心力配置,包括叶子节点、离散点、其他节点的向心中心及向心力大小
748
+ *
749
+ * <en/> Centripetal configuration, including the center of the leaf node, the center of the scattered point, and the center of the other nodes
750
+ */
169
751
  export interface CentripetalOptions {
170
- /** Force strength for leaf nodes. */
752
+ /**
753
+ * <zh/> 叶子节点(即度数为 1 的节点)受到的向心力大小
754
+ * - number: 固定向心力大小
755
+ * - ((node: Node, nodes: Node[], edges: Edge[]) => number): 可根据节点、边的情况返回不同的值
756
+ * <en/> The centripetal force of the leaf node (i.e., the node with degree 1)
757
+ * - number: fixed centripetal force size
758
+ * - ((node: Node, nodes: Node[], edges: Edge[]) => number): return different values according to the node, edge, and situation
759
+ * @defaultVaule 2
760
+ */
171
761
  leaf?: number | ((node: Node, nodes: Node[], edges: Edge[]) => number);
172
- /** Force strength for single nodes. */
762
+ /**
763
+ * <zh/> 离散节点(即度数为 0 的节点)受到的向心力大小
764
+ * - number: 固定向心力大小
765
+ * - ((node: Node, nodes: Node[], edges: Edge[]) => number): 可根据节点情况返回不同的值
766
+ * <en/> The centripetal force of the scattered node (i.e., the node with degree 0)
767
+ * - number: fixed centripetal force size
768
+ * - ((node: Node) => number): return different values according to the node situation
769
+ * @defaultVaule 2
770
+ */
173
771
  single?: number | ((node: Node) => number);
174
- /** Force strength for other nodes. */
772
+ /**
773
+ * <zh/> 除离散节点、叶子节点以外的其他节点(即度数 > 1 的节点)受到的向心力大小
774
+ * - number: 固定向心力大小
775
+ * - ((node: Node) => number): 可根据节点的情况返回不同的值
776
+ * <en/> The centripetal force of the other nodes (i.e., the node with degree > 1)
777
+ * - number: fixed centripetal force size
778
+ * - ((node: Node) => number): return different values according to the node situation
779
+ * @defaultVaule 1
780
+ */
175
781
  others?: number | ((node: Node) => number);
176
- /** Centri force's position and sterngth, points to the canvas center by default */
782
+ /**
783
+ * <zh/> 向心力发出的位置,可根据节点、边的情况返回不同的值、默认为图的中心
784
+ *
785
+ * <en/> The position where the centripetal force is emitted, which can return different values according to the node, edge, and situation. The default is the center of the graph
786
+ */
177
787
  center?: (node: Node, nodes: Node[], edges: Edge[], width: number, height: number) => {
178
788
  x: number;
179
789
  y: number;
@@ -181,52 +791,308 @@ export interface CentripetalOptions {
181
791
  centerStrength?: number;
182
792
  };
183
793
  }
794
+ /**
795
+ * <zh/>ComboCombined 复合布局配置项
796
+ *
797
+ * <en/> ComboCombined layout configuration item
798
+ */
184
799
  export interface ComboCombinedLayoutOptions {
800
+ /**
801
+ * <zh/> 布局的中心、默认为图的中心
802
+ *
803
+ * <en/> The center of the layout, default to the center of the graph
804
+ */
185
805
  center?: PointTuple;
806
+ /**
807
+ * <zh/> 节点大小(直径)。用于碰撞检测
808
+ *
809
+ * <en/> The size of the node (diameter). Used for collision detection
810
+ * @remarks
811
+ * <zh/> 若不指定,则根据传入的节点的 size 属性计算。若即不指定,节点中也没有 size,则默认大小为 10
812
+ *
813
+ * <en/> If not specified, it will be calculated based on the size attribute of the incoming node. If neither is specified, the default size is 10
814
+ * @defaultVaule 10
815
+ */
186
816
  nodeSize?: number | number[] | ((d?: Node) => number);
817
+ /**
818
+ * <zh/> preventNodeOverlap 或 preventOverlap 为 true 时生效, 防止重叠时节点/ combo 边缘间距的最小值。可以是回调函数, 为不同节点设置不同的最小间距
819
+ *
820
+ * <en/> It takes effect when preventNodeOverlap or preventOverlap is true. The minimum spacing between nodes when overlapping is prevented. It can be a callback function, and different minimum spacing can be set for different nodes
821
+ */
187
822
  spacing?: number | ((d?: Node) => number);
823
+ /**
824
+ * <zh/> 最外层的布局算法,默认为 gForce
825
+ *
826
+ * <en/> The outermost layout algorithm, default to gForce
827
+ * @example
828
+ * ```ts
829
+ * outerLayout: new G6.Layout['gForce']({
830
+ * gravity: 1,
831
+ * factor: 2,
832
+ * linkDistance: (edge: any, source: any, target: any) => {
833
+ * const nodeSize = ((source.size?.[0] || 30) + (target.size?.[0] || 30)) / 2;
834
+ * return Math.min(nodeSize * 1.5, 700);
835
+ * }
836
+ * });
837
+ * ```
838
+ * @defaultVaule GForce 实例
839
+ */
188
840
  outerLayout?: Layout<any>;
841
+ /**
842
+ * <zh/> combo 内部的布局算法,需要使用同步的布局算法,默认为 concentric
843
+ *
844
+ * <en/> The layout algorithm inside the combo, which needs to use a synchronized layout algorithm, default to concentric
845
+ * @example
846
+ * ```ts
847
+ * innerLayout: new G6.Layout['concentric']({
848
+ * sortBy: 'id'
849
+ * });
850
+ * ```
851
+ * @defaultVaule Concentric 实例
852
+ */
189
853
  innerLayout?: Layout<any>;
854
+ /**
855
+ * <zh/> Combo 内部的 padding 值,不用于渲染,仅用于计算力。推荐设置为与视图上 combo 内部 padding 值相同的值
856
+ *
857
+ * <en/> The padding value inside the combo, which is not used for rendering, but only for calculating force. It is recommended to set it to the same value as the combo internal padding value on the view
858
+ * @defaultVaule 10
859
+ */
190
860
  comboPadding?: ((d?: unknown) => number) | number | number[] | undefined;
861
+ /**
862
+ * <zh/> treeKey
863
+ *
864
+ * <en/> treeKey
865
+ */
191
866
  treeKey?: string;
192
867
  }
868
+ /**
869
+ * <zh/> 公共力导向布局配置项
870
+ *
871
+ * <en/> Common force layout configuration items
872
+ */
193
873
  interface CommonForceLayoutOptions {
874
+ /**
875
+ * <zh/> 布局的维度,2D 渲染时指定为 2;若为 3D 渲染可指定为 3,则将多计算 z 轴的布局
876
+ *
877
+ * <en/> The dimensions of the layout, specify 2 for 2D rendering; if it is 3D rendering, specify 3 to calculate the layout of the z axis
878
+ * @defaultVaule 2
879
+ */
194
880
  dimensions?: number;
881
+ /**
882
+ * <zh/> 布局的中心点,默认为图的中心
883
+ *
884
+ * <en/> The center point of the layout, default to the center of the graph
885
+ */
195
886
  center?: PointTuple;
887
+ /**
888
+ * <zh/> 当一次迭代的平均/最大/最小(根据distanceThresholdMode决定)移动长度小于该值时停止迭代。数字越小,布局越收敛,所用时间将越长
889
+ *
890
+ * <en/> When the average/max/min (depending on distanceThresholdMode) movement length of one iteration is less than this value, the iteration will stop. The smaller the number, the more converged the layout, and the longer the time it takes to use
891
+ * @defaultVaule 0.4
892
+ */
196
893
  minMovement?: number;
894
+ /**
895
+ * <zh/> 最大迭代次数,若为 0 则将自动调整
896
+ *
897
+ * <en/> Maximum number of iterations, if it is 0, it will be automatically adjusted
898
+ * @defaultVaule 0
899
+ */
197
900
  maxIteration?: number;
901
+ /**
902
+ * <zh/> minMovement 的使用条件
903
+ * - 'mean': 平均移动距离小于 minMovement 时停止迭代
904
+ * - 'max': 最大移动距离小于时 minMovement 时停止迭代
905
+ * - 'min': 最小移动距离小于时 minMovement 时停止迭代
906
+ * <en/> The condition for using minMovement
907
+ * - 'mean': The average movement distance is less than minMovement when stopped iterating
908
+ * - 'max': The maximum movement distance is less than minMovement when stopped iterating
909
+ * - 'min': The minimum movement distance is less than minMovement when stopped iterating
910
+ * @defaultVaule 'mean'
911
+ */
198
912
  distanceThresholdMode?: 'mean' | 'max' | 'min';
199
913
  /**
200
- * If distance is specified, sets the maximum distance between nodes over which this force is considered.
201
- * If distance is not specified, returns the current maximum distance, which defaults to infinity.
202
- * Specifying a finite maximum distance improves performance and produces a more localized layout.
914
+ * <zh/> 最大距离
915
+ *
916
+ * <en/> Maximum distance
203
917
  */
204
918
  maxDistance?: number;
205
919
  }
206
920
  export interface ForceLayoutOptions extends CommonForceLayoutOptions {
921
+ /**
922
+ * <zh/> 布局的宽度、默认为画布宽度
923
+ *
924
+ * <en/> The width of the layout, default to the width of the canvas
925
+ */
207
926
  width?: number;
927
+ /**
928
+ * <zh/> 布局的高度、默认为画布高度
929
+ *
930
+ * <en/> The height of the layout, default to the height of the canvas
931
+ */
208
932
  height?: number;
933
+ /**
934
+ * <zh/> 边的长度
935
+ * - number: 固定长度
936
+ * - ((edge?: Edge, source?: any, target?: any) => number): 根据边的信息返回长度
937
+ * <en/> The length of the edge
938
+ * - number: fixed length
939
+ * - ((edge?: Edge, source?: any, target?: any) => number): return length according to the edge information
940
+ * @defaultVaule 200
941
+ */
209
942
  linkDistance?: number | ((edge?: Edge, source?: any, target?: any) => number);
943
+ /**
944
+ * <zh/> 节点作用力,正数代表节点之间的引力作用,负数代表节点之间的斥力作用
945
+ *
946
+ * <en/> The force of the node, positive numbers represent the attraction force between nodes, and negative numbers represent the repulsion force between nodes
947
+ * @defaultVaule 1000
948
+ */
210
949
  nodeStrength?: number | ((d?: Node) => number);
950
+ /**
951
+ * <zh/> 边的作用力(引力)大小
952
+ *
953
+ * <en/> The size of the force of the edge (attraction)
954
+ * @defaultVaule 50
955
+ */
211
956
  edgeStrength?: number | ((d?: Edge) => number);
957
+ /**
958
+ * <zh/> 是否防止重叠,必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
959
+ *
960
+ * <en/> Whether to prevent overlap, must be used with the following properties nodeSize or data.size in the node data, and only when the data.size is set in the data or the nodeSize value is configured with the same value as the current graph node size in the layout configuration, can the node overlap collision detection be performed
961
+ * @defaultVaule true
962
+ */
212
963
  preventOverlap?: boolean;
964
+ /**
965
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
966
+ *
967
+ * <en/> The size of the node (diameter). Used for collision detection when preventing node overlap
968
+ */
213
969
  nodeSize?: number | number[] | ((d?: Node) => number);
970
+ /**
971
+ * <zh/> preventOverlap 为 true 时生效, 防止重叠时节点边缘间距的最小值。可以是回调函数, 为不同节点设置不同的最小间距
972
+ *
973
+ * <en/> It is effective when preventOverlap is true. The minimum spacing of the node edge when preventing overlap. It can be a callback function to set different minimum spacing for different nodes
974
+ */
214
975
  nodeSpacing?: number | ((d?: Node) => number);
976
+ /**
977
+ * <zh/> 阻尼系数,取值范围 [0, 1]。数字越大,速度降低得越慢
978
+ *
979
+ * <en/> Damping coefficient, the range of the value is [0, 1]. The larger the number, the slower the speed will decrease
980
+ * @defaultVaule 0.9
981
+ */
215
982
  damping?: number;
983
+ /**
984
+ * <zh/> 一次迭代的最大移动长度
985
+ *
986
+ * <en/> The maximum movement length of one iteration
987
+ * @defaultVaule 200
988
+ */
216
989
  maxSpeed?: number;
990
+ /**
991
+ * <zh/> 库伦系数,斥力的一个系数,数字越大,节点之间的斥力越大
992
+ *
993
+ * <en/> Coulomb's coefficient, a coefficient of repulsion, the larger the number, the larger the repulsion between nodes
994
+ * @defaultVaule 0.005
995
+ */
217
996
  coulombDisScale?: number;
997
+ /**
998
+ * <zh/> 中心力大小,指所有节点被吸引到 center 的力。数字越大,布局越紧凑
999
+ *
1000
+ * <en/> The size of the center force, which attracts all nodes to the center. The larger the number, the more compact the layout
1001
+ * @defaultVaule 10
1002
+ */
218
1003
  gravity?: number;
1004
+ /**
1005
+ * <zh/> 斥力系数,数值越大,斥力越大
1006
+ *
1007
+ * <en/> The repulsion coefficient, the larger the number, the larger the repulsion
1008
+ * @defaultVaule 1
1009
+ */
219
1010
  factor?: number;
1011
+ /**
1012
+ * <zh/> 控制每个迭代节点的移动速度
1013
+ *
1014
+ * <en/> Control the movement speed of each iteration node
1015
+ * @defaultVaule 0.02
1016
+ */
220
1017
  interval?: number;
1018
+ /**
1019
+ * <zh/> 向心力配置,包括叶子节点、离散点、其他节点的向心中心及向心力大小
1020
+ *
1021
+ * <en/> Centripetal configuration, including the centripetal center of leaf nodes, discrete points, and the centripetal center of other nodes
1022
+ */
221
1023
  centripetalOptions?: CentripetalOptions;
1024
+ /**
1025
+ * <zh/> 是否需要叶子结点聚类
1026
+ *
1027
+ * <en/> Whether to cluster leaf nodes
1028
+ * @remarks
1029
+ * <zh/> 若为 true,则 centripetalOptions.single 将为 100;centripetalOptions.leaf 将使用 getClusterNodeStrength 返回值;getClusterNodeStrength.center 将为叶子节点返回当前所有叶子节点的平均中心
1030
+ *
1031
+ * <en/> If it is true, centripetalOptions.single will be 100; centripetalOptions.leaf will use the return value of getClusterNodeStrength; getClusterNodeStrength.center will be the average center of all leaf nodes
1032
+ * @defaultVaule false
1033
+ */
222
1034
  leafCluster?: boolean;
1035
+ /**
1036
+ * <zh/> 是否需要全部节点聚类
1037
+ *
1038
+ * <en/> Whether to cluster all nodes
1039
+ * @remarks
1040
+ * <zh/> 若为 true,将使用 nodeClusterBy 配置的节点数据中的字段作为聚类依据。 centripetalOptions.single、centripetalOptions.leaf、centripetalOptions.others 将使用 getClusterNodeStrength 返回值;leaf、centripetalOptions.center 将使用当前节点所属聚类中所有节点的平均中心
1041
+ *
1042
+ * <en/> If it is true, the node data configured by nodeClusterBy will be used as the clustering basis. centripetalOptions.single, centripetalOptions.leaf, centripetalOptions.others will use the return value of getClusterNodeStrength; leaf、centripetalOptions.center will use the average center of all nodes in the current cluster
1043
+ * @defaultVaule false
1044
+ */
223
1045
  clustering?: boolean;
1046
+ /**
1047
+ * <zh/> 指定节点数据中的字段名称作为节点聚类的依据,clustering 为 true 时生效,自动生成 centripetalOptions,可配合 clusterNodeStrength 使用
1048
+ *
1049
+ * <en/> Specify the field name of the node data as the clustering basis for the node, and it takes effect when clustering is true. You can combine it with clusterNodeStrength to use it
1050
+ */
224
1051
  nodeClusterBy?: string;
1052
+ /**
1053
+ * <zh/> 配合 clustering 和 nodeClusterBy 使用,指定聚类向心力的大小
1054
+ *
1055
+ * <en/> Use it with clustering and nodeClusterBy to specify the size of the centripetal force of the cluster
1056
+ * @defaultVaule 20
1057
+ */
225
1058
  clusterNodeStrength?: number | ((node: Node) => number);
1059
+ /**
1060
+ * <zh/> 防止重叠的力强度,范围 [0, 1]
1061
+ *
1062
+ * <en/> The strength of the force that prevents overlap, range [0, 1]
1063
+ * @defaultVaule 1
1064
+ */
226
1065
  collideStrength?: number;
1066
+ /**
1067
+ * <zh/> 每一次迭代的回调函数
1068
+ *
1069
+ * <en/> The callback function for each iteration
1070
+ * @param data - <zh/> 布局数据 | <en/> Layout data
1071
+ */
227
1072
  onTick?: (data: LayoutMapping) => void;
1073
+ /**
1074
+ * <zh/> 每个节点质量的回调函数,如参为节点内部流转数据,返回值为质量大小
1075
+ *
1076
+ * <en/> The callback function for the mass of each node, if the parameter is the internal circulation data of the node, the return value is the size of the mass
1077
+ * @param node - <zh/> 节点数据 | <en/> Node data
1078
+ * @returns <zh/> 节点质量大小 | <en/> Mass size of the node
1079
+ */
228
1080
  getMass?: (node?: Node) => number;
1081
+ /**
1082
+ * <zh/> 每个节点中心力的 x、y、强度的回调函数,若不指定,则没有额外中心力
1083
+ *
1084
+ * <en/> The callback function for the center force of each node, if not specified, there will be no additional center force
1085
+ * @param node - <zh/> 节点数据 | <en/> Node data
1086
+ * @param degree - <zh/> 节点度数 | <en/> Node degree
1087
+ * @returns <zh/> 中心力 x、y、强度 | <en/> Center force x、y、strength
1088
+ */
229
1089
  getCenter?: (node?: Node, degree?: number) => number[];
1090
+ /**
1091
+ * <zh/> 每个迭代的监控信息回调,energy 表示布局的收敛能量。若配置可能带来额外的计算能量性能消耗,不配置则不计算
1092
+ *
1093
+ * <en/> The callback function for monitoring information of each iteration, energy indicates the convergence energy of the layout. If not configured, it will not calculate
1094
+ * @param params - <zh/> 监控信息 | <en/> Monitoring information
1095
+ */
230
1096
  monitor?: (params: {
231
1097
  energy: number;
232
1098
  nodes: Node[];
@@ -234,30 +1100,180 @@ export interface ForceLayoutOptions extends CommonForceLayoutOptions {
234
1100
  iterations: number;
235
1101
  }) => void;
236
1102
  }
1103
+ /**
1104
+ * <zh/> ForceAtlas2 力导向布局配置
1105
+ *
1106
+ * <en/> ForceAtlas2 layout configuration
1107
+ */
237
1108
  export interface ForceAtlas2LayoutOptions extends CommonForceLayoutOptions {
1109
+ /**
1110
+ * <zh/> 布局的宽度,默认使用容器宽度
1111
+ *
1112
+ * <en/> The width of the layout, default to use the container width
1113
+ */
238
1114
  width?: number;
1115
+ /**
1116
+ * <zh/> 布局的高度,默认使用容器高度
1117
+ *
1118
+ * <en/> The height of the layout, default to use the container height
1119
+ */
239
1120
  height?: number;
1121
+ /**
1122
+ * <zh/> 斥力系数,可用于调整布局的紧凑程度。kr 越大,布局越松散
1123
+ *
1124
+ * <en/> The repulsive coefficient, which can be used to adjust the compactness of the layout. The larger kr is, the more relaxed the layout is
1125
+ * @defaultVaule 5
1126
+ */
240
1127
  kr?: number;
1128
+ /**
1129
+ * <zh/> 重力系数。kg 越大,布局越聚集在中心
1130
+ *
1131
+ * <en/> The gravitational coefficient. The larger kg is, the more clustered the layout is in the center
1132
+ * @defaultVaule 1
1133
+ */
241
1134
  kg?: number;
1135
+ /**
1136
+ * <zh/> 控制迭代过程中,节点移动的速度
1137
+ *
1138
+ * <en/> Control the speed of node movement during iteration
1139
+ * @defaultVaule 0.1
1140
+ */
242
1141
  ks?: number;
1142
+ /**
1143
+ * <zh/> 迭代过程中,最大的节点移动的速度上限
1144
+ *
1145
+ * <en/> The upper limit of the maximum node movement speed during iteration
1146
+ * @defaultVaule 10
1147
+ */
243
1148
  ksmax?: number;
1149
+ /**
1150
+ * <zh/> 迭代接近收敛时停止震荡的容忍度
1151
+ *
1152
+ * <en/> The tolerance for stopping oscillation when iteration is close to convergence
1153
+ * @defaultVaule 0.1
1154
+ */
244
1155
  tao?: number;
1156
+ /**
1157
+ * <zh/> 聚类模式、'linlog' 模式下,聚类将更加紧凑
1158
+ * - 'nornal':普通模式
1159
+ * - 'linlog':linlog模式
1160
+ * <en/> Clustering mode, the clustering will be more compact in the 'linlog' mode
1161
+ * - 'normal':normal mode
1162
+ * - 'linlog':linlog mode
1163
+ * @defaultVaule 'normal'
1164
+ */
245
1165
  mode?: 'normal' | 'linlog';
1166
+ /**
1167
+ * <zh/> 是否防止重叠
1168
+ *
1169
+ * <en/> Whether to prevent overlap
1170
+ * @remarks
1171
+ * <zh/> 必须配合下面属性 nodeSize 或节点数据中的 data.size 属性,只有在数据中设置了 data.size 或在该布局中配置了与当前图节点大小相同的 nodeSize 值,才能够进行节点重叠的碰撞检测
1172
+ *
1173
+ * <en/> Must be used with the following properties: nodeSize or data.size in the node data. Only when data.size or nodeSize with the same value as the current graph node size is set in the layout configuration, can the collision detection of node overlap be performed
1174
+ * @defaultVaule false
1175
+ */
246
1176
  preventOverlap?: boolean;
1177
+ /**
1178
+ * <zh/> 是否打开 hub 模式。若为 true,相比与出度大的节点,入度大的节点将会有更高的优先级被放置在中心位置
1179
+ *
1180
+ * <en/> Whether to open the hub mode. If true, nodes with high out-degree will have higher priority than nodes with high in-degree to be placed in the center
1181
+ * @defaultVaule false
1182
+ */
247
1183
  dissuadeHubs?: boolean;
1184
+ /**
1185
+ * <zh/> 是否打开 barnes hut 加速,即四叉树加速
1186
+ *
1187
+ * <en/> Whether to open the barnes hut acceleration, that is, the quad tree acceleration
1188
+ * @remarks
1189
+ * <zh/> 由于每次迭代需要更新构建四叉树,建议在较大规模图上打开。默认情况下为 undefined,当节点数量大于 250 时它将会被激活。设置为 false 则不会自动被激活
1190
+ *
1191
+ * <en/> It is recommended to open it on large-scale graphs. By default, it will be activated when the number of nodes is greater than 250. Setting it to false will not be activated automatically
1192
+ */
248
1193
  barnesHut?: boolean;
1194
+ /**
1195
+ * <zh/> 是否开启自动剪枝模式
1196
+ *
1197
+ * <en/> Whether to enable the automatic pruning mode
1198
+ * @remarks
1199
+ * <zh/> 默认情况下为 undefined,当节点数量大于 100 时它将会被激活。注意,剪枝能够提高收敛速度,但可能会降低图的布局质量。设置为 false 则不会自动被激活
1200
+ *
1201
+ * <en/> By default, it will be activated when the number of nodes is greater than 100. Note that pruning can improve the convergence speed, but it may reduce the layout quality of the graph. Setting it to false will not be activated automatically
1202
+ */
249
1203
  prune?: boolean;
1204
+ /**
1205
+ * <zh/> 节点大小(直径)。用于防止节点重叠时的碰撞检测
1206
+ *
1207
+ * <en/> Node size (diameter). Used for collision detection when preventing node overlap
1208
+ */
250
1209
  nodeSize?: number | number[] | ((node?: Node) => number);
1210
+ /**
1211
+ * <zh/> 每一次迭代的回调函数
1212
+ *
1213
+ * <en/> The callback function for each iteration
1214
+ * @param data - <zh/> 当前迭代的布局数据 | <en/> Current layout data
1215
+ */
251
1216
  onTick?: (data: LayoutMapping) => void;
252
1217
  }
1218
+ /**
1219
+ * <zh/> Fruchterman 力导布局配置项
1220
+ *
1221
+ * <en/> Fruchterman force layout configuration
1222
+ */
253
1223
  export interface FruchtermanLayoutOptions extends CommonForceLayoutOptions {
1224
+ /**
1225
+ * <zh/> 布局的宽度,默认使用容器宽度
1226
+ *
1227
+ * <en/> The width of the layout, defaults to the container width
1228
+ */
254
1229
  width?: number;
1230
+ /**
1231
+ * <zh/> 布局的高度,默认使用容器高度
1232
+ *
1233
+ * <en/> The height of the layout, defaults to the container height
1234
+ */
255
1235
  height?: number;
1236
+ /**
1237
+ * <zh/> 中心力大小,指所有节点被吸引到 center 的力。数字越大,布局越紧凑
1238
+ *
1239
+ * <en/> The size of the center force, which means the force that all nodes are attracted to the center. The larger the number, the more compact the layout
1240
+ * @defaultVaule 10
1241
+ */
256
1242
  gravity?: number;
1243
+ /**
1244
+ * <zh/> 每次迭代节点移动的速度。速度太快可能会导致强烈震荡
1245
+ *
1246
+ * <en/> The speed at which the node moves in each iteration. A speed that is too fast may cause strong oscillations
1247
+ * @defaultVaule 5
1248
+ */
257
1249
  speed?: number;
1250
+ /**
1251
+ * <zh/> 是否按照聚类布局
1252
+ *
1253
+ * <en/> Whether to layout according to clustering
1254
+ * @defaultVaule false
1255
+ */
258
1256
  clustering?: boolean;
1257
+ /**
1258
+ * <zh/> 聚类内部的重力大小,影响聚类的紧凑程度,在 clustering 为 true 时生效
1259
+ *
1260
+ * <en/> The size of the gravity inside the cluster, which affects the compactness of the cluster, and it takes effect when clustering is true
1261
+ * @defaultVaule 10
1262
+ */
259
1263
  clusterGravity?: number;
1264
+ /**
1265
+ * <zh/> 聚类布局依据的节点数据 data 中的字段名,cluster: true 时使用
1266
+ *
1267
+ * <en/> The field name of the node data data in the data, which is used when cluster is true
1268
+ * @defaultVaule 'cluster'
1269
+ */
260
1270
  nodeClusterBy?: string;
1271
+ /**
1272
+ * <zh/> 每一次迭代的回调函数
1273
+ *
1274
+ * <en/> The callback function for each iteration
1275
+ * @param data - <zh/> 当前迭代的布局数据 | <en/> Current layout data
1276
+ */
261
1277
  onTick?: (data: LayoutMapping) => void;
262
1278
  }
263
1279
  export {};