Skip to content

Instantly share code, notes, and snippets.

@javedulu
Created October 1, 2014 11:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save javedulu/9eadfb987fba070c5c84 to your computer and use it in GitHub Desktop.
Save javedulu/9eadfb987fba070c5c84 to your computer and use it in GitHub Desktop.
Adding Dynamic content to d3.js tree on click of child node : http://bl.ocks.org/d3noob/8375092
function click(d) {
if (!d.children && !d._children)
{
d3.json("http://xxxx:2222/getChildNodes", function(error,response) {
response.children.forEach(function(child){
if (!tree.nodes(d)[0]._children){
tree.nodes(d)[0]._children = [];
}
child.x = d.x0;
child.y = d.y0;
tree.nodes(d)[0]._children.push(child);
});
if (d.children) {
d._children = d.children;
d.children = null;
}
else {
d.children = d._children;
d._children = null;
}
update(d);
});
}
if (d.children) {
d._children = d.children;
d.children = null;
}
else {
d.children = d._children;
d._children = null;
}
update(d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment