Traditional Chinese Medicine (TCM) Health Score

TCM Health Score

Five Element Wellness Quiz

Lifestyle: ${advice.lifestyle}

`; document.getElementById('download-pdf-btn').addEventListener('click', handlePdfDownload); renderChart(); }; const renderChart = () => { const ctx = document.getElementById('resultChart').getContext('2d'); new Chart(ctx, { type: 'radar', data: { labels: Object.keys(finalResult.scores), datasets: [{ label: 'Elemental Imbalance Score (Higher is more imbalanced)', data: Object.values(finalResult.scores), backgroundColor: 'rgba(87, 83, 78, 0.2)', borderColor: 'rgba(87, 83, 78, 1)', borderWidth: 2 }] }, options: { scales: { r: { beginAtZero: true, max: 9 // Each element has 3 questions, max score 3 each } } } }); }; const handlePdfDownload = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF(); const advice = WELLNESS_ADVICE[finalResult.dominantElement]; doc.setFillColor('#44403c').rect(0, 0, 210, 30, 'F'); doc.setFont('helvetica', 'bold').setFontSize(20).setTextColor('#FFFFFF'); doc.text('TCM Wellness Report', 105, 18, { align: 'center' }); doc.setFontSize(12).setFont('helvetica', 'normal').setTextColor('#1f2937'); doc.text(`For: ${finalResult.userName}`, 14, 45); doc.text(`Date: ${new Date().toLocaleDateString()}`, 14, 51); doc.setFontSize(16).setFont('helvetica', 'bold').text('Overall Health Score:', 14, 65); doc.setFontSize(26).setTextColor('#44403c').text(`${finalResult.healthScore}%`, 70, 65); doc.setFontSize(16).setFont('helvetica', 'bold').setTextColor('#1f2937').text('Dominant Element Profile: ' + finalResult.dominantElement, 14, 80); const descLines = doc.splitTextToSize(advice.description, 180); doc.setFontSize(11).setFont('helvetica', 'normal').text(descLines, 14, 88); let yPos = 88 + (descLines.length * 5) + 5; doc.setFontSize(12).setFont('helvetica', 'bold').text('Wellness Recommendations', 14, yPos); yPos += 7; const dietLines = doc.splitTextToSize(`Diet: ${advice.diet}`, 180); doc.setFontSize(11).setFont('helvetica', 'normal').text(dietLines, 14, yPos); yPos += (dietLines.length * 5) + 2; const lifeLines = doc.splitTextToSize(`Lifestyle: ${advice.lifestyle}`, 180); doc.setFontSize(11).setFont('helvetica', 'normal').text(lifeLines, 14, yPos); doc.save(`${finalResult.userName}_TCM_Report.pdf`); }; const addEventListeners = () => { nextBtn.addEventListener('click', () => handleNavigate(1)); prevBtn.addEventListener('click', () => handleNavigate(-1)); }; init(); });
Scroll to Top