【发布时间】:2014-08-08 21:07:27
【问题描述】:
在尝试选择 svg 中 rect 对象的属性时,我遇到了一个问题。 这是我想从中获取值的矩形:
<rect id="2" x="13.761467889908257" y="50" width="49.31192660550459" height="50" fill="rgb(43,0,0)"></rect>
为了计算另一个矩形的 x 位置,我需要 x 值。
我尝试了一些不同的想法,例如:
svg.selectAll("rect")
.select("id",2); // 1st version
.select("id","2"); // 2nd version
.select("#2"); // found in another d3 tutorial -> not working for me
还有更多。 有什么办法吗?
// 如果您需要更多我的代码,只需将其写在评论中我不确定要写多少才能不写太多
【问题讨论】:
-
哈哈“搞定”...我很抱歉。
标签: javascript svg d3.js selection