I'm using the HTML5 RGraph library and should update dynamically along with the bank.
However, I would like the chart to put the last imputed data in the database, so if I entered the value 10 in the database, the graph line would stay in 10 until I enter another value, such as 25, and the graph would give a jump.
But the graph is not making that immediate jump, if the last value is 10, and I say 25, it stays at 10 unless I refresh the page.
Here is the snippet of code:
function update ()
{
// A global
l$.ajax({
type: "POST",
url: "consulta.php",
data: {},
dataType: 'json',
success: function (last)
{
line.originalData[0].push(last);
line.originalData[0].shift();
RGraph.SVG.redraw();
}
});
setTimeout(function () { update() }, 50);
}
update();
Query.php file:
<?php
include("salvateste.php");
$execute_again = mysqli_query($conexao, "Select * FROM tabelapi order by Evento desc");
$lone = mysqli_fetch_object($execute_again);
$mostra_tudao[0] = $lone->Amperes;
echo json_encode($mostra_tudao[0]);
?>