This experiment wants to show the mood of each countries partecipating to the World Cup 2014. In this example the mood is a Randomic value between 0 and 100. Google Geo Chart was used for drawing the Earth Map.
Last active
August 29, 2015 14:02
-
-
Save fabiovalse/3a67f138753c49895b04 to your computer and use it in GitHub Desktop.
Randomic World Cup 2014 Mood Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Randomic World Cup 2014 Mood Map" /> | |
<script type='text/javascript' src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
<script type='text/javascript' src='https://www.google.com/jsapi'></script> | |
</head> | |
<body> | |
<div id="chart_div" style="width: 900px; height: 500px;"></div> | |
<script type='text/javascript' src='index.js'></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
google.load('visualization', '1', {'packages': ['geochart']}); | |
var chart; | |
google.setOnLoadCallback(function() { | |
chart = new google.visualization.GeoChart(document.getElementById('chart_div')); | |
}); | |
setInterval(function() { | |
drawRegionsMap(); | |
}, 2000); | |
function randomInt(min,max) { | |
return Math.floor(Math.random()*(max-(min+1))+(min+1)); | |
} | |
function drawRegionsMap() { | |
var data = google.visualization.arrayToDataTable([ | |
['Country', 'Mood'], | |
["Algeria",randomInt(0,100)], | |
["Argentina",randomInt(0,100)], | |
["Australia",randomInt(0,100)], | |
["Belgium",randomInt(0,100)], | |
["Bosnia and Herzegovina",randomInt(0,100)], | |
["Brazil",randomInt(0,100)], | |
["Cameroon",randomInt(0,100)], | |
["Chile",randomInt(0,100)], | |
["Colombia",randomInt(0,100)], | |
["Costa Rica",randomInt(0,100)], | |
["Côte d'Ivoire",randomInt(0,100)], | |
["Croatia",randomInt(0,100)], | |
["Ecuador",randomInt(0,100)], | |
["United Kingdom",randomInt(0,100)], | |
["France",randomInt(0,100)], | |
["Germany",randomInt(0,100)], | |
["Ghana",randomInt(0,100)], | |
["Greece",randomInt(0,100)], | |
["Honduras",randomInt(0,100)], | |
["Iran",randomInt(0,100)], | |
["Italy",randomInt(0,100)], | |
["Japan",randomInt(0,100)], | |
["Korea Republic",randomInt(0,100)], | |
["Mexico",randomInt(0,100)], | |
["Netherlands",randomInt(0,100)], | |
["Nigeria",randomInt(0,100)], | |
["Portugal",randomInt(0,100)], | |
["Russia",randomInt(0,100)], | |
["Spain",randomInt(0,100)], | |
["Switzerland",randomInt(0,100)], | |
["Uruguay",randomInt(0,100)], | |
["USA",randomInt(0,100)] | |
]); | |
var options = { | |
minValue: 0, | |
//displayMode: 'text', | |
magnifyingGlass: {enable: true, zoomFactor: 0}, | |
colors: ['#de2d26', '#2ca25f'] | |
}; | |
chart.draw(data, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example has a nice visual impact, and is relatively easy to implement with Google's high-level libraries. It is of course possible to obtain a more effective visualization by using a different type of diagram, and/or by taking the full-custom route of advanced libraries like d3.js.
A choropleth map like this should show the geographic density of a quantitative variable. In our case, though, we only want to show and compare the absolute value of sentiment of each country, so a bar chart would be a better choice. The downside is that it would lessen the appeal of the graphic, but that is something that could be resolved by graphic design.
If we still decide to show a map, more theoretical stuff must be considered. In order to show density information, raw sentiment data should be divided by the area of the country (data should also be defined in a negative-to-positive range, zero being the neutral value). That is beacuse we tend to perceive bigger areas as bigger values, regardless of the color coding. In a choropleth it is also necessary to avoid the distortion of areas, so an equal-area cartographic projection should be used. The Google map seems to use a Mercator projection instead: Such a projection heavily distorts areas (compare the area of Greenland with the one of South America).
A more advanced color scale could also be used to achieve better perceptual accuracy, and to make the map readable by people affected by color blindness. The scale should be a diverging scale, to reflect the polar nature of data, and it should define no more than seven colors (data must be quantized accordingly). We are in general not able to correctly interpret more than seven different color classes.