// Financial Data Analysis const financialData = { months: ['jan/25', 'fev/25', 'mar/25', 'abr/25', 'mai/25', 'jun/25', 'jul/25', 'ago/25', 'set/25', 'out/25', 'nov/25', 'dez/25'], revenues: { total: [32757, 36279, 37684, 34902, 34148, 42104, 33888, 44910, 46361, 49334, 51009, 47416], traffic: [22815, 23843, 25170, 19145, 23370, 32961, 27074, 34795, 30949, 39539, 37828, 38857], services: [0, 497, 497, 0, 1216, 547, 829, 714, 5490, 1547, 2627, 2394], webDesign: [7476, 11217, 11324, 14952, 9151, 8596, 5985, 8236, 8135, 7985, 9165, 6165], hosting: [0, 250, 250, 0, 0, 0, 0, 0, 0, 0, 222, 0] }, expenses: { total: [38408, 38022, 41353, 38789, 38435, 46177, 43866, 44193, 50352, 51320, 52617, 50153], taxes: [2754, 2177, 3447, 2763, 2227, 3029, 3047, 3290, 3981, 4146, 4813, 4282], sales: [2690, 6214, 6514, 6253, 7581, 10308, 7792, 8205, 9666, 9813, 6577, 6657], salaries: [7811, 2305, 7513, 6909, 5909, 6909, 7465, 7669, 10146, 9690, 11294, 11486], administrative: [1777, 3991, 3777, 2195, 2310, 3551, 2403, 2220, 2656, 2548, 5827, 2785], commercial: [191, 470, 402, 966, 709, 331, 1462, 1210, 1685, 1818, 893, 1310], plr: [19396, 19396, 19396, 19396, 19396, 21396, 21396, 21396, 20964, 22964, 22964, 22964] }, results: { contributionMargin: [24847, 27416, 27279, 25081, 23929, 28766, 23048, 32250, 30927, 35112, 38451, 36478], operationalProfit: [14289, 20353, 15290, 14714, 14704, 17381, 11422, 20951, 15252, 20792, 20249, 20231], cashGeneration: [-5651, -1743, -3668, -3887, -4286, -4073, -9978, 717, -3991, -1985, -1608, -2737], finalCash: [52114, 50371, 46703, 42816, 42529, 44457, 36478, 25195, 27204, 27102, 27611, 14874] } }; // Initialize Charts document.addEventListener('DOMContentLoaded', function() { initializeCharts(); setupEventListeners(); }); function initializeCharts() { // Revenue Composition Chart const revenueCtx = document.getElementById('revenueChart').getContext('2d'); new Chart(revenueCtx, { type: 'doughnut', data: { labels: ['Receita de Tráfego', 'Web Design', 'Serviços', 'Hospedagem'], datasets: [{ data: [37828, 9165, 2627, 222], backgroundColor: [ '#10B981', '#3B82F6', '#8B5CF6', '#F59E0B' ], borderWidth: 2, borderColor: '#ffffff' }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: 'bottom', labels: { padding: 20, usePointStyle: true } } } } }); // Expense Composition Chart const expenseCtx = document.getElementById('expenseChart').getContext('2d'); new Chart(expenseCtx, { type: 'bar', data: { labels: ['Impostos', 'Vendas', 'Salários', 'Administrativas', 'Comerciais', 'PLR'], datasets: [{ label: 'Valores em R$', data: [4813, 6577, 11294, 5827, 893, 22964], backgroundColor: [ '#EF4444', '#F59E0B', '#3B82F6', '#8B5CF6', '#10B981', '#EC4899' }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } }, scales: { y: { beginAtZero: true, grid: { drawBorder: false } }, x: { grid: { display: false } } } } }); // Cash Flow Projection Chart const cashFlowCtx = document.getElementById('cashFlowChart').getContext('2d'); new Chart(cashFlowCtx, { type: 'line', data: { labels: financialData.months, datasets: [{ label: 'Saldo Final de Caixa', data: financialData.results.finalCash, borderColor: '#10B981', backgroundColor: 'rgba(16, 185, 129, 0.1)', tension: 0.4, fill: true }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: true, position: 'top' } }, scales: { y: { beginAtZero: false, grid: { drawBorder: false } }, x: { grid: { display: false } } } } }); } function setupEventListeners() { // Add smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Add loading animation for charts const charts = document.querySelectorAll('canvas'); charts.forEach(chart => { chart.classList.add('fade-in'); }); } // Utility function to format currency function formatCurrency(value) { return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(value); } // Export data for potential download function exportFinancialData() { const dataStr = JSON.stringify(financialData, null, 2); const dataBlob = new Blob([dataStr], { type: 'application/json' }); const url = URL.createObjectURL(dataBlob); const link = document.createElement('a'); link.href = url; link.download = 'analise-financeira-novembro.json'; link.click(); URL.revokeObjectURL(url); }