AI-Powered Market Recession Probability Estimator
Economic Indicators Input
%
%
%
bps
%
%
%
Recession Probability Estimation
Note: This is a simplified model for educational purposes and not financial advice. Recession probabilities are complex and influenced by many factors.
`; downloadPdfButton.style.display = 'inline-block'; resultsSection.scrollIntoView({ behavior: 'smooth' }); }); } function displayMessage(text, type) { messageArea.textContent = text; messageArea.className = type === 'error' ? 'message-error' : 'message-info'; } // PDF Download Functionality if(downloadPdfButton) { downloadPdfButton.addEventListener('click', function () { const pdfExportContent = document.getElementById('pdfExportContent'); if (!pdfExportContent) { displayMessage('Error: PDF content area not found.', 'error'); return; } const originalDisplay = pdfExportContent.style.display; pdfExportContent.style.display = 'block'; html2canvas(pdfExportContent, { scale: 1.5, useCORS: true, logging: false }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const canvasAspectRatio = canvasWidth / canvasHeight; const margin = 15; const pageEffectiveWidth = pdfWidth - 2 * margin; const pageEffectiveHeight = pdfHeight - 2 * margin; let finalImgWidth, finalImgHeight; if ((canvasWidth / pageEffectiveWidth) > (canvasHeight / pageEffectiveHeight)) { finalImgWidth = pageEffectiveWidth; finalImgHeight = finalImgWidth / canvasAspectRatio; } else { finalImgHeight = pageEffectiveHeight; finalImgWidth = finalImgHeight * canvasAspectRatio; } const x = margin + (pageEffectiveWidth - finalImgWidth) / 2; const y = margin; pdf.setFontSize(18); pdf.text("Recession Probability Estimation Report", pdfWidth / 2, margin - 5 , { align: "center" }); pdf.addImage(imgData, 'PNG', x, y + 5, finalImgWidth, finalImgHeight); pdf.save('recession-probability-estimation.pdf'); pdfExportContent.style.display = originalDisplay; }).catch(error => { console.error('Error generating PDF:', error); displayMessage('Failed to generate PDF. See console for details.', 'error'); pdfExportContent.style.display = originalDisplay; }); }); } });