Multiple mode links in LayeredDigraph

Hi all,

I’m having trouble to link nodes using a function.
The code I use is:

var nodeArray = [ {key:1,name:"name1",child:[2,3]}, {key:2,name:"name2",child:[3]}, {key:3,name:"name3",child:[]}]; myDiagram.model.nodeDataArray = nodeArray; var linkArray = []; var nit = myDiagram.nodes; var nodes = new go.List(go.Node); nodes.addAll(nit); for (var i = 0; i < nodes.count; i++) { var fro = nodes.elt(i); for (var j=0; j<; j++){ var to =[j]; linkArray.push({, to:to}); } } myDiagram.model.linkDataArray = linkArray;

However, this doesn’t connect the nodes. I tried without the lists (single child per node) and this worked fine. I’m new to JS and I’m not sure how to generate a useful error message…

Any suggestions?

What link data does that code make? The values of from and to should always be the keys of the nodes – in this case only 1, 2, or 3.

Thanks Walter for your reply,

I took the idea from the layered digraph sample:Layered Digraph Layout.
It seems to be the way to access the data of the nodes.

I don’t know how to check the values of the variables (I do realize this is a very noobish thing); I write the code in a notepad and then test the code in my browser. Any suggestions on imporved debugging would be greatly appreciated.

Use the debugging facilities in each desktop browser. Search the web for how to get started, if you don’t want to figure it out yourself.

Thanks, that was actually very helpful.
I am unable to reproduce the error though, i.e., the problem is solved!

Thanks again