src/charts/tooltip.js
/**
         * Wraps a text given the text, width, x position and textFormatter function
         * @param  {D3Selection} text  Selection with the text to wrap inside
         * @param  {Number} width Desired max width for that line
         * @param  {Number} xpos  Initial x position of the text
         *
         * REF: http://bl.ocks.org/mbostock/7555321
         * More discussions on https://github.com/mbostock/d3/issues/1642
         */
Wraps a text given the text, width, x position and textFormatter function
@param  {D3Selection} text  Selection with the text to wrap inside
@param  {Number} width Desired max width for that line
@param  {Number} xpos  Initial x position of the text


Wraps a text given the text width x position and textFormatter function @param { D3Selection } text Selection with the text to wrap inside @param { Number } width Desired max width for that line @param { Number } xpos Initial x position of the text
function textWrap(text, width, xpos) {
            xpos = xpos || 0;
            text.each(function() {
                var words,
                    word,
                    line,
                    lineNumber,
                    lineHeight,
                    y,
                    dy,
                    tspan;
                text = d3Selection.select(this);
                words = text.text().split(/\s+/).reverse();
                line = [];
                lineNumber = 0;
                lineHeight = 1.2;
                y = text.attr('y');
                dy = parseFloat(text.attr('dy'));
                tspan = text
                    .text(null)
                    .append('tspan')
                    .attr('x', xpos)
                    .attr('y', y)
                    .attr('dy', dy + 'em');
                while ((word = words.pop())) {
                    line.push(word);
                    tspan.text(line.join(' '));
                    if (tspan.node().getComputedTextLength() > width) {
                        line.pop();
                        tspan.text(line.join(' '));
                        if (lineNumber < entryLineLimit - 1) {
                            line = [word];
                            tspan = text.append('tspan')
                                .attr('x', xpos)
                                .attr('y', y)
                                .attr('dy', ++lineNumber * lineHeight + dy + 'em')
                                .text(word);
                        }
                    }
                }
            });
        }
function textWrap ( text , width , xpos ) { xpos = xpos || 0 ; text . each ( function ( ) { var words , word , line , lineNumber , lineHeight , y , dy , tspan ; text = d3Selection . select ( this ) ; words = text . text ( ) . split ( / \s+ / ) . reverse ( ) ; line = [ ] ; lineNumber = 0 ; lineHeight = 1.2 ; y = text . attr ( 'y' ) ; dy = parseFloat ( text . attr ( 'dy' ) ) ; tspan = text . text ( null ) . append ( 'tspan' ) . attr ( 'x' , xpos ) . attr ( 'y' , y ) . attr ( 'dy' , dy + 'em' ) ; while ( ( word = words . pop ( ) ) ) { line . push ( word ) ; tspan . text ( line . join ( ' ' ) ) ; if ( tspan . node ( ) . getComputedTextLength ( ) > width ) { line . pop ( ) ; tspan . text ( line . join ( ' ' ) ) ; if ( lineNumber < entryLineLimit - 1 ) { line = [ word ] ; tspan = text . append ( 'tspan' ) . attr ( 'x' , xpos ) . attr ( 'y' , y ) . attr ( 'dy' , ++ lineNumber * lineHeight + dy + 'em' ) . text ( word ) ; } } } } ) ; }
Wraps a text given the text, width, x position and textFormatter function
 @param  {D3Selection} text  Selection with the text to wrap inside
 @param  {Number} width Desired max width for that line
 @param  {Number} xpos  Initial x position of the text
Wraps a text given the text width x position and textFormatter function @param { D3Selection } text Selection with the text to wrap inside @param { Number } width Desired max width for that line @param { Number } xpos Initial x position of the text