【发布时间】:2017-03-06 19:17:09
【问题描述】:
我一直在玩这个例子here 一段时间。我正在尝试做的是突出显示图中的单个节点/圆圈(通过使用边框使其变大;稍后我也想在其中添加文本或字母)。
目前,我在图中将Bhutan 的圆圈放大了,如下所示:
.attr("r",
function(d){return ( d.countryName === "Bhutan" ? r + 4 : r);})
.attr("stroke", function(d){if (d.countryName==="Bhutan"){return "black"}})
但是,它与其他圆圈重叠。避免这些冲突/重叠的最佳方法是什么?提前致谢。
链接到 Plunkr - https://plnkr.co/edit/rG6X07Kzkg9LeVVuL0PH?p=preview
我尝试了以下在不丹圈内添加一个字母
//find bhutan circle and add a "B" to it
countriesCircles
.data(data)
.enter().append("text")
.filter(function(d) { return d.countryName === "Bhutan"; })
.text("B");
更新 Plunkr - https://plnkr.co/edit/Bza5AMxqUr2HW9CYdpC6?p=preview
【问题讨论】:
标签: javascript d3.js