[英]Convert text header of image appended to node in typical graph of nodes and link, to image in D3
我想將標題添加到d3中的節點。 但是,我不想將其附加為文本,而是希望將其附加為圖像,以便在圖形方案中所有行都位於標題下方,圖片看起來更清晰。
目前由於許多鏈接,圖片看起來很亂,我想避免。
node.append('text')
.attr("class","label")
.attr("style","font-size:12px;")
.html(function(d){
return d.name;
}
})
.attr("x",0)
.attr("y",-radius);
有什么辦法可以做到這一點。 我讀過有關隱藏的畫布的信息,但由於我是D3的初學者,因此不確定確切的用法。
謝謝
您也可以附加圖像 。
我在這里設置了一個小提琴 ,以演示在圓內附加圖像(圖標)的工作示例。
node.append("circle")
.attr("cursor","pointer")
.attr("cx", 200)
.attr("cy", 200)
.attr("r", 25)
.style("fill","white")
.style("stroke", "black")
.style("stroke-width", 2);
node.append("image")
.attr("xlink:href", "http://i.stack.imgur.com/bZXWH.png")
.attr("x", 185)
.attr("y", 185)
.attr("width", 32)
.attr("height", 32);
您可能還會發現本教程很有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.