I've added some labels to my clustered bar chart but i'm unable to format them. I'm trying to apply a red background and white text for example.
Here is my fiddle
//labels
bars.selectAll("text")
.data(function(d) { return d.dataNew; })
.enter().append("text")
.style("color", "white")
.style("background", "red")
.attr("x", function(d) { return x1(d.name) +15 })
.attr("y",function(d) { return y(d.value) -10 })
.text(function(d) {return d.value})
I thought the .style property would suffice?
Also, is there a better way to force the labels to sit at the centre point of the bar? Currently i'm having to use return x1(d.name) +15
to nudge the text but it doesn't always look tidy