0
我想讓點擊時D3.js節點中的文本提交GET請求。點擊D3.js節點文本時獲取請求
代碼的jsfiddle可以在這裏找到:https://jsfiddle.net/ft5107wo/2/ 我希望GET請求位於節點的JSON中的id鍵上。
我試過this solution,但沒有奏效。
用於創建矩形和附加節點文本相關的代碼是從線191到218,並且是如下:
// Create the node rectangles.
nodes.append("rect")
.attr("class", "node")
.attr("height", 40)
.attr("width", 40)
.attr("id", function (d) {
return d.id;
})
.attr("display", function (d) {
if (d.hidden) {
return "none"
} else {
return ""
};
})
.attr("x", kx)
.attr("y", ky);
// Create the node text label.
nodes.append("text")
.text(function (d) {
return d.name;
}).attr("transform", "translate(0," + 5 + ")")
.style("text-anchor", "middle")
.attr("x", tx)
.attr("y", ty)
.attr("dy", 0)
.call(wrap, 40);
如何實現這一目標?