Skip to content

Commit 839c31e

Browse files
authored
docs: 改造circular环形布局文档 (#7019)
1 parent 7680243 commit 839c31e

File tree

1 file changed

+64
-68
lines changed

1 file changed

+64
-68
lines changed

packages/site/docs/manual/layout/build-in/CircularLayout.zh.md

+64-68
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,93 @@
22
title: Circular 环形布局
33
---
44

5-
## 配置项
6-
7-
### angleRatio
8-
9-
> _number_ **Default:** `1`
10-
11-
从第一个节点到最后节点之间相隔多少个 2\*PI
12-
13-
### center
14-
15-
> _PointTuple_
16-
17-
布局的中心
18-
19-
### clockwise
20-
21-
> _boolean_ **Default:** `true`
22-
23-
是否顺时针排列
24-
25-
### divisions
26-
27-
> _number_ **Default:** `1`
28-
29-
节点在环上的分段数(几个段将均匀分布)
5+
## 概述
306

31-
在 endRadius - startRadius != 0 时生效
7+
环形布局是一种把节点均匀或者按间隔放置在圆上的布局,也支持通过配置 startRadius 和 endRadius 为不一样的值实现螺旋状布局。参考更多环形布局[样例](https://g6.antv.antgroup.com/examples#layout-circular)[源码](https://github.com/antvis/layout/blob/v5/packages/layout/src/circular.ts)
328

33-
### endAngle
9+
## 使用场景
3410

35-
> _number_
11+
`环形布局`:
3612

37-
结束角度
13+
- 适用于平等关系网络、无层级结构的图
3814

39-
### endRadius
15+
`螺旋状布局`:
4016

41-
> _number \| null_ **Default:** `null`
17+
- 适用于隐式层级或时间序列图(如组织架构、传播网络)
4218

43-
螺旋状布局的结束半径
19+
## 基本用法
4420

45-
### height
21+
其余均使用默认配置(布局宽高默认是整个画布容器)
4622

47-
> _number_
23+
```js
24+
const graph = new Graph({
25+
// 其他配置
26+
layout: {
27+
type: 'circular',
28+
},
29+
});
30+
```
4831

49-
布局的高度
50-
51-
### nodeSize
52-
53-
> _Size \| ((nodeData: Node) = Size)_
54-
55-
节点大小(直径)。用于防止节点重叠时的碰撞检测
56-
57-
### nodeSpacing
58-
59-
> _((node?: Node) => number) \| number_
32+
## 配置项
6033

61-
环与环之间最小间距,用于调整半径
34+
| 属性 | 描述 | 类型 | 默认值 | 必选 |
35+
| ----------- | ----------------------------------------------------------------------------------- | --------------------------------------------- | -------------------------------- | ---- |
36+
| type | 布局类型 | circular | - ||
37+
| angleRatio | 从第一个节点到最后节点之间相隔多少个 2\*PI | number | 1 | |
38+
| center | 布局的中心 | [number, number]\|[number, number, number] | [`布局宽度` / 2, `布局高度` / 2] | |
39+
| clockwise | 是否顺时针排列 | boolean | true | |
40+
| divisions | 节点在环上的分段数(几个段将均匀分布,在 endRadius - startRadius != 0 时生效) | number | 1 | |
41+
| nodeSize | 节点大小(直径)。用于防止节点重叠时的碰撞检测 | Size \| ((nodeData: Node) => Size) | 10 | |
42+
| nodeSpacing | 环与环之间最小间距,用于调整半径 | number \| ((nodeData: Node) => number) | 10 | |
43+
| ordering | 节点在环上排序的依据,[说明](#ordering) | `topology` \| `topology-directed` \| `degree` | - | |
44+
| radius | 圆的半径,设置了则螺旋状布局的配置`startRadius``endRadius`不生效,[说明](#radius) | number | - | |
45+
| startAngle | 布局的开始角度 | number | 0 | |
46+
| endAngle | 布局的结束角度 | number | 2 \* Math.PI | |
47+
| startRadius | 螺旋状布局的开始半径,[用法](#螺旋状布局) | number | - | |
48+
| endRadius | 螺旋状布局的结束半径 | number | - | |
49+
| width | 布局的宽度 | number | 画布宽度 | |
50+
| height | 布局的高度 | number | 画布高度 | |
6251

6352
### ordering
6453

65-
> _'topology' \| 'topology-directed' \| 'degree' \| null_ **Default:** `null`
66-
6754
节点在环上排序的依据
6855

69-
- `null`: 直接使用数据中的顺序
70-
- `'topology'`: 按照拓扑排序
71-
- `'topology-directed'`: 按照拓扑排序(有向图)
72-
- `'degree'`: 按照度数大小排序
73-
74-
### radius
75-
76-
> _number \| null_ **Default:** `null`
77-
78-
圆的半径
56+
- `topology`: 按照拓扑排序
57+
- `topology-directed`: 按照拓扑排序(有向图)
58+
- `degree`: 按照度数大小排序
7959

80-
若设置了 radius,则 startRadius 与 endRadius 不生效
60+
不配置(`null`)则直接使用数组中的顺序
8161

82-
### startAngle
62+
### radius
8363

84-
> _number_
64+
如果radius、startRadius、endRadius都没配置,则默认为最终计算出来的`Math.min(布局宽度, 布局高度) / 2`,即布满整个布局区域
8565

86-
起始角度
66+
## 代码示例
8767

88-
### startRadius
68+
### 基础环形布局
8969

90-
> _number \| null_ **Default:** `null`
70+
```javascript
71+
const graph = new Graph({
72+
// 其他配置
73+
layout: {
74+
type: 'circular',
75+
},
76+
});
77+
```
9178

92-
螺旋状布局的起始半径
79+
<Playground path="layout/circular/demo/basic.js" rid="circular-basic"></Playground>
9380

94-
### width
81+
### 螺旋状布局
9582

96-
> _number_
83+
```javascript
84+
const graph = new Graph({
85+
// 其他配置
86+
layout: {
87+
type: 'circular',
88+
startRadius: 10,
89+
endRadius: 300,
90+
},
91+
});
92+
```
9793

98-
布局的宽度
94+
<Playground path="layout/circular/demo/spiral.js" rid="circular-spiral"></Playground>

0 commit comments

Comments
 (0)