D3:动画饼图更新

时间:2014-11-10 09:50:33

标签: javascript animation d3.js

我尝试使用d3.js在饼图中为更新添加动画效果。我尝试过使用attrTween函数,但似乎无法使其正常工作。

function updatePieChart() {
    $.when(someOtherAjaxFunction()).done(function (json) {
        for (x in json) {
            var npath = d3.select('svg' + x).selectAll("path").data(pie(json))
            npath.transition().duration(1000).attrTween("d", arcTween); // redraw the arcs
        }

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

} //updatePieChart

非常感谢任何帮助。

0 个答案:

没有答案