xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>Using Oakland 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: #9FFFD9;
}
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 870)
.attr("height", 380);
d3.csv("CF_AllSummary.csv", function(data) {
data.sort(function(a, b) {
//return d3.descending(a.Total, b.Total);
return d3.descending(+a.Total, +b.Total);
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
//i represents the index value of each rectangle
rects.attr("x", 0)
.attr("y", function(d, i) {
//console.log(i);
return i * 17;
})
.attr("width", function(d) {
return d.Total / 350;
})
.attr("height", 13)
.attr("fill", "#FF6347")
.append("title")
.text(function(d) {
return d.Name + " Contribution = " + d.Total;
});
});
</script>
</body>
</html>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js