-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
148 lines (129 loc) · 6.29 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
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bicycle Rental Statistics</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://d3js.org/d3.v7.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://d3-legend.susielu.com/d3-legend.min.js"></script>
<script src="components/bgmap.js" defer></script>
<script src="components/lollipop.js" defer></script>
<script src="components/heatmap.js" defer></script>
<script src="components/mosaicplot.js" defer></script>
</head>
<body>
<main class="container pb-3">
<div class="row">
<div class="col-left">
<div class="view-container">
<h4 class="view-title">Map</h4>
<div id="map-view" style="width: 648px; height: 800px;">
<div id="legend" style="position: absolute;"></div>
<div id="map-btn" style="position: absolute;"></div>
</div>
</div>
</div>
<div class="col-right">
<div class="view-container">
<h4 class="view-title">Usage Counts</h4>
<div class="col-full" id="lollipop">
<div class="btn-group btn-group-toggle" data-toggle="buttons" style="position: absolute; left:79%;">
<label class="btn">
<input type="radio" name="sortOrder" id="sort-desc" autocomplete="off" checked="True"> Max
</label>
<label class="btn">
<input type="radio" name="sortOrder" id="sort-asc" autocomplete="off"> Min
</label>
</div>
</div>
<div class="tooltip bs-tooltip-top show" id="sc-tooltip" role="tooltip" style="display:none; position: absolute;">
<div class="tooltip-arrow"></div>
<div class="tooltip-inner"></div>
</div>
</div>
<div class="view-container">
<h4 class="view-title d-flex justify-content-between align-items-center">
Traffic Volume and Demographics
<div class="form-check form-switch" style="margin-right: 40px;">
<input class="form-check-input" type="checkbox" id="viewToggle">
<label class="form-check-label" for="viewToggle" checked="False"></label>
</div>
</h4>
<div class="col-full" id="heatmap" style="display: block;"></div>
<div class="col-full" id="mosaic-plot" style="display: none;"></div>
</div>
</div>
</div>
</main>
<script>
let data, locationData, pathData;
let map, lollipop, heatmap, mosaicplot;
let currentSortOrder = 'desc';
function updateBgmap(data, state){
map.updateData(data);
map.updatePaths(state);
locationData = map.markerData;
pathData = map.pathCounts;
if(state === "return") map.showReturnLocations();
if(state === "rent") map.showRentLocations();
if(state === "combined") map.showCombinedLocations();
}
function updateLollipop(locationData, pathData, countMode) {
lollipop.update(locationData, pathData, countMode, currentSortOrder);
}
d3.csv("https://raw.githubusercontent.com/gnueaj/infovis-final/main/data.csv").then(csvData => {
data = csvData;
// map initialize
map = new Bgmap(data);
map.initialize();
locationData = map.markerData;
pathData = map.pathCounts;
// lollipop initialize
lollipop = new Lollipop(locationData, pathData);
lollipop.initialize();
// heatmap initialize
heatmap = new Heatmap(data);
heatmap.initialize();
// moisaicplot initialize
mosaicplot = new MosaicPlot(data);
mosaicplot.initialize();
d3.select('#return-locations').on('click', () => {
updateBgmap(data, 'return')
updateLollipop(locationData, pathData, 'return');
});
d3.select('#rent-locations').on('click', () => {
updateBgmap(data, 'rent')
updateLollipop(locationData, pathData, 'rent');
});
d3.select('#combined-locations').on('click', () => {
updateBgmap(data, 'combined')
updateLollipop(locationData, pathData, 'combined');
});
d3.select('#paths').on('click', () => {
updateBgmap(data, 'Paths')
updateLollipop(locationData, pathData, 'paths');
});
d3.selectAll('input[name="sortOrder"]').on('change', function() {
currentSortOrder = this.id === 'sort-asc' ? 'asc' : 'desc';
updateLollipop(locationData, pathData, lollipop.currentMode);
});
d3.select('#viewToggle').on('change', function() {
const isChecked = d3.select(this).property('checked');
d3.select('#mosaic-plot').style('display', isChecked ? 'block' : 'none');
d3.select('#heatmap').style('display', isChecked ? 'none' : 'block');
if (isChecked) {
mosaicplot.renderLegend();
}
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
</body>
</html>