0
我需要在此D3力导向图表中添加文本标签(来自Zoomable Force Directed Graph d3v4 link)。 但是我不明白将标签添加到圆圈和链接所需的编辑。节点标签为属性“node.label”,边缘标签为属性“edge.label”。 这d3 Node Labeling解释了需要编辑,但我一直无法得到它的工作(不幸的是,我不是一个JS程序员)。如何编辑此项,以便可以为节点添加属性“node.label”,并将“edge.label”属性添加到边缘?D3网络图:添加文字
//add encompassing group for the zoom
var g = svg.append("g")
.attr("class", "everything");
//draw lines for the links
var link = g.append("g")
.attr("class", "links")
.selectAll("line")
.data(links_data)
.enter().append("line")
.attr("stroke-width", 2)
.style("stroke", linkColour);
//draw circles for the nodes
var node = g.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(nodes_data)
.enter()
.append("circle")
.attr("r", radius)
.attr("fill", circleColour);
我使用d.name为节点,但你可以使用你的数据集属性。你可以做同样的链接。但你明白了。 –