我正在使用可折叠的树从上到下定向。在这里,我遇到了一些问题。使用 d3.v3.js 实现树。如何将复选框附加到每个节点的树中。
// Create the link lines.
svg.selectAll(".link")
.data(links)
.enter().append("path")
.attr("class", "link")
.attr("d", d3.svg.diagonal().projection(function(d) { return [o.x(d)+15, o.y(d)]; }));
svg.selectAll("input")
.data(nodes)
.enter().append("foreignObject")
.attr('x' , o.x)
.attr('y', o.y)
.attr('width', 50)
.attr('height', 20)
.append("xhtml:body")
.html("<form><input type=checkbox id=check></input></form>")
.on("click", function(d, i){
console.log(svg.select("#check").node().checked)
}) ;
svg.selectAll("image")
.data(nodes)
.enter().append("image")
.attr('x' , o.x)
.attr('y', o.y)
.attr('width', 30)
.attr('height', 20)
.attr("xlink:href", "check.png")
});
});
附加到 svg 但在浏览器中不可见的复选框。任何人都请帮我解决这个问题