Spaces:
Running
Running
Age range distribution; bar chart with the different ages.
Browse files- index.html +35 -34
index.html
CHANGED
|
@@ -201,7 +201,7 @@
|
|
| 201 |
<section class="py-24 bg-gray-900">
|
| 202 |
<div class="container mx-auto px-4">
|
| 203 |
<h3 class="text-3xl font-bold text-center mb-12">Nightlife Analytics</h3>
|
| 204 |
-
<!-- Age Range
|
| 205 |
<div class="bg-gray-800 bg-opacity-70 backdrop-blur-sm rounded-xl p-6 mb-12">
|
| 206 |
<div class="flex justify-between items-center mb-6">
|
| 207 |
<h4 class="text-2xl font-bold">Age Range Distribution</h4>
|
|
@@ -212,14 +212,12 @@
|
|
| 212 |
<button class="bg-blue-900 text-white px-4 py-2 rounded-lg text-sm hover:bg-blue-800 transition" id="age-35-45">35-45</button>
|
| 213 |
</div>
|
| 214 |
</div>
|
| 215 |
-
<div class="h-64 w-full
|
| 216 |
-
<
|
| 217 |
-
<!-- Pie Chart will be rendered here -->
|
| 218 |
-
</div>
|
| 219 |
</div>
|
| 220 |
</div>
|
| 221 |
|
| 222 |
-
<!-- Music Genre
|
| 223 |
<div class="bg-gray-800 bg-opacity-70 backdrop-blur-sm rounded-xl p-6">
|
| 224 |
<div class="flex justify-between items-center mb-6">
|
| 225 |
<h4 class="text-2xl font-bold">Music Genre Popularity</h4>
|
|
@@ -230,8 +228,10 @@
|
|
| 230 |
<button class="bg-indigo-900 text-white px-4 py-2 rounded-lg text-sm hover:bg-indigo-800 transition" id="genre-hiphop">Hip Hop</button>
|
| 231 |
</div>
|
| 232 |
</div>
|
| 233 |
-
<div class="h-64 w-full" id="genreChart">
|
| 234 |
-
<
|
|
|
|
|
|
|
| 235 |
</div>
|
| 236 |
</div>
|
| 237 |
</div>
|
|
@@ -357,13 +357,14 @@
|
|
| 357 |
// Initialize Vanta.js background
|
| 358 |
// Initialize Charts
|
| 359 |
document.addEventListener('DOMContentLoaded', function() {
|
| 360 |
-
// Age Range
|
| 361 |
-
const ageCtx = document.getElementById('ageChart').
|
| 362 |
const ageChart = new Chart(ageCtx, {
|
| 363 |
-
type: '
|
| 364 |
data: {
|
| 365 |
labels: ['18-25', '25-35', '35-45', '45+'],
|
| 366 |
datasets: [{
|
|
|
|
| 367 |
data: [42, 38, 15, 5],
|
| 368 |
backgroundColor: [
|
| 369 |
'rgba(219, 39, 119, 0.7)',
|
|
@@ -382,10 +383,25 @@
|
|
| 382 |
},
|
| 383 |
options: {
|
| 384 |
responsive: true,
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
plugins: {
|
| 387 |
legend: {
|
| 388 |
-
|
| 389 |
},
|
| 390 |
title: {
|
| 391 |
display: true,
|
|
@@ -398,14 +414,13 @@
|
|
| 398 |
}
|
| 399 |
});
|
| 400 |
|
| 401 |
-
// Genre
|
| 402 |
-
const genreCtx = document.getElementById('genreChart').getContext('2d');
|
| 403 |
const genreChart = new Chart(genreCtx, {
|
| 404 |
-
type: '
|
| 405 |
data: {
|
| 406 |
labels: ['EDM', 'Hip Hop', 'Rock', 'R&B', 'Jazz', 'Alternative', 'Pop', 'Other'],
|
| 407 |
datasets: [{
|
| 408 |
-
label: 'Venues by Genre',
|
| 409 |
data: [25, 20, 18, 15, 10, 7, 4, 1],
|
| 410 |
backgroundColor: [
|
| 411 |
'rgba(219, 39, 119, 0.7)',
|
|
@@ -432,24 +447,10 @@
|
|
| 432 |
},
|
| 433 |
options: {
|
| 434 |
responsive: true,
|
| 435 |
-
|
| 436 |
-
y: {
|
| 437 |
-
beginAtZero: true,
|
| 438 |
-
title: {
|
| 439 |
-
display: true,
|
| 440 |
-
text: 'Number of Venues'
|
| 441 |
-
}
|
| 442 |
-
},
|
| 443 |
-
x: {
|
| 444 |
-
title: {
|
| 445 |
-
display: true,
|
| 446 |
-
text: 'Music Genre'
|
| 447 |
-
}
|
| 448 |
-
}
|
| 449 |
-
},
|
| 450 |
plugins: {
|
| 451 |
legend: {
|
| 452 |
-
|
| 453 |
},
|
| 454 |
title: {
|
| 455 |
display: true,
|
|
@@ -460,7 +461,7 @@
|
|
| 460 |
}
|
| 461 |
}
|
| 462 |
}
|
| 463 |
-
|
| 464 |
// Filter buttons functionality
|
| 465 |
document.querySelectorAll('#age-all, #age-18-25, #age-25-35, #age-35-45').forEach(btn => {
|
| 466 |
btn.addEventListener('click', function() {
|
|
|
|
| 201 |
<section class="py-24 bg-gray-900">
|
| 202 |
<div class="container mx-auto px-4">
|
| 203 |
<h3 class="text-3xl font-bold text-center mb-12">Nightlife Analytics</h3>
|
| 204 |
+
<!-- Age Range Bar Chart -->
|
| 205 |
<div class="bg-gray-800 bg-opacity-70 backdrop-blur-sm rounded-xl p-6 mb-12">
|
| 206 |
<div class="flex justify-between items-center mb-6">
|
| 207 |
<h4 class="text-2xl font-bold">Age Range Distribution</h4>
|
|
|
|
| 212 |
<button class="bg-blue-900 text-white px-4 py-2 rounded-lg text-sm hover:bg-blue-800 transition" id="age-35-45">35-45</button>
|
| 213 |
</div>
|
| 214 |
</div>
|
| 215 |
+
<div class="h-64 w-full" id="ageChart">
|
| 216 |
+
<!-- Bar Chart will be rendered here -->
|
|
|
|
|
|
|
| 217 |
</div>
|
| 218 |
</div>
|
| 219 |
|
| 220 |
+
<!-- Music Genre Pie Chart -->
|
| 221 |
<div class="bg-gray-800 bg-opacity-70 backdrop-blur-sm rounded-xl p-6">
|
| 222 |
<div class="flex justify-between items-center mb-6">
|
| 223 |
<h4 class="text-2xl font-bold">Music Genre Popularity</h4>
|
|
|
|
| 228 |
<button class="bg-indigo-900 text-white px-4 py-2 rounded-lg text-sm hover:bg-indigo-800 transition" id="genre-hiphop">Hip Hop</button>
|
| 229 |
</div>
|
| 230 |
</div>
|
| 231 |
+
<div class="h-64 w-full flex justify-center items-center" id="genreChart">
|
| 232 |
+
<div class="w-48 h-48 md:w-64 md:h-64">
|
| 233 |
+
<!-- Pie Chart will be rendered here -->
|
| 234 |
+
</div>
|
| 235 |
</div>
|
| 236 |
</div>
|
| 237 |
</div>
|
|
|
|
| 357 |
// Initialize Vanta.js background
|
| 358 |
// Initialize Charts
|
| 359 |
document.addEventListener('DOMContentLoaded', function() {
|
| 360 |
+
// Age Range Bar Chart
|
| 361 |
+
const ageCtx = document.getElementById('ageChart').getContext('2d');
|
| 362 |
const ageChart = new Chart(ageCtx, {
|
| 363 |
+
type: 'bar',
|
| 364 |
data: {
|
| 365 |
labels: ['18-25', '25-35', '35-45', '45+'],
|
| 366 |
datasets: [{
|
| 367 |
+
label: 'Percentage of Visitors',
|
| 368 |
data: [42, 38, 15, 5],
|
| 369 |
backgroundColor: [
|
| 370 |
'rgba(219, 39, 119, 0.7)',
|
|
|
|
| 383 |
},
|
| 384 |
options: {
|
| 385 |
responsive: true,
|
| 386 |
+
scales: {
|
| 387 |
+
y: {
|
| 388 |
+
beginAtZero: true,
|
| 389 |
+
max: 100,
|
| 390 |
+
title: {
|
| 391 |
+
display: true,
|
| 392 |
+
text: 'Percentage (%)'
|
| 393 |
+
}
|
| 394 |
+
},
|
| 395 |
+
x: {
|
| 396 |
+
title: {
|
| 397 |
+
display: true,
|
| 398 |
+
text: 'Age Range'
|
| 399 |
+
}
|
| 400 |
+
}
|
| 401 |
+
},
|
| 402 |
plugins: {
|
| 403 |
legend: {
|
| 404 |
+
display: false
|
| 405 |
},
|
| 406 |
title: {
|
| 407 |
display: true,
|
|
|
|
| 414 |
}
|
| 415 |
});
|
| 416 |
|
| 417 |
+
// Music Genre Pie Chart
|
| 418 |
+
const genreCtx = document.getElementById('genreChart').querySelector('div').getContext('2d');
|
| 419 |
const genreChart = new Chart(genreCtx, {
|
| 420 |
+
type: 'pie',
|
| 421 |
data: {
|
| 422 |
labels: ['EDM', 'Hip Hop', 'Rock', 'R&B', 'Jazz', 'Alternative', 'Pop', 'Other'],
|
| 423 |
datasets: [{
|
|
|
|
| 424 |
data: [25, 20, 18, 15, 10, 7, 4, 1],
|
| 425 |
backgroundColor: [
|
| 426 |
'rgba(219, 39, 119, 0.7)',
|
|
|
|
| 447 |
},
|
| 448 |
options: {
|
| 449 |
responsive: true,
|
| 450 |
+
maintainAspectRatio: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
plugins: {
|
| 452 |
legend: {
|
| 453 |
+
position: 'right',
|
| 454 |
},
|
| 455 |
title: {
|
| 456 |
display: true,
|
|
|
|
| 461 |
}
|
| 462 |
}
|
| 463 |
}
|
| 464 |
+
});
|
| 465 |
// Filter buttons functionality
|
| 466 |
document.querySelectorAll('#age-all, #age-18-25, #age-25-35, #age-35-45').forEach(btn => {
|
| 467 |
btn.addEventListener('click', function() {
|