-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
406 lines (366 loc) · 14.4 KB
/
Copy pathtest.html
File metadata and controls
406 lines (366 loc) · 14.4 KB
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Important for mobile responsiveness -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traffic Wave Dynamics</title>
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&display=swap" rel="stylesheet">
<style>
/* Global Styles */
body {
font-family: 'Lora', serif;
display: flex;
flex-direction: row;
margin: 20px;
/* Optional: set a max-width to keep content narrower on very wide screens */
max-width: 1200px;
margin-left: auto;
margin-right: auto;
}
.controls {
flex: 1;
margin-right: 20px;
/* On really small screens, keep some padding so it doesn't bump against edges */
box-sizing: border-box;
}
.visualization {
flex: 1;
border: 1px solid #ccc;
padding: 20px;
text-align: center;
box-sizing: border-box;
}
/* Buttons */
.button {
background-color: #007BFF;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
margin: 5px;
font-family: 'Lora', serif;
}
.button:hover {
background-color: #0056b3;
}
.input-field {
margin: 10px 0;
}
.input-field label {
display: block;
font-size: 16px;
margin-bottom: 5px;
}
.input-field select {
padding: 8px;
font-size: 14px;
width: 200px;
}
#cluster-section, #index-section {
margin-top: 20px;
}
#index-container {
margin-top: 20px;
}
canvas {
margin-top: 20px;
max-width: 100%;
max-height: 600px; /* Let the canvas be auto-height, so it scales on mobile */
}
/*
Media Query:
Switch to column layout on smaller screens (e.g., below 768px).
Adjust as needed.
*/
@media (max-width: 768px) {
body {
flex-direction: column;
margin: 0; /* or keep some margin if you prefer */
}
.controls, .visualization {
flex: none;
width: 100%;
margin: 0; /* Remove side margin so they take full width on mobile */
margin-bottom: 20px; /* add some spacing at the bottom */
}
}
</style>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body onload="preloadLane1()">
<!-- Controls Panel -->
<div class="controls">
<h1> Gallery of Traffic Wave Dynamics</h1>
<p>
This is the gallery of the wave components identified from
<a href="https://i24motion.org" target="_blank" style="color: #3498db; text-decoration: none;">I-24 MOTION INCEPTIONv1</a> data.
Visit <a href="https://trafficwaves.github.io/demo" target="_blank" style="color: #3498db; text-decoration: none;">this demo</a> for
2-hour demo of the speed field data from the I-24 MOTION INCEPTIONv1 dataset.
</p>
<p>
You can select the lane number (defualt lane 1, i.e. <a href="https://www.tn.gov/tdot/traffic-design/high-occupancy-vehicle-hov-lane.html" style="color: #3498db; text-decoration: none;">HOV lane </a>) and then click on the "Load Lane Data" button to view the clusters of wave components by the number of bifurcations,
the number of mergers, and wave length.
</p>
<!-- Lane Selection -->
<div class="input-field">
<label for="lane-select">Select Lane:</label>
<select id="lane-select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
<button class="button" onclick="loadLaneCSV()">Load Lane Data</button>
<p>
The visualization panel <a href="https://trafficwaves.github.io//#visualization-panel">Go to Cluster Visualization</a>
is a simplified scatter plot of the wave length (mile, in Y-axis)
vs. the number of bifurcations (in X-axis).
</p>
<p>
You can have an idea of how complex each wave component is (based on the number of bifurcations) and how long it is (wave length).
</p>
<p style="background-color: #FEEEB6; padding: 10px; border-radius: 5px;">
Highlight: Wave topology can range from remarkably simple to incredibly complex.
Some waves travel over three miles without any bifurcations before merging, while others can bifurcate more than 10 times along their propagation!
</p>
<p>
Click on any point on the "Cluster Visualization" plot to view the corresponding detailed wave component in the SVG format.
</p>
<p style="background-color: #FEEEB6; padding: 12px; border-radius: 5px; font-size: 20px; font-weight: bold;">
Enjoy the beauty of the wave dynamics!
</p>
<p>
For technical details, please refer to the paper:
<a href="https://arxiv.org/abs/2409.00326" target="_blank" style="color: #3498db; text-decoration: none;">Scalable analysis of stop-and-go waves</a>.
</p>
<p>
If you find this resource useful, please consider citing the paper:
</p>
<div style="background-color: #f4f4f4; border-left: 4px solid #3498db; padding: 10px; margin: 15px 0; font-family: 'Courier New', monospace; font-size: 0.95em; overflow-x: auto;">
<pre style="margin: 0; white-space: pre-wrap;">
@article{ji2026scalable,
title={Scalable analysis of stop-and-go waves: Representation, measurements and insights},
author={Ji, Junyi and Gloudemans, Derek and Wang, Yanbing and Zach{\'a}r, Gergely and Barbour, William and Sprinkle, Jonathan and Piccoli, Benedetto and Work, Daniel B},
journal={Transportation Research Part C: Emerging Technologies},
volume={182},
pages={105385},
year={2026},
publisher={Elsevier}
}
</pre>
</div>
<p>
Contact <a href="mailto:
junyi.ji@vanderbilt.edu" style="color: #3498db; text-decoration: none;"> Junyi Ji</a> at Vanderbilt University if you have any questions or suggestions.
</p>
<p>
To explore wave components by date, first select a date, then choose a cluster of interest. Click "Next" to view detailed wave components by clicking the buttons under "Available Indices".
This will display all wave components for the selected date, lane, and cluster, along with information on wave length, number of bifurcations, and number of mergers.
</p>
<p>
Click on the button to view the detailed wave component in the SVG format.
</p>
<!-- Date Selection -->
<div class="input-field">
<label for="date-select">Select Date:</label>
<select id="date-select">
<option value="2022-11-22">2022-11-22</option>
<option value="2022-11-28">2022-11-28</option>
<option value="2022-11-29">2022-11-29</option>
<option value="2022-11-30">2022-11-30</option>
<option value="2022-12-01">2022-12-01</option>
<option value="2022-12-02">2022-12-02</option>
</select>
</div>
<!-- Cluster Selection -->
<div id="cluster-section" style="display: none;">
<h2>Select Cluster</h2>
<div class="input-field">
<label for="cluster-select">Select Cluster:</label>
<select id="cluster-select"></select>
</div>
<button class="button" onclick="showIndexSection()">Next</button>
</div>
<!-- Index Display -->
<div id="index-section" style="display: none;">
<h2>Available Indices</h2>
<div id="index-container"></div>
</div>
</div>
<!-- Visualization Panel -->
<div id="visualization-panel" class="visualization">
<h2 id="visualization-title">Cluster Visualization for Lane 1</h2>
<!-- Add Lane Selection Inside Visualization -->
<div class="input-field" style="margin-bottom: 10px;">
<label for="lane-select-visual">Select Lane:</label>
<select id="lane-select-visual">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<button class="button" onclick="loadLaneCSVFromVisualization()">Load Lane Data</button>
</div>
<canvas id="clusterChart"></canvas>
</div>
<script>
let csvData = [];
let clusterChart;
async function preloadLane1() {
document.getElementById('lane-select').value = '1';
await loadLaneCSV();
}
// Load Lane Data from Visualization Panel
async function loadLaneCSVFromVisualization() {
const lane = document.getElementById('lane-select-visual').value;
document.getElementById('lane-select').value = lane; // Sync with main dropdown
await loadLaneCSV(); // Reuse the existing loadLaneCSV function
}
// Load CSV Data
async function loadLaneCSV() {
const lane = document.getElementById('lane-select').value;
document.getElementById('lane-select-visual').value = lane; // Sync with main dropdown
document.getElementById('visualization-title').innerText = `Cluster Visualization for Lane ${lane}`;
if (!lane) {
alert('Please select a lane first.');
return;
}
const csvFile = `https://trafficwaves.github.io/cc_properties_lane_${lane}.csv`;
try {
const response = await fetch(csvFile);
if (!response.ok) {
throw new Error(`Failed to load ${csvFile}.`);
}
const csvText = await response.text();
parseCSV(csvText);
} catch (error) {
console.error('Error loading CSV:', error);
alert(`Failed to load CSV file for Lane ${lane}.`);
}
}
// Parse CSV
function parseCSV(csvText) {
const rows = csvText.trim().split('\n').map(row => row.split(','));
const headers = rows.shift().map(header => header.trim());
csvData = rows.map(row => {
const entry = {};
headers.forEach((header, index) => {
entry[header] = row[index]?.trim();
});
return entry;
});
populateClusterDropdown();
renderVisualization();
}
// Populate Cluster Dropdown
function populateClusterDropdown() {
const date = document.getElementById('date-select').value;
const clusterSelect = document.getElementById('cluster-select');
clusterSelect.innerHTML = '';
const uniqueClusters = [...new Set(csvData.filter(row => row.date === date).map(row => row.cluster))];
uniqueClusters.forEach(cluster => {
const option = document.createElement('option');
option.value = cluster;
option.textContent = `Cluster ${cluster}`;
clusterSelect.appendChild(option);
});
document.getElementById('cluster-section').style.display = 'block';
}
// Show Indices
function showIndexSection() {
const date = document.getElementById('date-select').value;
const lane = document.getElementById('lane-select').value;
const cluster = document.getElementById('cluster-select').value;
const indexContainer = document.getElementById('index-container');
indexContainer.innerHTML = '';
// Filter rows based on selected date and cluster
const filteredRows = csvData.filter(row => row.date === date && row.cluster === cluster);
// Sort filtered rows by wave_length (descending order)
filteredRows.sort((a, b) => parseFloat(b.wave_length) - parseFloat(a.wave_length));
// Create buttons for each row
filteredRows.forEach(row => {
const button = document.createElement('button');
button.className = 'button';
button.textContent = `View Index ${row.cc_id} (Wave Length: ${parseFloat(row.wave_length).toFixed(2)} mile, Bifurcations: ${row.num_bifurcations}, Merges: ${row.num_mergers})`;
button.onclick = () => {
const filePath = `https://trafficwaves.github.io/${date}/lane_${lane}/${row.cc_id}_15.svg`;
window.open(filePath, '_blank');
};
indexContainer.appendChild(button);
});
document.getElementById('index-section').style.display = 'block';
}
// Render Visualization with Clickable Points
function renderVisualization() {
const ctx = document.getElementById('clusterChart').getContext('2d');
const groupedData = {};
csvData.forEach(row => {
if (!groupedData[row.cluster]) groupedData[row.cluster] = [];
groupedData[row.cluster].push({
x: parseFloat(row.num_bifurcations),
y: parseFloat(row.wave_length),
date: row.date,
cc_id: row.cc_id,
num_bifurcations: row.num_bifurcations,
num_mergers: row.num_mergers
});
});
const datasets = Object.keys(groupedData).map(cluster => ({
label: `Cluster ${cluster}`,
data: groupedData[cluster],
pointRadius: 5,
}));
if (clusterChart) clusterChart.destroy();
clusterChart = new Chart(ctx, {
type: 'scatter',
data: { datasets },
options: {
plugins: {
tooltip: {
callbacks: {
label: function(context) {
const point = context.raw;
return `[${point.date}, index id: ${point.cc_id}, bifurcations: ${point.num_bifurcations}, mergers: ${point.num_mergers}, wave length: ${point.y.toFixed(2)} mile]`;
}
}
}
},
scales: {
x: {
title: {
display: true,
text: 'Number of Bifurcations' // X-axis Title
}
},
y: {
title: {
display: true,
text: 'Wave Length (mile)' // Y-axis Title
},
min: 0,
max: 4
}
},
responsive: true,
maintainAspectRatio: false,
onClick: (event, elements) => {
if (elements.length > 0) {
const clickedElementIndex = elements[0].index;
const datasetIndex = elements[0].datasetIndex;
const clickedPoint = clusterChart.data.datasets[datasetIndex].data[clickedElementIndex];
if (clickedPoint) {
const filePath = `https://trafficwaves.github.io/${clickedPoint.date}/lane_${document.getElementById('lane-select').value}/${clickedPoint.cc_id}_15.svg`;
window.open(filePath, '_blank');
}
}
}
}
});
}
</script>
</body>
</html>