简体   繁体   中英

Highchart live data gauge

Seem to have an issue with my live data for my gauge, it's pemanently stuck on 80.
Code is here: http://pastebin.com/bysshBE0

This is my JSON array:

{"HumOut": 90, "BatteryStatus": 0, "TempIn": 21.27777777777778, "RainYear": 2.8, "HumIn": 28, "WindDir": 258, "WindSpeed": 0.0, "RainStorm": 0.0, "StormStartDate": "2127-15-31", "BatteryVolts": 4.751953125, "Pressure": 990.3826616999661, "ForecastIcon": 2, "SunSet": "16:21", "ForecastRuleNo": 122, "BarTrend": 60, "RainMonth": 0.0, "RainDay": 0.0, "TempOut": -1.7777777777777775, "WindSpeed10Min": 0.0, "SunRise": "08:37", "RainRate": 0.0}

What is wrong, i dont have any javascript errors in Chrome Debugger?

function (chart) {
    setInterval(function() {
    $(function() {
    $.getJSON('livedata.php', function(data) {
        $.each(data, function(key,val) {
        if (key == 'WindSpeed')
        {
            newVal = val;
            var point = chart.series[0].points[0];
            point.update(newVal);
        }
        });
    });
    })
},3000)
})

If you get JSON, you don't need to use each function.

function (chart) {
        setInterval(function() {
            $.getJSON("livedata.json", function(data, textStatus) {

                  var point = chart.series[0].data[0],
                  newVal = data.WindSpeed;
                  point.update(newVal);
            });
    }, 3000);
    });

I've used livedata.json instead of php file, because i have no php file,only json form your post.

Morever anonymous function (line above getJSON) is not needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM