/
index.html
81 lines (63 loc) · 1.82 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.land {
fill: #222;
}
.county-boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
.state-boundary {
fill: none;
stroke: #fff;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="albersUsa-proj.js"></script>
<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);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
// border for development
svg.append("rect")
.attr("height", height)
.attr("width", width)
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", "1px")
.style("opacity", .2);
d3.json("tl_2015_us_cd114_2pc.json", function(error, us) {
console.log('us', us);
svg.insert("path", ".graticule")
.datum(topojson.feature(us, us.objects.tl_2015_us_cd114))
.attr("class", "land")
.attr("d", path);
var topojsonObjects = Object.keys(us.objects);
console.log('topojsonObjects', topojsonObjects);
// svg.insert("path", ".graticule")
// .datum(topojson.mesh(us, us.objects.counties, function(a, b) { return a !== b && !(a.id / 1000 ^ b.id / 1000); }))
// .attr("class", "county-boundary")
// .attr("d", path);
// svg.insert("path", ".graticule")
// .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; }))
// .attr("class", "state-boundary")
// .attr("d", path);
// svg
// .append("path")
// .style("fill","none")
// .style("stroke","#000")
// .attr("d", projection.getCompositionBorders());
});
d3.select(self.frameElement).style("height", height + "px");
</script>