AI-Powered On-Chain Data Analysis Dashboard

AI-Powered On-Chain Data Analysis Dashboard

Select parameters to view simulated AI-driven on-chain insights.

Generated: ${new Date().toLocaleString()}

Dashboard: ${blockchain} - ${dataCategory} (${timePeriod})

${specificAddress ? `

Target: ${specificAddress}

` : ''}
${metricsHtml}

Simulated Trend Visualizations

${chartsHtml}

AI-Generated Insights & Outlook

${data.insights}

Potential Risks/Opportunities:

${data.riskOpportunity}

Disclaimer: This dashboard uses simulated data and AI-generated insights for illustrative purposes only. It does not constitute financial advice. On-chain data analysis is complex; conduct thorough research.

`; dashboardArea.style.display = 'block'; dashboardArea.scrollIntoView({ behavior: 'smooth' }); } async function generateDashboardPdf() { const pdfContent = document.getElementById('pdf-content'); const downloadBtn = event.target; if (!pdfContent) { console.error("PDF content area not found."); if(typeof alert === 'function') alert("Error: Could not find content to generate PDF."); return; } if (!html2canvas || !jsPDF) { console.error("html2canvas or jsPDF library not found."); if(typeof alert === 'function') alert("Error: PDF generation library not loaded."); return; } const originalButtonText = downloadBtn.textContent; downloadBtn.textContent = "Generating..."; downloadBtn.disabled = true; const pdfHeaderElement = pdfContent.querySelector('.pdf-header'); const screenHeaderElements = pdfContent.querySelectorAll('.screen-only'); if (pdfHeaderElement) pdfHeaderElement.style.display = 'block'; screenHeaderElements.forEach(el => el.style.display = 'none'); try { const canvas = await html2canvas(pdfContent, { scale: 1.5, useCORS: true, logging: false, backgroundColor: '#0b1120', // Ensure background for PDF matches theme if needed onclone: (doc) => { const clonedHeader = doc.querySelector('.pdf-header'); if (clonedHeader) clonedHeader.style.display = 'block'; doc.querySelectorAll('.screen-only').forEach(el => el.style.display = 'none'); } }); if (pdfHeaderElement) pdfHeaderElement.style.display = 'none'; screenHeaderElements.forEach(el => el.style.display = 'block'); const imgData = canvas.toDataURL('image/jpeg', 0.8); const pdf = new jsPDF({ orientation: 'p', // Portrait unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const margin = 10; const contentWidth = pdfWidth - 2 * margin; let contentHeight = (imgProps.height * contentWidth) / imgProps.width; let currentPosition = margin; if (contentHeight <= pdfHeight - 2 * margin) { pdf.addImage(imgData, 'JPEG', margin, currentPosition, contentWidth, contentHeight); } else { let remainingImgHeight = imgProps.height; let sourceY = 0; const sourceWidth = imgProps.width; const pageCanvasHeight = ((pdfHeight - 2 * margin) / contentWidth) * sourceWidth; while (remainingImgHeight > 0) { const currentChunkHeight = Math.min(remainingImgHeight, pageCanvasHeight); const tempCanvas = document.createElement('canvas'); tempCanvas.width = sourceWidth; tempCanvas.height = currentChunkHeight; const tempCtx = tempCanvas.getContext('2d'); tempCtx.drawImage(canvas, 0, sourceY, sourceWidth, currentChunkHeight, 0, 0, sourceWidth, currentChunkHeight); const chunkImgData = tempCanvas.toDataURL('image/jpeg', 0.8); const chunkDisplayHeight = (currentChunkHeight * contentWidth) / sourceWidth; pdf.addImage(chunkImgData, 'JPEG', margin, currentPosition, contentWidth, chunkDisplayHeight); remainingImgHeight -= currentChunkHeight; sourceY += currentChunkHeight; if (remainingImgHeight > 0) { pdf.addPage(); currentPosition = margin; } } } const blockchain = document.getElementById('blockchain').value; const category = document.getElementById('dataCategory').value; pdf.save(`AI_OnChain_Dashboard_${blockchain}_${category}.pdf`); } catch (error) { console.error("Error generating PDF:", error); if(typeof alert === 'function') alert("An error occurred while generating the PDF: " + error.message); } finally { downloadBtn.textContent = originalButtonText; downloadBtn.disabled = false; if (pdfHeaderElement) pdfHeaderElement.style.display = 'none'; screenHeaderElements.forEach(el => el.style.display = 'block'); } }
Scroll to Top