-
Notifications
You must be signed in to change notification settings - Fork 1
/
pct_minority.html
92 lines (78 loc) · 2.16 KB
/
pct_minority.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
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<title>Map Key Demo</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="key-fonts.css" />
<link rel="stylesheet" type="text/css" href="key.css" />
</head>
<body>
<script type="text/javascript">
var data_value = [ 50, 30, 20 ];
var data_color = [ "e5e2d5", "adbfc6", "789cad" ];
var data_label = [ "LMA", "MMA", "HMA" ];
var data_description = [ "Low Minority Areas", "Mixed Minority Areas", "High Minority Areas" ];
var data_plabel = [ "0%", "50%", "80%" ];
d3.select("body")
.append("div")
.attr("id","key-container")
.append("h3")
.text("Percent Minority by Census Tract")
.style("margin-bottom", "0.5em");
d3.select("body #key-container")
.append("div")
.attr("id","label-container");
d3.select("body #key-container")
.append("div")
.attr("id","bar-container");
d3.select("body #key-container")
.append("div")
.attr("id","tick-container");
d3.select("body #key-container")
.append("div")
.attr("id","plabel-container");
d3.select("body #label-container").selectAll("div.bar")
.data(data_value)
.enter()
.append("div")
.style("width", function(d) {
return d + "%";
})
.data(data_label)
.append("h5").text(function(d) { return d; });
d3.select("body #bar-container").selectAll("div.bar")
.data(data_value)
.enter()
.append("div")
.attr("class","bar")
.style("width", function(d) {
return d + "%";
});
d3.select("body").selectAll("div.bar")
.data(data_color)
.style("background-color", function(d) {
return "#" + d;
});
d3.select("body #tick-container").selectAll("div")
.data(data_value)
.enter()
.append("div")
.attr("class","tick")
.style("padding-left", function(d) {
return d + "%";
})
.style("margin-left", function(d) {
return "-2px";
});
d3.select("body #plabel-container").selectAll("div.bar")
.data(data_value)
.enter()
.append("div")
.style("width", function(d) {
return d + "%";
})
.data(data_plabel)
.append("h6").text(function(d) { return d; });
</script>
</body>
</html>