Skip to content

Instantly share code, notes, and snippets.

@smckissock
Last active November 7, 2015 14:00
Show Gist options
  • Save smckissock/dea1d6b6606b03add021 to your computer and use it in GitHub Desktop.
Save smckissock/dea1d6b6606b03add021 to your computer and use it in GitHub Desktop.
US Corporate Tax as a Percentage of GDP 1934-2020
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bar Chart</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
font-family: Helvetica, Arial, sans-serif;
}
#container {
width: 700px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
padding: 50px;
background-color: white;
box-shadow: 3px 3px 5px 6px #ccc;
}
h1 {
font-size: 24px;
margin: 0;
}
p {
font-size: 14px;
margin: 10px 0 0 0;
}
svg {
background-color: white;
}
rect:hover {
fill: darkgreen;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
.y.axis path,
.y.axis line {
opacity: 0;
}
</style>
</head>
<body>
<div id="container">
<h1>US Corporate Tax Highest During World War II</h1>
<p>Corporate Income Taxes as a percentage of US GDP: 1934-2020. Source: <a href="https://www.whitehouse.gov/omb/budget/Historicals">OMB</a> Table 2.3</p>
</div>
<script type="text/javascript">
var w = 700;
var h = 1200;
var padding = [ 20, 10, 30, 30 ]; //Top, right, bottom, left
var widthScale = d3.scale.linear()
.range([ 0, w - padding[1] - padding[3] ]);
var heightScale = d3.scale.ordinal()
.rangeRoundBands([ padding[0], h - padding[2] ], 0.1);
var xAxis = d3.svg.axis()
.scale(widthScale)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(heightScale)
.orient("left");
var svg = d3.select("#container")
.append("svg")
.attr("width", w)
.attr("height", h);
d3.csv("usg_receipts.csv", function(data) {
widthScale.domain([ 0, d3.max(data, function(d) {
return +d["Corporation Income Taxes"];
}) ]);
heightScale.domain(data.map(function(d) { return d["Fiscal Year"]; } ));
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", padding[3])
.attr("y", function(d) {
return heightScale(d["Fiscal Year"]);
})
.attr("width", 0)
.attr("height", heightScale.rangeBand())
.attr("fill", "green")
.append("title")
.text(function(d) {
return "In " + d["Fiscal Year"] + " US corporate income tax was " + d["Corporation Income Taxes"] + "% of GDP";
});
rects.transition()
.delay(function(d, i) {
return i * 6;
})
.duration(300)
.attr("width", function (d) {
return widthScale(d["Corporation Income Taxes"]);
});
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(" + padding[3] + "," + (h - padding[2]) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + padding[3] + ",0)")
.call(yAxis);
});
</script>
</body>
</html>
Fiscal Year Individual Income Taxes Corporation Income Taxes Social Insurance and Retirement Receipts Excise Taxes Other
1934 0.7 0.6 0.0 2.2 1.3
1935 0.7 0.8 0.0 2.0 1.5
1936 0.8 0.9 0.1 2.0 1.1
1937 1.2 1.2 0.7 2.1 0.9
1938 1.4 1.4 1.7 2.1 0.9
1939 1.1 1.2 1.8 2.1 0.7
1940 0.9 1.2 1.8 2.0 0.7
1941 1.1 1.8 1.7 2.2 0.7
1942 2.2 3.2 1.7 2.3 0.5
1943 3.5 5.2 1.6 2.2 0.4
1944 9.2 6.9 1.6 2.2 0.5
1945 8.1 7.1 1.5 2.8 0.5
1946 7.1 5.2 1.4 3.1 0.5
1947 7.5 3.6 1.4 3.0 0.6
1948 7.4 3.7 1.4 2.8 0.6
1949 5.6 4.0 1.4 2.7 0.5
1950 5.6 3.7 1.6 2.7 0.5
1951 6.6 4.3 1.7 2.6 0.5
1952 7.8 5.9 1.8 2.5 0.5
1953 7.8 5.6 1.8 2.6 0.5
1954 7.6 5.4 1.9 2.6 0.5
1955 7.1 4.4 1.9 2.2 0.5
1956 7.3 4.8 2.1 2.3 0.5
1957 7.7 4.6 2.2 2.3 0.6
1958 7.3 4.2 2.4 2.2 0.6
1959 7.3 3.4 2.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003 7.0 1.2 6.3 0.6 0.7
2004 6.7 1.6 6.1 0.6 0.6
2005 7.2 2.2 6.2 0.6 0.6
2006 7.6 2.6 6.1 0.5 0.7
2007 8.1 2.6 6.1 0.5 0.7
2008 7.8 2.1 6.1 0.5 0.7
2009 6.3 1.0 6.2 0.4 0.7
2010 6.1 1.3 5.8 0.5 1.0
2011 7.1 1.2 5.3 0.5 0.9
2012 7.1 1.5 5.3 0.5 0.9
2013 7.9 1.6 5.7 0.5 0.9
2014 8.1 1.9 5.9 0.5 1.1
2015 estimate 8.2 1.9 5.9 0.5 1.1
2016 estimate 8.7 2.5 5.9 0.6 1.0
2017 estimate 9.0 2.5 6.0 0.6 1.0
2018 estimate 9.2 2.4 6.0 0.6 1.0
2019 estimate 9.3 2.4 5.9 0.6 1.0
2020 estimate 9.4 2.3 5.9 0.6 1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment