gpt4 book ai didi

javascript - 每 5 秒更新一次 jqplot 仪表

转载 作者:行者123 更新时间:2023-11-30 17:50:10 27 4
gpt4 key购买 nike

我在模态窗口内显示 jqplot 仪表,我想每 5 秒更新一次。我写了下面的代码,但它不起作用

$(document).ready(function(){
s1 = [Math.floor(Math.random()*(401)+100)];

plot3 = $.jqplot('meter',[s1],{
seriesDefaults: {
renderer: $.jqplot.MeterGaugeRenderer,
rendererOptions: {
min: 100,
max: 500,
intervals:[200, 300, 400, 500],
intervalColors:['#66cc66', '#93b75f', '#E7E658', '#cc6666'],
smooth: true,
animation: {
show: true
}
}
}
});
$('a[href=\"#yw1_tab_3\"]').on('shown', function(e) {
if (plot3._drawCount === 0) {
plot3.replot();
}
});
windows.setInterval(function() { plot3.destroy();
s1 = [Math.floor(Math.random()*(401)+100)];
plot3.replot();
}, 5000);
});

如何在不更新整个页面的情况下每 5 秒更新一次仪表?

最佳答案

这里是修复:JsFiddle link

$(document).ready(function () {
var s1 = [Math.floor(Math.random() * (401) + 100)];

var plot3 = $.jqplot('meter', [s1], {
seriesDefaults: {
renderer: $.jqplot.MeterGaugeRenderer,
rendererOptions: {
min: 100,
max: 500,
intervals: [200, 300, 400, 500],
intervalColors: ['#66cc66', '#93b75f', '#E7E658', '#cc6666'],
smooth: true,
animation: {
show: true
}
}
}
});
setInterval(function () {
s1 = [Math.floor(Math.random() * (401) + 100)];
plot3.series[0].data[0] = [1,s1]; //here is the fix to your code
plot3.replot();
}, 1000);
});

关于javascript - 每 5 秒更新一次 jqplot 仪表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19196876/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com