-
Notifications
You must be signed in to change notification settings - Fork 0
/
orgchart.html
194 lines (168 loc) · 6.47 KB
/
orgchart.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
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<title>Austin Pets Alive! Organizational Chart</title>
<style>
.node circle {
fill: #999;
}
.node text {
font: 10px sans-serif;
}
.node--internal circle {
fill: #555;
}
.node--internal text {
text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff;
}
.link {
fill: none;
stroke: #555;
stroke-opacity: 0.4;
stroke-width: 1.5px;
}
form {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
left: 10px;
top: 10px;
}
label {
display: block;
}
.header{
font-family: 'Ubuntu', sans-serif;
font-weight: 600;
font-size: 60px;
}
.contentvisual{
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}
</style>
<h1 class="header">Austin Pets Alive! Organizational Chart</h1>
<p class="contentvisual">You can press <font color="#DC5928">CTRL+F</font> to search for a position.</br>
Volunteers are highlighted in green. Clicking any position shows the escalation chain above that position in blue.</br>
If you need to get in touch with someone you can email <font color="#DC5928">[email protected]</font> (filling in their first and last name).</br>
You can also access the employee email directory <a href="https://app.betterimpact.com/Volunteer/Main/Contact">here</a>.</p>
<p>This organizational chart is not in a finalized state and is meant for internal use only. If you see an issue, cannot find yourself in the chart, or otherwise have questions/comments or concerns, please use the <a href="https://docs.google.com/forms/d/e/1FAIpQLSe8EN_E81JVTvvQYTPryzLAkYdapZk4n8s17CPOMKTuZZcB3w/viewform">Feedback Form</a> to let us know!</p>
<hr>
<form>
<label><input type="radio" name="mode" value="cluster" checked> Dendrogram</label>
<label><input type="radio" name="mode" value="tree"> Tree</label>
</form>
<svg id="tree" height="3200"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
document.getElementById("tree").setAttribute("width", (window.innerWidth - 100).toString());
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height"),
g = svg.append("g").attr("transform", "translate(200,0)");
var tree = d3.tree()
.size([height - 400, width - 500]);
var cluster = d3.cluster()
.size([height, width - 500]);
var stratify = d3.stratify()
.parentId(function(d) { return d.id.substring(0, d.id.lastIndexOf(".")); });
var dataFile = "https://docs.google.com/document/export?format=txt&id=1Vy8tmnRzrwxJkLLzrEoVcsEKRRvLdbF1GlalzASUnqw";
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = this.responseText;
// Custom parsing from google doc txt output of bulletted list
// parsed_data = data.split('\n').slice(3).join('\n'); //Remove CORS header
parsed_data = data.replace(/\* /g, "");
parsed_data = parsed_data.replace(/\./g, "");
parsed_data = parsed_data.replace(/ /g, "\t");
parsed_data = parsed_data.split('\n');
for(var i = 0; i < parsed_data.length; i++){
depth = 0;
for(var j = 0; j < parsed_data[i].length; j++)
if (parsed_data[i][j] == '\t')
depth += 1;
else
break;
parsed_data[i] = {id: parsed_data[i].substring(depth), depth: depth};
}
chain_data = [{id: parsed_data[0].id, value: 1}];
for(var i = parsed_data.length-1; i >= 1; i--){
chain = parsed_data[i].id;
curr_depth = parsed_data[i].depth;
for(var j = i-1; j >= 0; j--){
if (parsed_data[j].depth < curr_depth){
curr_depth = parsed_data[j].depth;
chain = parsed_data[j].id + "." + chain
}
}
chain_data.push({id: chain, value: 1});
}
data = chain_data;
// End custom parser
var root = stratify(data)
.sort(function(a, b) { return (a.height - b.height) || a.id.localeCompare(b.id); });
cluster(root);
var link = g.selectAll(".link")
.data(root.descendants().slice(1))
.enter().append("path")
.attr("class", "link")
.attr("d", diagonal);
var node = g.selectAll(".node")
.data(root.descendants())
.enter().append("g")
.attr("class", function(d) { return "node" + (d.children ? " node--internal" : " node--leaf"); })
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
node.append("circle")
.attr("r", 2.5);
node.append("text")
.attr("dy", 3)
.attr("x", function(d) { return d.children ? -8 : 8; })
.attr("class", "nametext")
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
.on("click", function(d) {
d3.event.stopPropagation();
elements = d3.selectAll('.nametext')._groups[0];
for(var i = 0; i < elements.length; i++)
if (d.id.includes(elements[i].innerHTML))
d3.select(elements[i]).attr("fill", "#07AACB").style("font-size", "14px");
else
d3.select(elements[i]).attr("fill", "#D3D3D3").style("font-size", "10px");
})
.text(function(d) { return d.id.substring(d.id.lastIndexOf(".") + 1); });
var setDefaultColors = function(){
elements = d3.selectAll('.nametext')._groups[0];
console.log(elements);
for(var i = 0; i < elements.length; i++){
var color = "black";
if (elements[i].innerHTML.trim().endsWith('`'))
color = "green";
d3.select(elements[i]).attr("fill", color).style("font-size", "10px");
}
}
setDefaultColors();
d3.select("body").on("click",function(){
setDefaultColors();
});
d3.selectAll("input")
.on("change", changed);
var timeout = setTimeout(function() {
d3.select("input[value=\"tree\"]")
.property("checked", true)
.dispatch("change");
}, 250);
function changed() {
timeout = clearTimeout(timeout);
(this.value === "tree" ? tree : cluster)(root);
var t = d3.transition().duration(500);
node.transition(t).attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
link.transition(t).attr("d", diagonal);
}
}
};
xhttp.open("GET", dataFile, true);
xhttp.send();
function diagonal(d) {
return "M" + d.y + "," + d.x
+ "C" + (d.parent.y + 100) + "," + d.x
+ " " + (d.parent.y + 100) + "," + d.parent.x
+ " " + d.parent.y + "," + d.parent.x;
}
</script>