-
Notifications
You must be signed in to change notification settings - Fork 1
/
step2.html
44 lines (40 loc) · 1.35 KB
/
step2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<script src="js/d3.v3.min.js"></script>
<script src="js/topojson.js"></script>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<h1>Step 2</h1>
<div id="container">
</div>
<script>
var width = 960, height = 500;
var projection = d3.geo.albersUsa().scale(1000).translate([width / 2, height / 2]);
var path = d3.geo.path().projection(projection), svg;
svg = d3.select("#container").append("svg");
svg.attr("width", width) .attr("height", height);
fields = [ "Code", "1990-advanced", "1990-bachelors", "1990-hs", "1990-not-hs", "2000-advanced",
"2000-bachelors", "2000-hs", "2006-advanced", "2006-bachelors", "2006-hs", "2007-advanced",
"2007-bachelors", "2007-hs", "2008-advanced", "2008-bachelors", "2008-hs", "2009-advanced",
"2009-bachelors", "2009-hs"];
d3.json("data/us.json", function(us) {
d3.csv("data/education.csv", function(edu) {
var dataById = {}
edu.forEach(function(d) {
fields.forEach(function(field) {
d[field] = +d[field];
});
})
svg.append("g")
.classed("states", true)
.selectAll("path")
.data(topojson.feature(us, us.objects.states).features)
.enter()
.append("path")
.attr("d", path)
});
});
</script>
</body>
</html>