I'm currently looking at building a tree layout from a CSV file using the d3.layout.tree module. I am able to replicate the answer given here. Yet by simply modifying the data to look like:
source,target
A0,A1
A0,A2
A1,A2
A2,A3
A2,A4
we find that after calling tree.node(links) we get the following sample output (from Chrome Dev console) for the first element in the link array
Object
source: Object
children: Array[2]
depth: 0
name: "A0"
x: NaN
y: 0
__proto__: Object
target: Object
children: Array[1]
depth: 1
name: "A1"
parent: Object
x: NaN
y: 440
__proto__: Object
__proto__: Object
and the corresponding node array is:
Object
children: Array[2]
0: Object
1: Object
length: 2
__proto__: Array[0]
depth: 0
name: "A0"
x: NaN
y: 0
__proto__: Object
Notice it includes "NaN" values in the "x" field. I am unable to determine why this example does not produce A0 is the root with two children (A1,A2) like A2 does for (A3,A4). Appreciate any help, really love D3. Clearly this means I will not get the desired tree, how do I construct the tree data structure to provide the desired tree?