code: function wrap(text, width, wrapSplitter) {
    var lineHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.2;
  
    text.each(function () {
      var text = select(this),
          words = text.text().split(wrapSplitter || /[ \t\r\n]+/).reverse().filter(function (w) {
        return w !== "";
      });
      var word = void 0,
          line$$1 = [],
          tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", 0.8 + "em");
  
      while (word = words.pop()) {
        line$$1.push(word);
        tspan.text(line$$1.join(" "));
        if (tspan.node().getComputedTextLength() > width && line$$1.length > 1) {
          line$$1.pop();
          tspan.text(line$$1.join(" "));
          line$$1 = [word];
          tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + "em").text(word);
        }
      }
    });
  }
docs: Text wrapping code adapted from Mike Bostock