I have a graph on the screen and all the data that is needed is in a variable called jsonData, this being my way to avoid a JSON-File stored seperately on a server.
Now the jsonData contains more than i really want to show at the beginning, so I have to select the needed nodes.
The idea is to have a root node and show all the nodes directly connected with it and the conections between them.
Is there any simple possibility to do this?
Maybe I can change the line
var node = svg.selectAll(".node")
.data(jsonData.nodes)
.enter().append("g")
.attr("class", "node")
.call(force.drag);
because it doesn’t need to select all of them, but how can I pick the ones needed?
I have an array in the background that contains all the needed links and I’m up to writing a part that will store the connected nodes.
I can’t give this new array directly to the svg.selectAll-part because otherwise the links will crash (they refer to the number of the node by it’s original position in the bigger array).
Any hints on that? I couldn’t find any examples for this on via Google-research, but if you can spot something out there in the net, just feel free to answer with the link!
Thanks in advance,
David
And then
update()just deletes anything on the screen, gets the new data and rebuilds the visualisation.Just in case anyone has the same trouble… 😉