Not kokomo, but I'm using PHP to pull the data out of a mysql database and display it using a simple line graph from the google chart API. You can check out the code I used (basically copied and pasted, replaced with data) here
<?php
// Connec to the database
mysql_connect("DATABASEHOST", "DATABASEUSER", "DATABASEPASSWORD");
mysql_select_db("DATABASENAME");
// Run query for all temp readings, oldest first.
$result = mysql_query("SELECT * FROM readings order by reading_time desc ");
// Initialize a blank array
$temps = array();
// Push those temperatures into the array, using the time as the key
while ($row = mysql_fetch_array($result)) {
$temps[strtotime($row['reading_time'])] = $row['reading'];
}
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
function mysqlTimeStampToDate(timestamp) {
//function parses mysql datetime string and returns javascript Date object
//input has to be in this format: 2007-06-05 15:26:02
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
}
// Initialization code from Google
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
// Setup the column name and types
var data = new google.visualization.DataTable();
data.addColumn('datetime','Time');
data.addColumn('number', 'Temp');
// Add rows of data
data.addRows([
<?php
// Iterate through that php array, echoing it out in [date, temp] format, a javascript array.
foreach ($temps as $k => $v) {
echo "[new Date(" . $k . " * 1000), " . $v ."],\n";
}
?>
]);
var options = {
title: 'Fermentation Chamber'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 100%; height: 600px;"></div>
</body>
</html>
Enter your email address to join: