I\'m trying to add data labels to stacked bar chart in d3.
I wanted the data labels to be in the middle of the bar. So far i just figured out how to add data labels
You just need to adjust the y coordinate of the text elements:
y
text
circle.selectAll("text") .data(function(d) { return d.hours; }) .enter() .append("text") .attr("x", 75) .attr("y", function(d, i) { return y(d.y1) + (y(d.y0) - y(d.y1))/2; }) .style("text-anchor", "middle") .text("test")