deduct height of text element using d3
d3.js
Solution
Use .getBBox():
> text.node().getBBox()
SVGRect {height: 17, width: 56, y: -14, x: 0}
var rect = svg.append('rect')
.attr(text.node().getBBox())
Problem
Since you can't wrap `<text>` elements with another graphical element, I'd though I'd just add a `rect` 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: ``` var text = svg.append("text") .attr({ ... }); var rect = svg.append("rect") .attr({ width: text.attr("width") + 5, height: text.attr("height") + 5 }); ``` 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.