我很难弄清楚如何制作protovis流图的动画。我认为最好的方法是简单地将一组i, j索引传递给.layers(),并让.x()和.y()函数查找实际的更新值。有没有更简单的方法?
发布于 2011-02-01 06:11:23
难道你不能在每次渲染之前更新数据吗?假设数据已经更改,我不确定是否看到了这样做的好处,因为我认为整个vis都需要重新渲染。
function getData(offset) {
// get/create your data here, maybe seeded with an offset
}
var offset = 0;
// ... define scales and stuff
var vis = new pv.Panel()
.width(w)
.height(h);
vis.add(pv.Layout.Stack)
// wrap in a function to re-evaluate on render
.layers(function() getData(offset))
.offset("wiggle")
.x(x.by(pv.index))
.y(y)
.layer.add(pv.Area);
// use setInterval to animate
setInterval(function() {
offset++; // still working on the offset idea
vis.render();
}, 20);这似乎是有效的,尽管它确实取决于你想要创建的动画类型--对于某些类型的动画,可能会有更有效的方法。
https://stackoverflow.com/questions/3884556
复制相似问题