--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/e105c322-3f54-49f5-951d-63f44d7d673b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/d2171d3c-67cd-4cd7-8c7f-10e3e9004cbb%40googlegroups.com.
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query('SELECT Temperature, Time FROM dp00000001 ORDER BY ID DESC LIMIT 10');
$rows = array();
$table = array();
$table['cols'] = array(
array('label' => 'Time', 'type' =>'datetime'),
array('label' => 'Temperature', 'type' => 'number')
);
foreach($result as $r) {
$temp = array();
$temp[] = array('v' => 'Date('.date('m',strtotime($r['Time'])).','.(date('d',strtotime($r['Time']))).','.(date('H',strtotime($r['Time']))).','.date('i',strtotime($r['Time'])).')');
$temp[] = array('v' => (float) $r['Temperature']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;
?>
<html>
<head>
<meta http-equiv="refresh" content="600">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);function drawChart() {
var data = new google.visualization.DataTable(<?=$jsonTable?>);
var options = {
haxis:{format:'mm-dd hh:ii'},
title: 'Temperature',
curveType: 'function',
width: 1200,
height:400,
explorer:{maxZoomIn:10, actions:["dragToZoom","rightClickToReset"],axis: "horizontal"
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/751ef014-fd7e-40e5-a91c-7e6f8647dae9%40googlegroups.com.
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query('SELECT Temperature, Time FROM dp00000001 ORDER BY ID DESC LIMIT 20');
$last = $mysqli->query('SELECT Temperature, Time FROM dp00000001 ORDER BY ID DESC LIMIT 1');
$rows = array();
$table = array();
$table['cols'] = array(
array('label' => 'Time', 'type' =>'datetime'),
array('label' => 'Temperature', 'type' => 'number')
);
foreach($result as $r) {
$temp = array();
$temp[] = array('v' => 'Date('.date('Y',strtotime($r['Time'])).','.(date('m',strtotime($r['Time']))-1).','.(date('d',strtotime($r['Time']))).',' .date('H',strtotime($r['Time'])).',' .date('i',strtotime($r['Time'])).')');
$temp[] = array('v' => (float) $r['Temperature']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;
$row = $last->fetch_array(MYSQLI_ASSOC);
$temp = $row['Temperature'];
$time = $row['Time'];
$timetz = date('H:i:s', strtotime($time . ' + 11 hours'));
$datetz = date('d-m-Y', strtotime($time . ' +11 hours'));
$nowtime = date('H:i:s', strtotime ($time . ' + 11 Hours'));
echo "<h1 style='text-align:center;'> Home Weather </h1>";
echo "<p style='text-align:center;'> Temperature $temp degrees C </h1>";
echo "<p style='text-align:center;'> Time $timetz </h1>";
echo "<p style='text-align:center;'> Date $datetz </h1>";
echo "<p style='text-align:center;'> </h1>";
?>
<html>
<head>
<meta http-equiv="refresh" content="600">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);function drawChart() {
var data = new google.visualization.DataTable(<?=$jsonTable?>);
var options = {
haxis:{format:'mm-dd hh:ii'},
title: 'Temperature/UTC Time',
curveType: 'function',
width: 1200,
height:400,
explorer:{maxZoomIn:10, actions:["dragToZoom","rightClickToReset"],axis: "horizontal"
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
Sorry Daniel, I posted my last reply before I saw you response. Indeed adding the year was one of the changes I made.