6
I’m displaying a state-level geochart. When configuring with the region of Brazil works, as you can see below, but not with the state code, for example: BR-SP
google.load('visualization', '1', {
'packages': ['geochart', 'table']
});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Views'],
['BR-AL', 300],
['BR-SP', 300],
['BR-RJ', 400]
]);
var geochart = new google.visualization.GeoChart(document.getElementById('chart_div'));
var options = {
region: 'BR',
resolution: 'provinces',
width: 800,
height: 600,
colorAxis: {
colors: ['#acb2b9', '#2f3f4f']
}
};
geochart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://www.google.com/jsapi"></script>
<div id="chart_div"></div>
At state level:
google.load('visualization', '1', {
'packages': ['geochart', 'table']
});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Views'],
['Sao Paulo', 300],
['Campinas', 300],
]);
var geochart = new google.visualization.GeoChart(document.getElementById('chart_div'));
var options = {
region: 'BR-SP',
displayMode: 'markers',
width: 800,
height: 600,
colorAxis: {
colors: ['#acb2b9', '#2f3f4f']
}
};
geochart.draw(data, options);
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<div id="chart_div"></div>
What about the status "Zoom"? What I need is that when I click one, it zooms in on the state and the markers appear.
– Marcelo de Andrade
Buddy I did a quick search here on api and google group Charts, and it says like this: "Not all countries have Province-level maps in the Geocharts, and it looks like Brazil is one of the ones that doesn’t have them. In order to zoom in on the Region, you would have to use Google Maps". Basically Brazil does not have this kind of zoom, you can test in Gion, put: 'BR-SP', it from the error. But if you put it by e.g.: 'US-AL' it will zoom in. Unfortunately what remains to be done is either use google maps or simply use markers. Google has unfortunately not updated for us
– Raphael Caldas
And it looks like this since 2012. Source: https://groups.google.com/forum/#! topic/google-Visualization-api/G4mobm_ztxy To use google maps: https://developers.google.com/chart/interactive/docs/gallery/map
– Raphael Caldas