score:1

Accepted answer

This is how you make text to the nodes.

  node.append("text")
      .attr("x", -6)
      .attr("y", function(d) { return d.dy / 2; })
      .attr("dy", ".35em")
      .attr("text-anchor", "end")
      .attr("transform", null)
      .text(function(d) { return d.name; })
      .filter(function(d) { return d.x < width / 2; })
      .attr("x", 6 + sankey.nodeWidth())
      .attr("text-anchor", "start");

For making the text on the right always do :

  node.append("text")
      .attr("x", -6)
      .attr("y", function(d) { return d.dy / 2; })
      .attr("dy", ".35em")
      .attr("text-anchor", "end")
      .attr("transform", null)
      .text(function(d) { return d.name; })
    //.filter(function(d) { return d.x < width / 2; }) //COMMENT THIS LINE
      .attr("x", 6 + sankey.nodeWidth())
      .attr("text-anchor", "start");

Comment the line shown above so that it does not filter the nodes > half of width SVG.

working code here


Related Query

More Query from same tag