但是我想停止setInterval函数而不让图形消失?当setInterval停止时,图形消失或至少显示最后7个点。我该怎么办?提前谢谢!
`
var graphingID = setInterval(function(){
if (itertn == char.length){
clearInterval(graphingID);
}
itertn++;
//Add two random numbers for each dataset
myLiveChart.addData([char[itertn], char[itertn]], ++latestLabel);
// Remove the first point so we dont just add values forever
//updateDaw();
myLiveChart.removeData(2);
}, 50);
`
答案 0 :(得分:0)
这样的事可能吗?
var graphingID = setInterval(function(){
if (itertn == char.length){// is it time to stop? if yes clear interval
clearInterval(graphingID);
}
else{// if not, go on as usual
itertn++;
//Add two random numbers for each dataset
myLiveChart.addData([char[itertn], char[itertn]], ++latestLabel);
// Remove the first point so we dont just add values forever
//updateDaw();
myLiveChart.removeData(2);
}
}, 50);
答案 1 :(得分:0)
清除时不要继续:
if (itertn == char.length){ clearInterval(graphingID); return; }