Executive Summary Dashboard

Total Revenue

${formatCurrency(totalRevenue)}

Avg. Profit Margin

${avgMargin.toFixed(1)}%

New Customers

${totalNewCustomers.toLocaleString()}

Avg. Monthly Turnover

${avgTurnover.toFixed(1)}%

`; } const renderWidgetChart = (id, labels, data, color) => { const ctx = document.getElementById(id)?.getContext('2d'); if(!ctx) return; if(charts[id]) charts[id].destroy(); charts[id] = new Chart(ctx, { type: 'line', data: { labels, datasets: [{ data, borderColor: color, tension: 0.2, pointRadius: 0, fill: true, backgroundColor: `${color}20` }] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { display: false }, y: { display: false } }, plugins: { legend: { display: false } } } }); } function renderWidgets(data) { const labels = data.map(r => r.date); const widgetConfigs = [ { id: 'finance', title: 'Financial Health', kpiKey: 'revenue_usd', kpiLabel: 'Total Revenue', chartKey: 'revenue_usd', color: '#3b82f6', format: formatCurrency }, { id: 'sales', title: 'Sales & Marketing', kpiKey: 'new_customers', kpiLabel: 'New Customers', chartKey: 'new_customers', color: '#16a34a', format: (v) => v.toLocaleString() }, { id: 'ops', title: 'Operations', kpiKey: 'op_efficiency_percent', kpiLabel: 'Avg. Efficiency', chartKey: 'op_efficiency_percent', color: '#f97316', format: (v) => `${v.toFixed(1)}%` }, { id: 'hr', title: 'Human Resources', kpiKey: 'employee_turnover_rate_percent', kpiLabel: 'Avg. Turnover Rate', chartKey: 'employee_turnover_rate_percent', color: '#9333ea', format: (v) => `${v.toFixed(1)}%` } ]; elements.widgetContainer.innerHTML = ''; widgetConfigs.forEach(cfg => { const widgetEl = document.createElement('div'); widgetEl.className = 'exec-section exec-widget'; const kpiValues = data.map(r => r[cfg.kpiKey]); const kpiValue = cfg.kpiLabel.includes('Total') ? kpiValues.reduce((s,v)=>s+v,0) : avg(kpiValues); widgetEl.innerHTML = `

${cfg.title}

${cfg.format(kpiValue)} ${cfg.kpiLabel}
`; elements.widgetContainer.appendChild(widgetEl); renderWidgetChart(`sparkline-${cfg.id}`, labels, data.map(r => r[cfg.chartKey]), cfg.color); }); } window.execDownloadPDF = () => { html2canvas(document.getElementById('exec-pdf-content'), { scale: 2 }).then(canvas => { const pdf = new jspdf.jsPDF({ orientation: 'landscape', unit: 'pt', format: 'a4' }); pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 40, 40, pdf.internal.pageSize.getWidth() - 80, 0); pdf.save('Executive_Summary.pdf'); }); }; loadSampleData(); });
Scroll to Top