Stroke
Nodes have two strokes: the inner stroke (controlled by the innerStroke attribute) and
the outer stroke (controlled by the outerStroke attribute).
Open in a new window.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../build/ogma.min.js"></script>
<style>
#graph-container { top: 0; bottom: 0; left: 0; right: 0; position: absolute; margin: 0; overflow: hidden; }
</style>
</head>
<body>
<div id="graph-container"></div>
<script>
'use strict';
var ogma = new Ogma({
container: 'graph-container'
});
// Define the default stroke appearance
// innerStroke is the node border
ogma.styles.addNodeRule({
innerStroke: {
color: 'black',
width: 2,
minVisibleSize: 5
}
});
// Define the stroke appearance on hover
ogma.styles.setHoveredNodeAttributes({
outerStroke: {
width: 10,
color: 'red'
}
});
// Define the stroke appearance on selection
ogma.styles.setSelectedNodeAttributes({
innerStroke: {
color: 'white'
},
outerStroke: {
width: 7,
color: 'red'
}
});
// Generate a random graph and assign it to Ogma
ogma.generate.random({
nodes: 10,
edges: 5
}).then(function(graph) {
ogma.setGraph(graph);
ogma.view.locateGraph();
});
</script>
</body>
</html>