d3-measure-text
A JavaScript component to measure the the width and height of SVG text.
Why?
If you're creating a graph with SVG, it's especially nice to know the size of the axis labels' text so that you can position the graph appropriately.
Install
Node.js/Browserify
npm install --save d3-measure-text
Component
component install jprichardson/d3-measure-text
Bower
bower install d3-measure-text
Script
Usage
d3MeasureText(text, [className])
var d3MeasureText = d3MeasureTextd3 = d3 //<--- set d3 if it's not global. var dim = consoledirdim //{width: 33, height: 12}
Credits
This code is modified from Bill's answer on StackOverflow.
License
(MIT License)
Copyright 2013, JP Richardson jprichardson@gmail.com