我正在尝试制作一个生成随机线条的图形,并且每5秒钟重新绘制一次。它重绘,但旧的比例重叠。有没有办法在重新绘制新图表之前删除旧图表?
HTML
<div id="pointg"></div>
的JavaScript
var k=0;//if graph() is first time
function graph(){
var ga=[];
for(var j=0;j<11;j++){
ga[j] = Math.random() *20;
}
$(function () {
$.jqplot('pointg', [[[0, ga[0]], [2, ga[1]], [4, ga[2]], [6, ga[3]], [8, ga[4]],[10, ga[5]],[12, ga[6]],[14, ga[7]],[16, ga[8]],[18, ga[9]],[20, ga[10]],[22, ga[11]] ]],{
axes: {
xaxis: {
ticks: [ '0', '5', '10', '15', '20' ],
},
yaxis: {
ticks: [ '0', '5', '10', '15', '20' ],
}
},
animate: true,
seriesDefaults: {
color: '#ffffff',
markerOptions: {
size: 6
}
},
grid: {
background: '#000000'
},
});
});
if(k!=0){
//remove?
}
k++;
;}
graph();
setInterval('graph()',5000);
答案 0 :(得分:0)