Skip to content

Instantly share code, notes, and snippets.

@carpiediem
Last active January 1, 2020 10:42
Show Gist options
  • Save carpiediem/01e845e2973c4866d7f37fa46a1b5c6b to your computer and use it in GitHub Desktop.
Save carpiediem/01e845e2973c4866d7f37fa46a1b5c6b to your computer and use it in GitHub Desktop.
Most Recent Transition of Political Power in Each Country
license: cc-by-4.0
height: 520
border: no

This map identifies the most recent event in each country's history in which political power was transferred from a ruling party, coalition, or family to its opposition. Each country is colored according to the way that its most recent transition took place. The date of each transition is displayed and clicking the country will open an associated Wikipedia article.

Any system of categorizing historical events will have a difficult time choosing the right label for every case; this attempt is far from perfect. There are blurred lines between peace, protests, violence, military intervention, and all-out war. In some cases one may argue that power was transferred between parties, while someone else would argue that they are memebrs of the same coalition (resulting in no real transition).

Data is stored in this Google Sheets document. Any political changes that have occurred since the last edit of that spreadsheet will not be reflected in this map. If you identify errors in the data, please comment on the GitHub Gist page.

<!DOCTYPE html>
<html>
<head>
<title>Most Recent Transition of Political Power in Each Country</title>
<script type="text/javascript" src="https://www.amcharts.com/lib/3/ammap.js"></script>
<script type="text/javascript" src="https://www.amcharts.com/lib/3/maps/js/worldHigh.js"></script>
<script type="text/javascript" src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://www.amcharts.com/lib/3/plugins/export/export.css">
<script type="text/javascript" src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<style type="text/css">
#chartdiv {
width: 100%;
height: 500px;
}
</style>
<script type='text/javascript'>//<![CDATA[
function parseData(json) {
var areas = json.table.rows.map(function(row){
if (row.c[2]==null) return false;
return {
"title": row.c[0].v,
"id": row.c[1].v,
"customData": row.c[2].f,
"groupId": row.c[3].v,
"color": row.c[4].v,
"link": row.c[5].v
};
});
wikipediaLinks = {};
for (var i=0, count=areas.length; i<count && !!areas[i]; i++) {
wikipediaLinks[areas[i].title.toLowerCase()] = areas[i].link;
}
var categories = [
{
"title": "Peaceful Election",
"color": "#2166ac"
},{
"title": "Presidential Succession",
"color": "#67a9cf"
}, {
"title": "Constitutional Reform",
"color": "#d1e5f0"
}, {
"title": "Peaceful Independance",
"color": "#535353"
}, {
"title": "Election amid violence",
"color": "#fddbc7"
}, {
"title": "Miltary Coup",
"color": "#ef8a62"
}, {
"title": "War",
"color": "#b2182b"
}
];
var map = AmCharts.makeChart( "chartdiv", {
"type": "map",
"theme": "light",
"dataProvider": {
"map": "worldHigh",
"areas": areas
},
"areasSettings": {
"alpha": 0.8,
"rollOverColor": undefined,
"unlistedAreasAlpha": 0.1,
"balloonText": "[[title]] on [[customData]]",
"labelText": "[[customData]]",
},
"legend": {
"width": "100%",
"marginRight": 27,
"marginLeft": 27,
"equalWidths": false,
"backgroundAlpha": 0.5,
"backgroundColor": "#FFFFFF",
"borderColor": "#ffffff",
"borderAlpha": 1,
"top": 450,
"left": 0,
"horizontalGap": 10,
"data": categories
},
"export": {
"enabled": true
}
} );
map.addListener("rendered", function(event) {
var areas = document.getElementsByClassName("amcharts-map-area");
for(var i = 0; i < areas.length; i++) {
areas[i].addEventListener("click", function() {
var countryName = this.getAttribute("aria-label").trim().toLowerCase();
window.open(wikipediaLinks[countryName]);
});
}
});
}
google = {
visualization: {
Query: {
setResponse: parseData
}
}
};
//]]>
</script>
</head>
<body>
<script src="https://docs.google.com/spreadsheets/d/1daHIqQDpavKDBxF1i8OmxRzj_tDQvITS43C3_-ylmRY/gviz/tq"></script>
<div id="chartdiv"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment