我正在尝试将节点插入为圆形并在其中插入图像。 这就是我到目前为止所拥有的...
现在我只为圆圈填充颜色。
private updateNode() {
// UPDATE
this.node = this.node.data(this.data.nodes, (d) => d.id);
// EXIT
this.node.exit().remove();
// ENTER
const newNode = this.node.enter().append('circle')
.attr('class', (d) => `node ${d.id}`)
.attr('fill', (d) => this.getColor(d.group))
.attr('r', (d) => this.radius + d.group)
.call(d3.drag()
.on('start', (e) => { this.dragStarted(e); })
.on('drag', (e) => { this.dragged(e); })
.on('end', (e) => { this.dragEnded(e); })
);
newNode.append('title')
.text((d) => 'group: ' + d.group + '\n' + 'id: ' + d.id);
this.node = this.node.merge(newNode);
}
有什么想法吗?