我尝试使用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
非常感谢任何帮助。