Spaces:
Running

data-analyser / index.html
Admintools's picture
remova mais funções desnecessarias
452a7d2 verified
Raw History Blame Contribute Delete
64.4 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>📊 IGR-BDSM Advanced Analytics</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <script src="https://cdn.tailwindcss.com"></script> <script> tailwind.config = { darkMode: 'class', theme: { extend: { colors: { dark: { 800: '#2d3748', 900: '#1a202c', } } } } } </script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> :root { --primary-color: #7c3aed; --secondary-color: #8b5cf6; --dark-bg: #0f172a; --dark-card: #1e293b; --dark-text: #f8fafc; --dark-border: #334155; --accent-1: #f59e0b; --accent-2: #10b981; --danger: #ef4444; --success: #10b981; --glass-effect: rgba(30, 41, 59, 0.6); --gradient: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%); } body { background: radial-gradient(circle at 10% 20%, var(--dark-bg) 0%, #0b1120 100%); color: var(--dark-text); min-height: 100vh; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; } @supports (font-variation-settings: normal) { body { font-family: 'Inter var', -apple-system, BlinkMacSystemFont, sans-serif; } } .file-input-wrapper { position: relative; overflow: hidden; display: inline-block; border-radius: 12px; background: var(--gradient); box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3); transition: all 0.3s ease; } .file-input-wrapper:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4); } .file-input-wrapper input[type=file] { position: absolute; top: 0; right: 0; min-width: 100%; min-height: 100%; font-size: 100px; text-align: right; filter: alpha(opacity=0); opacity: 0; outline: none; background: white; cursor: pointer; display: block; } .multiselect { min-height: 42px; border: 1px solid var(--dark-border); border-radius: 12px; padding: 0.5rem 1rem; background-color: var(--glass-effect); backdrop-filter: blur(10px); transition: all 0.2s ease; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .multiselect:focus-within { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3); } .multiselect:focus-within { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 1px var(--primary-color); } .multiselect-option { display: inline-block; background-color: #4a5568; border-radius: 0.25rem; padding: 0.25rem 0.5rem; margin-right: 0.5rem; margin-bottom: 0.5rem; color: var(--dark-text); } .multiselect-option-remove { margin-left: 0.5rem; cursor: pointer; color: #a0aec0; } .multiselect-option-remove:hover { color: #fc8181; } .dropdown-content { max-height: 200px; overflow-y: auto; background-color: var(--dark-card); border: 1px solid var(--dark-border); } .highlight { background-color: #4a5568; } .card { background-color: var(--glass-effect); border: 1px solid var(--dark-border); backdrop-filter: blur(10px); border-radius: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2); transition: all 0.3s ease; } .card:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); } .table-container { max-height: 400px; overflow-y: auto; } .table-container::-webkit-scrollbar { width: 8px; height: 8px; } .table-container::-webkit-scrollbar-track { background: var(--dark-bg); } .table-container::-webkit-scrollbar-thumb { background-color: #4a5568; border-radius: 4px; } .chart-container { position: relative; height: 500px; width: 100%; background: var(--glass-effect); border-radius: 16px; padding: 1rem; border: 1px solid var(--dark-border); } .loading-spinner { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; } .data-table { width: 100%; border-collapse: collapse; } .data-table th, .data-table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--dark-border); } .data-table th { background-color: #2d3748; color: var(--dark-text); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; } .data-table tr:hover td { background-color: #4a5568; } .tab-button { padding: 0.5rem 1rem; border-radius: 0.375rem 0.375rem 0 0; background-color: var(--dark-card); border: 1px solid var(--dark-border); border-bottom: none; color: var(--dark-text); cursor: pointer; transition: all 0.2s; } .tab-button.active { background-color: var(--primary-color); color: white; border-color: var(--primary-color); } .tab-content { display: none; } .tab-content.active { display: block; } .stat-card { background: var(--glass-effect); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--dark-border); transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } .stat-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2); border-color: var(--primary-color); } .stat-card h3 { font-size: 0.875rem; color: #a0aec0; margin-bottom: 0.5rem; } .stat-card p { font-size: 1.5rem; font-weight: 600; color: var(--dark-text); } .tooltip { position: relative; display: inline-block; } .tooltip .tooltip-text { visibility: hidden; width: 200px; background-color: #4a5568; color: #fff; text-align: center; border-radius: 6px; padding: 5px; position: absolute; z-index: 1; bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; } .tooltip:hover .tooltip-text { visibility: visible; opacity: 1; } .date-cell { color: var(--accent-2); font-weight: 500; } .numeric-cell { color: var(--primary-color); font-weight: 500; } .text-cell { color: var(--accent-1); font-weight: 500; } /* Custom scrollbar */ ::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-track { background: var(--dark-bg); } ::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: var(--secondary-color); } /* Animations */ @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .animate-fade-in { animation: fadeIn 0.5s ease-out forwards; } /* Tooltips */ .tooltip .tooltip-text { background: var(--dark-card); color: var(--dark-text); border: 1px solid var(--dark-border); box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); font-size: 0.875rem; } /* Buttons */ button { transition: all 0.2s ease; } button:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } </style> </head> <body class="min-h-screen"> <div class="container mx-auto px-4 py-8"> <header class="mb-8 text-center"> <h1 class="text-4xl font-bold text-indigo-400 mb-2">IGR-BDSM Advanced Data Analyser</h1> <p class="text-lg text-gray-400">Powerful data visualization and analysis tool</p> <p class="text-lg text-gray-700">Developed by Jair ALMEIDA & Herman REIS</p> </header> <div class="flex mb-4 space-x-2 border-b border-gray-700"> <button class="tab-button active" data-tab="analysis">Data Analysis</button> <button class="tab-button" data-tab="statistics">Statistics</button> <button class="tab-button" data-tab="export">Export</button> </div> <div id="analysis" class="tab-content active"> <div class="card rounded-lg shadow-lg p-6 mb-8"> <div class="flex flex-col md:flex-row gap-6"> <div class="w-full md:w-1/3"> <h2 class="text-xl font-semibold mb-4">Upload Data</h2> <div class="file-input-wrapper mb-4"> <button class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center justify-center"> <i class="fas fa-file-excel mr-2"></i> Choose Excel File <input type="file" id="fileInput" class="hidden" accept=".xlsx, .xls, .csv"> </button> </div> <div id="fileName" class="text-sm text-gray-400 mt-2 italic"></div> <div class="mt-6"> <h3 class="font-medium mb-2 flex items-center"> Search Columns <div class="tooltip ml-2"> <i class="fas fa-info-circle text-gray-400"></i> <span class="tooltip-text">Search for specific columns in your dataset</span> </div> </h3> <div class="relative"> <input type="text" id="columnSearch" placeholder="Search columns..." class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <i class="fas fa-search absolute right-3 top-3 text-gray-400"></i> </div> </div> <div class="mt-4"> <h3 class="font-medium mb-2">Available Columns</h3> <div id="columnList" class="border border-gray-600 rounded-lg p-2 max-h-60 overflow-y-auto bg-dark-900"> <p class="text-gray-400 italic">Upload a file to see available columns</p> </div> </div> <div class="mt-6"> <h3 class="font-medium mb-2">Quick Stats</h3> <div class="grid grid-cols-2 gap-4" id="quickStats"> <div class="stat-card"> <h3>Total Rows</h3> <p id="totalRows">-</p> </div> <div class="stat-card"> <h3>Total Columns</h3> <p id="totalColumns">-</p> </div> </div> </div> </div> <div class="w-full md:w-2/3"> <h2 class="text-xl font-semibold mb-4">Visualization Settings</h2> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6"> <div> <label for="xAxisSelect" class="block text-sm font-medium mb-1 flex items-center"> X-Axis (Multiple Selection) <div class="tooltip ml-2"> <i class="fas fa-info-circle text-gray-400"></i> <span class="tooltip-text">Select one or more columns for the X-axis</span> </div> </label> <div class="multiselect" id="xAxisSelect"> <div class="multiselect-selected flex flex-wrap"></div> <input type="text" class="multiselect-input w-full border-0 focus:ring-0 p-0 bg-transparent text-white" placeholder="Select columns..."> <div class="dropdown-content hidden absolute z-10 mt-1 w-full rounded-lg shadow-lg"> <div class="multiselect-options max-h-60 overflow-y-auto"></div> </div> </div> </div> <div> <label for="yAxisSelect" class="block text-sm font-medium mb-1 flex items-center"> Y-Axis (Multiple Selection) <div class="tooltip ml-2"> <i class="fas fa-info-circle text-gray-400"></i> <span class="tooltip-text">Select one or more columns for the Y-axis</span> </div> </label> <div class="multiselect" id="yAxisSelect"> <div class="multiselect-selected flex flex-wrap"></div> <input type="text" class="multiselect-input w-full border-0 focus:ring-0 p-0 bg-transparent text-white" placeholder="Select columns..."> <div class="dropdown-content hidden absolute z-10 mt-1 w-full rounded-lg shadow-lg"> <div class="multiselect-options max-h-60 overflow-y-auto"></div> </div> </div> </div> </div> <div class="mb-6"> <label for="chartType" class="block text-sm font-medium mb-1">Chart Type</label> <select id="chartType" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="line">Line Chart (Auto)</option> <option value="bar">Bar Chart</option> <option value="scatter">Scatter Plot</option> <option value="pie">Pie Chart</option> <option value="doughnut">Doughnut Chart</option> <option value="radar">Radar Chart</option> <option value="bubble">Bubble Chart</option> <option value="boxplot">Box Plot</option> <option value="heatmap">Heatmap</option> <option value="area">Area Chart</option> </select> </div> <div class="mb-6 grid grid-cols-1 md:grid-cols-3 gap-4"> <div> <label for="secondaryYAxis" class="block text-sm font-medium mb-1">Secondary Y-Axis Column</label> <select id="secondaryYAxis" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="">None</option> <!-- Will be populated dynamically --> </select> </div> <div> <label for="xScaleType" class="block text-sm font-medium mb-1">X-Axis Scale</label> <select id="xScaleType" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="linear">Linear</option> <option value="logarithmic">Logarithmic</option> <option value="category">Category</option> <option value="time">Time</option> </select> </div> <div> <label for="yScaleType" class="block text-sm font-medium mb-1">Y-Axis Scale</label> <select id="yScaleType" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="linear">Linear</option> <option value="logarithmic">Logarithmic</option> </select> </div> <div> <label for="minYValue" class="block text-sm font-medium mb-1">Min Y Value</label> <input type="number" id="minYValue" placeholder="Auto" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> </div> <div> <label for="maxYValue" class="block text-sm font-medium mb-1">Max Y Value</label> <input type="number" id="maxYValue" placeholder="Auto" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> </div> </div> <div class="flex justify-between items-center mb-4"> <h3 class="font-medium">Chart Preview</h3> <div class="flex space-x-2"> <button id="resetChart" class="bg-gray-600 hover:bg-gray-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center"> <i class="fas fa-redo mr-2"></i> Reset </button> <button id="generateChart" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center"> <i class="fas fa-chart-line mr-2"></i> Generate Chart </button> <button id="analyzeData" class="bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center"> <i class="fas fa-chart-bar mr-2"></i> Analyze </button> </div> </div> <div class="bg-dark-900 p-4 rounded-lg border border-gray-600 relative"> <div class="loading-spinner" id="chartLoading"> <i class="fas fa-circle-notch fa-spin text-4xl text-indigo-400"></i> </div> <div class="chart-container"> <canvas id="dataChart"></canvas> </div> </div> </div> </div> </div> <div class="card rounded-lg shadow-lg p-6"> <div class="flex justify-between items-center mb-4"> <h2 class="text-xl font-semibold">Data Preview</h2> <div class="flex items-center space-x-2"> <div class="relative"> <input type="text" id="tableSearch" placeholder="Search data..." class="px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <i class="fas fa-search absolute right-3 top-3 text-gray-400"></i> </div> <button id="exportData" class="bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center"> <i class="fas fa-file-export mr-2"></i> Export </button> </div> </div> <div class="table-container"> <table id="dataTable" class="data-table"> <thead> <tr> <!-- Table headers will be populated dynamically --> </tr> </thead> <tbody> <!-- Table data will be populated dynamically --> </tbody> </table> </div> <div class="mt-4 text-sm text-gray-400" id="tableInfo"> Showing 0 rows of 0 total </div> </div> </div> <div id="statistics" class="tab-content"> <div class="card rounded-lg shadow-lg p-6 mb-8"> <div class="mb-6 flex justify-between items-center"> <h2 class="text-xl font-semibold">Dataset Statistics</h2> <button id="calculateCorrelations" class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center"> <i class="fas fa-calculator mr-2"></i> Calculate Correlations </button> </div> <h2 class="text-xl font-semibold mb-4">Dataset Statistics</h2> <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6" id="datasetStats"> <div class="stat-card"> <h3>Total Rows</h3> <p id="statTotalRows">-</p> </div> <div class="stat-card"> <h3>Total Columns</h3> <p id="statTotalColumns">-</p> </div> <div class="stat-card"> <h3>File Size</h3> <p id="fileSize">-</p> </div> </div> <h3 class="font-medium mb-2">Column Statistics</h3> <div class="overflow-x-auto"> <table class="data-table w-full"> <thead> <tr> <th>Column</th> <th>Type</th> <th>Unique Values</th> <th>Missing Values</th> <th>Min</th> <th>Max</th> <th>Mean</th> </tr> </thead> <tbody id="columnStats"> <tr> <td colspan="7" class="text-center py-4 text-gray-400">Upload a file to see column statistics</td> </tr> </tbody> </table> </div> <div class="mt-8" id="correlationSection" style="display: none;"> <h3 class="font-medium mb-4 text-lg">Correlation Matrix</h3> <div class="chart-container"> <canvas id="correlationChart"></canvas> </div> </div> <div class="mt-8" id="outliersSection" style="display: none;"> <h3 class="font-medium mb-4 text-lg">Outliers Detection</h3> <div class="overflow-x-auto"> <table class="data-table w-full" id="outliersTable"> <thead> <tr> <th>Column</th> <th>Outliers Count</th> <th>% of Data</th> <th>Min Value</th> <th>Max Value</th> </tr> </thead> <tbody></tbody> </table> </div> </div> </div> </div> <div id="export" class="tab-content"> <div class="card rounded-lg shadow-lg p-6"> <h2 class="text-xl font-semibold mb-4">Export Options</h2> <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div> <h3 class="font-medium mb-2">Export Data</h3> <div class="space-y-4"> <div class="flex items-center"> <input type="radio" id="exportAll" name="exportScope" value="all" checked class="mr-2"> <label for="exportAll">All data</label> </div> <div class="flex items-center"> <input type="radio" id="exportFiltered" name="exportScope" value="filtered" class="mr-2"> <label for="exportFiltered">Filtered data (if search applied)</label> </div> </div> <div class="mt-6"> <h3 class="font-medium mb-2">Export Format</h3> <select id="exportFormat" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="csv">CSV</option> <option value="xlsx">Excel (XLSX)</option> <option value="json">JSON</option> </select> </div> <button id="exportDataBtn" class="mt-6 w-full bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center justify-center"> <i class="fas fa-file-export mr-2"></i> Export Data </button> </div> <div> <h3 class="font-medium mb-2">Export Chart</h3> <div class="space-y-4"> <div class="flex items-center"> <input type="radio" id="exportChartPNG" name="chartFormat" value="png" checked class="mr-2"> <label for="exportChartPNG">PNG Image</label> </div> <div class="flex items-center"> <input type="radio" id="exportChartJPEG" name="chartFormat" value="jpeg" class="mr-2"> <label for="exportChartJPEG">JPEG Image</label> </div> <div class="flex items-center"> <input type="radio" id="exportChartSVG" name="chartFormat" value="svg" class="mr-2"> <label for="exportChartSVG">SVG Vector</label> </div> </div> <div class="mt-6"> <h3 class="font-medium mb-2">Chart Quality</h3> <select id="chartQuality" class="w-full px-4 py-2 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-dark-900 text-white"> <option value="1">High (1x)</option> <option value="2">Very High (2x)</option> <option value="0.5">Medium (0.5x)</option> </select> </div> <button id="exportChartBtn" class="mt-6 w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center justify-center"> <i class="fas fa-chart-pie mr-2"></i> Export Chart </button> </div> </div> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { // Global variables let rawData = []; let filteredData = []; let columns = []; let currentChart = null; let currentFile = null; let columnTypes = []; // Tab functionality document.querySelectorAll('.tab-button').forEach(button => { button.addEventListener('click', function() { // Remove active class from all buttons and content document.querySelectorAll('.tab-button').forEach(btn => btn.classList.remove('active')); document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active')); // Add active class to clicked button and corresponding content this.classList.add('active'); const tabId = this.getAttribute('data-tab'); document.getElementById(tabId).classList.add('active'); }); }); // File input handler // Auto generate charts when file is loaded document.getElementById('fileInput').addEventListener('change', function(e) { handleFileUpload(e).then(() => { // Auto select first two columns for X and Y axes if (columns.length >= 2) { addSelectedOption('xAxisSelect', columns[0], 0); addSelectedOption('yAxisSelect', columns[1], 1); generateChart(); } }); }); ======= // Column search functionality document.getElementById('columnSearch').addEventListener('input', function(e) { const searchTerm = e.target.value.toLowerCase(); const columnItems = document.querySelectorAll('#columnList .column-item'); columnItems.forEach(item => { const columnName = item.textContent.toLowerCase(); if (columnName.includes(searchTerm)) { item.classList.remove('hidden'); item.classList.add('highlight'); } else { item.classList.add('hidden'); item.classList.remove('highlight'); } }); }); // Table search functionality document.getElementById('tableSearch').addEventListener('input', function(e) { const searchTerm = e.target.value.toLowerCase(); if (searchTerm === '') { filteredData = [...rawData]; populateDataTable(); return; } filteredData = rawData.filter(row => { return row.some(cell => { return cell !== undefined && cell.toString().toLowerCase().includes(searchTerm); }); }); populateDataTable(); updateTableInfo(); }); // Initialize multiselect components initMultiselect('xAxisSelect'); initMultiselect('yAxisSelect'); // Reset chart button // File upload handler (now returns Promise) function handleFileUpload(e) { return new Promise((resolve, reject) => { const file = e.target.files[0]; if (!file) return reject('No file selected'); currentFile = file; document.getElementById('fileName').textContent = `Selected file: ${file.name}`; document.getElementById('fileSize').textContent = formatFileSize(file.size); // Show loading state const chartLoading = document.getElementById('chartLoading'); chartLoading.style.display = 'block'; const reader = new FileReader(); reader.onload = function(e) { try { const data = new Uint8Array(e.target.result); const workbook = XLSX.read(data, { type: 'array', cellDates: true }); // Get first sheet const firstSheet = workbook.Sheets[workbook.SheetNames[0]]; // Convert to JSON with raw values to preserve dates rawData = XLSX.utils.sheet_to_json(firstSheet, { header: 1, raw: false, defval: null }); // Extract headers (assuming first row is headers) columns = rawData[0] || []; rawData = rawData.slice(1); // Remove header row filteredData = [...rawData]; // Analyze column types analyzeColumnTypes(); // Populate column list populateColumnList(); // Populate data table populateDataTable(); // Update stats updateStats(); // Initialize multiselect options updateMultiselectOptions('xAxisSelect', columns); updateMultiselectOptions('yAxisSelect', columns); } catch (error) { console.error('Error processing file:', error); alert('Error processing file: ' + error.message); } finally { // Hide loading state and resolve chartLoading.style.display = 'none'; resolve(); } }); reader.onerror = function() { alert('Error reading file'); chartLoading.style.display = 'none'; }; reader.readAsArrayBuffer(file); } // Simplified column type analysis function analyzeColumnTypes() { columnTypes = []; if (columns.length === 0 || rawData.length === 0) return; columns.forEach((col, colIndex) => { // Default to text for simplicity columnTypes[colIndex] = 'text'; }); } // Format file size function formatFileSize(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } // Populate column list function populateColumnList() { const columnList = document.getElementById('columnList'); columnList.innerHTML = ''; if (columns.length === 0) { columnList.innerHTML = '<p class="text-gray-400 italic">No columns found</p>'; return; } columns.forEach((column, index) => { const columnItem = document.createElement('div'); columnItem.className = 'column-item p-2 hover:bg-gray-700 cursor-pointer rounded flex items-center justify-between'; columnItem.innerHTML = ` <span>${column}</span> <span class="text-xs ${getTypeColorClass(columnTypes[index])}">${columnTypes[index]}</span> `; columnItem.dataset.columnIndex = index; columnItem.addEventListener('click', function() { // Highlight selected column document.querySelectorAll('#columnList .column-item').forEach(item => { item.classList.remove('bg-indigo-900'); }); this.classList.add('bg-indigo-900'); }); columnList.appendChild(columnItem); }); } // Get CSS class for type indicator function getTypeColorClass(type) { switch(type) { case 'date': return 'text-green-400'; case 'number': return 'text-blue-400'; default: return 'text-yellow-400'; } } // Populate data table function populateDataTable() { const table = document.getElementById('dataTable'); const thead = table.querySelector('thead tr'); const tbody = table.querySelector('tbody'); // Clear existing content thead.innerHTML = ''; tbody.innerHTML = ''; // Add headers with type indicators columns.forEach((column, index) => { const th = document.createElement('th'); th.innerHTML = ` <div class="flex flex-col"> <span>${column}</span> <span class="text-xs ${getTypeColorClass(columnTypes[index])}">${columnTypes[index]}</span> </div> `; thead.appendChild(th); }); // Add data rows (limit to 100 for performance) const displayData = filteredData.slice(0, 100); displayData.forEach(row => { const tr = document.createElement('tr'); columns.forEach((_, index) => { const td = document.createElement('td'); const value = row[index]; // Format based on type let displayValue = ''; let cellClass = ''; if (value === null || value === undefined || value === '') { displayValue = ''; cellClass = 'text-gray-500 italic'; } else if (columnTypes[index] === 'date') { // Format date if (value instanceof Date) { displayValue = value.toLocaleDateString(); } else if (typeof value === 'number') { // Convert Excel date number to Date const date = new Date((value - (25567 + 2)) * 86400 * 1000); displayValue = date.toLocaleDateString(); } else { // Try to parse string as date const dateFormats = [ 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY' ]; const parsedDate = moment(value, dateFormats, true); displayValue = parsedDate.isValid() ? parsedDate.format('YYYY-MM-DD') : value; } cellClass = 'date-cell'; } else if (columnTypes[index] === 'number') { // Format number const num = parseFloat(value); displayValue = isNaN(num) ? value : num.toLocaleString(); cellClass = 'numeric-cell'; } else { // Text displayValue = value.toString(); cellClass = 'text-cell'; } td.className = cellClass; td.textContent = displayValue; tr.appendChild(td); }); tbody.appendChild(tr); }); updateTableInfo(); } // Update table info function updateTableInfo() { const totalRows = rawData.length; const showingRows = filteredData.length; const isFiltered = showingRows !== totalRows; let infoText = `Showing ${Math.min(showingRows, 100)} rows of ${showingRows} total`; if (isFiltered) { infoText += ` (filtered from ${totalRows} total rows)`; } document.getElementById('tableInfo').textContent = infoText; } // Update stats function updateStats() { document.getElementById('totalRows').textContent = rawData.length; document.getElementById('totalColumns').textContent = columns.length; document.getElementById('statTotalRows').textContent = rawData.length; document.getElementById('statTotalColumns').textContent = columns.length; // Update column stats const columnStats = document.getElementById('columnStats'); columnStats.innerHTML = ''; if (columns.length === 0) { columnStats.innerHTML = '<tr><td colspan="7" class="text-center py-4 text-gray-400">No columns found</td></tr>'; return; } columns.forEach((col, index) => { const values = rawData.map(row => row[index]); const nonEmptyValues = values.filter(val => val !== null && val !== undefined && val !== ''); // For numeric columns const numericValues = columnTypes[index] === 'number' || columnTypes[index] === 'date' ? nonEmptyValues.map(val => { if (columnTypes[index] === 'date') { if (val instanceof Date) return val.getTime(); if (typeof val === 'number') return (val - (25567 + 2)) * 86400 * 1000; const parsedDate = moment(val, ['YYYY-MM-DD', 'MM/DD/YYYY', 'DD/MM/YYYY'], true); return parsedDate.isValid() ? parsedDate.valueOf() : null; } return parseFloat(val); }).filter(val => !isNaN(val)) : []; // For all columns const uniqueValues = new Set(nonEmptyValues.map(String)); const missingCount = values.length - nonEmptyValues.length; const row = document.createElement('tr'); row.className = 'hover:bg-gray-700'; // Column name and type const nameCell = document.createElement('td'); nameCell.innerHTML = ` <div class="flex flex-col"> <span>${col}</span> <span class="text-xs ${getTypeColorClass(columnTypes[index])}">${columnTypes[index]}</span> </div> `; row.appendChild(nameCell); // Type const typeCell = document.createElement('td'); typeCell.textContent = columnTypes[index]; row.appendChild(typeCell); // Unique values const uniqueCell = document.createElement('td'); uniqueCell.textContent = uniqueValues.size; row.appendChild(uniqueCell); // Missing values const missingCell = document.createElement('td'); missingCell.textContent = missingCount; row.appendChild(missingCell); // Min (for numeric/date columns) const minCell = document.createElement('td'); if (numericValues.length > 0) { const min = Math.min(...numericValues); minCell.textContent = columnTypes[index] === 'date' ? new Date(min).toLocaleDateString() : min.toLocaleString(); } else { minCell.textContent = '-'; } row.appendChild(minCell); // Max (for numeric/date columns) const maxCell = document.createElement('td'); if (numericValues.length > 0) { const max = Math.max(...numericValues); maxCell.textContent = columnTypes[index] === 'date' ? new Date(max).toLocaleDateString() : max.toLocaleString(); } else { maxCell.textContent = '-'; } row.appendChild(maxCell); // Mean (for numeric/date columns) const meanCell = document.createElement('td'); if (numericValues.length > 0) { const sum = numericValues.reduce((a, b) => a + b, 0); const mean = sum / numericValues.length; meanCell.textContent = columnTypes[index] === 'date' ? new Date(mean).toLocaleDateString() : mean.toFixed(2); } else { meanCell.textContent = '-'; } row.appendChild(meanCell); columnStats.appendChild(row); }); } // Simplified multiselect init function initMultiselect(id) { const container = document.getElementById(id); const input = container.querySelector('.multiselect-input'); const dropdown = container.querySelector('.dropdown-content'); input.addEventListener('focus', () => dropdown.classList.remove('hidden')); input.addEventListener('blur', () => dropdown.classList.add('hidden')); } // Simplified update multiselect options function updateMultiselectOptions(id, options) { const optionsContainer = document.querySelector(`#${id} .multiselect-options`); optionsContainer.innerHTML = options.map((option, index) => ` <div class="multiselect-option-item px-4 py-2 hover:bg-gray-700 cursor-pointer" data-value="${index}" onclick="addSelectedOption('${id}', '${option}', ${index})"> ${option} </div> `).join(''); } // Simplified add selected option function addSelectedOption(id, option, index) { const selectedContainer = document.querySelector(`#${id} .multiselect-selected`); if (selectedContainer.querySelector(`[data-value="${index}"]`)) return; selectedContainer.innerHTML += ` <div class="multiselect-option bg-indigo-900 text-indigo-100 p-1 m-1 rounded"> ${option} <span class="ml-2 cursor-pointer" onclick="this.parentNode.remove()">&times;</span> </div> `; } // Get selected options from multiselect function getSelectedOptions(id) { const container = document.getElementById(id); const selectedOptions = container.querySelectorAll('.multiselect-selected [data-value]'); return Array.from(selectedOptions).map(option => ({ index: parseInt(option.dataset.value), name: option.textContent.replace('×', '').trim(), type: option.dataset.type })); } // Generate chart based on selected options function generateChart() { const xAxisOptions = getSelectedOptions('xAxisSelect'); const yAxisOptions = getSelectedOptions('yAxisSelect'); const chartType = document.getElementById('chartType').value; if (xAxisOptions.length === 0 || yAxisOptions.length === 0) { alert('Please select at least one column for both X and Y axes'); return; } // Show loading state const chartLoading = document.getElementById('chartLoading'); chartLoading.style.display = 'block'; // Use setTimeout to allow UI to update before heavy processing setTimeout(() => { try { // Prepare data for Chart.js const labels = rawData.map(row => { return xAxisOptions.map(opt => { const value = row[opt.index]; if (value === null || value === undefined || value === '') return ''; if (opt.type === 'date') { if (value instanceof Date) return value.toLocaleDateString(); if (typeof value === 'number') { // Convert Excel date number to Date const date = new Date((value - (25567 + 2)) * 86400 * 1000); return date.toLocaleDateString(); } // Try to parse string as date const dateFormats = [ 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY' ]; const parsedDate = moment(value, dateFormats, true); return parsedDate.isValid() ? parsedDate.format('YYYY-MM-DD') : value; } return value.toString(); }).join(' - '); }); const datasets = yAxisOptions.map((yOpt, i) => { const colors = [ '#4f46e5', '#ef4444', '#10b981', '#f59e0b', '#8b5cf6', '#ec4899', '#14b8a6', '#f97316', '#64748b', '#84cc16' ]; return { label: yOpt.name, data: rawData.map(row => { const value = row[yOpt.index]; if (value === null || value === undefined || value === '') return null; if (yOpt.type === 'date') { if (value instanceof Date) return value.getTime(); if (typeof value === 'number') return (value - (25567 + 2)) * 86400 * 1000; const parsedDate = moment(value, ['YYYY-MM-DD', 'MM/DD/YYYY', 'DD/MM/YYYY'], true); return parsedDate.isValid() ? parsedDate.valueOf() : null; } return parseFloat(value); }), borderColor: colors[i % colors.length], backgroundColor: colors[i % colors.length], borderWidth: 2, tension: 0.1, fill: false }; }); // Get chart canvas and destroy previous chart if exists const ctx = document.getElementById('dataChart').getContext('2d'); if (currentChart) { currentChart.destroy(); } // Get min/max Y values if specified const minYValue = document.getElementById('minYValue').value; const maxYValue = document.getElementById('maxYValue').value; // Create new chart currentChart = new Chart(ctx, { type: chartType, data: { labels: labels, datasets: datasets }, options: { responsive: true, maintainAspectRatio: false, animation: { duration: 1000, easing: 'easeOutQuart' }, plugins: { title: { display: true, text: 'Data Visualization', font: { size: 16 }, color: '#e2e8f0' }, tooltip: { mode: 'index', intersect: false, backgroundColor: '#2d3748', titleColor: '#e2e8f0', bodyColor: '#e2e8f0', borderColor: '#4a5568', borderWidth: 1, callbacks: { label: function(context) { const dataset = context.dataset; const value = context.raw; let label = dataset.label || ''; if (yAxisOptions[context.datasetIndex].type === 'date') { if (value !== null) { return label + ': ' + new Date(value).toLocaleDateString(); } } if (value !== null) { return label + ': ' + value; } return label + ': N/A'; } } }, legend: { position: 'bottom', labels: { boxWidth: 12, color: '#e2e8f0' } } }, scales: { x: { title: { display: true, text: xAxisOptions.map(opt => opt.name).join(' + '), font: { weight: 'bold' }, color: '#e2e8f0' }, grid: { color: '#4a5568' }, ticks: { color: '#a0aec0' } }, y: { title: { display: true, text: yAxisOptions.length === 1 ? yAxisOptions[0].name : 'Multiple Values', font: { weight: 'bold' }, color: '#e2e8f0' }, grid: { color: '#4a5568' }, ticks: { color: '#a0aec0', callback: function(value) { if (yAxisOptions.some(opt => opt.type === 'date')) { return new Date(value).toLocaleDateString(); } return value; }, min: minYValue !== '' ? parseFloat(minYValue) : undefined, max: maxYValue !== '' ? parseFloat(maxYValue) : undefined }, min: minYValue !== '' ? parseFloat(minYValue) : undefined, max: maxYValue !== '' ? parseFloat(maxYValue) : undefined } } } }); } catch (error) { console.error('Error generating chart:', error); alert('Error generating chart: ' + error.message); } finally { // Hide loading state chartLoading.style.display = 'none'; } }, 100); } }); </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>📊 IGR-BDSM Advanced Analytics</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
dark: {
800: '#2d3748',
900: '#1a202c',
}
}
}
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary-color: #7c3aed;
--secondary-color: #8b5cf6;
--dark-bg: #0f172a;
--dark-card: #1e293b;
--dark-text: #f8fafc;
--dark-border: #334155;
--accent-1: #f59e0b;
--accent-2: #10b981;
--danger: #ef4444;
--success: #10b981;
--glass-effect: rgba(30, 41, 59, 0.6);
--gradient: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}
body {
background: radial-gradient(circle at 10% 20%, var(--dark-bg) 0%, #0b1120 100%);
color: var(--dark-text);
min-height: 100vh;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
@supports (font-variation-settings: normal) {
body {
font-family: 'Inter var', -apple-system, BlinkMacSystemFont, sans-serif;
}
}
.file-input-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
border-radius: 12px;
background: var(--gradient);
box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
transition: all 0.3s ease;
}
.file-input-wrapper:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}
.file-input-wrapper input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: pointer;
display: block;
}
.multiselect {
min-height: 42px;
border: 1px solid var(--dark-border);
border-radius: 12px;
padding: 0.5rem 1rem;
background-color: var(--glass-effect);
backdrop-filter: blur(10px);
transition: all 0.2s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.multiselect:focus-within {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
}