Inflation Rate Estimator

Inflation Rate Estimator

Calculate your personal inflation rate based on a custom basket of goods.

Inflation Analysis

Inflation Rate by Category

Settings & Basket of Goods

Category Item Name Start Price ($) End Price ($) Actions

${value}

`; function renderChart(chartData) { if (inflationChart) inflationChart.destroy(); inflationChart = new Chart(document.getElementById('inflation-chart'), { type: 'bar', data: { labels: chartData.map(d => d.category), datasets: [{ label: 'Inflation Rate (%)', data: chartData.map(d => d.inflation), backgroundColor: chartData.map(d => d.inflation > 0 ? 'rgba(220, 38, 38, 0.6)' : 'rgba(21, 128, 61, 0.6)'), borderColor: chartData.map(d => d.inflation > 0 ? 'rgb(220, 38, 38)' : 'rgb(21, 128, 61)'), borderWidth: 1 }] }, options: { indexAxis: 'y' } }); } // --- PDF GENERATION --- async function generatePdfReport() { const result = state.analysisResult; if (!result) return alert("Please run an analysis first."); downloadPdfBtn.disabled = true; downloadPdfBtn.textContent = 'Generating...'; const chartImg = inflationChart.toBase64Image(); const { kpis } = result; const reportHtml = `

Personal Inflation Report

${state.settings.analysisName}: Comparing ${state.settings.startPeriod} to ${state.settings.endPeriod}

Summary of Findings

Overall Inflation Rate
${kpis.overallInflation.toFixed(2)}%
Total Cost Change
$${kpis.costChange.toFixed(2)}
Highest Inflation Category
${kpis.biggestMover.category}

Category Inflation Breakdown

`; const pdfTemplate = document.getElementById('pdf-template'); pdfTemplate.innerHTML = reportHtml; pdfTemplate.classList.remove('invisible'); try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-report-container'), { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); pdf.addImage(imgData, 'PNG', 0, 0, pdf.internal.pageSize.getWidth(), (canvas.height * pdf.internal.pageSize.getWidth()) / canvas.width); pdf.save(`${state.settings.analysisName.replace(/\s+/g, '_')}_Inflation_Report.pdf`); } catch(e) { console.error('PDF Generation Error:', e); } finally { downloadPdfBtn.disabled = false; downloadPdfBtn.textContent = 'Download Inflation Report'; pdfTemplate.classList.add('invisible'); } } downloadPdfBtn.addEventListener('click', generatePdfReport); // --- INITIALIZATION --- populateSettingsUI(); renderDataTable(); attachDataListeners(); runAnalysis(); switchTab(0); });
Scroll to Top