我正在尝试使用nvd3.js创建一个实时图,它将定期更新,并且给人的印象是数据是实时处理的。
目前,我已经能够创建一个函数来定期更新图形,但我无法在“状态”之间进行平稳的转换,比如向左转换的直线。
Here是我使用nvd3.js所做的,这里的有趣代码是:
d3.select('#chart svg')
.datum(data)
.transition().duration(duration)
.call(chart);现在,我已经能够使用d3.js生成我想要的东西,但我更希望能够使用nvd3.js提供的所有工具。Here是我想用nvd3制作的产品
使用d3.js进行转换的有趣代码是:
function tick() {
// update the domains
now = new Date();
x.domain([now - (n - 2) * duration, now - duration]);
y.domain([0, d3.max(data)]);
// push the accumulated count onto the back, and reset the count
data.push(Math.random()*10);
count = 0;
// redraw the line
svg.select(".line")
.attr("d", line)
.attr("transform", null);
// slide the x-axis left
axis.transition()
.duration(duration)
.ease("linear")
.call(x.axis);
// slide the line left
path.transition()
.duration(duration)
.ease("linear")
.attr("transform", "translate(" + x(now - (n - 1) * duration) + ")")
.each("end", tick);
// pop the old data point off the front
data.shift();
}发布于 2013-05-16 23:18:44
你可能想看看:D3 Real-Time streamgraph (Graph Data Visualization),
特别是答案的链接:http://bost.ocks.org/mike/path/
总的来说,我看到了处理垂直过渡问题的两种方法:
https://stackoverflow.com/questions/15330390
复制相似问题