xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>HLE data</title>
<script type="text/javascript" src="https://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
}
svg {
background-color: white;
}
</style>
</head>
<body>
<h1>Healthy life expectancy for men</h1>
<h2>by English region, 2010 to 2012</h2>
<p>Healthy life expectancy (HLE) is an estimate of the years of life that will be spent in good health, and is calculated for England by the Office for National Statistics.</p>
<p>The chart here shows HLE for men for the nine regions in England in 2010-12. It shows about a six year difference between the highest (South East) and lowest (North East) regions.</p>
<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>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js