to append an image i use this code
node.append("image")
.attr("xlink:href", function(d) { return d.img; })
.attr("x", -25)
.attr("y", -25)
.attr("width", 50)
.attr("height", 50)
i want the image to be round i have tried to use this code
.attr("style", "border-radius: 30px;");
but it didn't work.. i also tried this one
<style>
.node image{
border-color: 2px solid orange;
border-radius: 25px;
}
</style>
but to no avail. .
You need to use patterns.
<defs>
tag.eg.:
var defs = svg.append("defs").attr("id", "imgdefs")
var catpattern = defs.append("pattern")
.attr("id", "catpattern")
.attr("height", 1)
.attr("width", 1)
.attr("x", "0")
.attr("y", "0")
Adding the image:
catpattern.append("image")
.attr("x", -130)
.attr("y", -220)
.attr("height", 640)
.attr("width", 480)
.attr("xlink:href", imgurl)
And then setting the fill:
svg.append("circle")
.attr("r", 100)
.attr("cy", 80)
.attr("cx", 120)
.attr("fill", "url(#catpattern)")
A JS Fiddle example: http://jsfiddle.net/wcnxywuy/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With