-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
240 lines (191 loc) · 6.65 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="date" content="2016-04-21" />
<link rel="stylesheet" href="style.css">
<script src="d3plus/d3.js"></script>
<script src="d3plus/d3plus.js"></script>
<script src="d3plus/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
<body>
<div class="w3-row-padding">
<div class="w3-col s2">
<div id="levelcontrol">
<fieldset>
<legend for = "level" id="mylegend"> Options: </legend>
<h6>Select Level</h6>
<select id="level">
<option selected="selected">College</option>
<option>Graduate</option>
<option>Undergraduate</option>
</select>
<br>
<h6>Notes:</h6>
<p> Year is a graduation year </p>
<p class="datasource"> Data source: <a href="http://oerc.osu.edu/"> Ohio Education Research Center</a></p>
<p class="datasource"> Industry sectors are based on the North American Industry Classification System (NAICS)<br>
Source: <a href="http://www.census.gov/eos/www/naics/"> U.S. Census Bureau</a></p>
</fieldset>
</div>
</div>
<div class="w3-col s6">
<div class="w3-container" id="treemap"></div>
</div>
<div class="w3-col s4">
<div class ="w3-container" id="bar"></div>
</div>
</div>
<script type="text/javascript">
//trying custom color scheme
/*
var attributes = [
{"naics2_descr": "Education", "hex": "#F24747"},
{"naics2_descr": "Retail", "hex": "#C5A233"},
{"naics2_descr": "Accommodation & Food Services", "hex": "#3F6662"},
{"naics2_descr": "Health Care & Social Assistance", "hex": "#187ED0"},
{"naics2_descr": "Arts, Entertainment, & Recreation", "hex": "#FDBA91"},
{"naics2_descr": "Admin. & Support & Waste Management & Remediation Services", "hex": "#C32B97"},
{"naics2_descr": "Other Services", "hex": "#FDBA70"},
{"naics2_descr": "Public Administration", "hex": "#5BA5D0"},
{"naics2_descr": "Professional, Scientific, & Technical Services", "hex": "#FBF096"},
{"naics2_descr": "Manufacturing", "hex": "#45778B"},
{"naics2_descr": "Finance & Insurance", "hex": "#E57352"},
{"naics2_descr": "Transportation & Warehousing", "hex": "#4233C5"},
{"naics2_descr": "Construction", "hex": "#C45532"},
{"naics2_descr": "Wholesale Trade", "hex": "#33C5B3"},
{"naics2_descr": "Information", "hex": "#956587"},
{"naics2_descr": "Real Estate & Rental & Leasing", "hex": "#B2BA89"},
{"naics2_descr": "Management of Companies & Enterprises", "hex": "#FFC7CE"},
{"naics2_descr": "Agriculture, Forestry, Fishing & Hunting", "hex": "#FFD4AA"},
{"naics2_descr": "Mining, Quarrying, & Oil & Gas Extraction", "hex": "#FFD4AA"}
]
*/
//custom ploting function; should probably modify it to be more generic
var myset = []
function make_viz(data){
var visualization = d3plus.viz()
.container("#treemap")
.data(data)
.type("tree_map")
.id(["naics2_descr","naics3_descr"])
.font({ "family": "Pathway Gothic One, sans-serif"})
.size("count")
.time({"value": "AY", "solo": 2014})
.labels({"align": "left", "valign": "top"})
.title("Employment by Sector")
.title({
"font" : { "family": "Montserrat, sans-serif",
"size" : 16,
"transform" : "uppercase"
}
})
.tooltip({"font" : { "family": "Raleway, sans-serif"} })
/* .attrs(attributes)
.color("hex")
*/
.draw()
}
// creating a function to read in the employment data and storing it in the myset var
function reader (file, variable, condition){
d3.csv(file, function(error, temp) {
if (error) return console.error(error);
temp = temp.filter(function(d){
return d[variable] == condition;
})
temp.forEach(function(d) {
d3.keys(d).forEach(function(k){
if(k == "count" & k != "AY"){
d[k] = +d[k]
}
})
})
for ( var i=0; i < temp.length; i++){
myset[i] = {"AY" : temp[i].AY, "Department" : temp[i].Department, "Level" : temp[i].Level,
"naics2_descr" : temp[i].naics2_descr, "naics3_descr" : temp[i].naics3_descr, "count" : temp[i].count}
}
})
}
// Loading the time-to-employment file and storing it in the time var
var time = []
d3.csv("other.csv",function(data){
data.forEach(function(d) {
d3.keys(d).forEach(function(k){
if(k != "Period"){
d[k] = +d[k]
}
})
})
for ( var i=0; i < data.length; i++){
time[i] = {"Year" : data[i].Year, "Period" : data[i].Period, "College" : data[i].College, "Undergraduate" : data[i].Undergraduate,
"Graduate" : data[i].Graduate}
}
});
// drawing initial treemap
reader("final.csv");
make_viz(myset);
// drawing a bar chart
var barchart = d3plus.viz()
.container("#bar")
.data(time)
.type("bar")
.id("Period")
.x("Period")
.y("College")
.time({"value": "Year", "solo": 2013})
.ui([
{
"label" : "Select Level",
"type" : "button",
"value" : [{"College":"College"},{"Undergraduate":"Undergraduate"}, {"Graduate":"Graduate"}],
"method" : function(value, viz){
if(value == "College"){
viz.y({"value": "College"}).draw();
}
else if (value == "Undergraduate"){
viz.y({"value": "Undergraduate"}).draw();
}
else {
viz.y({"value": "Graduate"}).draw();
}
}
}
])
.title("Percent Employed")
.title({
"font" : { "family": "Montserrat, sans-serif",
"size" : 16,
"transform" : "uppercase"
}
})
.tooltip({"font" : { "family": "Raleway, sans-serif"} })
.order({"value": "Period"})
.draw()
// interactivity with dropdown controls
$("#level").change(function () {
if($("#level :selected").val()=="Undergraduate")
{
$('#treemap').empty();
myset = []
reader("final.csv","Level","U");
make_viz(myset);
} else if ($("#level :selected").val()=="Graduate") {
$('#treemap').empty();
myset = []
reader("final.csv","Level","G");
make_viz(myset);
}
else {
$('#treemap').empty();
myset = []
reader("final.csv");
make_viz(myset);
}
});
</script>
</body>
</html>