我是using a D3 brush to update the arcs of a donut chart ,但只有在我释放画笔后才会发生更新。我知道 D3 能够像 Mike 那样进行基于画笔的持续更新 in this example ;我在改编中错过了该代码的哪一部分?
这是我当前用于执行更新的函数:
function brushended() {
path.select('.donutPath')
.data(pie([brush.extent()[1],100 - brush.extent()[1]]))
.enter().append("path")
.attr("fill", function(d, i) { return color(i); })
.attr("d", arc);
}
最佳答案
需要监听的事件是.on("brush",...
,比如:
var brush = d3.svg.brush()
.x(x)
.extent([0,40])
.on("brush", brushended);
您应该更改函数的名称以更好地反射(reflect)情况,但仅此一项就可以使其工作。
FIDDLE监听器发生变化,而且更新选择的处理方式也发生变化。
关于javascript - 根据画笔范围更新圆环图弧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22923387/