Created
October 1, 2014 11:42
-
-
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
This file contains hidden or 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
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