-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchoropleth-area.html
48 lines (39 loc) · 999 Bytes
/
choropleth-area.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="../../d3.v2.js"></script>
<style type="text/css">
svg {
background: #eee;
width: 960px;
height: 500px;
}
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.call(d3.behavior.zoom()
.on("zoom", redraw))
.append("g");
var counties = svg.append("g")
.attr("id", "counties");
var path = d3.geo.path();
var fill = d3.scale.log()
.domain([10, 500])
.range(["brown", "steelblue"]);
d3.json("../data/us-counties.json", function(json) {
counties.selectAll("path")
.data(json.features)
.enter().append("path")
.attr("d", path)
.attr("fill", function(d) { return fill(path.area(d)); });
});
function redraw() {
svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
}
</script>
</body>
</html>