Local Radial
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'
});
// Generate a balanced tree graph
ogma.generate.balancedTree({
children : 2,
height: 6
}).then(function (graph) {
// Assign it to Ogma
ogma.setGraph(graph);
ogma.view.locateGraph();
// Remove the root node
ogma.removeNode(0);
// Get the right tree and show its root in orange
ogma.getNode(2).setAttributes({color:'orange'});
var rightTree = ogma.getNode(2).getConnectedComponent(2);
// Apply a radial layout on the root node of the right tree
ogma.layouts.radial({
centralNode: 2,
nodes: rightTree,
radiusDelta:20
}, {
duration: 1000,
onEnd: function () {
ogma.view.locateGraph({ duration: 300 });
}
});
});
</script>
</body>
</html>