Appearance
Size
This example shows how to use the size attribute on nodes and edges texts.
ts
import Ogma from '@linkurious/ogma';
const ogma = new Ogma({
container: 'graph-container'
});
ogma.styles.addNodeRule({
text: {
content: n => n.getId(),
color: '#6a6',
scaling: true, // if true, node text is proportional to node size
size: node => 5 + +node.getId() * 5, // applied if scaling is false
scale: node => 0.25 + 0.1 * +node.getId(), // applied if scaling is true
minVisibleSize: 7
}
});
ogma.styles.addEdgeRule({
text: {
color: '#0094ff',
content: e => e.getId(),
scaling: true, // if true, node text is proportional to node size
size: 12, // applied if scaling is false
scale: edge => 5 - +edge.getId(), // applied if scaling is true
minVisibleSize: 3
}
});
const graph = await ogma.generate.grid({ columns: 5, rows: 1 });
await ogma.setGraph(graph);
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;
}