d3 has a demo of a Force-Directed Graph Layout.
Instead of circles, I want all nodes in the graph to be images.
so, I changed
.append("svg:circle")
.attr("class", "node")
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; })
.attr("r", 5)
.style("fill", function(d) { return fill(d.group); })
.call(force.drag);
to
.append("xhtml:img")
.attr("src", ".lgqdzwfu.png")
.call(force.drag);
But I can not see any images. What am I doing wrong?
d3 has a demo of a Force-Directed Graph Layout.
Instead of circles, I want all nodes in the graph to be images.
so, I changed
.append("svg:circle")
.attr("class", "node")
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; })
.attr("r", 5)
.style("fill", function(d) { return fill(d.group); })
.call(force.drag);
to
.append("xhtml:img")
.attr("src", "http://a577.phobos.apple.com/us/r1000/081/Purple/12/61/13/mzi.lgqdzwfu.png")
.call(force.drag);
But I can not see any images. What am I doing wrong?
Share Improve this question edited Jan 19, 2014 at 15:23 VividD 10.5k8 gold badges66 silver badges112 bronze badges asked Sep 5, 2011 at 9:36 TinyfoolTinyfool 1,4802 gold badges18 silver badges42 bronze badges1 Answer
Reset to default 18node.append("svg:image")
.attr("class", "circle")
.attr("xlink:href", "https://d3nwyuy0nl342s.cloudfront.net/images/icons/public.png")
.attr("x", "-8px")
.attr("y", "-8px")
.attr("width", "16px")
.attr("height", "16px");
Here is an example of using an image as the node: http://bl.ocks.org/950642