Hi All,
I'm working w/ the example
"Force Directed Tree Layout From List", trying to understand the associative arrays that are fed into the "nodes" and "links" for a Force based diagram. My goal is to get a simple example working with in-page data that is modeled as associative arrays and my initial data structures look like:
var nodes = [
{id: "N1", name: "Node 1", type: "Type 1"},
{id: "N2", name: "Node 2", type: "Type 2"},
{id: "N3", name: "Node 3", type: "Type 3"}
];
var links = [
{source: "N1", linkName: "Relationship 1", target: "N2"},
{source: "N3", linkName: "Relationship 2", target: "N1"}
];
However, when I run the following code in the debugger:
var force = d3.layout.force()
.charge(-120)
.distance(30)
.nodes(nodes)
.links(links)
.size([w, h])
.start();
I get an error that reads "TypeError: 'undefined' is not an object (evaluating 'neighbors[o.source.index].push')". The d3.js library appears to be trying to determine neighboring nodes at failure.
Pardon my inexperience but are my data structures not laid out properly? I don't see anything in the documentation or in the forum that addresses the topic of data structure layout for Forces and I'm kind of stumped. Trying to work backwards, from the interior of the d3.js library is not easy (although I'm trying).
Thanks for any help you can offer. It's greatly appreciated,
Frank