Dynamically update gauge on highcharts

Eduardo de Carvalho picture Eduardo de Carvalho · Jun 11, 2014 · Viewed 7.3k times · Source

I'm working in a university website project, and I choose to work with Highcharts, it has a very easy usage. But i'm having some problems to work with .getjson for dynamically update.

I used this http://www.highcharts.com/studies/live-server.htm, and this http://jsfiddle.net/oceog/zpwdp/ samples. And I havenn't got any success. Then i try to learn by my own on the API, and i came to this:

function requestData() {
    $.jQuery.getJSON('values.php', data, 
        function(){
            var series = chart.series[0]
            chart.series.update()
            setTimeout(requestData, 1000);  
        }
)}

I left the data values on the chart empty, and i loaded requestData on the file, but it still don't work. Can someone help me? Sorry for my english. Thanks!

Answer

Rahul Gupta picture Rahul Gupta · Jun 13, 2014

Refer this fiddle:

var new_value = 160;
var point = $('#container').highcharts().series[0].points[0];       
point.update(new_value);

According to your case, it should be like:

function requestData() {
    $.jQuery.getJSON('values.php', data, 
        function(){
            var new_value = 160;//the value you wish to update and set to guage
            var point = $('#div_id_of_chart_rendering').highcharts().series[0].points[0];       
            point.update(new_value);  
        }
)}