Skip to content

Instantly share code, notes, and snippets.

@toxford
Created April 6, 2015 02:09
Show Gist options
  • Save toxford/0152eea0ca2c9c2c8a22 to your computer and use it in GitHub Desktop.
Save toxford/0152eea0ca2c9c2c8a22 to your computer and use it in GitHub Desktop.
d3-mod3-airlinedelays
Airline Jan_2015 Feb_2015 March_2015 April_2015 May_2015 June_2015 July_2015 Aug_2015 Sept_2015 Oct_2015 Nov_2015 Dec_2015
AirTran Airways 7.41 5.2 5.29 3.86 4.53 4.85 4.69 4.45 3.26 3.12 2.74 4.09
Alaska Airlines 3.34 2.88 3.2 2.34 2.52 3.47 3.32 3.74 2.99 2.95 3.41 4.2
American Airlines 6.75 6.04 5.4 4.82 6.03 7.43 7.1 7.24 5.61 6.04 6.16 7.85
Delta Air Lines 6 5.81 5.33 4.61 5.03 5.82 4.64 4.89 4.05 3.85 4 3.66
ExpressJet Airlines 7.14 8.48 6.82 5.89 6.33 7.25 6.53 6.34 5.96 5.74 4.9 6.2
Frontier Airlines 7.07 6.05 4.61 4.09 4.5 5.45 4.06 3.87 3.48 3.19 4.29 6.07
Hawaiian Airlines 5.24 6.23 4.96 3.49 3.84 3.2 4.01 3.68 4.56 5.85 5.76 6.81
JetBlue Airways 8.55 8.83 6.48 5.56 5.97 6.01 8.35 6.58 3.47 4.08 4.92 5.75
SkyWest Airlines 5.4 5.24 4.61 4.21 4.65 5.39 5.17 5.03 3.98 3.97 4.88 6.48
Southwest Airlines 7.98 7.73 8.03 7.48 8.35 9.44 9.13 7.35 5.41 5.54 5.47 8.58
United Air Lines 8.7 9.14 7.16 5.22 6.46 8.73 7.45 6.97 5.25 7.09 6.76 9.89
US Airways 5.95 5.8 5.82 5.12 5.65 6.69 6.96 5.48 4.69 4.97 5.35 5.53
Virgin America 3.49 3.82 2.71 2.43 2.68 3.81 3.1 3.39 3.07 3.42 2.8 4.87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>d3 module 3 - oxford</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: #fff;
}
svg {
background-color: #fff;
}
p {
width: 450px;
font-family: "Arial", sans-serif;
}
rect {
fill: #c9c9c9;
}
rect:hover {
fill: #ed5e17;
}
</style>
</head>
<body>
<script type="text/javascript">
d3.select("body")
.append("p")
.text("Percentage of U.S. domestic flights delayed by circumstances within the airline's control (December 2015)");
var svg = d3.select("body")
.append("svg")
.attr("width", 450)
.attr("height", 320);
d3.csv("airline_carrier_delay2015v2.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.Dec_2015, +b.Dec_2015);
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 24;
})
.attr("width", function(d) {
return d.Dec_2015 * 40;
})
.attr("height", 16)
.append("title")
.text(function(d) {
return d.Airline + ": " + d.Dec_2015 + "%";
});
});
</script>
<script type="text/javascript">
d3.csv("airline_carrier_delay2015v2.csv", function(data) {
console.log(data);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment