Spaces:
Running
Running
i want it to create visualization and filters like age gender booth yadi no and create necessary bar graph or pie chart which ever is the best to demonstrate data report
Browse files- index.html +199 -26
index.html
CHANGED
|
@@ -7,7 +7,9 @@
|
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
|
| 9 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
-
<script src="https://cdn.jsdelivr.net/npm/
|
|
|
|
|
|
|
| 11 |
<style>
|
| 12 |
.dropzone {
|
| 13 |
border: 2px dashed #94a3b8;
|
|
@@ -114,18 +116,51 @@
|
|
| 114 |
<!-- Summary will be inserted here -->
|
| 115 |
</div>
|
| 116 |
</div>
|
| 117 |
-
|
| 118 |
<div class="mb-6">
|
| 119 |
-
<div class="flex items-center mb-
|
| 120 |
-
<
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
</div>
|
| 123 |
-
<div
|
| 124 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
</div>
|
| 126 |
</div>
|
| 127 |
-
|
| 128 |
-
<div>
|
| 129 |
<div class="flex items-center mb-2">
|
| 130 |
<i data-feather="alert-triangle" class="w-5 h-5 text-indigo-500 mr-2"></i>
|
| 131 |
<h4 class="font-medium">Potential Issues</h4>
|
|
@@ -300,36 +335,174 @@
|
|
| 300 |
|
| 301 |
dataPreview.classList.remove('hidden');
|
| 302 |
});
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
function showAnalysisResults() {
|
| 305 |
const fileSummary = document.getElementById('fileSummary');
|
| 306 |
-
const dataStats = document.getElementById('dataStats');
|
| 307 |
const dataIssues = document.getElementById('dataIssues');
|
| 308 |
const resultsSection = document.getElementById('resultsSection');
|
| 309 |
|
| 310 |
-
//
|
|
|
|
| 311 |
fileSummary.innerHTML = `
|
| 312 |
-
<div class="grid grid-cols-2 gap-4">
|
| 313 |
-
<div>
|
| 314 |
<p class="text-sm text-gray-500">File Type</p>
|
| 315 |
-
<p class="font-
|
| 316 |
</div>
|
| 317 |
-
<div>
|
| 318 |
-
<p class="text-sm text-gray-500">
|
| 319 |
-
<p class="font-
|
| 320 |
</div>
|
| 321 |
-
<div>
|
| 322 |
-
<p class="text-sm text-gray-500">
|
| 323 |
-
<p class="font-
|
| 324 |
</div>
|
| 325 |
-
<div>
|
| 326 |
-
<p class="text-sm text-gray-500">
|
| 327 |
-
<p class="font-
|
| 328 |
</div>
|
| 329 |
</div>
|
| 330 |
`;
|
| 331 |
-
|
| 332 |
-
dataStats.innerHTML = `
|
| 333 |
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
| 334 |
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 335 |
<p class="text-sm text-gray-500">Numeric Columns</p>
|
|
|
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
|
| 9 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 13 |
<style>
|
| 14 |
.dropzone {
|
| 15 |
border: 2px dashed #94a3b8;
|
|
|
|
| 116 |
<!-- Summary will be inserted here -->
|
| 117 |
</div>
|
| 118 |
</div>
|
|
|
|
| 119 |
<div class="mb-6">
|
| 120 |
+
<div class="flex items-center justify-between mb-4">
|
| 121 |
+
<div class="flex items-center">
|
| 122 |
+
<i data-feather="bar-chart-2" class="w-5 h-5 text-indigo-500 mr-2"></i>
|
| 123 |
+
<h4 class="font-medium">Data Visualizations</h4>
|
| 124 |
+
</div>
|
| 125 |
+
<div class="flex space-x-2">
|
| 126 |
+
<select id="chartType" class="text-sm border rounded px-2 py-1">
|
| 127 |
+
<option value="bar">Bar Chart</option>
|
| 128 |
+
<option value="pie">Pie Chart</option>
|
| 129 |
+
<option value="line">Line Chart</option>
|
| 130 |
+
</select>
|
| 131 |
+
<select id="filterField" class="text-sm border rounded px-2 py-1">
|
| 132 |
+
<option value="age">Age</option>
|
| 133 |
+
<option value="gender">Gender</option>
|
| 134 |
+
<option value="booth">Booth</option>
|
| 135 |
+
</select>
|
| 136 |
+
</div>
|
| 137 |
</div>
|
| 138 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 139 |
+
<div class="bg-white p-4 rounded-lg shadow-sm">
|
| 140 |
+
<h5 class="text-sm font-medium mb-3">Distribution by Selected Field</h5>
|
| 141 |
+
<div id="mainChart" class="h-64"></div>
|
| 142 |
+
</div>
|
| 143 |
+
<div class="bg-white p-4 rounded-lg shadow-sm">
|
| 144 |
+
<h5 class="text-sm font-medium mb-3">Gender Distribution</h5>
|
| 145 |
+
<div id="genderChart" class="h-64"></div>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
<div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 149 |
+
<div class="bg-white p-4 rounded-lg shadow-sm">
|
| 150 |
+
<h5 class="text-sm font-medium mb-3">Age Groups</h5>
|
| 151 |
+
<div id="ageChart" class="h-48"></div>
|
| 152 |
+
</div>
|
| 153 |
+
<div class="bg-white p-4 rounded-lg shadow-sm">
|
| 154 |
+
<h5 class="text-sm font-medium mb-3">Booth Analysis</h5>
|
| 155 |
+
<div id="boothChart" class="h-48"></div>
|
| 156 |
+
</div>
|
| 157 |
+
<div class="bg-white p-4 rounded-lg shadow-sm">
|
| 158 |
+
<h5 class="text-sm font-medium mb-3">Other Metrics</h5>
|
| 159 |
+
<div id="otherChart" class="h-48"></div>
|
| 160 |
+
</div>
|
| 161 |
</div>
|
| 162 |
</div>
|
| 163 |
+
<div>
|
|
|
|
| 164 |
<div class="flex items-center mb-2">
|
| 165 |
<i data-feather="alert-triangle" class="w-5 h-5 text-indigo-500 mr-2"></i>
|
| 166 |
<h4 class="font-medium">Potential Issues</h4>
|
|
|
|
| 335 |
|
| 336 |
dataPreview.classList.remove('hidden');
|
| 337 |
});
|
| 338 |
+
function initializeCharts() {
|
| 339 |
+
// Sample data - in real app this would come from Excel file
|
| 340 |
+
const data = {
|
| 341 |
+
age: {
|
| 342 |
+
'18-24': 120,
|
| 343 |
+
'25-34': 240,
|
| 344 |
+
'35-44': 180,
|
| 345 |
+
'45-54': 90,
|
| 346 |
+
'55+': 60
|
| 347 |
+
},
|
| 348 |
+
gender: {
|
| 349 |
+
Male: 350,
|
| 350 |
+
Female: 320,
|
| 351 |
+
Other: 30
|
| 352 |
+
},
|
| 353 |
+
booth: {
|
| 354 |
+
'Booth A': 150,
|
| 355 |
+
'Booth B': 220,
|
| 356 |
+
'Booth C': 180,
|
| 357 |
+
'Booth D': 150
|
| 358 |
+
}
|
| 359 |
+
};
|
| 360 |
+
|
| 361 |
+
// Main chart
|
| 362 |
+
const mainChartCtx = document.getElementById('mainChart').getContext('2d');
|
| 363 |
+
window.mainChart = new Chart(mainChartCtx, {
|
| 364 |
+
type: 'bar',
|
| 365 |
+
data: {
|
| 366 |
+
labels: Object.keys(data.age),
|
| 367 |
+
datasets: [{
|
| 368 |
+
label: 'Count',
|
| 369 |
+
data: Object.values(data.age),
|
| 370 |
+
backgroundColor: '#6366f1',
|
| 371 |
+
borderColor: '#4f46e5',
|
| 372 |
+
borderWidth: 1
|
| 373 |
+
}]
|
| 374 |
+
},
|
| 375 |
+
options: {
|
| 376 |
+
responsive: true,
|
| 377 |
+
maintainAspectRatio: false,
|
| 378 |
+
plugins: {
|
| 379 |
+
legend: { display: false },
|
| 380 |
+
datalabels: { color: '#4b5563', align: 'top', offset: 5 }
|
| 381 |
+
},
|
| 382 |
+
scales: {
|
| 383 |
+
y: { beginAtZero: true }
|
| 384 |
+
}
|
| 385 |
+
},
|
| 386 |
+
plugins: [ChartDataLabels]
|
| 387 |
+
});
|
| 388 |
+
|
| 389 |
+
// Gender pie chart
|
| 390 |
+
const genderChartCtx = document.getElementById('genderChart').getContext('2d');
|
| 391 |
+
window.genderChart = new Chart(genderChartCtx, {
|
| 392 |
+
type: 'pie',
|
| 393 |
+
data: {
|
| 394 |
+
labels: Object.keys(data.gender),
|
| 395 |
+
datasets: [{
|
| 396 |
+
data: Object.values(data.gender),
|
| 397 |
+
backgroundColor: ['#6366f1', '#a855f7', '#ec4899'],
|
| 398 |
+
borderWidth: 1
|
| 399 |
+
}]
|
| 400 |
+
},
|
| 401 |
+
options: {
|
| 402 |
+
responsive: true,
|
| 403 |
+
maintainAspectRatio: false,
|
| 404 |
+
plugins: {
|
| 405 |
+
legend: { position: 'bottom' },
|
| 406 |
+
datalabels: {
|
| 407 |
+
formatter: (value, ctx) => {
|
| 408 |
+
let sum = ctx.chart.data.datasets[0].data.reduce((a, b) => a + b, 0);
|
| 409 |
+
let percentage = (value * 100 / sum).toFixed(1) + '%';
|
| 410 |
+
return percentage;
|
| 411 |
+
},
|
| 412 |
+
color: '#fff',
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
},
|
| 416 |
+
plugins: [ChartDataLabels]
|
| 417 |
+
});
|
| 418 |
+
|
| 419 |
+
// Age groups chart
|
| 420 |
+
const ageChartCtx = document.getElementById('ageChart').getContext('2d');
|
| 421 |
+
window.ageChart = new Chart(ageChartCtx, {
|
| 422 |
+
type: 'bar',
|
| 423 |
+
data: {
|
| 424 |
+
labels: Object.keys(data.age),
|
| 425 |
+
datasets: [{
|
| 426 |
+
label: 'Count',
|
| 427 |
+
data: Object.values(data.age),
|
| 428 |
+
backgroundColor: '#6366f1',
|
| 429 |
+
borderColor: '#4f46e5',
|
| 430 |
+
borderWidth: 1
|
| 431 |
+
}]
|
| 432 |
+
},
|
| 433 |
+
options: {
|
| 434 |
+
responsive: true,
|
| 435 |
+
maintainAspectRatio: false,
|
| 436 |
+
plugins: { legend: { display: false } },
|
| 437 |
+
scales: { y: { beginAtZero: true } }
|
| 438 |
+
}
|
| 439 |
+
});
|
| 440 |
+
|
| 441 |
+
// Booth analysis chart
|
| 442 |
+
const boothChartCtx = document.getElementById('boothChart').getContext('2d');
|
| 443 |
+
window.boothChart = new Chart(boothChartCtx, {
|
| 444 |
+
type: 'doughnut',
|
| 445 |
+
data: {
|
| 446 |
+
labels: Object.keys(data.booth),
|
| 447 |
+
datasets: [{
|
| 448 |
+
data: Object.values(data.booth),
|
| 449 |
+
backgroundColor: ['#6366f1', '#a855f7', '#ec4899', '#f59e0b'],
|
| 450 |
+
borderWidth: 1
|
| 451 |
+
}]
|
| 452 |
+
},
|
| 453 |
+
options: {
|
| 454 |
+
responsive: true,
|
| 455 |
+
maintainAspectRatio: false,
|
| 456 |
+
plugins: { legend: { position: 'bottom' } }
|
| 457 |
+
}
|
| 458 |
+
});
|
| 459 |
+
|
| 460 |
+
// Update chart when filter changes
|
| 461 |
+
document.getElementById('filterField').addEventListener('change', function() {
|
| 462 |
+
const field = this.value;
|
| 463 |
+
const labels = Object.keys(data[field]);
|
| 464 |
+
const values = Object.values(data[field]);
|
| 465 |
+
|
| 466 |
+
window.mainChart.data.labels = labels;
|
| 467 |
+
window.mainChart.data.datasets[0].data = values;
|
| 468 |
+
window.mainChart.update();
|
| 469 |
+
});
|
| 470 |
+
|
| 471 |
+
// Change chart type
|
| 472 |
+
document.getElementById('chartType').addEventListener('change', function() {
|
| 473 |
+
window.mainChart.config.type = this.value;
|
| 474 |
+
window.mainChart.update();
|
| 475 |
+
});
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
function showAnalysisResults() {
|
| 479 |
const fileSummary = document.getElementById('fileSummary');
|
|
|
|
| 480 |
const dataIssues = document.getElementById('dataIssues');
|
| 481 |
const resultsSection = document.getElementById('resultsSection');
|
| 482 |
|
| 483 |
+
// Initialize charts
|
| 484 |
+
initializeCharts();
|
| 485 |
fileSummary.innerHTML = `
|
| 486 |
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
| 487 |
+
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 488 |
<p class="text-sm text-gray-500">File Type</p>
|
| 489 |
+
<p class="text-xl font-bold text-indigo-600">Excel (.xlsx)</p>
|
| 490 |
</div>
|
| 491 |
+
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 492 |
+
<p class="text-sm text-gray-500">Total Records</p>
|
| 493 |
+
<p class="text-xl font-bold text-indigo-600">700</p>
|
| 494 |
</div>
|
| 495 |
+
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 496 |
+
<p class="text-sm text-gray-500">Gender Fields</p>
|
| 497 |
+
<p class="text-xl font-bold text-indigo-600">Male: 350</p>
|
| 498 |
</div>
|
| 499 |
+
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 500 |
+
<p class="text-sm text-gray-500">Age Fields</p>
|
| 501 |
+
<p class="text-xl font-bold text-indigo-600">25-34: 240</p>
|
| 502 |
</div>
|
| 503 |
</div>
|
| 504 |
`;
|
| 505 |
+
dataStats.innerHTML = `
|
|
|
|
| 506 |
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
| 507 |
<div class="p-3 bg-white rounded-lg shadow-sm">
|
| 508 |
<p class="text-sm text-gray-500">Numeric Columns</p>
|