这是使用D3.js的温度计示例代码。 jsfiddle
我创建了一个温度计网页,其值在每个1秒的时间间隔内动态传递。以下是功能
setInterval(function(){ getNewValue() }, 1000);
function getNewValue(){
var currentTemp = getLastValue(); //Get latest values from database.
// remaining js
}
在每个时间间隔,它会创建新的温度计图表,而不是仅使用新值更新图表..我一直无法弄清楚如何解决这个问题。?
Plz有人帮助我..先谢谢。
答案 0 :(得分:1)
I hope this is what do you need
setInterval(function() {
$('#thermo').empty(); //add Jquery and this
showNewValues();
}, 1000);