2016-06-22 43 views

回答

0

這就是你如何使節點的文本。

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"); 

爲了使在右側的文本總是這樣:上面顯示

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"); 

註釋行,以便它不過濾的節點>寬度SVG的一半。

工作代碼here

+1

謝謝你:) – d33a

相關問題