This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
113 lines (99 loc) · 3.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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-62581922-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-62581922-1');
</script>
<title>TSA Passenger Throughput Visualization</title>
</head>
<body class="h-100 py-3">
<main class="container" style="padding-bottom: 40px;">
<h1 class="display-2">TSA Checkpoint Throughput Visualization</h1>
<p class="lead">
This is a mini web scraping & data visualization project. Original raw data can be found @ TSA.gov.
</p>
<section class="card mb-3 w-100" id="chartContainer">
<div class="card-body">
<canvas id="chart">
<p>Your browser does not support the canvas element.</p>
</canvas>
</div>
</section>
<p><em>
More insight coming soon...
</em></p>
</main>
<nav class="navbar fixed-bottom navbar-light bg-light">
<div class="container-fluid">
<a href="https://www.tsa.gov/coronavirus/passenger-throughput" target="_blank">Original data from TSA.gov</a>
<a href="https://github.com/hunj/tsa-passenger-throughput/" target="_blank">View this page's GitHub Repository</a>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script type="text/javascript">
var xhr = new XMLHttpRequest();
var rawData;
var data = {};
xhr.onreadystatechange = alertContents;
xhr.open("GET", "https://raw.githubusercontent.com/hunj/tsa-passenger-throughput/main/output.csv");
xhr.send();
function alertContents() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
rawData = xhr.responseText;
let rows = rawData.split(/\r?\n|\r/);
rows.map(function(row) {
let cols = row.split(',');
data[cols[0]] = cols[1];
});
drawChart();
} else {
// TODO handle error
}
}
}
function drawChart() {
var ctx = document.getElementById('chart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: Object.keys(data),
datasets: [
{
label: '# of Travellers',
data: Object.values(data),
backgroundColor: [
'rgba(99, 255, 132, 0.2)'
],
borderColor: [
'rgba(99, 255, 132, 1)'
],
borderWidth: 1
}
]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
</script>
</body>
</html>