javascript - How to rotate a group of text elements -
i have fiddle : https://jsfiddle.net/thatoneguy/j0gnm5mw/1/
i have group of text elements create :
var text = container.append('g').selectall('text'); text.data(testdata).enter() .append('text') .attr('x', function(d, i) { return (i + 1) * 100; }) .attr('y', 100) .text(function(d) { return d.label; })
i try rotate :
.attr("transform", "rotate(-10)");
i have found few examples similar :
http://bl.ocks.org/mbostock/4403522
they following rotate :
.selectall("text") .attr("y", 0) .attr("x", 9) .attr("dy", ".35em") .attr("transform", "rotate(90)") .style("text-anchor", "start");
however still gives same output.
thanks @robert longson, has been solved.
i didn't realise can rotate different centre point. rotate function looks :
var thisx = (i + 1) * 100, thisy = 100 ; return "rotate(-90," + thisx + ","+ thisy+")";
updated fiddle : https://jsfiddle.net/thatoneguy/j0gnm5mw/4/
Comments
Post a Comment