Vitamin Chart Generator

Vitamin Chart Generator

VitaGuide

Essential Vitamin Chart Builder
Chart Metadata
Vitamin Details (Rows)
Vitamin
RDA / Unit
Primary Function
Food Sources
Remove

Live Chart Rendering

Add vitamins in the builder tab to generate the chart.

'; } else { html += ``; data.forEach(item => { html += ``; }); html += `
Vitamin RDA (Adult) Primary Function Common Sources
${item.vitamin} ${item.rda} ${item.func} ${item.sources}
`; } container.innerHTML = html; } function vcgSwitchTab(tabId) { document.querySelectorAll('.vcg-tab-btn').forEach(b => b.classList.remove('active')); document.querySelectorAll('.vcg-content').forEach(c => c.classList.remove('active')); const idx = tabId === 'builder' ? 0 : 1; document.querySelectorAll('.vcg-tab-btn')[idx].classList.add('active'); document.getElementById('vcg-' + tabId).classList.add('active'); if (tabId === 'preview') { vcgRenderChart(); } } function vcgLoadExample() { if(!confirm("Overwrite current data and load full B-complex and fat-soluble vitamins example?")) return; document.getElementById('inp-chart-title').value = "Essential Micronutrients Reference Guide"; // Clear and fill rows document.getElementById('vcg-chart-rows-container').innerHTML = ''; vcgAddChartRow("B1 (Thiamin)", "1.2 mg", "Energy metabolism, nerve function.", "Pork, whole grains, beans."); vcgAddChartRow("B9 (Folate)", "400 mcg", "DNA synthesis, prevents neural tube defects.", "Leafy greens, liver, legumes."); vcgAddChartRow("B12 (Cobalamin)", "2.4 mcg", "Nerve cells, red blood cell formation.", "Meat, fish, dairy (animal products only)."); vcgAddChartRow("K", "120 mcg", "Blood clotting and bone mineralization.", "Broccoli, spinach, vegetable oils."); vcgAddChartRow("E", "15 mg", "Powerful fat-soluble antioxidant.", "Nuts, seeds, vegetable oils."); vcgRenderChart(); vcgSwitchTab('preview'); } /* --- PDF Generation --- */ async function vcgGeneratePDF() { vcgRenderChart(); // Final render check const data = vcgGetChartData(); const title = document.getElementById('inp-chart-title').value || "Vitamin Reference Chart"; if (data.length === 0) { alert("Please add vitamin data before generating the PDF."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('l', 'mm', 'a4'); // Landscape for wider table const green = [0, 128, 0]; let y = 20; // Header doc.setFillColor(...green); doc.rect(0, 0, 297, 20, 'F'); doc.setTextColor(255, 255, 255); doc.setFontSize(18); doc.text(title, 14, 14); // Meta doc.setTextColor(0, 0, 0); doc.setFontSize(10); doc.text(`Date Generated: ${new Date().toLocaleDateString()}`, 14, y + 15); y += 20; // Table Body Construction const tableBody = data.map(item => [ item.vitamin, item.rda, item.func, item.sources ]); doc.autoTable({ startY: y, head: [['Vitamin', 'RDA (Adult)', 'Primary Function', 'Common Sources']], body: tableBody, theme: 'grid', headStyles: { fillColor: green, fontSize: 11 }, styles: { fontSize: 9, cellPadding: 3 }, columnStyles: { 0: { cellWidth: 20, fontStyle: 'bold' }, 1: { cellWidth: 25 }, 2: { cellWidth: 70, overflow: 'linebreak' }, 3: { cellWidth: 'auto', overflow: 'linebreak' } } }); // Footer Note let finalY = doc.internal.pageSize.height - 10; doc.setFontSize(8); doc.setTextColor(150, 150, 150); doc.text("Source data provided by user. Consult a medical professional before making dietary changes.", 14, finalY); doc.save("Vitamin_Reference_Chart.pdf"); }
Scroll to Top