Customer Experience Dashboard

Customer Experience Dashboard

Overall Customer Experience Metrics

Net Promoter Score (NPS)

0

CSAT Score (1-5)

0.00

CES Score (1-7)

0.00

Total Support Tickets

0

Avg. Resolution Time

0.00 hours

First Contact Resolution Rate

0.00%

Positive Feedback

0

Negative Feedback

0

Overall Sentiment

Neutral

${displayCSAT.textContent}

CES Score (1-7)

${displayCES.textContent}

Total Support Tickets

${displayTotalTickets.textContent}

Avg. Resolution Time

${displayAvgResolutionTime.textContent}

First Contact Resolution Rate

${displayFCRRate.textContent}

Positive Feedback

${displayPositiveFeedback.textContent}

Negative Feedback

${displayNegativeFeedback.textContent}

Overall Sentiment

${displayOverallSentiment.textContent}

`; // Append to body temporarily to render for html2canvas document.body.appendChild(pdfContentWrapper); try { const canvas = await html2canvas(pdfContentWrapper, { scale: 2, // Increase scale for better resolution useCORS: true, // Required if images are from different origin (though we don't use images here) logging: false // Disable logging for cleaner console }); const imgData = canvas.toDataURL('image/png'); const pdf = new window.jspdf.jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const imgWidth = 210; // A4 width in mm const pageHeight = 297; // A4 height in mm const imgHeight = canvas.height * imgWidth / canvas.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; while (heightLeft >= 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } pdf.save('Customer_Experience_Dashboard.pdf'); } catch (error) { console.error('Error generating PDF:', error); // Provide a user-friendly message if PDF generation fails alert('Failed to generate PDF. Please try again.'); } finally { // Remove the temporary wrapper document.body.removeChild(pdfContentWrapper); } } // --- Event Listeners --- // Tab switching if (dashboardTabBtn) { dashboardTabBtn.addEventListener('click', function() { switchTab('dashboard'); }); } if (dataConfigTabBtn) { dataConfigTabBtn.addEventListener('click', function() { switchTab('dataConfig'); }); } // Navigation buttons if (prevTabBtn) { prevTabBtn.addEventListener('click', function() { if (currentActiveTab === 'dataConfig') { switchTab('dashboard'); } }); } if (nextTabBtn) { nextTabBtn.addEventListener('click', function() { if (currentActiveTab === 'dashboard') { switchTab('dataConfig'); } }); } // Input change listener (for real-time updates) const inputElements = [ npsScoreInput, csatScoreInput, cesScoreInput, totalTicketsInput, resolvedTicketsInput, avgResolutionTimeHoursInput, firstContactResolutionTicketsInput, positiveFeedbackCountInput, negativeFeedbackCountInput ]; inputElements.forEach(input => { if (input) { input.addEventListener('input', function() { updateCxMetricsFromInputs(); renderDashboard(); // Update dashboard in real-time }); } }); // PDF download button if (downloadPdfBtn) { downloadPdfBtn.addEventListener('click', downloadPdf); } // --- Initial Load --- populateInputFields(); // Populate inputs with initial data renderDashboard(); // Render dashboard with initial data switchTab('dashboard'); // Ensure dashboard tab is active on load });
Scroll to Top