Hi Im trying to add square images to circular nodes but cropping the image to the node size. Ive successfully added the images but cant seem to crop them to the circular node. Any suggestions on what I'm doing wrong?
var node = svg.selectAll(".node")
.data(json.nodes)
.enter().append("g")
.attr("class", "node")
.call(force.drag)
.on('mouseover', connectedNodes)
.on('mouseout', allNodes)
.on('contextmenu', function(d){d3.event.preventDefault();tip.show(d);}) //.on('mousedown', tip.show)
.on('mouseleave', tip.hide);
node.append("circle")
.attr("r", function(d) { return d.degree;})
.style("fill", function (d) {return color(d.group);})
node.append("image")
.attr("xlink:href", function(d) { return d.image;})
.attr("x", function(d) { return -25;})
.attr("y", function(d) { return -25;})
.attr("height", 50)
.attr("width", 50);
I also want to show the node there if there isn't any image.