Gowri
Gowri

Reputation: 1856

Google geochart doesn't show continents

I'm using google geochart to display data.

My code:

<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 geochart = new google.visualization.GeoChart(
     document.getElementById('visualization'));

     var options = {region: 'world', resolution: 'continents', width: 556, height: 347};
     var data = google.visualization.arrayToDataTable([
            ['continents', 'Aircrafts'],
            ['Asia', 700]
          ]);

      geochart.draw(data, options);

        };
    </script>
     <div id="visualization" style="width: 800px; height: 400px;"></div>

In chart it doesn't show asia as data.

Upvotes: 1

Views: 2616

Answers (3)

urchino
urchino

Reputation: 340

Although the 'continents' resolution option isn't in the official docs it does work. You need to change your data table to include a column of continent region codes, e.g.:

 var data = google.visualization.arrayToDataTable([
        ['Region code', 'Continent', 'Aircraft'],
        ['142', 'Asia', 700]
      ]);

  geochart.draw(data, options);

The region codes are required but don't get rendered in the tooltips. The codes matching each continent are explained here, beneath the options in the section called 'Continent Hierarchy and Codes'. It doesn't actually say you need to use them in your data table (that would be too easy...)

The only caveat is that I haven't yet found a way to get it to recognise the subregion codes that will allow separating 'Americas' into North & South. If you stick to using the continent codes then they should work - they do for me. Note that the codes need to be in the data table as strings.

See here for a working example : http://jsfiddle.net/6hrhj9qs/

Upvotes: 4

Amar
Amar

Reputation: 1936

Try using VectorWorkz' GeoChart, it supports Asia as a Continent and you have full control of the regions and add/modify the underlying maps to your needs. We can help create custom maps for you too.

Upvotes: 0

Anto Jurković
Anto Jurković

Reputation: 11258

You are using undocumented options described in this post

There it was also said that this bug would be fixed soon... and date was 5/25/11!

I didn't find other update.

Upvotes: 0

Related Questions