I am trying to adapt this Chord diagram by Mike Bostock:
I want to have the text labels rotating outwards like this chord diagram:
http://bost.ocks.org/mike/uberdata/
There is an example here
http://bl.ocks.org/mbostock/910126
However, the transformation is done using the svg:text :
g.append("svg:text")
.each(function(d) { d.angle = (d.startAngle + d.endAngle) / 2; })
.attr("dy", ".35em")
.attr("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; })
.attr("transform", function(d) {
return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")"
+ "translate(" + (r0 + 26) + ")"
+ (d.angle > Math.PI ? "rotate(180)" : "");
})
.text(function(d) { return nameByIndex[d.index]; });
The one I am trying to adapt uses "text" and "textPath" and I don't seem to be able to simply add a transform/rotate attribute. Adding this line
.attr("transform",function(d,i){return "rotate(90)";})
to the code below does nothing:
// Add a text label.
var groupText = group.append("text")
.attr("x", 6)
.attr("dy", 15);
groupText.append("textPath")
.attr("xlink:href", function(d, i) { return "#group" + i; })
.text(function(d, i) { return cities[i].country; });
Any ideas how I can rotate the text outwards so smaller chord groups text labels can be displayed without being bunched up or (as is the orginal solution) turned off altogether?