【发布时间】:2017-06-16 11:52:38
【问题描述】:
我需要将文本标签添加到此 D3 力导向图表(来自 Zoomable Force Directed Graph d3v4 link)。 但是,我不明白向圆圈和链接添加标签所需的编辑。节点标签是属性“node.label”,边缘标签是属性“edge.label”。 这个d3 Node Labeling 解释了所需的编辑,但我无法让它工作(不幸的是,我不是 JS 程序员)。如何编辑它以便可以为节点添加属性“node.label”,并将属性“edge.label”添加到边缘?
//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);
【问题讨论】:
标签: d3.js