我有一棵树,我想单击一个节点并添加另一个。
但我不能。我在哪里可以从树形布局中获得更多知识?
var root = {"name": "A", "info": "tst", "children": [
......
]};
var nodes = tree(root), links , diagonal = d3.svg.diagonal();
var canvas = d3.select("body").append("svg").....
var node = canvas.selectAll(".node")
....
.on("click", function(d) {
//try add one node in this node. for example {"name":"asdf"};
}) ;
node.append("text").attr("id", function(d) {
.....
});
var diagonal = d3.svg.diagonal()
....
});
links = tree.links(nodes);
.....
.attr("d", diagonal)
;