forked from usf-cs360-spring2020/homework1-alexziweiwang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
areaChart1.html
278 lines (216 loc) · 9.1 KB
/
areaChart1.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Area Chart: Passenger count during January to September in 2019</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 Font Awesome 5 (free) icons -->
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
</head>
<body>
<!-- Page header -->
<!-- https://bulma.io/documentation/layout/hero/ -->
<section class="hero is-primary is-bold">
<div class="hero-body">
<div class="container">
<h1 class="title">Area Chart: Passenger count during January to September in 2019</h1>
<h2 class="subtitle">prototype + d3 drawing</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">
<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" title="Data">
<span class="icon"><i class="fas fa-table"></i></span>
<span>Data</span>
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
Visualizations
</a>
<div class="navbar-dropdown">
<a class="navbar-item" href="barChart1.html">
<span>Bar Chart</span>
</a>
<a class="navbar-item" href="heatMap1.html">
<span>Heat Map</span>
</a>
<a class="navbar-item" href="areaChart1.html">
<span>Area Chart</span>
</a>
</div>
</div>
</div>
<!-- Right navbar items -->
</div>
</div>
</nav>
<!-- End page navigation -->
<section class="section">
<div class="container">
<!-- Begin page content -->
<div class="content">
<h1 class="title">
Area Chart
</h1>
<p class="subtitle">
Passenger count during January to September in 2019
</p>
<p>This visualization shows passenger count during January to September in 2019 in SFO.</p>
<h2 id="data">Data</h2>
<ol>
<li><strong>Passenger Count:</strong> A quantitative discrete variable, representing number of passengers. In range of 2093 to 52176.</li>
<li><strong>Activity Period:</strong> A categorical variable, represents the month in 2019. In range of 01 to 09 in this visualization.</li>
</ol>
<h3>Prototype:</h3>
<img src="hw1-gn5-mco.png" width="960" height="500">
<h3>d3.js version:
<script src="https://d3js.org/d3.v4.js"></script>
<div id="d3area1"></div>
<script>
// set the dimensions and margins of the graph
var margin = {top: 20, right: 30, bottom: 120, left: 180},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
// append the svg object to the body of the page
var svg = d3.select("#d3area1")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
//Read the data
d3.csv("ATPS-gn5-mco.csv",
function(data) {
let sortColumn = 'ActivityPeriod';
data = data.sort(function(a, b) {
return d3.ascending(a[sortColumn], b[sortColumn]);
});
console.log(data);
console.log("before drawing area chart...");
// Add X axis
var x = d3.scaleTime()
.domain(d3.extent(data, function(d) { return d.ActivityPeriod; }))
.range([ 0, width ]);
svg.append("g")
.attr("transform", "translate(0," + height + ")")
.attr('y', + 370)
.call(d3.axisBottom(x).ticks(5));
svg.append('text')
.attr('class', 'axis-title')
.attr('x', + 330)
.attr('y', + 425)
.text('Activity Period');
// Add Y axis
var y = d3.scaleLinear()
.domain([0, d3.max(data, function(d) { return d.PassengerCount; })])
.range([ height, 0 ]);
svg.append("g")
.call(d3.axisLeft(y));
svg.append('text')
.attr('class', 'axis-title')
.attr('x', -280)
.attr('y', -80)
.attr('transform', 'rotate(-90)')
.text('Passenger Count');
console.log("after adding axis..");
// Add the area
svg.append("path")
.datum(data)
.attr("x", x(0) + 5 )
.attr("y", y(0) + 1.1)
.attr("fill", "#377eb8")
.attr("d", d3.area()
.x(function(d) { return x(d.ActivityPeriod) })
.y0(y(0))
.y1(function(d) { return y(+d.PassengerCount) })
)
svg.append('text')
.attr('y', + 460)
.attr('x', -160)
.text('by Alex Wang');
})
</script></h3>
<h3>Source : <a href="https://data.sfgov.org/Transportation/Air-Traffic-Passenger-Statistics/rkru-6vcg/data">
The plot of sum of Passenger Count for Activity Period.</h3>
<h3>Instructions</h3>
<p>The Y-axis represents passenger count and X-axis represents activity period. The passenger count is encoded by the height of the area, so higher positions represent higher passenger count. The sequence of X-axis is chronological.</p>
<h3>Discussion</h3>
<h4 id="wrangling">Wrangling</h4>
<p> The dataset was chosen in range of greater than 201812 in Activity Period for fetching data for year of 2019. Filtering was applied on the website interface of original dataset.</p>
<h4 id="conclusion">Conclusion</h4>
<p> The volume of passenger is increasing from Feburary to August, and reached the max in August. There is possibility that activities of traveling by flights differs among months, or potentially among seasons, but it worths further studies.</p>
<span class="heading">Acknowledgements</span>
<p>
<a href="#">Link to insiration</a><br/>
<a href="#">Link to StackOverflow snippet</a>
</p>
<p class="is-6">
<em>Thanks to Person Name for their suggestion to do something with the visualization.</em>
</p>
<!-- 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>