`;
});
// Chart Data
const capTableLabels = ['Founders', 'Series A', 'Series B', 'Series C'];
const capTableData = [
results.founderShares,
results.rounds[0].investorShares,
results.rounds[1].investorShares,
results.rounds[2].investorShares,
];
const valuationLabels = ['Start', 'Series A', 'Series B', 'Series C', 'IPO'];
const valuationData = [
results.rounds[0].preMoney,
results.rounds[0].postMoney,
results.rounds[1].postMoney,
results.rounds[2].postMoney,
results.ipo.valuation
];
const founderEquityData = [
100,
results.rounds[0].founderOwnership,
results.rounds[1].founderOwnership,
results.rounds[2].founderOwnership,
founderFinalOwnership
];
renderCapTableChart(capTableLabels, capTableData);
renderValuationChart(valuationLabels, valuationData, founderEquityData);
}
function renderCapTableChart(labels, data) {
const ctx = document.getElementById('capTableChart').getContext('2d');
if (capTableChart) capTableChart.destroy();
capTableChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: ['#7c3aed', '#a78bfa', '#c4b5fd', '#ddd6fe'],
borderColor: '#fff',
borderWidth: 2,
}]
},
options: { responsive: true, plugins: { legend: { position: 'top' } } }
});
}
function renderValuationChart(labels, valData, equityData) {
const ctx = document.getElementById('valuationChart').getContext('2d');
if(valuationChart) valuationChart.destroy();
valuationChart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [
{
type: 'bar',
label: 'Valuation ($M)',
data: valData.map(v => (v/1000000).toFixed(2)),
backgroundColor: '#a78bfa',
yAxisID: 'y'
},
{
type: 'line',
label: 'Founder Equity (%)',
data: equityData.map(v => v.toFixed(2)),
borderColor: '#db2777',
backgroundColor: '#fdf2f8',
tension: 0.1,
fill: true,
yAxisID: 'y1'
}
]
},
options: {
responsive: true,
interaction: { mode: 'index', intersect: false },
scales: {
y: { type: 'linear', display: true, position: 'left', title: { display: true, text: 'Valuation ($M)' } },
y1: { type: 'linear', display: true, position: 'right', max: 100, title: { display: true, text: 'Founder Equity (%)' }, grid: { drawOnChartArea: false } }
}
}
});
}
window.downloadPDF = async () => {
const { jsPDF } = window.jspdf;
const content = document.getElementById('pdf-content');
const canvas = await html2canvas(content, { scale: 2, backgroundColor: '#ffffff' });
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'px', format: [canvas.width, canvas.height] });
pdf.addImage(imgData, 'PNG', 0, 0, canvas.width, canvas.height);
pdf.save(`${ui.inputs.companyName.value}_IPO_Simulation.pdf`);
};
// Initial setup
Object.values(ui.tabs).forEach(p => p.classList.add('hidden'));
ui.tabs[1].classList.remove('hidden');
updateNav();
});