最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Transition on pie-chart resize in d3.js - Stack Overflow

programmeradmin2浏览0评论

I am looking for an example on how to make a transition for a pie-chart resize (arc's paths). I have been looking at this example but I still don't know how to modify it to make the transition on the resize. So far I am able to resize the pie-chart by changing the outerRadius (and innerRadius) of the arc object, but no luck with the transition. Here is the example I am working on.

arc.innerRadius(newInnerRad)
   .outerRadius(newOuterRad);

path.transition().duration(500).attrTween("d", arcTween);

function arcTween(a) {
  var i = d3.interpolate(this._current, a);
  this._current = i(0);
  return function(t) {
    return arc(i(t));
  };
}

Any ideas?

I am looking for an example on how to make a transition for a pie-chart resize (arc's paths). I have been looking at this example but I still don't know how to modify it to make the transition on the resize. So far I am able to resize the pie-chart by changing the outerRadius (and innerRadius) of the arc object, but no luck with the transition. Here is the example I am working on.

arc.innerRadius(newInnerRad)
   .outerRadius(newOuterRad);

path.transition().duration(500).attrTween("d", arcTween);

function arcTween(a) {
  var i = d3.interpolate(this._current, a);
  this._current = i(0);
  return function(t) {
    return arc(i(t));
  };
}

Any ideas?

Share Improve this question edited Nov 7, 2014 at 12:19 VividD 10.5k8 gold badges66 silver badges112 bronze badges asked Nov 3, 2012 at 11:50 emepycemepyc 9691 gold badge10 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

It works if you create arcTween inline and add an interpolator for the radius -- see the updated fiddle.

发布评论

评论列表(0)

  1. 暂无评论