Accepted answer

You are appending the text to rect elements -- this isn't valid in SVG and the text won't show up. Instead, append the text either to a g element or the top-level SVG:

  .attr("class", "bar")
  .attr("text-anchor", "middle")
  .attr("x", function(d) { return x(d.letter); })
  .attr("y", function(d) { return y(d.frequency) - 10; })
  .text(function(d) { return d.frequency; });

Complete demo here.

Related Query

More Query from same tag