generated from usf-cs360-spring2020/template-bulma
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ned.html
317 lines (256 loc) · 9.78 KB
/
ned.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- TODO: Change title -->
<title>Chinchillas</title>
<!-- Load Bulma from CDN (consider saving it to repository instead) -->
<!-- https://bulma.io/ -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<!-- load D3 minified -->
<script src="//d3js.org/d3.v5.min.js"></script>
<script src="https://d3js.org/d3-axis.v1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-legend/2.25.6/d3-legend.js"></script>
<!-- Load Font Awesome 5 (free) icons -->
<script defer src="https://use.fontawesome.com/releases/v5.10.2/js/all.js"></script>
<style>
.axis text {
font-family: sans-serif;
font-size: 12px;
}
rect:hover
{
stroke:#000
}
</style>
</head>
<body>
<!-- Page header -->
<!-- https://bulma.io/documentation/layout/hero/ -->
<section class="hero is-primary is-bold">
<div class="hero-body">
<div class="container">
<!-- TODO: Change title -->
<h1 class="title">Midterm Project</h1>
<!-- TODO: Change subtitle -->
<h2 class="subtitle">By: Ned Azar, Enrique Bascur, and Jaden Hamid </h2>
</div>
</div>
</section>
<!-- End page header -->
<!-- Page navigation -->
<!-- https://bulma.io/documentation/components/navbar/ -->
<nav class="navbar is-light" role="navigation" aria-label="main navigation">
<div class="container">
<div class="navbar-brand">
<!-- TODO: Change link to repository homepage if needed -->
<!-- TODO: Change which navbar-item is-active if needed -->
<a class="navbar-item is-active" href="index.html">
<span class="icon"><i class="fas fa-home"></i></span>
<span>Home</span>
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="main-menu">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="main-menu" class="navbar-menu has-text-weight-medium">
<!-- Left navbar items -->
<div class="navbar-start">
<a class="navbar-item" href="data.html" title="Data">
<span class="icon"><i class="fas fa-table"></i></span>
<span>Data</span>
</a>
<!-- TODO: Modify or remove dropdown -->
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
<span class="icon"><i class="fas fa-fire-alt"></i></span>
Visualizations
</a>
<div class="navbar-dropdown">
<a href="ned.html" class="navbar-item">
<span class="icon"><i class="fas fa-chart-line"></i></span>
<span>Ned's Chart</span>
</a>
<a href="enrique.html" class="navbar-item">
<span class="icon"><i class="fas fa-chart-area"></i></span>
<span>Enrique's Chart</span>
</a>
<a href="jaden.html" class="navbar-item">
<span class="icon"><i class="fas fa-chart-bar"></i></span>
<span>Jaden's Chart</span>
</a>
</div>
</div>
</div>
<!-- Right navbar items -->
<div class="navbar-end">
<!-- TODO: Update as needed -->
<a class="navbar-item" href="" title="About">
<span class="icon"><i class="fas fa-tasks"></i></span>
<span>Grade</span>
</a>
<a class="navbar-item" href="about.html" title="About">
<span class="icon"><i class="fas fa-info-circle"></i></span>
<span>About</span>
</a>
</div>
</div>
</div>
</nav>
<!-- End page navigation -->
<section class="section">
<div class="container">
<!-- Begin page content -->
<div class="content">
<h1>Ned</h1>
<h2>Personal Wrangling</h2>
<p>To create this visualization, I reduced the data using Tableau after prototyping and reformatted it using a Python script that I wrote to meake the JS code more readable.</p>
<h2>Tableau Prototype</h2>
<img src="nedPrototype.png" alt="">
<h2>D3 Implementation</h2>
<p>The interactivity I plan to implement in the final version of this visualization is that when you brush over a line with a mouse, it will grey out all the other ones and bring the selected line to the top so it can be better observed.</p>
<div class="heatmap">
</div>
<script>
var itemSize = 20;
var cellSize = itemSize - 1;
var cellSize2 = cellSize * (960/500) / 2;
var margin = {top: 50, right: 100, bottom: 100, left: 150};
var width = 960;
var height = 500;
d3.csv('Fire-dictionary_files/heatmapData.csv').then(function(response) {
var data = response.map(function( item ) { // create new array, don't mutate
if(item){
var newItem = {};
newItem.neighborhood = item.Neighborhood;
newItem.hour = item.Hour;
newItem.value = item.Value;
return newItem;
}
})
var x_elements = d3.set(data.map(function( item ) { return item.hour; } )).values();
var y_elements = d3.set(data.map(function( item ) { return item.neighborhood; } )).values();
var xScale = d3.scaleBand()
.domain(x_elements)
.range([0, x_elements.length * (itemSize )]);
var xAxis = d3.axisBottom()
.scale(xScale)
.tickFormat(function (d) {
return d;
});
var yScale = d3.scaleBand()
.domain(y_elements)
.range([0, y_elements.length *10]);
var yAxis = d3.axisLeft()
.scale(yScale)
.tickFormat(function (d) {
return d;
});
var colorScale = d3.scaleSequential(d3.interpolateGnBu).domain([7.15, 22.63]);
var svg = d3.select('.heatmap')
.append("svg")
.attr("width", width + 40)
.attr("height", height )
.append("g");
var cells = svg.selectAll('rect')
.data(data)
.enter().append('g').append('rect')
.attr('class', 'cell')
.attr('width', cellSize2)
.attr('height', cellSize)
.attr('y', function(d) { return yScale(d.neighborhood); })
.attr('x', function(d) { return xScale(d.hour); })
.attr('fill', function(d) { return colorScale(d.value); });
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
svg.append("g")
.attr("class", "x axis")
.call(xAxis);
svg.append("g")
.attr("class", "legendLinear")
.attr("transform", "translate(600,30)")
var legendLinear = d3.legendColor()
.shapeWidth(3)
.cells(50)
.shapePadding(0)
.orient('horizontal')
.scale(colorScale)
// .title("Avg. Minutes");
svg.select(".legendLinear")
.call(legendLinear);
svg.append("text").attr("id","legendtitle")
.attr("x", 640)
.attr("y",20)
.style("text-anchor", "middle")
.style("font-weight", 600)
.style("font-size", "14px")
.text("Avg. Response Time (minutes)");
svg.append("text").attr("id","legendMinScale")
.attr("x", 563)
.attr("y",41)
.style("text-anchor", "left")
.style("font-weight", 500)
.style("font-size", "12px")
.text("7.15");
svg.append("text").attr("id","legendMaxScale")
.attr("x", 755)
.attr("y",41)
.style("text-anchor", "left")
.style("font-weight", 500)
.style("font-size", "12px")
.text("22.63");
});
</script>
<p>Data source: <a href="https://data.sfgov.org/Public-Safety/Fire-Department-Calls-for-Service/nuek-vuh3/data">Data SF</a>, Author: Nedim Azar</p>
<h2>The Bigger Picture</h2>
<p>This visualization supports the group theme by showing the variance in average response times throughout the day in the 5 year period.</p>
</section>
<!-- Page footer -->
<!-- https://bulma.io/documentation/layout/footer/ -->
<footer class="footer">
<div class="content has-text-centered is-size-7">
<p>
<a href="#top">
<span class="fas fa-arrow-up"></span>
<span class="has-text-weight-medium">Back to Top</span>
</a>
</p>
<p>
<!-- TODO: Change to link to your Github repository -->
<a href="https://github.com/usf-cs360-spring2020/template-bulma" class="button is-small" style="padding-left: 1em; padding-right: 1em;">
<i class="fab fa-github-alt"></i> <strong>Github</strong>
</a>
<a href="https://fontawesome.com/" class="button is-small" style="padding-left: 1em; padding-right: 1em;">
<i class="fab fa-font-awesome"></i> <strong>FontAwesome</strong>
</a>
<a href="https://bulma.io" class="button is-small">
<img src="https://bulma.io/images/made-with-bulma--semiblack.png" alt="Made with Bulma" width="128" height="24">
</a>
</p>
</div>
</footer>
<!-- End page footer -->
<!-- Mobile menu responsiveness -->
<!-- https://bulma.io/documentation/components/navbar/ -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
if ($navbarBurgers.length > 0) {
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
const target = el.dataset.target;
const $target = document.getElementById(target);
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
</script>
<!-- End mobile menu responsiveness -->
</body>
</html>