jaynp
jaynp

Reputation: 3325

TypeError: google.visualization.arrayToDataTable is not a function

I am trying to copy this example.

The example has this definition:

var data = google.visualization.arrayToDataTable([
['a', 14],
['b', 47],
['c', 80],
['d', 55],
['e', 16],
['f', 90],
['g', 29],
['h', 23],
['i', 58],
['j', 48]
// Treat first row as data as well.
  ], true);

I have replaced the first parameter with my variable buckets which is also an array of length-2 arrays. I'm getting the following error which makes no sense:

TypeError: google.visualization.arrayToDataTable is not a function

Even if buckets is malformed(which I don't think it is) how could that change the identity of arrayToDataTable? It's still a function!

Upvotes: 7

Views: 13409

Answers (2)

abagh0703
abagh0703

Reputation: 911

I understand that this is a very late answer, but just in case anybody else comes across this question I'll post this here. I had the same error, but then I checked out how Google Developers did it on their jsfiddle.

Replace this:

<script src="//www.google.com/jsapi"></script>

With this:

<script type="text/javascript" src="https://www.google.com/jsapi?autoload= 
{'modules':[{'name':'visualization','version':'1.1','packages':
['corechart']}]}"></script>

And then delete this line:

google.load("visualization", "1", {packages:["corechart"]});

And of course, make sure that you run it on a server.

Upvotes: 24

Phil
Phil

Reputation: 164980

Looks like you haven't loaded the Google Visualization API. Have you got this somewhere?

<script src="//www.google.com/jsapi"></script>
<script>
    google.load('visualization', '1', {packages: ['imagechart']});
</script>

FYI - I got this by clicking the Edit HTML button on the example page

Upvotes: 1

Related Questions