Reflexology Chart Generator
1. Select System to View
2. Chart Legend
Select a system to populate the legend.
3. Export
Select a system to populate the legend.
'; return; } let points = []; if (systemKey === 'all') { for (const key in REFLEX_DATA) { points.push(...REFLEX_DATA[key]); } } else { points = REFLEX_DATA[systemKey] || []; } // Group by color/system for clean legend const groupedPoints = points.reduce((acc, point) => { (acc[point.color] = acc[point.color] || []).push(point); return acc; }, {}); for (const color in groupedPoints) { const systemName = groupedPoints[color][0].name.split(' ')[0]; // Use first word as grouping title const systemGroup = document.createElement('div'); systemGroup.className = 'mb-2'; systemGroup.innerHTML = `${systemName} Points:
`; groupedPoints[color].forEach(point => { const item = document.createElement('div'); item.className = 'rcg-legend-item'; item.innerHTML = ` ${point.name}: ${point.desc} `; systemGroup.appendChild(item); }); legendEl.appendChild(systemGroup); } } // --- PDF Generation --- function downloadPDF() { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Error: jsPDF library not loaded.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('landscape', 'pt', 'a4'); const margin = 40; const pageWidth = doc.internal.pageSize.getWidth(); let currentY = margin; const systemKey = systemSelect.value; const systemText = systemSelect.options[systemSelect.selectedIndex].text; // --- Header --- doc.setFontSize(22); doc.setFont('helvetica', 'bold'); doc.setTextColor(3, 105, 161); // sky-700 doc.text("Reflexology Chart Report", pageWidth / 2, currentY, { align: 'center' }); currentY += 15; doc.setFontSize(14); doc.text(`System Selected: ${systemText}`, pageWidth / 2, currentY, { align: 'center' }); currentY += 30; // --- Draw Canvas Image --- const canvasImage = canvas.toDataURL('image/png'); const imageWidth = 250; const imageX = (pageWidth / 2) - (imageWidth / 2); doc.addImage(canvasImage, 'PNG', imageX, currentY, imageWidth, imageWidth * (1.4)); currentY += imageWidth * 1.4 + 20; // --- Detailed Points Table --- doc.setFontSize(14); doc.setFont('helvetica', 'bold'); doc.setTextColor(3, 105, 161); doc.text("Mapped Reflex Points", margin, currentY); currentY += 15; let points = []; if (systemKey === 'none') { points = []; } else if (systemKey === 'all') { for (const key in REFLEX_DATA) { points.push(...REFLEX_DATA[key]); } } else { points = REFLEX_DATA[systemKey] || []; } const tableHead = [['System Area', 'Point Name', 'Description']]; const tableBody = points.map(p => [ systemKey === 'all' ? p.name.split(' ')[0] : systemText.split(' ')[0], // Use system name for grouping in all mode p.name, p.desc ]); if (points.length > 0) { doc.autoTable({ startY: currentY, head: tableHead, body: tableBody, theme: 'striped', headStyles: { fillColor: [14, 165, 233], textColor: [255, 255, 255] }, // sky-500 styles: { fontSize: 8, minCellHeight: 15 }, columnStyles: { 0: { fontStyle: 'bold', cellWidth: 80 }, 1: { fontStyle: 'bold', cellWidth: 80 } }, margin: { left: margin, right: margin } }); } else { doc.setFontSize(10); doc.setTextColor(51, 65, 85); doc.text("No specific points selected or data available for this system.", margin, currentY); } doc.save('reflexology-chart.pdf'); } // --- Event Listeners --- systemSelect.addEventListener('change', drawCanvas); pdfBtn.addEventListener('click', downloadPDF); // Responsive canvas new ResizeObserver(resizeCanvas).observe(document.getElementById('rcg-canvas-wrapper')); // Initial Load resizeCanvas(); });