1 <script type='text/javascript' src='https://www.google.com/jsapi'></script>2 <div id="chart_div" style=""></div>3 4 <script type="text/javascript">5 6 // First: Preprocess data from mongo7 var countries_by_prefix = {}; // Index countries by prefix8 for (var k in db_countries) {9 var item = db_countries[k];10 countries_by_prefix[item.prefix] = item;11 }12 13 var countries_by_isocode = {}; // Index countries by isocode14 for (var k in db_countries) {15 var item = db_countries[k];16 countries_by_isocode[item.iso_code] = item;17 }18 19 var chart_data = [['Country', 'Log10', 'Roamers']];20 21 var log_10 = Math.log(10);22 23 for (var k in db_aggregation) {24 var item = db_aggregation[k];25 console.log(item);26 country = countries_by_prefix[item._id]27 if (country != undefined) {28 chart_data[chart_data.length] = [country.iso_code, ( Math.log(item.n) / log_10 ) , item.n];29 }30 }31 32 google.load('visualization', '1', {'packages': ['geochart']});33 google.setOnLoadCallback(drawRegionsMap);34 35 function drawRegionsMap() {36 var data = google.visualization.arrayToDataTable(chart_data);37 38 var options = {enableRegionInteractivity: true, backgroundColor: 'rgb(179, 219, 241)'}; // backgroundColor39 40 var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));41 chart.draw(data, options);42 43 google.visualization.events.addListener(chart, 'regionClick', function (eventData) {44 var wikipedia = document.getElementById('wikipedia');45 if (wikipedia.className == 'show') {46 wikipedia.className = '';47 } else {48 var isocode = eventData.region;49 var country = countries_by_isocode[isocode];50 console.log(country);51 wikipedia.setAttribute('src', '');52 wikipedia.setAttribute('src', 'http://en.m.wikipedia.org/w/index.php?title='+country.name+'&printable=yes');53 wikipedia.className = 'show';54 }55 56 57 });58 59 60 };61 </script>62 63 <iframe id="wikipedia" src=""></iframe>64 65 <a class="logo" href="http://jetsetme.com/"><span></span></a>66
Enlace
El enlace para compartir es: