Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically update gauge on highcharts

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!

like image 468
Eduardo de Carvalho Avatar asked Mar 19 '23 08:03

Eduardo de Carvalho


1 Answers

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);  
        }
)}
like image 135
Rahul Gupta Avatar answered Mar 21 '23 22:03

Rahul Gupta