Simple line chart showing USAF Active Duty Officer End Strength. The infamous cycle of shrink and expand is quite apparent from the early 90s to early 2000s. Example from /mbostock/02d893e3486c70c4475f.
xxxxxxxxxx
<html>
<!--Example from https://bl.ocks.org/mbostock/02d893e3486c70c4475f-->
<meta charset="utf-8">
<style>
.axis {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis--x path {
display: none;
}
.axis-title {
font-weight: bold;
text-anchor: end;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.0.0-alpha.4.min.js"></script>
<script>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parseTime = d3.timeParse("%b-%y");
var x = d3.scaleTime()
.range([0, width]);
var y = d3.scaleLinear()
.range([height, 0]);
var xAxis = d3.axisBottom()
.scale(x);
var yAxis = d3.axisLeft()
.scale(y);
var line = d3.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.price); });
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.requestTsv("bae_hist_count.tsv", function(d) {
d.date = parseTime(d.date);
d.price = +d.price;
return d;
}, function(error, data) {
if (error) throw error;
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain(d3.extent(data, function(d) { return d.price; }));
svg.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "axis axis--y")
.call(yAxis)
.append("text")
.attr("class", "axis-title")
.attr("transform", "rotate(-90)")
.attr("y", 10)
.attr("dy", ".71em")
.text("Active Duty End Strength");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
});
</script>
</body>
</html>
Modified http://d3js.org/d3.v4.0.0-alpha.4.min.js to a secure url
https://d3js.org/d3.v4.0.0-alpha.4.min.js