Re: Invalid 2D Array in IE

103 views
Skip to first unread message

Mike H

unread,
Nov 23, 2012, 4:32:47 PM11/23/12
to google-visua...@googlegroups.com
Sorry, let me rephrase this.

The page presents just a white page when viewed in IE. In Chrome and Firefox it presents the world map with associated colours that I wanted based upon amount of hits.

When debugging in IE9, I get the error stating "Invalid 2D Array"

On Friday, November 23, 2012 11:38:05 AM UTC-7, Mike H wrote:
Hi!

I'm hoping you guys can help me out. I'm attempting to utilize Google Visualization API's for a world map, with a php script and HTML/Javascript to show how many hits we have recieved and mapping to a heat map on the map.

What I have works in Chrome and Firefox, but does not work in IE, unfortunately I want this presented in a Sharepoint iFrame which uses IE by default :(

The PHP portion works so I dont think I need to paste that in here, but here is the compiled HTML source that doesnt appear to be working out in IE only.

                                                                                                                                                                                  
<html>                                                                                                                                                                              
  <head>                                                                                                                                                                            
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>                                                                                                     
    <script type='text/javascript'>                                                                                                                                                 
     google.load('visualization', '1', {'packages': ['geochart']});                                                                                                                 
     google.setOnLoadCallback(drawRegionsMap);                                                                                                                                      
                                                                                                                                                                                     
      function drawRegionsMap() {
        var data = google.visualization.arrayToDataTable([
        ['Country','Blocks'],
      ['Japan', 11],
['United States', 45],
['Argentina', 1],
['Brazil', 1],
['Bosnia and Herzegovina', 1],
['Germany', 4],
['France', 2],
['Russia', 5],
['China', 24],
['Thailand', 1],
['New Zealand (Aotearoa)', 1],
['Turkey', 1],
['Korea (South)', 6],
['Panama', 2],
['Taiwan', 6],
['Canada', 14],
['Luxembourg', 1],
['United Kingdom', 1],
['Philippines', 1],
['Singapore', 3],
['Switzerland', 2],
['Hong Kong', 2],
        ]);
 
        var options = {
                        backgroundColor : '#25383c',
                        colors : ['#FFFFFF', '#FF0000']
                        };
 
        var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    };
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>


Any thoughts on what may be happening? I didn't call "var chart" more than once which I saw was a resolution for someone else in the group.

asgallant

unread,
Nov 23, 2012, 10:54:56 PM11/23/12
to google-visua...@googlegroups.com
You get that error because you have an errant comma hanging out at the end of your data array, which is technically invalid javascript, and will IE will throw a tantrum if you give it one:

['Hong Kong'2]// <---this comma is naughty and has to go

Mike H

unread,
Nov 26, 2012, 2:37:29 PM11/26/12
to google-visua...@googlegroups.com
Ugh, silly PHP, thanks for pointing that out!

Attempted to implode the comma, or strip the last comma, but instead re-did the whole array and now it works go away trailing commas!

Thanks!!

asgallant

unread,
Nov 26, 2012, 4:01:59 PM11/26/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages