Reputation: 11
see code below, i was using inline table and converted to add column and add rows so i could specify the column type - this code will not display any error or render chart...what's wrong - thanks in advance
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", '1.1', {packages:['corechart', 'annotationchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.DataTable();
data.addColumn('datetime', 'TimeStamp');
data.addColumn('number', 'Temp(F)');
data.addColumn('number', 'pH');
data.addRows([
[new Date(2014,02,04,15,15,14), 58.75, 7.97],
[new Date(2014,02,04,15,15,19), 58.78, 7.93],
[new Date(2014,02,04,15,23,08), 58.69, 7.94],
[new Date(2014,02,04,20,49,46), 58.10, 7.94],
[new Date(2014,02,04,21,14,15), 57.99, 7.92],
[new Date(2014,02,04,21,15,05), 57.99, 7.92]
]);
var options = {
title: 'Temperature compensated pH',
curveType: "function",
hAxis: {format: 'e hh:mm:ss a'},
vAxes: {0: {logScale: false, minValue: 40}, 1: {logScale: false}},
series: {0: {targetAxisIndex: 0}, 1: {targetAxisIndex: 1}}
};
var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<h1>pH Logger</h1>
<hr>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
Upvotes: 1
Views: 1586
Reputation: 26340
You are missing the new
keyword before the google.visualization.DataTable()
constructor call:
var data = new google.visualization.DataTable();
Upvotes: 1