Highcharts Dynamic Chart (Updating over certain interval) PHP+MySql Example -


i'm trying use this demo make work php & mysql after interval updated values database.

when use

// using random value using javascript setinterval(function() {         var x = (new date()).gettime(), // current time         var y = math.random();         series.addpoint([x, y], true, true);         }, 5000); 

i get

normal chart

but when try putting ajax function like

var t; setinterval(function() {     var x = (new date()).gettime(), // current time     $.ajax({         type:'post',         url:'blahblah.php',         success:function(data)         {              t = data;   // data random numeric value         }     });             series.addpoint([x, t], true, true);     }, 5000); 

the chart turns wrong chart

blahblah.php

echo rand(10, 99); 

i'm not able determine why line disappears on every ajax call. plotting of points not correct. returned values greater 10, can see in second chart, plotting range -2 8

i don't seem find appropriate mysql example work kind chart (auto updating after interval)

are there other alternatives fetch data server , use value inside setinterval function?

put series.addpoint([x, t], true, true); inside success function - otherwise 't' undefined mess chart.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -