score:1

Accepted answer

in your code translate function x and y values are hard coded that is why it is causing the issue

edit:1

 var labels = svg
    .selectall("mylabels")
    .data(data.nodes)
    .enter()
    .append("text")
      .attr("x", function(d){ return(0)})
      .attr("y", 0)
      .text(function(d){ return(d.name)})
      .attr("transform", function(d){ console.log(d); return( "translate(" + (x(d.name)) + ", " + (height-15) + ") rotate(-45)")})
.style("text-anchor", "middle")

above changes will work


Related Query

More Query from same tag