0๐
โ
My Answer
google.load('visualization', '1', {
'packages': ['geochart', 'table']
});
google.setOnLoadCallback(drawRegionsMap);
async function drawRegionsMap() {
let region = await request();
var lista = [];
for(var i = 0; i < region.length; i++){
lista.push("BR-" + region[i].key, region[i].value);
}
var estados = region.filter(myFunction);
function myFunction(estado){
if(estado.key != null){
return estado.key.length == 2;
}
}
var charData = [
['Estados', 'Pedidos']
]
estados.forEach(pedido => charData.push(["BR-" + pedido.key, pedido.value]));
var data = google.visualization.arrayToDataTable(charData);
var view = new google.visualization.DataView(data)
view.setColumns([0, 1])
var options = {
region: 'BR',
resolution: 'provinces',
height: 600
};
var chart = new google.visualization.GeoChart(
document.getElementById('chart_div'));
chart.draw(data, options);
var geochart = new google.visualization.GeoChart(
document.getElementById('chart_div'));
var options = {
region: 'BR',
resolution: 'provinces',
displayMode: 'regions',
height: 600,
colorAxis: {
colors: ['#d00d0d']
},
};
geochart.draw(data, options);
};
Source:stackexchange.com