-
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.
chore: opt the layout of force-directed graph (#5484)
* chore: opt the layout of force-directed graph * fix: resolve conversation
- Loading branch information
Showing
6 changed files
with
67 additions
and
407 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,21 @@ | ||
import { Graph, Extensions, extend } from '@antv/g6'; | ||
|
||
const ExtGraph = extend(Graph, { | ||
layouts: { | ||
forceAtlas2: Extensions.ForceAtlas2Layout, | ||
}, | ||
}); | ||
|
||
const container = document.getElementById('container'); | ||
const width = container.scrollWidth; | ||
const height = container.scrollHeight || 500; | ||
import { Graph } from '@antv/g6'; | ||
|
||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json') | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
const graph = new ExtGraph({ | ||
const graph = new Graph({ | ||
container: 'container', | ||
width, | ||
height, | ||
transforms: [ | ||
{ | ||
type: 'transform-v4-data', | ||
activeLifecycle: ['read'], | ||
}, | ||
], | ||
modes: { | ||
default: ['zoom-canvas', 'drag-canvas', 'drag-node', 'click-select'], | ||
}, | ||
data, | ||
layout: { | ||
type: 'forceAtlas2', | ||
type: 'force-atlas2', | ||
preventOverlap: true, | ||
kr: 20, | ||
center: [250, 250], | ||
}, | ||
autoFit: 'view', | ||
data, | ||
behaviors: ['zoom-canvas', 'drag-canvas'], | ||
autoResize: true, | ||
zoomRange: [0.1, 5], | ||
}); | ||
window.graph = graph; | ||
|
||
graph.render(); | ||
}); |
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
155 changes: 0 additions & 155 deletions
155
packages/site/examples/net/forceDirected/demo/forceBubbles.js
This file was deleted.
Oops, something went wrong.
80 changes: 0 additions & 80 deletions
80
packages/site/examples/net/forceDirected/demo/forceConstrainedInRect.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.