dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.86k stars 591 forks source link

Cannot set edges in nodes which are defined as parents. #261

Open keizer619 opened 8 years ago

keizer619 commented 8 years ago

Imagine there are 3 nodes namely node1, node2 and node3. Then set node3 as the parent of node2. Then i need to create an edge from from node1 to node3. I wrote following code and it gives TypeError: label is undefined.

g.setNode("node1", {label: "node2"}); g.setNode("node2", {label: "node2"}); g.setNode("node3", {label: "node3", clusterLabelPos: "top", style: "fill: #ffd47f"}); g.setParent("node2", "node3"); g.setEdge("node1", "node3");

if i comment g.setParent('node2', 'node3'); or g.setEdge('node1', 'node3'); graph will be drawn. Apparently we cannot do both for a node.

https://jsfiddle.net/keizer619/6f1dxpa2/