This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
269 lines (253 loc) · 12.6 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
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
<html lang="en">
<head>
<link href="style.css" rel="stylesheet">
<link href="vendor/fontawesome/css/all.css" rel="stylesheet">
<title>HSL Bike Stands 2017-2019</title>
<!-- Bootstrap & jQuery -->
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" rel="stylesheet">
<script crossorigin="anonymous"
src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="content">
<div id="alert-box">
<div></div>
</div>
<!-- Introduction -->
<div class="row">
<div class="col-md-9">
<div id="map" style="height:65vh; width:100%;"></div>
<div class="row mt-3">
<div class="col-2 text-center" style="flex-direction: row">
<!-- <h5><i class="fa fa-biking"></i> Season</h5>-->
<button class="col-12 btn btn-outline-secondary btn-lg season-btn" id="btn2019"
onclick="changeYear(2019)">2019
</button>
<button class="mt-2 col-12 btn btn-outline-secondary btn-lg season-btn" id="btn2018"
onclick="changeYear(2018)">2018
</button>
<button class="mt-2 col-12 btn btn-outline-secondary btn-lg season-btn" id="btn2017"
onclick="changeYear(2017)">2017
</button>
<div aria-label="Chart mode" class="mt-2 col-12 btn-group btn-group-lg" role="group"
style="padding: 0;">
<button class="btn btn-outline-primary" id="choose-line" type="button"><i
class="fa fa-chart-line"></i> line
</button>
<button class="btn btn-outline-secondary" id="choose-bar" type="button"><i
class="fa fa-chart-bar"></i> bar
</button>
</div>
</div>
<div class="col-10 pl-0">
<div class="text-center" id="loader-background">
<div class="loader" id="loader-spinner">
<div class="ball-pulse">
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
<div class="text-center text-black-50 hidden" id="select-stand-text">Select a bike stand</div>
<div class="text-center text-black-50 hidden" id="too-many-text">Up to 50 stands can be graphed.
Select fewer stands.
</div>
<div class="hidden" id="graph-container">
<div class="graph-time-buttons">
<button class="btn btn-sm btn-outline-secondary" id="zoomOnAll">365d</button>
<button class="btn btn-sm btn-outline-secondary" id="zoomOnMonth">30d</button>
<button class="btn btn-sm btn-outline-secondary" id="zoomOnWeek">7d</button>
</div>
<div id="graph" style="height: 27.5vh; width: 100%;"></div>
</div>
<div class="hidden" id="bar-container" style="width: 100%;">
<canvas aria-label="bar chart" height="21.5vh" id="barChart" role="img" width="100%"></canvas>
<div class="slider">
<label for="timeSlider" id="slider-label">Date</label>
<button class="btn btn-outline-secondary float-left" id="play-pause"><i
class="fa fa-play-circle"></i> Play
</button>
<input aria-labelledby="slider-label" class="mt-1 float-right slider" id="timeSlider"
max="2100" min="0"
style="width: 90%;" type="range" value="0">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<table class="table table-striped" id="stands">
<thead>
<tr>
<th><i class="fa fa-bicycle"></i> Loading Bike Stands..</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<a class="btn color-primary" data-target="#exampleModal" data-toggle="modal"
style="position: fixed; bottom: 1rem; left: 0.5rem;" type="button">
<i class="far fa-2x fa-question-circle"></i>
</a>
</div>
<!-- Modal -->
<div aria-hidden="true" aria-labelledby="exampleModalLongTitle" class="modal fade" id="exampleModal" role="dialog"
tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">How to use the visualization</h5>
<button aria-label="Close" class="close" data-dismiss="modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
Simple selection: Click on a bike stand on the map or on the list.
</div>
<div class="col-md-6">
<img alt="Example of ctrl selection" loading="lazy" src="img/select-simple.gif">
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<p>You can modify selection by holding down <code>Ctrl</code> key while clicking on the map or
on the list.</p>
</div>
<div class="col-md-6">
<img alt="Example of ctrl selection" loading="lazy" src="img/select-ctrl.gif">
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
You can select multiple on the map by holding down <code>Shift</code> key and dragging.
</div>
<div class="col-md-6">
<img alt="Example of shift map selection" loading="lazy" src="img/select-map-shift.gif">
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<code>Ctrl</code>+<code>Shift</code> drag toggles selection of stands within the square.
This can be used to add to selection or remove from selection.
</div>
<div class="col-md-6">
<img alt="Example of shift map selection" loading="lazy" src="img/select-shift-ctrl-map.gif">
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<p>Selected bike stands are drawn on the chart.</p>
<p>Series can be zoomed and panned with the controls below the chart. Hover over series to see
available bikes.</p>
</div>
<div class="col-md-6">
<img alt="Example of shift map selection" loading="lazy" src="img/view-chart.gif">
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<p>You can switch between line and bar chart view at any time. Bar chart view allows playback of
the data.</p>
<p>The time selectors are linked.</p>
</div>
<div class="col-md-6">
<img alt="Example of shift map selection" loading="lazy" src="img/line-bar-switch.gif">
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-outline-secondary" data-dismiss="modal" type="button">Got it!</button>
</div>
</div>
</div>
</div>
<!-- Plugins -->
<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin="anonymous"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin="anonymous"></script>
<!-- jQuery Datatables -->
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/v/bs4/dt-1.10.20/r-2.2.3/sc-2.0.1/sp-1.0.1/sl-1.3.1/datatables.min.css"/>
<script type="text/javascript"
src="https://cdn.datatables.net/v/bs4/dt-1.10.20/r-2.2.3/sc-2.0.1/sp-1.0.1/sl-1.3.1/datatables.min.js"></script>
<!-- Charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css"></script>
<!--<script src="https://d3js.org/d3.v5.min.js" crossorigin="anonymous"></script>-->
<script src="//cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.css"/>
<!-- Utilities -->
<script src="xmlhttprequest.js" charset="UTF-8"></script>
<script src="vendor/es-csv/es-csv.js"></script>
<script src="vendor/gunzip/gunzip.min.js"></script>
<link href="vendor/loaders/loaders.css" rel="stylesheet">
<!-- Page level scripts -->
<script src="stands.js" charset="UTF-8"></script>
<script>
let alerts = 0;
function showAlert(message, timeout, style) {
const alertID = `alert-${alerts}`;
$('#alert-box').append(
`<div id="${alertID}" class="alert alert-${style ? style : 'secondary'} fade show" role="alert">` +
`${message}` +
`</div>`
);
setTimeout(() => $(`#${alertID}`).alert('close'), timeout ? timeout : 1950);
alerts++;
}
// Source: https://digitransit.fi/en/developers/apis/3-map-api/background-map/
const map = L.map('map', {closePopupOnClick: false}).setView([60.192059, 24.945831], 13);
// Show the HSL map background
L.tileLayer('https://cdn.digitransit.fi/map/v1/{id}/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
maxZoom: 17,
minZoom: 9,
tileSize: 512,
zoomOffset: -1,
id: 'hsl-map'
}).addTo(map);
// Switch to control labels on the map
L.Control.LabelSwitch = L.Control.extend({
onAdd: function (map) {
const controlDiv = L.DomUtil.create('div', 'mt-2 custom-control custom-switch');
controlDiv.innerHTML = '<input checked class="custom-control-input" id="popupSwitch" type="checkbox">' +
'<label class="custom-control-label mt-1" for="popupSwitch">Labels</label>';
controlDiv.addEventListener('click', event => {
state.showPopups = $('#popupSwitch').is(":checked");
updateMapView();
});
return controlDiv;
},
onRemove: function (map) {
}
});
L.control.labelSwitch = function (opts) {
return new L.Control.LabelSwitch(opts);
};
L.control.labelSwitch({position: 'bottomleft'}).addTo(map);
request("data/gz/tellingit_filtered_2017-2019.csv.gz", loadStands);
</script>
</body>
</html>