Sigma.js lists several examples on their GitHub, but it is not clear from them what is required to load a plugin.
I have tried simply including a <script>
tag pointing to the plugin's JavaScript file but that did not work. How do I import/use/copypaste the plugin to my site?
What graph algorithms are implemented in sigma.js? None in sigma.js, but graphology has a lot, from ForceAtlas2 layout to various metrics or even community detection . You can see an overview in the documentation . Why should I use sigma.js and not d3.js?
Sigma.js is a modern JavaScript library for rendering and interacting with network graphs in the browser. It works in symbiosis with graphology, a multipurpose graph manipulation library. The most basic use case: you have a graph dataset, with colors, sizes and positions for each node. For instance, you exported a GEXF graph file from Gephi.
*X3I files taken with SFD mode are not compatible. Furthermore, X3F files taken with the SIGMA SD9, SD10, SD14, SD15 as well as DP1, DP1s, DP1x, DP2, DP2s, DP2x cannot be developed in the SIGMA X3F Plug-in for Photoshop®. Please use Adobe Camera Raw instead.
First, include the sigma-files you need:
<script src="sigma/sigma.concat.js"></script>
<script src="sigma/plugins/sigma.parseGexf.js"></script>
<script src="sigma/plugins/sigma.forceatlas2.js"></script>
Then start your script;
<script type="text/javascript">
function init() {
// Instanciate sigma.js and customize rendering :
sigInst = sigma.init(document.getElementById('graph')).drawingProperties({
defaultLabelColor: '#fff',
defaultLabelSize: 14,
defaultLabelBGColor: '#fff',
defaultLabelHoverColor: '#000',
labelThreshold: 6,
defaultEdgeType: 'curve'
}).graphProperties({
minNodeSize: 2,
maxNodeSize: 5,
minEdgeSize: 1,
maxEdgeSize: 1
}).mouseProperties({
maxRatio: 32
});
// Parse a GEXF encoded file to fill the graph
// (requires "sigma.parseGexf.js" to be included)
sigInst.parseGexf('getgefx.php');
sigInst.bind('downnodes',function(event){
var nodes = event.content;
var neighbors = {};
sigInst.iterEdges(function(e){
if(nodes.indexOf(e.source)>=0 || nodes.indexOf(e.target)>=0){
neighbors[e.source] = 1;
neighbors[e.target] = 1;
}
}).iterNodes(function(n){
if(!neighbors[n.id]){
n.attr['temphidden'] = 1;
n.attr['oldcolor'] = n.color;
// var c = sigma.tools.getRGB(n.color);
n.color = "#eee"; // #ccc";
// n.color = "rgba("+c['r']+","+c['g']+","+c['b']+",0.2)";
}
}).draw(2,2,2);
}).bind('upnodes',function(){
sigInst.iterNodes(function(n){
if(n.attr['temphidden'] == 1) {
n.color = n.attr['oldcolor'];
n.attr['temphidden'] = 0;
}
}).draw(2,2,2);
});
// Draw the graph :
sigInst.draw(2,2,2);
sigInst.startForceAtlas2();
var isRunning = true;
document.getElementById('stop-layout').addEventListener('click',function(){
if(isRunning){
isRunning = false;
sigInst.stopForceAtlas2();
document.getElementById('stop-layout').childNodes[0].nodeValue = 'Start Layout';
}else{
isRunning = true;
sigInst.startForceAtlas2();
document.getElementById('stop-layout').childNodes[0].nodeValue = 'Stop Layout';
}
},true);
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
} else {
window.onload = init;
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With