我希望把周围的一些SVG圈的SVG圈。我找到了使用d3.selectAll().filter()
的所需圆圈。这几乎奏效 - 创建一个圆圈。但我无法弄清楚如何从旧圆的中心设置新圆的中心,因此新圆创建在0,0。没有我试过的工作。使用d3.select从另一个圆的属性设置圆的属性?
// first I find the circles I want
foundNodeCircles = d3.selectAll(".node").filter(function(d,i){return d.label == nodeRE;});
// Then I create a new, larger circle for each circle that I found:
svg.selectAll(".nodeHighlightRing")
.data(foundNodeCircles) // make one ring per node circle
.enter().append("circle") // make the ring
.attr("class", "nodeHighlightRing") // specify its qualities
.attr("cx", function(d) { return d.cx;}) // BROKEN: set center to center of old circle
.attr("cy", function(d) { return d.cy;}) // BROKEN: set center to center of old circle
.attr("r", 10)
.style("opacity", 0)
.style("stroke", "green")
.style("stroke-width", "1.5")
.style("stroke-opacity", "1");
在除了d.cx
,我已经试过this.cx
,d.attr["cx"]
,this.attr["cx"]
,d3.select(this).attr("cx")
,d3.select(d).attr("cx")
,而且似乎不太可能奏效一些其他的东西。没有成功。
我认为this问题或this one会帮助,但我显然做了一些不同的事情。
我们可以看看你在foundNodeCircles中得到了什么,或者做一个小提琴我们可以对它做些什么。 – 2014-09-11 05:58:12
谢谢@ saikiran.vsk。 jshanley猜对了。我将不得不更多地了解小提琴的世界。 – Mars 2014-09-12 04:08:26