Skip to content

Instantly share code, notes, and snippets.

@sporange
Created March 30, 2015 21:13
Show Gist options
  • Save sporange/d07bd35257742b675f05 to your computer and use it in GitHub Desktop.
Save sporange/d07bd35257742b675f05 to your computer and use it in GitHub Desktop.
Male healthy life expectancy
<!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: #ddddff;
}
svg {
background-color: white;
}
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 300)
.attr("height", 300);
d3.csv("PHOF_LE_data_EngRegion.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(a.HealthyLE_Male_2010to12, b.HealthyLE_Male_2010to12);
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("fill","#009999");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 30;
})
.attr("width", function(d) {
return d.HealthyLE_Male_2010to12 * 4;
})
.attr("height", 25)
.append("title")
.text(function(d) {
return d.Region + "'s male healthy life expectancy in 2010-12 was " + d.HealthyLE_Male_2010to12 + " years.";
});
});
</script>
</body>
</html>
Region HealthyLE_Female_2009to11 HealthyLE_Female_2010to12 HealthyLE_Male_2009to11 HealthyLE_Male_2010to12 LEat65_Female_2000to02 LEat65_Female_2001to03 LEat65_Female_2002to04 LEat65_Female_2003to05 LEat65_Female_2004to06 LEat65_Female_2005to07 LEat65_Female_2006to08 LEat65_Female_2007to09 LEat65_Female_2008to10 LEat65_Female_2009to11 LEat65_Female_2010to12 LEat65_Female_2011to13 LEat65_Male_2000to02 LEat65_Male_2001to03 LEat65_Male_2002to04 LEat65_Male_2003to05 LEat65_Male_2004to06 LEat65_Male_2005to07 LEat65_Male_2006to08 LEat65_Male_2007to09 LEat65_Male_2008to10 LEat65_Male_2009to11 LEat65_Male_2010to12 LEat65_Male_2011to13 LE_Female_2000to02 LE_Female_2001to03 LE_Female_2002to04 LE_Female_2003to05 LE_Female_2004to06 LE_Female_2005to07 LE_Female_2006to08 LE_Female_2007to09 LE_Female_2008to10 LE_Female_2009to11 LE_Female_2010to12 LE_Female_2011to13 LE_Male_2000to02 LE_Male_2001to03 LE_Male_2002to04 LE_Male_2003to05 LE_Male_2004to06 LE_Male_2005to07 LE_Male_2006to08 LE_Male_2007to09 LE_Male_2008to10 LE_Male_2009to11 LE_Male_2010to12 LE_Male_2011to13 SlopeIndexLE_Female_2002to04 SlopeIndexLE_Female_2003to05 SlopeIndexLE_Female_2004to06 SlopeIndexLE_Female_2005to07 SlopeIndexLE_Female_2006to08 SlopeIndexLE_Female_2007to09 SlopeIndexLE_Female_2008to10 SlopeIndexLE_Female_2009to11 SlopeIndexLE_Female_2010to12 SlopeIndexLE_Female_2011to13 SlopeIndexLE_Male_2002to04 SlopeIndexLE_Male_2003to05 SlopeIndexLE_Male_2004to06 SlopeIndexLE_Male_2005to07 SlopeIndexLE_Male_2006to08 SlopeIndexLE_Male_2007to09 SlopeIndexLE_Male_2008to10 SlopeIndexLE_Male_2009to11 SlopeIndexLE_Male_2010to12 SlopeIndexLE_Male_2011to13
East Midlands 63.3 63.6 63 63.2 19.1 19.1 19.2 19.4 19.7 19.9 20.1 20.4 20.6 20.9 21 21 16.1 16.2 16.4 16.7 17 17.3 17.4 17.7 17.9 18.2 18.3 18.5 80.5 80.5 80.7 80.9 81.3 81.6 81.8 82 82.3 82.8 82.9 83 76.1 76.3 76.5 76.9 77.3 77.6 77.8 78.1 78.3 78.7 79.1 79.3 6 5.9 6 6.2 6.4 6.8 6.6 6.7 6.4 6.6 8.7 8.6 8.5 8.8 8.8 9 8.9 8.9 8.7 8.6
East of England 66.2 66.1 64.8 64.9 19.6 19.7 19.8 20 20.3 20.5 20.7 21 21.1 21.5 21.5 21.6 16.6 16.9 17.1 17.3 17.6 17.9 18.2 18.5 18.6 18.9 19.1 19.2 81.4 81.4 81.6 81.8 82.3 82.5 82.7 83 83.2 83.6 83.7 83.8 77 77.3 77.6 77.9 78.3 78.6 78.9 79.2 79.5 79.9 80.1 80.3 4.4 4.6 4.6 4.8 4.9 4.9 5 5.1 5.4 5.5 6.7 7 7 7.2 7.2 7.3 7.3 7.4 7.4 7.5
London 63.8 63.6 63 63.2 19.5 19.5 19.6 19.8 20.3 20.6 20.8 21.1 21.3 21.7 21.7 21.9 16.2 16.4 16.6 16.9 17.3 17.6 17.9 18.1 18.4 18.7 18.9 19.1 80.8 80.8 81.1 81.4 81.9 82.3 82.6 82.9 83.2 83.6 83.8 84.1 75.8 76 76.4 76.8 77.3 77.7 78.1 78.5 78.8 79.3 79.7 80 5.2 5.4 5.5 5.4 5.4 5.5 5.5 5.4 5.1 4.8 8.5 8.3 8.3 8.6 8.9 8.8 8.3 7.8 7.5 7.3
North East 60.2 60.1 59.7 59.5 18.2 18.3 18.4 18.5 18.7 19 19.2 19.4 19.6 20 20 20 15.1 15.3 15.5 15.8 16.1 16.4 16.6 16.9 17.1 17.5 17.6 17.8 79.3 79.5 79.6 79.8 80.1 80.4 80.6 80.9 81.1 81.5 81.6 81.7 74.5 74.7 74.9 75.3 75.7 76.2 76.4 76.7 77.1 77.5 77.8 78 8 7.9 7.9 8.1 8.5 8.8 8.7 8.7 8.3 8.7 10.9 11 11.6 11.7 12 12.1 11.6 11.5 11 10.8
North West 61.7 61.8 61 61.3 18.4 18.4 18.5 18.7 19.1 19.2 19.3 19.5 19.8 20.1 20.2 20.2 15.3 15.5 15.7 16 16.3 16.5 16.8 17 17.2 17.6 17.8 17.9 79.4 79.5 79.7 79.9 80.3 80.5 80.6 80.8 81.1 81.5 81.7 81.8 74.6 74.8 75.1 75.4 75.8 76.1 76.4 76.6 77 77.4 77.7 78 8.4 8.7 8.7 8.7 9.1 8.9 8.9 8.7 8.9 8.9 10.9 11.2 11.4 11.8 11.9 11.8 11.7 11.5 11.5 11.3
South East 67 67.1 65.7 65.8 19.8 19.8 20 20.1 20.4 20.7 20.9 21.2 21.4 21.6 21.6 21.7 16.8 17 17.1 17.5 17.8 18.1 18.4 18.6 18.8 19 19.2 19.3 81.5 81.6 81.8 82 82.4 82.6 82.9 83.2 83.5 83.8 83.8 83.9 77.2 77.4 77.7 78.1 78.5 78.9 79.1 79.4 79.7 80 80.3 80.4 4.4 4.7 4.7 4.9 4.9 5.1 5.1 5.2 5.2 5.4 7.6 7.6 7.7 7.6 7.7 7.8 7.7 7.8 7.6 7.7
South West 66.3 66 65.1 65.2 20 20 20.1 20.3 20.7 20.9 21.1 21.3 21.4 21.6 21.7 21.7 16.9 17.1 17.3 17.5 17.9 18.1 18.3 18.5 18.7 19 19.1 19.2 81.7 81.8 82 82.2 82.7 82.9 83 83.2 83.4 83.7 83.9 83.8 77.1 77.4 77.7 78.1 78.4 78.7 78.9 79.1 79.4 79.8 80 80.1 4.6 4.9 4.8 4.8 4.9 5 5 5.1 5.1 5.1 7.2 7.1 7 7.1 7.4 7.6 7.5 7.1 7.1 7.5
West Midlands 62.8 62.7 62.5 62.3 19.1 19.1 19.2 19.4 19.7 19.9 20.1 20.4 20.6 21 21 21.1 15.8 16 16.2 16.4 16.8 17 17.3 17.6 17.9 18.2 18.4 18.4 80.3 80.4 80.6 80.8 81.1 81.4 81.6 81.9 82.2 82.6 82.7 82.8 75.4 75.6 75.9 76.2 76.6 76.9 77.2 77.5 77.9 78.4 78.7 78.8 6 6.2 6.3 6.3 6.6 6.6 6.7 6.7 6.8 6.8 9.6 9.4 9.4 9.7 10 9.6 9.3 9.3 9.2 9.2
Yorkshire and the Humber 62.1 62 61 61.2 19 19 19 19.2 19.5 19.6 19.8 20 20.2 20.5 20.5 20.5 15.7 15.9 16.1 16.4 16.7 17 17.2 17.4 17.6 17.8 18 18 80.2 80.3 80.4 80.6 81 81.1 81.3 81.4 81.7 82 82.2 82.2 75.4 75.6 75.8 76.2 76.5 76.8 77.1 77.4 77.7 78.1 78.3 78.5 6.6 6.8 7 7.1 7.3 7.5 7.8 7.6 7.4 7.5 9.9 10 10.5 10.7 11 10.6 10.3 10 9.8 9.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment