0
我有项目温度mesuare使用mySQL存储数据的beaglebone。 我能够显示谷歌图表形式MySQL使用PHP,但我不能实时更新它,任何人都可以帮助我,非常感谢。实时更新谷歌图表,php,mySQL
<html>
<head>
<title>BeagleBone Temperature</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Time', 'Temperature'],
<?php
$con = mysqli_connect("localhost", "hoangviet", "hoangviet", "test");
$query = "SELECT * FROM TempMeas"; // form table
$result = mysqli_query($con, $query);
mysqli_close($con);
while ($row = mysqli_fetch_array($result))
{
$time = $row['MeasTime'];
$temp = $row['Temp'];
echo "['$time', $temp],";
}
?>
]);
var options = {
title: 'BeagleBone Measured Temperature',
vAxis: { title: "Degrees Celsius" }
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
实时更新意味着您希望不更新就更新它? – sandeepsure
没错,你能帮助我吗? –
你需要每30秒调用一次ajax,它将是同步的方式。 – sandeepsure