且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

每5秒钟更新一次jqplot仪表量表

更新时间:2022-12-28 18:34:02

此处是解决方法: JsFiddle链接

$(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);
});