title: Align text node centrally(horizontally) inside group element
body: <p>I have this group element and a text node inside it:</p>
  
  <pre><code>var legend = svg_container.append('g');
  var legend_text = legend.append('text').attr('y', 0)
  //other elements inside 'g'
  </code></pre>
  
  <p>This is just part of the code. In actuality, I have other child nodes inside the group element created on the fly after the text node(these other elements decide the width of the group element).</p>
  
  <p>How do I position the text node centrally inside the group element?</p>