Appearance
Outline
This example shows how the outline attribute can be used to add a shadow to edges in a graph. Outlines are different from strokes as they appear on one side of the edge.
ts
import Ogma from '@linkurious/ogma';
const ogma = new Ogma({
container: 'graph-container'
});
ogma.styles.addEdgeRule({
color: '#0094ff',
outline: {
enabled: true,
color: '#30332E'
}
});
// Change the outline style of hovered edges
ogma.styles.setHoveredEdgeAttributes({
outline: {
enabled: true,
color: 'orange'
}
});
const graph = await ogma.generate.grid({ rows: 3, columns: 3 });
await ogma.setGraph(graph);
await ogma.view.locateGraph();
// Remove the outline of a specific edge
await ogma.getEdge('0')!.setAttributes({ outline: false });
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;
}