Skip to content

Instantly share code, notes, and snippets.

@FrankRuns
Created December 21, 2015 21:49
Show Gist options
  • Save FrankRuns/0b9e113e34e3e6595beb to your computer and use it in GitHub Desktop.
Save FrankRuns/0b9e113e34e3e6595beb to your computer and use it in GitHub Desktop.
Top 25
Country Continent Region Debt2GDP TotalDebt GDP PercentDebt Above99 10yGDPGrowth
United States North America North America 0.744 12908400000000 17350000000000 0.239 FALSE 1.58
Japan Asia Eastern Asia 2.319 11054673000000 4767000000000 0.205 TRUE 0.61
India Asia South-Central Asia 0.517 3831487000000 7411000000000 0.071 FALSE 7.69
Italy Europe Southern Europe 1.320 2818200000000 2135000000000 0.052 TRUE -0.48
Germany Europe Western Europe 0.743 2784764000000 3748000000000 0.052 FALSE 1.32
China Asia Eastern Asia 0.149 2695410000000 18090000000000 0.050 FALSE 9.99
France Europe Western Europe 0.955 2474405000000 2591000000000 0.046 FALSE 0.87
United Kingdom Europe Northern Europe 0.881 2263289000000 2569000000000 0.042 FALSE 1.34
Brazil South America Central Eastern South America 0.589 1929564000000 3276000000000 0.036 FALSE 3.41
Spain Europe Southern Europe 0.977 1535844000000 1572000000000 0.028 FALSE 0.53
Canada North America North North America 0.948 1513008000000 1596000000000 0.028 FALSE 1.90
Mexico North America North America 0.421 904729000000 2149000000000 0.017 FALSE 2.46
Egypt Middle East Middle East 0.937 886964200000 946600000000 0.016 FALSE 4.37
Indonesia Asia Maritime South-East Asia 0.259 695674000000 2686000000000 0.013 FALSE 5.72
Korea, South Asia Eastern Asia 0.345 615480000000 1784000000000 0.011 FALSE 3.68
Pakistan Middle East South-Central Asia 0.643 568540600000 884200000000 0.011 FALSE 4.02
Netherlands Europe Western Europe 0.690 558072000000 808800000000 0.010 FALSE 0.98
Turkey Europe Southeastern Europe 0.350 530250000000 1515000000000 0.010 FALSE 4.30
Belgium Europe Western Europe 1.063 513747900000 483300000000 0.010 TRUE 1.25
Greece Europe Southern Europe 1.771 505266300000 285300000000 0.009 TRUE -1.96
Thailand Asia South-East Asia 0.463 495410000000 1070000000000 0.009 FALSE 3.49
Russia Asia Eastern Europe 0.134 479318000000 3577000000000 0.009 FALSE 3.46
Singapore Asia Southeast Asia 1.032 468837600000 454300000000 0.009 TRUE 5.89
Australia Australia Australia/Oceania 0.424 466400000000 1100000000000 0.009 FALSE 2.84
Poland Europe Eastern Europe 0.437 419432600000 959800000000 0.008 FALSE 3.84
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.0.0.min.js"></script>
<style>
h2 {
text-align: center;
}
p {
margin-left: 150px;
margin-right: 150px;
}
svg {
margin-left: 170px;
}
/* .dimple-series-0 {
fill: #222222;
}*/
</style>
<script type="text/javascript">
function draw(data) {
// Data Sources
// Redoing this data visualization of government debt
/* http://viz.wtf/ */
// Majority are 2014 estimates unless specified as 2012 or 2013. See source for clarity
/* https://www.cia.gov/library/publications/the-world-factbook/rankorder/2186rank.html
*/
/* https://www.cia.gov/library/publications/the-world-factbook/rankorder/rawdata_2001.txt
*/
/* http://www.nationsonline.org/oneworld/countries_of_the_world.htm */
/* http://data.worldbank.org/indicator/NY.GDP.MKTP.KD.ZG */
/*
D3.js setup code
*/
"use strict";
var margin = 50,
width = 960 - margin,
height = 500 - margin;
d3.select('body').append('h2').text('Percentage of Global Government Debt by Country')
d3.select('body').append('p').text("Chart below shows top 25 nations by government debt outstanding in 2014. The rest of the world accounts for roughly 15% of debt issued. Data comes from the CIA's World Factbook. The red dots indicate nations with debt to GDP levels greater than 99%, a commonly used benchmark (although highly debatable) to indicate unsustainable debt levels.")
debugger;
var svg = d3.select("body")
.append("svg")
.attr("width", width + margin)
.attr("height", height + margin)
.append('g')
.attr('class','chart');
/*
Dimple.js Chart construction code
*/
var myChart = new dimple.chart(svg, data);
var x1 = myChart.addMeasureAxis("x", "Debt2GDP");
var x2 = myChart.addMeasureAxis("x", "PercentDebt");
var y = myChart.addCategoryAxis("y", "Country");
y.addOrderRule("PercentDebt", false);
myChart.defaultColors = [
new dimple.color("#000000"),
new dimple.color("#97BFDA"),
new dimple.color("#FD998C")
]
myChart.addSeries("null", dimple.plot.bar, [y, x2]);
myChart.addSeries("Above99", dimple.plot.scatter, [y, x1]);
x1.tickFormat = "%f";
x1.title = "Debt to GDP Ratio (dots)";
x2.tickFormat = "%f";
x2.title = "Percent of World Gov Debt (bars)";
myChart.draw();
};
</script>
</head>
<body>
<script type="text/javascript">
/*
Use D3 (not dimple.js) to load the TSV file
and pass the contents of it to the draw function
*/
d3.csv("globaldebt.csv", draw);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment