D3有向图。节点作为图像

时间:2019-12-03 12:23:41

标签: javascript css angular d3.js

我正在尝试将节点插入为圆形并在其中插入图像。 这就是我到目前为止所拥有的...

现在我只为圆圈填充颜色。

    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);
      }

有什么想法吗?

0 个答案:

没有答案
相关问题