I have been trying to follow different d3.js tutorials to create my own hexagon mesh.
I have come up to this I need to replace the random colors with images, I read that I need to do something like this:
var imagePatterns = svg.selectAll('pattern').data(data).
enter().append('pattern')
.attr('x',50)
.attr('y',50)
.attr('width',1)
.attr('height',1)
.append('image').attr("xlink:href", function(d,i){
return data[i].img;
})
.attr("x", function(d,i){
return i+100;
})
.attr("y", function(d,i){
return i+200;
})
.attr("width", 230)
.attr("height", 230)
.attr("id", function(d,i){
return 'fillImage'+i
});
I have a data array with 40 images, the number of hexagon of a radius 120 form the topoApi is 40 , I know I need to set my image some how to the center of each hexagon, but with the above code I only see the patterns in the generated html but nothing else
First thing I need to get the images to show on my screen then I should work on positioning them, please help