7

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!

1

2 Answers 2

24

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.

4
  • @abagh0703:- What if i am using this:-google.charts.load('current', { 'packages': ['corechart', 'annotationchart', 'calendar', 'gantt', 'gauge', 'map', 'orgchart', 'sankey', 'timeline', 'treemap', 'wordtree'] });. How to write.?
    – Sanjiv
    Sep 20, 2016 at 11:01
  • if i am using google.charts.load('current', { 'packages': ['corechart', 'annotationchart', 'calendar', 'gantt', 'gauge', 'map', 'orgchart', 'sankey', 'timeline', 'treemap', 'wordtree'] }); instead of google.load("visualization", "1", {packages:["corechart"]});?
    – Sanjiv
    Sep 20, 2016 at 11:02
  • @Sanjiv what happens if you try using the <script type="text/javascript" src="https://www.google.com/jsapi?autoload= {'modules':[{'name':'visualization','version':'1.1','packages': ['corechart', 'annotationchart', 'calendar', 'gantt', 'gauge', 'map', 'orgchart', 'sankey', 'timeline', 'treemap', 'wordtree']}]}"></script> method instead of the google.charts.load method?
    – abagh0703
    Sep 20, 2016 at 21:06
  • You make my day Thanks
    – M Maavia
    Feb 24, 2017 at 14:23
1

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

1
  • Phil I do have that loaded at the top. The example works fine for me; I am getting that error when I replace the first parameter with my own buckets.
    – jaynp
    Aug 28, 2013 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.