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)
    .attr("class", "nodes");

    .attr("xlink:href", '')
    .attr("height", 50)
    .attr("width", 50);

    .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