Skip to content Skip to sidebar Skip to footer

Google Arraytodatatable - Invalid Row Type For Row 0

I am stuck (again!) and cannot seem to find an example for this. I have tried multiple variations of extracting and formatting the data to no avail. I have the following data whic

Solution 1:

By declaring var data in your callback function, you fall prey to the hoisting mechanism of javascript and its accompanying scopes subtleties. Basically, your declaration goes to the top of the function and masks your named argument : data isn't equal to [...] but to undefined, see this Fiddle http://jsfiddle.net/dVaC2/ to illustrate my point.

Rename your variable to gdata for example (and use parseInt() instead of int() and [].push instead of [].append) :

var gdata = google.visualization.arrayToDataTable(jsonData);
// ...
chart.draw(gdata, options);  

And a demo http://jsfiddle.net/dVaC2/1/


See http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html or Javascript function scoping and hoisting for example

Post a Comment for "Google Arraytodatatable - Invalid Row Type For Row 0"