【发布时间】:2014-05-31 14:27:51
【问题描述】:
当使用Meteor 0.8.0时,当新数据到达时如何更新flot图表?我查看了Meteor-flot 的示例,但它正在通过页面上的计时器使用假数据进行更新。而不是来自集合的反应性数据。
到目前为止,我有类似的东西:
// returns an object with a label and an array of timestamp, value
// like { label:'test', data:[[1397605016000, 1332],[1397605616000,1356],[1397606216000,1380]]}
Template.example.helpers({
readings: function(){
DataReadings.find();
}
});
Template.example.rendered = function() {
$.plot ($("#flot"), [this.data.data], {
series: {
lines: {
show: true
},
points: {
show: true
}
},
xaxis: {
mode: 'time',
timeformat: '%H:%M'
}
});
};
这对于初始渲染非常有用,但不确定如何在新数据到达后更新图表,大约每五分钟一次。那么当新数据到来时如何调用 plot.setData(newData) & plot.draw() 呢?
【问题讨论】:
-
看看 Deps 包 - 或 Tracker (meteor 0.9)
标签: javascript meteor meteor-blaze