Created
March 26, 2012 20:57
-
-
Save jacomyal/2209633 to your computer and use it in GitHub Desktop.
sigma.js - How to programmatically adjust the size of the nodes based on the number of outbound edges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add the function to the public prototype : | |
*/ | |
sigma.publicPrototype.outDegreeToSize = function() { | |
this.iterNodes(function(node){ | |
node.size = node.outDegree; | |
}).draw(); | |
}; | |
/* | |
Of course, it works as well with node.degree and node.inDegree. | |
How to test it: | |
1. Open any sigma example - http://sigmajs.org/examples.html | |
2. Open a console - http://bit.ly/GVshi6 | |
3. Enter the previous code | |
4. Try it on the first sigma.js instance on the page: | |
sigma.instances[1].outDegreeToSize(); | |
Also, if you want to choose the minimum/maximum node sizes: | |
sigma.instances[1].graphProperties({ | |
minNodeSize: 1, | |
maxNodeSize: 3 | |
}); | |
*/ |
First, I am trying sigma.instances()
, but this method is not working without id:
TypeError: Object #<Object> has no method 'extends'
This is throwing an error:"sigma.publicPrototype is undefined".What to do?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did this change with v1.0.0? I am opening examples/basic.html but I am getting one error. I will post what I do.