Smart E-wallet & Digital Payment Performance Analyzer

Smart E-wallet & Digital Payment Performance Analyzer

Analyze and compare the performance of your digital payment methods.

Payment Method Breakdown

Payment Method Success Rate (%) Failure Rate (%) Transaction Volume ($)

Transaction Volume by Method

Successful Transactions Distribution

${bestPerformer.name}

`; // Performance Table document.getElementById('performance-table-body').innerHTML = results.map(r => ` ${r.name} ${r.successRate.toFixed(2)}% ${r.failureRate.toFixed(2)}% $${r.volume.toLocaleString('en-US', {minimumFractionDigits:2})} `).join(''); // Charts if(volumeChart) volumeChart.destroy(); volumeChart = new Chart(document.getElementById('volume-chart').getContext('2d'), { type: 'bar', data: { labels: results.map(r => r.name), datasets: [{ label: 'Transaction Volume ($)', data: results.map(r => r.volume), backgroundColor: '#60a5fa' }] }, options: { plugins: { legend: { display: false } } } }); if(distributionChart) distributionChart.destroy(); distributionChart = new Chart(document.getElementById('distribution-chart').getContext('2d'), { type: 'doughnut', data: { labels: results.map(r => r.name), datasets: [{ data: results.map(r => r.successful), backgroundColor: ['#60a5fa', '#a78bfa', '#34d399', '#fbbf24'] }] }, options: { responsive: true, plugins: { legend: { position: 'top' } } } }); }; // --- EVENT HANDLERS --- const handleConfigChange = (e) => { const input = e.target; if (input.tagName !== 'INPUT') return; const id = parseInt(input.closest('tr').dataset.id); const field = input.dataset.field; const value = input.type === 'number' ? parseFloat(input.value) || 0 : input.value; const method = paymentMethods.find(p => p.id === id); if(method) method[field] = value; }; const handleAddMethod = () => { const newId = paymentMethods.length > 0 ? Math.max(...paymentMethods.map(p => p.id)) + 1 : 1; paymentMethods.push({ id: newId, name: "New Method", successful: 0, failed: 0, avgValue: 0 }); renderConfigTable(); }; const handleDeleteMethod = (e) => { const btn = e.target.closest('.delete-method-btn'); if (btn) { const id = parseInt(btn.closest('tr').dataset.id); paymentMethods = paymentMethods.filter(p => p.id !== id); renderConfigTable(); } }; const generatePDF = () => { const pdfContent = document.getElementById('pdf-content'); const pdfBtnContainer = document.getElementById('pdf-button-container'); if (!pdfContent || !pdfBtnContainer) return; pdfBtnContainer.style.display = 'none'; html2canvas(pdfContent, { scale: 2, useCORS: true }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'l', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgWidth = pdfWidth - 20; const imgHeight = (canvas.height * imgWidth) / canvas.width; pdf.setFontSize(22); pdf.setFont('helvetica', 'bold'); pdf.text('Digital Payment Performance Report', pdfWidth / 2, 15, { align: 'center' }); pdf.addImage(imgData, 'PNG', 10, 25, imgWidth, imgHeight); pdf.save('payment-performance-report.pdf'); pdfBtnContainer.style.display = 'block'; }); }; // --- ATTACH LISTENERS --- prevBtn.addEventListener('click', () => showTab('dashboard')); nextBtn.addEventListener('click', () => showTab('config')); tabButtons.dashboard.addEventListener('click', () => showTab('dashboard')); tabButtons.config.addEventListener('click', () => showTab('config')); addMethodBtn.addEventListener('click', handleAddMethod); configTableBody.addEventListener('change', handleConfigChange); configTableBody.addEventListener('click', handleDeleteMethod); downloadPdfBtn.addEventListener('click', generatePDF); // --- INITIAL SETUP --- showTab('dashboard'); });
Scroll to Top