Appearance
Tree
This example shows how to generate a balanced tree using the balancedtree method.
ts
import Ogma from '@linkurious/ogma';
const ogma = new Ogma({
container: 'graph-container'
});
// pastel dark blue color for nodes
ogma.styles.addNodeRule({
color: '#122140'
});
const graph = await ogma.generate.balancedTree({
children: 2,
height: 4
});
await ogma.setGraph(graph);
await ogma.view.locateGraph();
document.getElementById('load')?.remove();
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>
<span id="load">Loading...</span>
<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;
}
#load {
position: absolute;
top: 0;
left: 0;
padding: 5px;
color: #fff;
background: #141229;
font-size: 12px;
font-family: monospace;
}