title: How to limit the text of polygons in Voronoi diagram with D3.js?
body: <p>I've see the Example of D3.js-<a href="http://bl.ocks.org/mbostock/4060366" rel="nofollow">Voronoi Tessellation</a>.But I want to put some text in each of polygons instead of a circle,Here is my js code:</p>
  
  <pre><code>var width = 600, height = 400;
  
  var vertices = d3.range(20).map(function(d){
    return [Math.random() * width, Math.random() * height]
  });
  
  var voronoi = d3.geom.voronoi();
  
  var svg = d3.select("body").append("svg")
      .attr("width", width)
      .attr("height", height);
  
  path = svg.append("g").selectAll("path");
  
  svg.selectAll("info")
      .data(vertices.slice(1))
      .enter().append("text")
      .attr("transform", function(d) {
        return "translate(" + d + ")";
      })
      .text("someText")
      .attr("shape-rendering","crispEdges")
      .style("text-anchor","middle");
  
  redraw();
  
  function redraw(){
    path = path
        .data(voronoi(vertices), polygon);
  
    path.exit().remove();
  
    path.enter().append("path")
        .attr("class", function(d, i) {return "q" + (i % 9) + "-9";})
        .attr("d", polygon);
  
    path.order();
  }
  
  function polygon(d){
    return "M" + d.join("L") + "Z";
  }
  </code></pre>
  
  <p>I have a JSFiddle for that basic example here:
  <a href="http://jsfiddle.net/MockingBird/aEtmq/" rel="nofollow">my voronoi code</a></p>
  
  <p>now, I want each of the polygons' text in the center of the polygon, and don't cross with the polygon's border. If the polygon have not enough space to contain the all text, just contain the first part of it!
  Let me know if there is anything I can do to solve this issue, thank you!</p>
  
  <p>PS:I'm so sorry to my English, yes, it's so poor!  :)</p>