title: deduct height of text element using d3
body: <p>Since you can't wrap <code>&lt;text&gt;</code> elements with another graphical element, I'd though I'd just add a <code>rect</code> element on a similar coordinates to wrap the text in a rectangular border. However, I'd like to calculate the width and height of that rectangular according to that of the text (which changes). So, something like this:</p>
  
  <pre><code>var text = svg.append("text")
      .attr({ ... });
  
  var rect = svg.append("rect")
      .attr({
          width: text.attr("width") + 5,
          height: text.attr("height") + 5
      });
  </code></pre>
  
  <p>Only that doesn't work. How can I grab the height and width of a text element (if at all)? I searched around Google and SO and didn't find any similar questions on the subject.</p>