src/charts/helpers/text.js
function(text, fontSize = defaultTextSize, fontFace = defaultFontFace) {
        let a = document.createElement('canvas'),
            b = a.getContext('2d');

        b.font = fontSize + 'px ' + fontFace;

        return b.measureText(text).width;
    }
function(text, fontSize = defaultTextSize, fontFace = defaultFontFace) {
        let a = document.createElement('canvas'),
            b = a.getContext('2d');

        b.font = fontSize + 'px ' + fontFace;

        return b.measureText(text).width;
    }
function ( text , fontSize = defaultTextSize , fontFace = defaultFontFace ) { let a = document . createElement ( 'canvas' ) , b = a . getContext ( '2d' ) ; b . font = fontSize + 'px ' + fontFace ; return b . measureText ( text ) . width ; }
Figures out an approximate of the text width by using a canvas element
This avoids having to actually render the text to measure it from the DOM itself
@param  {String} text                Text to measure
@param  {Number} [fontSize=12]       Font size (or default)
@param  {String} [fontFace='Arial']  Font family to use in the calculation (or default)
@return {String}                     Approximated width of the text
Figures out an approximate of the text width by using a canvas element This avoids having to actually render the text to measure it from the DOM itself