Performance (Cosmic Web)
It loads a large graph exported from the Gephi software. The dataset comes from the "Cosmic Web" study of the network of
galaxies. See cosmicweb.barabasilab.com.
Open in a new window.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../build/ogma.min.js"></script>
<style>
body { background-color: #000; }
#graph-container { top: 0; bottom: 0; left: 0; right: 0; position: absolute; margin: 0; overflow: hidden; }
.info {
position: absolute;
color: #fff;
background: #141229;
font-size: 12px;
font-family: monospace;
padding: 5px;
}
.info.n { top: 0; left: 0; }
.info.e { top: 20px; left: 0; }
</style>
</head>
<body>
<div id="graph-container"></div>
<div id="n" class="info n">loading a large graph, it can take a few seconds...</div>
<div id="e" class="info e"></div>
<script>
'use strict';
var ogma = new Ogma({
container: 'graph-container'
});
ogma.setOptions({
detect: {
// disable the detection of edges and texts, making them impossible to hover or select.
// edges: false,
// nodes: false,
nodeTexts: false,
edgeTexts: false
},
interactions: {
drag: {
//enabled: false // disable node dragging
}
}
});
ogma.styles.addNodeRule({
text: {
size: 12,
content: function(node) { return node.getId(); }
},
innerStroke: {
minVisibleSize: 5,
width: 1,
color: 'black'
}
});
ogma.styles.addEdgeRule({
minVisibleSize: 0.3,
color: 'source'
});
ogma.parse.gexfFromUrl('files/ccnr-universe-fa2-ncolorModularity-nsizeBeteewnessCentrality.gexf').then(function(g) {
ogma.setGraph(g);
ogma.view.locateGraph();
document.getElementById('n').textContent = 'nodes: ' + ogma.getNodes().size;
document.getElementById('e').textContent = 'edges: ' + ogma.getEdges().size;
});
// TODO: highlight neighbors or selected node
</script>
</body>
</html>