Javascript 如何使用d3使图像显示为圆形?

Javascript 如何使用d3使图像显示为圆形?,javascript,jquery,json,d3.js,svg,Javascript,Jquery,Json,D3.js,Svg,我必须在圆圈中显示图像。我尝试了堆栈溢出中可用的代码,但对我无效。我尝试了使用svg模式。我也尝试过使用nodeEnter.append(“image”)和nodeEnter.append(“circle”),但只得到正方形图像。非常感谢 function update() { var nodes = flatten(root), links = d3.layout.tree().links(nodes);

我必须在圆圈中显示图像。我尝试了堆栈溢出中可用的代码,但对我无效。我尝试了使用svg模式。我也尝试过使用nodeEnter.append(“image”)和nodeEnter.append(“circle”),但只得到正方形图像。非常感谢

          function update() {
            var nodes = flatten(root),
            links = d3.layout.tree().links(nodes);
            force.nodes(nodes).links(links).start();

            link = link.data(links, function(d) { return d.target.id; });
            link.exit().remove();
            link.enter().insert("line", ".node")
           .attr("style", function(d) { if(d.target.strength==1){ return "stroke:Red"; } else if(d.target.strength==2) { return "stroke:Green"; } else if(d.target.strength==3) { return "stroke:yellow"; }
                                                                            else return "stroke:Blue" })
           .attr("class", "link");
            node = node.data(nodes, function(d) { return d.id; });
            node.exit().remove();

            var nodeEnter = node.enter().append("g").attr("class", "node").on("click", click).on("mouseover", showDetails)
                   .on("mouseout", hideDetails).call(force.drag);

            nodeEnter.append("svg:image")
              .attr("xlink:href", function(d){ return d.imgUrl;})
              .attr("x", -10)
              .attr("y", -10)
              .attr("width", 32)
              .attr("height", 32);
              //.attr("radius", function(d) { return Math.sqrt(d.size) / 10 || 15; });  

          node.select("circle").style("fill", color);
        }

我今天刚刚回答了这个问题。你们必须使用模式:你们试过类似问题中给出的解决方案吗?请阅读和。可能重复的thanq Gerardo Furtado,user3711952和lax1089,以获得您的帮助。最终获得解决方案