Reputation: 8397
Working with the Google Charts API for the first time, and with everything I've got here I would imagine it works. But when I look at the Chrome console, I get an error saying invalid row type for row 0
. Tried looking around for why that would happen, but I can't exactly figure it out.
If it helps, here is the tutorial I was basing all of this off of.
Here's the code I have:
<script type='text/javascript'>
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type='text/javascript'>
function drawVisualization() {
var gdata = google.visualization.arrayToDataTable(['TurbTemp_F'], ['45.68'], ['45.68'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.5'], ['45.5'], ['45.68'], ['45.86'], ['45.86'], ['46.04'], ['46.22'], ['46.4'], ['46.58'], ['46.58'], ['46.76'], ['46.94'], ['47.12'], ['47.12'], ['47.3'], ['47.66'], ['47.66'], ['47.66'], ['47.84'], ['48.02'], ['48.02'], ['48.02'], ['48.2'], ['48.38'], ['48.74'], ['48.74'], ['48.92']);
var options = {
title: 'Title here',
vAxis: { title: 'vvv' },
seriesType: 'bars',
series: {
3: { type: 'area' }
}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(gdata, options);
}
google.setOnLoadCallback(drawVisualization);
</script>
Any help would be greatly appreciated! Thanks!
Upvotes: 1
Views: 4511
Reputation: 841
You forgot surrounding [] in gdata Should be
var gdata = google.visualization.arrayToDataTable([['TurbTemp_F'], ['45.68'], ['45.68'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.86'], ['45.5'], ['45.5'], ['45.68'], ['45.86'], ['45.86'], ['46.04'], ['46.22'], ['46.4'], ['46.58'], ['46.58'], ['46.76'], ['46.94'], ['47.12'], ['47.12'], ['47.3'], ['47.66'], ['47.66'], ['47.66'], ['47.84'], ['48.02'], ['48.02'], ['48.02'], ['48.2'], ['48.38'], ['48.74'], ['48.74'], ['48.92']]);
this produces another error "Not enough columns given to draw the requested chart." I add another column, then error with values as Strings, so i end up with
var gdata = google.visualization.arrayToDataTable([['Day','TurbTemp_F'], ['1',45.68], ['2',45.68], ['3',45.86], ['4',45.86], ['5',45.86], ['6',45.86], ['7',45.86]]);
Upvotes: 3