xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mapping data to visual properties</title>
<script type="text/javascript" src="https://d3js.org/d3.v3.js"></script>
</head>
<body>
<p>Exercise for Module 3: Mapping data to visual properties.</p>
<p><strong>12-Year Ranking: Percentage of Points Won</strong></p>
<p>Brazilian Soccer League, Divisions A and B, from 2003 to 2014</p>
<p><em>(The title box shows: Team, Year, Division, Percentage of Points Won)</em>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width",600)
.attr("height", 7000);
d3.csv("BrazilianLeague_A_B_2003_2014.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(a.PctPts, b.PctPts);
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 12;
})
.attr("width", function(d) {
return d.PctPts * 400;
})
.attr("height", 10)
.append("title")
.text(function(d) {
return d.Team + " " + d.Year + " (" + d.Division + ") " + d.PctPts;
});
});
</script>
</body>
</html>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js