score:2

Accepted answer

You cannot append a <text> element to an <image> element. You have to append the <text> to the <g>.

The easiest solution is breaking your selection:

this.node = this.d3Graph.selectAll(null)
    .data(Nodes)
    .enter()
    .append("g")
    .attr("class", "nodes");

this.node.append("svg:image")
    .attr("xlink:href", 'https://seeklogo.com/images/T/twitter-2012-negative-logo-5C6C1F1521-seeklogo.com.png')
    .attr("height", 50)
    .attr("width", 50);

this.node.append("text")
    .attr("x", 20)
    .attr("y", 20)
    .attr("fill", "black")
    .text("test text");

Here we use the data to create <g> elements in the enter selection. Then, to each <g> element, we append an <image> and a <text> as children.


Related Query

More Query from same tag