Accepted answer

I figured this out.

The height and width on a pattern element seem to function sort of like a scale / percentage. So a width of "1" means it will fill the whole element it is set to. A width of ".25" means 25% of that element. Then, within the <pattern> you would specify the height and width of the image as the actual pixel value of the height and width of the circle they are filling, so in this case my code was changed to:

  var patterns = defs.selectAll("pattern")
      .data(nodes.filter(function(d){ return !d.children }))
        return 'id'
      .attr('height',function(d){ return d.r*2})
      .attr('width',function(d){ return d.r*2*1.333333})
        return 'img/img' + d.image;

and then, because the circle pack layout zooms in, I had to make sure to change the defs of the image as well, so:

function zoomTo(v) {
    var k = diameter / v[2]; view = v;
      return d.r*2*1.333333*k
      return d.r*2*k
    node.attr("transform", function(d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
    circle.attr("r", function(d) { return d.r * k; });


is needed if you're modifying the example mentioned above.

Related Query