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
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
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
Post a Comment