Appearance
ForceLink
This example shows the legacy force-link layout algorithm. It is much slower than the new version but can give good results on very small graphs.
ts
import Ogma from '@linkurious/ogma';
const ogma = new Ogma({
container: 'graph-container'
});
ogma.events.on('layoutStart', layout => console.log('Layout started', layout));
ogma.events.on('layoutEnd', layout => console.log('Layout done', layout));
ogma.generate
.barabasiAlbert({
nodes: 100,
m0: 10,
m: 1
})
.then(graph => {
ogma.setGraph(graph);
ogma.view.locateGraph();
ogma.layouts.forceLink().then(() => {
ogma.view.locateGraph({
easing: 'linear',
duration: 300
});
});
});
html
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="graph-container"></div>
<script type="module" src="index.ts"></script>
</body>
</html>
css
#graph-container {
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
margin: 0;
overflow: hidden;
}