javascript - 根据画笔范围更新圆环图弧

标签 javascript svg d3.js

enter image description here

我是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/

相关文章:

javascript - 如何跨多个 ASP.Net 站点共享 TinyMCE Javascript 源代码

javascript - 纯javascript : overlay object

javascript - 带有 SVG 数据 URI 的 img 将不会在 Firefox 中显示

javascript - D3 中的控制轴刻度数

javascript - d3 从 svg 元素中选择数据

javascript - 向 jQuery Modal 发送 ajax 成功响应

javascript - Angular-foundation 多个指令要求嵌入

javascript - 使用 JavaScript 在 SVG 元素上设置填充不透明度动画

javascript - 使用溢出 :scoll,SVG 无法在 Div Wrapper 中滚动

javascript - d3.js x3dom : How to freeze camera position and get an axis?