Geochart and Greece ISO-3166-2 codes. Is there a bug?

196 views
Skip to first unread message

Parasound

unread,
Dec 9, 2012, 5:03:03 PM12/9/12
to google-visua...@googlegroups.com
Hi there, 

my code follows and I am trying to display a geochart with  ISO-3166-2 codes of Greece eg GR-A, GR-K but what I only see is a world map with no colors and nothing else.

Is there a bug, or am I missing something? 
thanks


<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
 <script type="text/javascript"> 
        
 google.load("visualization", "1", {packages:["geochart"]});
 google.setOnLoadCallback(setupData);
 
 var newData = null;
 var viewgeomap = null;
 var map = null;

///////////////////////////////
// Function setupData
// Initializes the query and service to pull the data
///////////////////////////////      
       function setupData() 
  {
     //SPARQL endpoint we will use to query the datasets
//this is where the actual SPARQL query is stored
//url that will execute the query
var queryurl = sparqlproxy + "output=gvds&service-uri=http://mysparqlendpoint =" + encodeURIComponent(queryloc);
//construct the query
var query = new google.visualization.Query(queryurl);
//send query with callback function
query.send(handleQueryResponse);
};
  
 
///////////////////////////////
// Function handleQueryResponse
// Checks for query errors, then processes
///////////////////////////////      
function handleQueryResponse(response) 
{
 
// Check for query response errors.
       if (response.isError()) 
{
           alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
        }
       
//gets the query result as a DataTable object
 
  
 var predata = response.getDataTable();
     var vals = new Array();
     var rownum = predata.getNumberOfRows();
// Make sure our data isn't empty.
        if (null==predata) 
         return;

        //Get all available data coming from Q
    var newdata =new google.visualization.DataTable();
        newdata.addColumn('string', 'CODE_3166');
        newdata.addColumn('string', 'example1');
        newdata.addColumn('number', 'example2');
        newdata.addColumn('number', 'example3');
      newdata.addColumn('number', 'example4');
      newdata.addRows(newdata.getNumberOfRows());


for (var i = 0; i < rownum; i++ )
{
var CODE_3166 = predata.getValue(i,0);
                                var example1 =predata.getValue(i,1);
var example2 =predata.getValue(i,2);
var example3 =predata.getValue(i,3);
var example4 =predata.getValue(i,4);
vals [0] = CODE_3166;
vals [1] = example1+"<br />example2: "+example2+"<br />example3: "+example3;
vals [2] = example2;
vals [3] = example3;
vals [4] = example4;
newdata.addRow(vals);
  
 viewmap = new google.visualization.DataView( newdata );
  viewmap.setColumns([0, 1]);
}

    
  var options = {};
//Now draw the map using this viewmap as a customized data table:
   
geomap = new google.visualization.GeoChart(document.getElementById('visualization_Map'));
      geomap.draw(viewmap, options);         
};
</script>
</head>
<body>

<!-- Presentation Content -->
<table >
<tr>
<td style="width: 950px;" >
<div id= 'visualization_Map'style="height:880px"><p><img src="http://data-gov.tw.rpi.edu/images/ajax-loader.gif" alt="loading ..."></p></div>
</td>

</div>
</td>
</tr>
</table>
</body>
</html>

asgallant

unread,
Dec 9, 2012, 7:34:01 PM12/9/12
to google-visua...@googlegroups.com
Did you set the "region" option to "GR" and the "resolution" option to "provinces"?  That is needed to get a map of Greece with state/province (or whatever they are called in Greece) sub-regions.

Parasound

unread,
Dec 9, 2012, 7:35:33 PM12/9/12
to google-visua...@googlegroups.com
No, I missed that part completely, I suppose that it is included in the documentation.

Thanks a lot 

Parasound

unread,
Dec 9, 2012, 8:32:53 PM12/9/12
to google-visua...@googlegroups.com
Just two more small questions, 

1.is there a way to change the color of the displayed regions, (the ones defined by provinces) ? 

2.Is the problem of new line in tooltip text fixed?


Thanks again
 
On Monday, December 10, 2012 12:03:03 AM UTC+2, Parasound wrote:

asgallant

unread,
Dec 10, 2012, 2:06:11 AM12/10/12
to google-visua...@googlegroups.com
Color is determined by value, so it is possible to give your regions specific colors (setting colorAxis.values and colorAxis.colors options to arrays that map values to colors 1-to-1, and then setting the data point values to the values in the colorAxis.values array).  This changes the value displayed in the tooltip, unless you override it by setting the formatted value of the data point to whatever you actually want displayed.  I can make an example of this if you need one.

To the best of my knowledge, newlines are still not supported in GeoCharts.  The chart team recently rolled out HTML tooltips in some of the core charts, and I believe that they are planning on bringing these to GeoCharts, though I cannot say when that will be.
Reply all
Reply to author
Forward
0 new messages