Hey Marty,
The first example works because you're passing numbers for all your data and all your columns have 'number' types assigned to them.
The second example doesn't work because this date line is a string:
echo date('d M',strtotime($levelresults->timestamp) +18000); // output example: 26 Dec
Since it's a string, you'll need to add quotes around it:
echo "'".date('d M',strtotime($levelresults->timestamp) +18000)."'";
Then you'll need to change the column to 'string'. Give this a whirl:
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', '');
data.addColumn('number', 'Time of Reading');
data.addColumn('number', 'Blood Glucose Reading');
data.addRows([
<?php
$level=DB::getInstance()->query("SELECT * FROM tabbyhealth WHERE reading!=0");
foreach ($level->results() as $levelresults)
{
echo "[";
echo "'".date('d M',strtotime($levelresults->timestamp) +18000)."'";
echo ",";
echo date('H',strtotime($levelresults->timestamp) +18000);
echo ",";
echo $levelresults->reading;
echo "],";
}
?>
]);
var options = {
title:'Blood Glucose Monitoring',
curveType: 'function',
legend: { position: 'bottom' },
width:600,
height:300,
hAxis: {
title: 'Date'
},
vAxis: {
title: 'Reading and Time'
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
Here is a fiddle:
http://jsfiddle.net/jay0316/pxcozvep/4/