Make graphic update without refresh AJAX / JS

0

I have a donut style chart where, until then, I used a simple SQL call in data , like this code below:

data: 
<?php 
$mysqli = new mysqli('localhost', 'performance','46019725','db_intranet');
$sql = $mysqli->query("select disponibilidade from panelstart"); ?>
[<?php while ($result = mysqli_fetch_array($sql))
{?> <?php echo $result["disponibilidade"]?>,
<?php } ?> ] 

However, I need every time the value in the database is changed the graphic is also, without having to refresh the page. I tried using this code:

setInterval(function () {
var point,
    newVal;

if (chartSpeed) {
    point = chartSpeed.series[0].points[0];
    newVal = <?php 
$mysqli = new mysqli('localhost', 'performance','46019725','db_intranet');
$sql = $mysqli->query("select disponibilidade from panelstart"); ?>
       <?php while ($result = mysqli_fetch_array($sql)) {?>
       <?php echo $result["disponibilidade"]?>, <?php } ?> ;

point.update(newVal);
}

}, 1000);

This JS code did not work. How can I resolve?

Note: The graphic I'm using is a modification of this: link

    
asked by anonymous 11.04.2018 / 15:13

0 answers