function textWrap(text, width, 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(' '));

                    // fixes for IE wrap text issue
                    const textWidth = getTextWidth(line.join(' '), 16, 'Karla, sans-serif');

                    if (textWidth > 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
REF: http://bl.ocks.org/mbostock/7555321
More discussions on https://github.com/mbostock/d3/issues/1642
@private