-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
315 lines (281 loc) · 10.3 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
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
<HTML>
<head>
<script type="text/javascript"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://rawgit.com/jasondavies/d3-cloud/master/build/d3.layout.cloud.js"></script>
<link href="https://fonts.googleapis.com/css?family=Bitter" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/solid.css" integrity="sha384-QokYePQSOwpBDuhlHOsX0ymF6R/vLk/UQVz3WHa6wygxI5oGTmDTv8wahFOSspdm" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/fontawesome.css" integrity="sha384-vd1e11sR28tEK9YANUtpIOdjGW14pS87bUBuOIoBILVWLFnS+MCX9T6MMf0VdPGq" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="bar-update.css">
<link rel="stylesheet" href="word-radar.css">
<link rel="stylesheet" href="radar.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="//d3js.org/d3-scale-chromatic.v0.3.min.js"></script>
<link rel="stylesheet" href="d3.slider.css" />
<style>
.wrapper {
width: 800px;
margin-left: auto;
margin-right: auto;
}
.wrapper > div {
margin: 35px 0;
}
</style>
</head>
<body>
<section class='section-title align-center'>
<div class='blank'></div>
<div class='website-title'>Hoogle </div>
<div class='website-subtitle'>Find your Home away from Home</div>
<div class='website-sub'>Hotel Review Data-Set Visualisation<br> Group - 21</div>
<div class="arrow bounce align-center" id='arrow'>
<i class="fa fa-arrow-down fa-2x"></i>
</div>
</section>
<section class='section-heatmap'>
<div class="heatmap align-center">
<div class="chart-info__heading">Distribution of Hotels based on States in the US</div>
<div id='heatmap_1'></div>
<div id='heatmap_info_1'>
Click on any coloured state to proceed
</div>
</div>
<div class="heatmap-content">
<div class="heatmap-info__heading">Description</div>
<div class="heatmap-info__content">The given data ranks Hotels based on 7 factors, namely : Cleanliness, Location, Overall Rating, Rooms, Service, Sleep Quality and Value for Money. Each factor is given a rating out of 5, which we add cumulatively for all the hotels in a State, thus assigning a color to the State based on the overall calculated rating of all the Hotels in that State. </div>
</div>
</section>
<section class='hide'>
<div class="chart-container" id='bar-chart_2'>
<div class='badge'>
<div class='badge-common badge-warning' id='bar-chart-state'></div>
<div class='badge-common badge-primary' id='bar-chart-year'></div>
<div class='badge-common badge-secondary' id='bar-chart-month'></div>
</div>
<div class='chart-layout'>
<div id='chart-info' class='chart-info'>
<div class="chart-info__heading">Growth of Hotels over the Years</div>
<div class="chart-info__content">The following Bar Chart shows the Best Hotels i.e, Hotels that are rated the highest based on the 7 factors, each of which are rated out of 5. Our cumulative rating thus becomes out of 35. The visualisation travels from 2005 to 2012, showing the growth and change in Hotel Ratings for each Month. Use the buttons below to view the Bar Graph as per your convenience.</div>
<div class="chart-info__buttons">
<i class="fas fa-fast-backward" id='fast-backward'></i>
<i class="fas fa-step-backward" id='back'></i>
<i class="fas fa-pause-circle" id='pause'></i>
<i class="fas fa-step-forward" id='forward'></i>
<i class="fas fa-fast-forward" id='fast-forward'></i>
</div>
<div class="arrow bounce align-center chart-scroll">
<i class="fa fa-arrow-down fa-2x"></i>
</div>
</div>
<div id="chart"></div>
</div>
</div>
</section>
<section class=' hide section-word'>
<!-- Add the Radar and Word Cloud chart here -->
<div>
<div id='heading' class="chart-info__heading"></div>
<div class='hotel-nav'>
<div class='hotel-selection' >
<!-- hotel selection tab -->
<div id="b1"></div>
<div id="b2"></div>
<div id="b3"></div>
<div id="b4"></div>
<div id="b5"></div>
<div id="b6"></div>
<div id="b7"></div>
<div id="b8"></div>
<div id="b9"></div>
<div id="b10"></div>
</div>
<div class="hotel-heading">
Please select a hotel
</div>
</div>
<div class="wrapper">
<div id="slider" ></div>
</div>
</div>
<div class='hotel-charts'>
<div class='finalwordcloud'>
<svg id='wordCloudSVG' class="word-cloud" width="490" height="600">
<!-- add the word cloud here -->
</svg>
</div>
<div class='radar-chart'>
<svg id="radar-chart" width="490" height="600"></svg>
</div>
</div>
</section>
<script type="module">
import drawChart, { togglePauseButton } from './bar-update.js'
function scrollSmooth(top) {
window.scrollTo({
top,
behavior: 'smooth',
duration: 2000
})
}
const scrollSectionHeight = document.querySelector('.section-heatmap').offsetHeight
const arrow = document.querySelector('#arrow');
arrow.addEventListener('click', () => {
scrollSmooth(scrollSectionHeight)
})
function showBarChart() {
const hiddenSection = document.querySelectorAll('section.hide')
console.log(hiddenSection, hiddenSection.length)
if (hiddenSection.length) {
hiddenSection.forEach(e => e.classList.toggle('hide'))
} else {
togglePauseButton()
}
}
(function createHeatMap(){
var margin = { top: 0, right: 0, bottom: 0, left: 0 }
, width = 800 - margin.left - margin.right
, height = 630 - margin.top - margin.bottom;
// D3 Projection
var projection = d3.geo.albersUsa()
.translate([width / 2, height / 2]) // translate to center of screen
.scale([1000]); // scale things down so see entire US
// Define path generator
var path = d3.geo.path() // path generator that will convert GeoJSON to SVG paths
.projection(projection); // tell path generator to use albersUsa projection
// Define linear scale for output
var color = d3.scale.linear().range(["rgb(230,197,192)", "rgb(212,139,131)", "rgb(194,97,90)", "rgb(181,69,65)","rgb(173,52,52)"]);
var legendText = ["1-7", "8-14", "15-21", "21-28","29-35"];
var svg = d3.select("#heatmap_1")
.append("svg")
.attr("width", width)
.attr("height", height);
var div = d3.select("#heatmap_1")
.append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Load in my states data!
d3.csv("stateslived1.csv", function (data) {
color.domain([0, 1, 2, 3, 4]); // setting the range of the input data
// Load GeoJSON data and merge with states data
d3.json("us-states.json", function (json) {
// Loop through each state data value in the .csv file
var legendSVG = d3.select("#heatmap_1").append("svg").attr("class", "legend")
.attr("width", 150)
.attr("height", 140)
var legend = legendSVG
.selectAll("g")
.data(color.domain().slice())
.enter()
.append("g")
.attr("transform", function (d, i) { return "translate(5," + i * 20 + ")"; });
legend.append("rect")
.attr("width", 18)
.attr("height", 18)
.style("fill", color);
legend.append("text")
.data(legendText)
.attr("x", 24)
.attr("y", 9)
.attr("dy", ".35em")
.text(function (d) { return d; });
for (var i = 0; i < data.length; i++) {
// Grab State Name
var dataState = data[i].state;
// Grab data value
var dataValue = data[i].visited;
// Find the corresponding state inside the GeoJSON
for (var j = 0; j < json.features.length; j++) {
//var jsonState = json.features[j].properties.name;
var jsonState = json.features[j].properties.NAME;
if (dataState == jsonState) {
// Copy the data value into the JSON
json.features[j].properties.visited = dataValue;
// Stop looking through the JSON
//break;
}
}
}
// Bind the data to the SVG and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.style("stroke", "#fff")
.style("stroke-width", "1")
.on("mouseover", function (d) {
div.transition()
.duration(200)
.style("opacity", .9);
div.text(d.properties.NAME)
.style("left", (d3.event.pageX - 300) + "px")
.style("top", (d3.event.pageY - 1000) + "px");
})
.on("click", d => {
if (d.properties.visited !== "-133") {
showBarChart()
scrollSmooth(scrollSectionHeight * 2)
drawChart(d.properties)
d3.selectAll('button').remove();
d3.select('#heading').text("All Time Top 10 Best Hotels Of " + d.properties.NAME);
$("#slider").empty();
$("#wordCloudSVG").empty();
$("#radar-chart").empty();
WordCloud(d.properties['AB']);
}
})
// fade out tooltip on mouse out
.on("mouseout", function (d) {
div.transition()
.duration(500)
.style("opacity", 0);
})
.style("fill", "rgb(213,222,217)")
.transition()
.duration(3000)
.style("fill", function (d) {
// Get data value
var value = d.properties.visited;
//console.log(value);
// if (value)
// {
// //If value exists…
// return color(value);
// }
if (value >= 0 && value <=7) {
//If value exists…
return "rgb(230,197,192)";
}
else if (value >7 && value <=14) {
//If value exists…
return "rgb(212,139,131)";
}
else if (value >14 && value <=21) {
//If value exists…
return "rgb(194,97,90)";
} else if (value >21 && value <=28) {
//If value exists…
return "rgb(181,69,65)";
}else if (value >28 && value <=35) {
//If value exists…
return "rgb(173,52,52)";
}
else {
//If value is undefined…
return "rgb(208,228,231)";
//return "red";
}
})
});
});
})()
</script>
<script src="WordCloudCheck.js"></script>
<script src="bar-update.js"></script>
<script src="radar.js"></script>
<script src="d3.slider.js"></script>
</body>
</html>