convenience functions for analysis of d3.layout.force().links() arrays.
Want to see pretty graphs? Log in now!
npm install d3.force-link-status
|1||downloads in the last week|
|9||downloads in the last month|
|Last Published By|
|Version||0.1.0 last updated 5 months ago|
|Keywords||d3, force, d3.layout.force, layout, graph, directed, simple|
A very small module so you can stop thinking about certain repetetive
operations while managing d3js force directed graphs
Status is designed to work with d3, although it should work for anything which
imnplements a similar API, meaning the force argument has a
method which returns an incidince list of the edges in the graph. In any event,
you need a few things before we can et started:
var Status = require('d3.force-link-status') , d3 = require('d3') /* A few parameters */ var loops = false // node cannot link to itself , directed = false // link from A to B == link from B to A , multiedge = false // at most one link between nodes A and B. var s = new Status(loops, directed, multiedge) var force = d3.layout.force() /* Supposing you've defined links and nodes somewhere. */ force .links(links_array) .nodes(nodes_array) var one_link = // a link , another_link = // another link /* start the layout -- this gives the nodes an index. although their positions * wont update until the first tick. */ force.start()
Checking for equality will respect your settings:
A method to easily find the index of the link in the force. Mimics the api of Array#indexOf api.
There is a convenient membership check:
s.has(another_link, force) // -> true or false
And finally a method to count the number of times a link appears (useful when
multiedge == true.
Is very short and available here