Reputation: 740
Here is the example I'm referring to: http://bl.ocks.org/d3noob/c9b90689c1438f57d649
The second level nodes have their title to their right. How can I place those to the left of the nodes? Please help.
Upvotes: 2
Views: 1369
Reputation: 32327
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
Upvotes: 1