I wish to load a JSON data array from within a file to generate a collapsible tree diagram per the Mike Bostock example here. The example uses a correctly formatted external
You are very close, all you need to do is set the treeData you created as the root of the tree. So instead of loading the JSON data, you would do:
// replace this line
// d3.json("/d/4063550/flare.json", function(error, flare) {
root = treeData[0];
root.x0 = height / 2;
root.y0 = 0;
function collapse(d) {
if (d.children) {
d._children = d.children;
d._children.forEach(collapse);
d.children = null;
}
}
root.children.forEach(collapse);
update(root);
//remove this line
// });