How would I set the depth between parent and child nodes for specified child nodes in a tree?
For example, the code below sets the depth between parent and child nodes for the whole tree:
nodes.forEach(function(d) {
d.y = (d.depth === 0 ? 50 : d.depth * 230);
});
So in the JSON example below, set the depth for d.name = "Son of Child 2", with the others at a default depth?
var treeData =
{
"name": "Top Level",
"children": [
{
"name": "Child 1",
"children": [
{ "name": "Son of Child 1" },
{ "name": "Daughter of Child 1" }
]
},
{ "name": "Child 2",
"children": [
{ "name": "Son of Child 2" },
{ "name": "Daughter of Child 2" }
] }
]
};
See fiddle
