d3.js how to dynamically add nodes to a tree

I was able to dynamically add nodes by adding the following code in the toggle function:

$.getJSON(addthese.json, function(addTheseJSON) {
    var newnodes = tree.nodes(addTheseJSON.children).reverse();
    d.children = newnodes[0];
    update(d);
});

Notes: I am using jQuery to retrieve the json file

Leave a Comment