I'm fairly new to d3 but this seems like a fairly simple question that I can't find the answer to. Maybe I'm just missing something fundamental. Anyway, any help is much appreciated.
I've create circles in my svg and I want to label them with text, which I have accomplished, but the text overlaps, so I want to rotate the text 45 degrees (technically 315 degrees). Here is a snippet of my code to attempt this:
var texts = svg.selectAll("text")
.data(data)
.enter()
.append("text")
.attr ("x",function(d, i) { return (i * 30) + 50;})
.attr ("y",function(d) { return 250 - (d.some_var * 50);})
.attr("rotate", 315)
.text(function(d){ return d.name; });
Weirdly though, this rotates each letter in the word instead of rotating the whole word. Screenshot is attached.
What am I missing here? Thanks for any direction!