-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf847f5
commit 5dd3288
Showing
13 changed files
with
196 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: Force Atlas 2 | ||
order: 11 | ||
--- | ||
|
||
_It is a new feature of V3.2.2._ FA2 is a kind of force directed layout, which performs better on the convergence and compactness. | ||
|
||
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*MqwAQZLIVPwAAAAAAAAAAAAAARQnAQ' width=430 alt='img'/> | ||
|
||
```javascript | ||
const graph = new G6.Graph({ | ||
container: 'mountNode', | ||
width: 1000, | ||
height: 600, | ||
layout: { | ||
type: 'random', | ||
width: 300, | ||
height: 300, | ||
}, | ||
}); | ||
``` | ||
|
||
## layoutCfg.center | ||
|
||
**Type**: Array<br />**Example**: [ 0, 0 ]<br />**Default**: The center of the graph<br />**Required**: false<br />**Description**: The center of the layout | ||
|
||
## layoutCfg.width | ||
|
||
**Type**: Number<br />**Default**: The width of the graph<br />**Required**: false<br />**Description**: The width of the layout | ||
|
||
## layoutCfg.height | ||
|
||
**Type**: Number<br />**Default**: The height of the graph<br />**Required**: false<br />**Description**: The height of the layout | ||
|
||
## layoutCfg.workerEnabled | ||
|
||
**Type**: Boolean<br />**Default**: false<br />**Required**: false<br />**Description**: Whether to enable the web-worker in case layout calculation takes too long to block page interaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
title: Force Atlas 2 | ||
order: 11 | ||
--- | ||
|
||
*V4.2.2 新增功能。*Force Atlas 2 是一种力导向布局的变形,比 force 收敛地更好,更紧凑。 | ||
|
||
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*MqwAQZLIVPwAAAAAAAAAAAAAARQnAQ' width=430 alt='img'/> | ||
|
||
```javascript | ||
const graph = new G6.Graph({ | ||
container: 'mountNode', | ||
width: 1000, | ||
height: 600, | ||
layout: { | ||
type: 'random', | ||
width: 300, | ||
height: 300, | ||
}, | ||
}); | ||
``` | ||
|
||
## layoutCfg.center | ||
|
||
**类型**: Array<br />**示例**:[ 0, 0 ]<br />**默认值**:图的中心<br />**是否必须**:false<br />**说明**:布局的中心 | ||
|
||
## layoutCfg.width | ||
|
||
**类型**: Number<br />**默认值**:图的宽度<br />**是否必须**:false<br />**说明**:布局的宽度范围 | ||
|
||
## layoutCfg.height | ||
|
||
**类型**: Number<br />**默认值**:图的高度<br />**是否必须**:false<br />**说明**:布局的高度范围 | ||
|
||
## layoutCfg.workerEnabled | ||
|
||
**类型**: Boolean<br />**默认值**: false<br />**是否必须**: false<br />**说明**: 是否启用 web-worker 以防布局计算时间过长阻塞页面交互 | ||
|
||
## layoutCfg.kr | ||
|
||
**类型**: Number<br />**默认值**:5<br />**是否必须**:false<br />**说明**:斥力系数,可用于调整布局的紧凑程度。kr 越大,布局越松散 | ||
|
||
## layoutCfg.kg | ||
|
||
**类型**: Number<br />**默认值**:5<br />**是否必须**:false<br />**说明**:重力系数。kg 越大,布局越聚集在中心 | ||
|
||
## layoutCfg.ks | ||
|
||
**类型**: Number<br />**默认值**:0.1<br />**是否必须**:false<br />**说明**:控制迭代过程中,节点移动的速度 | ||
|
||
## layoutCfg.tao | ||
|
||
**类型**: Number<br />**默认值**:0.1<br />**是否必须**:false<br />**说明**:迭代接近收敛时停止震荡的容忍度 | ||
|
||
## layoutCfg.mode | ||
|
||
**类型**: 'normal' | 'linlog'<br />**默认值**:'normal'<br />**是否必须**:false<br />**说明**:'normal' 模式下,聚类将更加紧凑 | ||
|
||
## layoutCfg.preventOverlap | ||
|
||
**类型**: boolean<br />**默认值**:false<br />**是否必须**:false<br />**说明**:是否防止节点重叠 | ||
|
||
## layoutCfg.dissuadeHubs | ||
|
||
**类型**: boolean<br />**默认值**:false<br />**是否必须**:false<br />**说明**:是否打开 hub 模式。若为 true,相比与出度大的节点,入度大的节点将会有更高的优先级被放置在中心位置 | ||
|
||
## layoutCfg.barnesHut | ||
|
||
**类型**: boolean<br />**默认值**:false<br />**是否必须**:false<br />**说明**:是否打开 barnes hut 加速,即四叉树加速。由于每次迭代需要更新构建四叉树,建议在较大规模图上打开 | ||
|
||
## layoutCfg.prune | ||
|
||
**类型**: boolean<br />**默认值**:false<br />**是否必须**:false<br />**说明**:是否开启自动剪枝模式。默认情况下,当节点数量大于 100 时它将会被激活。注意,剪枝能够提高收敛速度,但可能会降低图的布局质量 | ||
|
||
## layoutCfg.maxIteration | ||
|
||
**类型**: number<br />**默认值**:0<br />**是否必须**:false<br />**说明**:最大迭代次数,若为 0 则将自动调整 | ||
|
||
## layoutCfg.getWidth | ||
|
||
**类型**: function<br />**默认值**:undefined<br />**是否必须**:false<br />**说明**:节点宽度的函数,参数为节点数据 | ||
|
||
## layoutCfg.getHeight | ||
|
||
**类型**: function<br />**默认值**:undefined<br />**是否必须**:false<br />**说明**:节点高度的函数,参数为节点数据 | ||
|
||
## layoutCfg.onLayoutEnd | ||
|
||
**类型**: function<br />**默认值**:undefined<br />**是否必须**:false<br />**说明**:布局结束后的回调函数 | ||
|
||
## layoutCfg.onTick | ||
|
||
**类型**: function<br />**默认值**:undefined<br />**是否必须**:false<br />**说明**:布局每次迭代的回调函数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import G6 from '@antv/g6'; | ||
|
||
const container = document.getElementById('container'); | ||
const width = container.scrollWidth; | ||
const height = container.scrollHeight || 500; | ||
const graph = new G6.Graph({ | ||
container: 'container', | ||
width, | ||
height, | ||
modes: { | ||
default: ['zoom-canvas', 'drag-canvas', 'drag-node'], | ||
}, | ||
layout: { | ||
type: 'forceAtlas2', | ||
preventOverlap: true, | ||
kr: 10, | ||
center: [250, 250], | ||
}, | ||
defaultNode: { | ||
size: 20, | ||
}, | ||
}); | ||
|
||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json') | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
data.nodes.forEach(node => { | ||
node.x = Math.random() * 1; | ||
}); | ||
graph.on('afterlayout', e => { | ||
graph.fitView() | ||
}) | ||
graph.data(data); | ||
graph.render(); | ||
}); | ||
|
||
if (typeof window !== 'undefined') | ||
window.onresize = () => { | ||
if (!graph || graph.get('destroyed')) return; | ||
if (!container || !container.scrollWidth || !container.scrollHeight) return; | ||
graph.changeSize(container.scrollWidth, container.scrollHeight); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters