Skip to content

Instantly share code, notes, and snippets.

@atdarrigo
Created April 5, 2015 17:34
Show Gist options
  • Select an option

  • Save atdarrigo/be1abb66c9339ef4a00d to your computer and use it in GitHub Desktop.

Select an option

Save atdarrigo/be1abb66c9339ef4a00d to your computer and use it in GitHub Desktop.
Seattle Seahawks' Beneficiary Penalty Yards 2014
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Adding Tooltips</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
}
svg {
background-color: white;
}
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 500)
.attr("height", 400);
d3.csv("SeattlePenalties2014.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.benefitYards, +b.benefitYards);
//If your numeric values aren't sorting properly,
//try commenting out the line above, and instead using:
//
//return d3.descending(+a.lifeSatisfaction, +b.lifeSatisfaction);
//
//Data coming in from the CSV is saved as strings (text),
//so the + signs here force JavaScript to treat those
//strings instead as numeric values, thereby fixing the
//sort order (hopefully!).
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 10;
})
.attr("width", function(d) {
return d.benefitYards * 2;
})
.attr("height", 9)
.append("title")
.text(function(d) {
return d.penalty + " penalty yards: " + d.benefitYards;
});
});
</script>
</body>
</html>
penalty Against League Avg League Avg-Against Yards Lost Benefit benefitYards Dismissed Home Away Rank beneficiaryRank
False Start 34 19.13 -14.87 165 14 61 0 20 14 32 27
Offensive Holding 20 20.06 0.06 189 25 236 1 7 13 15 4
Unnecessary Roughness 9 5.38 -3.62 121 3 42 1 5 4 28 26
Neutral Zone Infraction 10 3.91 -6.09 50 1 5 0 5 5 32 26
Defensive Holding 11 7.34 -3.66 55 11 53 3 4 7 25 4
Defensive Offside 13 4.34 -8.66 63 2 10 2 4 9 32 25
Defensive Pass Interference 7 6.72 -0.28 165 2 80 0 4 3 17 29
Encroachment 4 1.91 -2.09 20 2 10 0 3 1 27 10
Illegal Use of Hands 6 5.22 -0.78 35 3 25 4 3 3 17 24
Illegal Motion 2 0.34 -1.66 10 0 0 0 2 0 31 11
Face Mask (15 Yards) 3 2.88 -0.12 43 4 43 0 2 1 16 4
Ineligible Downfield Pass 2 0.75 -1.25 10 0 0 2 2 0 26 18
Defensive 12 On-field 3 1.13 -1.87 12 0 0 0 2 1 29 22
Illegal Forward Pass 1 0.22 -0.78 5 0 0 0 1 0 26 7
Unsportsmanlike Conduct 1 2.09 1.09 15 4 41 1 1 0 7 2
Disqualification 1 0.16 -0.84 15 0 0 0 1 0 28 6
Running Into the Kicker 1 0.22 -0.78 5 1 5 1 1 0 26 1
Offensive Pass Interference 2 3.28 1.28 20 3 30 1 1 1 4 16
Taunting 2 0.88 -1.12 30 2 30 1 1 1 24 1
Tripping 1 0.31 -0.69 10 0 0 0 1 0 23 8
Illegal Block Above the Waist 4 3.59 -0.41 37 1 10 0 1 3 17 29
Clipping 2 0.25 -1.75 30 0 0 0 1 1 31 7
Illegal Formation 1 1.31 0.31 5 0 0 0 0 1 11 26
Illegal Forward Handoff 0 0 0 0 0 0 0 0 0 1 1
Leverage 0 0 0 0 0 0 0 0 0 1 1
Illegal Kick 0 0 0 0 0 0 0 0 0 1 1
Leaping 0 0 0 0 0 0 0 0 0 1 1
Illegal Onside Kick 0 0 0 0 0 0 0 0 0 1 1
Illegal Peelback 0 0.03 0.03 0 0 0 0 0 0 1 2
Illegal Procedure 0 0 0 0 0 0 0 0 0 1 1
Illegal Receiver Pass 0 0 0 0 0 0 0 0 0 1 1
Chop Block 0 0.22 0.22 0 0 0 0 0 0 1 8
Illegal Substitution 0 0.47 0.47 0 0 0 0 0 0 1 14
Illegal Touch Kick 0 0.09 0.09 0 0 0 0 0 0 1 4
Illegal Touch Pass 0 0.13 0.13 0 0 0 0 0 0 1 5
Invalid Fair Catch Signal 0 0.09 0.09 0 0 0 0 0 0 1 3
Illegal Wedge 0 0.03 0.03 0 0 0 0 0 0 1 2
Illegally Kicking Ball 0 0 0 0 0 0 0 0 0 1 1
Ineligible Downfield Kick 0 0.22 0.22 0 1 5 0 0 0 1 1
Interference with Opportunity to Catch 0 0.16 0.16 0 0 0 0 0 0 1 5
Intentional Grounding 1 0.94 -0.06 15 0 0 1 0 1 14 20
Illegal Shift 0 0.53 0.53 0 0 0 0 0 0 1 14
Short Free Kick 0 0 0 0 0 0 0 0 0 1 1
Defensive Delay of Game 0 0.03 0.03 0 0 0 0 0 0 1 2
Roughing the Passer 0 3.09 3.09 0 1 8 0 0 0 1 24
Roughing the Kicker 0 0.19 0.19 0 0 0 0 0 0 1 5
Player Out of Bounds on Punt 0 0.25 0.25 0 0 0 0 0 0 1 9
Delay of Game 5 4.53 -0.47 25 3 15 0 0 5 18 20
Personal Foul 2 2.03 0.03 17 0 0 0 0 2 12 27
Offside on Free Kick 0 0.69 0.69 0 0 0 0 0 0 1 16
Offensive Offside 0 0.25 0.25 0 0 0 0 0 0 1 7
Face Mask (5 Yards) 0 0 0 0 0 0 0 0 0 1 1
Fair Catch Interference 0 0.06 0.06 0 0 0 0 0 0 1 3
Offensive 12 On-field 1 0.38 -0.62 5 0 0 0 0 1 22 9
Horse Collar 0 0 0 0 0 0 0 0 0 1 1
Horse Collar Tackle 0 0.53 0.53 0 0 0 0 0 0 1 13
Illegal Bat 0 0 0 0 0 0 0 0 0 1 1
Illegal Blindside Block 0 0.34 0.34 0 1 15 0 0 0 1 2
Low Block 0 0.19 0.19 0 0 0 0 0 0 1 5
Illegal Contact 2 3.31 1.31 10 1 5 0 0 2 5 25
Illegal Crackback 0 0 0 0 0 0 0 0 0 1 1
Illegal Cut 0 0 0 0 0 0 0 0 0 1 1
Kickoff Out of Bounds 0 0 0 0 0 0 0 0 0 1 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment