我正在從可伸縮的樹頂部到底部使用。我在這裏遇到了一些問題。 爲了實現使用d3.v3.js的樹。我如何追加複選框到每個節點的樹中。D3 v3追加複選框?
// 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但在瀏覽器中不可見。有人請幫我解決這個問題
我正在尋找附加與圖像相關的每個點的複選框。用戶可以通過單擊複選框來選擇特定圖像。 –