【发布时间】:2013-12-06 04:08:11
【问题描述】:
我正在尝试更新折线图,它没有抛出任何错误,但也没有更新图表。
我正在删除一个点并添加一个新的点,其速率增加,created_at 日期增加一秒(尝试关注http://bl.ocks.org/benjchristensen/1148374)
function redrawWithoutAnimation() {
for (var i in chart_data) {
linedata = chart_data[i];
//delete first element of array
linedata.points.reverse().shift();
//create a new point
rate = linedata.points[0].rate + 1;
created_at = linedata.points[0].created_at + 6000;
new_point = {};
new_point.rate = rate;
new_point.created_at = created_at;
linedata.points.push(new_point);
console.log(linedata);
}
// static update without animation
svg.selectAll("path")
.data([linedata.points]); // set the new data
line(linedata.points); // apply the new data values
}
redrawWithoutAnimation();
setInterval(function () {
redrawWithoutAnimation();
}, 8000);
这是我的代码 http://jsfiddle.net/yr2Nw/8/
【问题讨论】:
标签: javascript svg d3.js nvd3.js