So I'm trying to fill in the node circles with an image from a url. The url points to cloudfront. I looked at this question Adding an image within a circle object in d3 javascript?
However, all I get are blank images. I double checked and made sure that the images exist, yet they won't fill the image. Here is the d3 node.
var node = g.selectAll(".node");
node = node.data(nodes, function(d) {return d.id;});
node.enter().append("circle")
.attr("class", "node").attr("r", 10)
.attr("id", function(d,i) {
return "node"+d.id;
})
.attr("fill", function(d) {
if (d.mediapath !== undefined) {
var url = cloudfront + d.mediapath;
url = "https://github.com/favicon.ico"
return "url("+url+")";
return "url(#bg"+d.id+")";
}
return color(d.group); })
.on("mouseover", function(d) {
d3.select("p").text(d.handle);
})
.on("click", clicked);
Not all images have an image associated with them. If they do, they have a mediapath attribute, and we use it. Otherwise, we color it. The coloring of the nodes with no images is fine. However, all I get is a white fill instead of an image for the ones that need an image.
Any help is appreciated. Thanks.