I have HighCharts in a div tag that feeds from a MySQL table. I get this data by using PHP and converting JSON.
<?php
$query = "some query here ";
$result = $conn->query($query);
if (!$result) {
echo "Could not successfully run query ($query) from DB: " . mysql_error();
exit;
}
if (mysqli_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
//array
$table = array();
while($row= mysqli_fetch_assoc($result)) {
$table[] =$row;
};
$jsonTable= json_encode($table)
?>
And I can see the graph correctly by using this :
$(function () {
var chartData = <?php echo $jsonTable ?>;
var seriesA = [];
var seriesB = [];
for (i=0; i<chartData.length; i++){
tempDate = Date.parse(chartData[i].ctime);
seriesA.push([Date.parse(chartData[i].ctime), parseInt(chartData[i].totalKbpsin)]);
seriesB.push([Date.parse(chartData[i].ctime), parseInt(chartData[i].totalKbpsout)]);
};
But, I want to update my chart every 1 hour with new data. How can I do that?