title: D3 JS Drawing bar charts
body: <p>I'm trying to draw some bar charts in JS using D3. So what I've done until now is:</p>
  
  <pre><code>var svg = d3.select("body").append("svg").attr("width", 500).attr("height", 200);
  svg.selectAll("rect").... //drawing the bars
  svg.selectAll("text").... //putting labels on top of bars
  </code></pre>
  
  <p>But when I am trying to put the labels, I need them to be in the top-middle of the bars. But to know where to put them I need to somehow reference those d3 objects for the bars... how can I do that?</p>