Property Value Comparison
`;
downloadBtn.classList.remove('hidden');
const ctx = document.getElementById('valueChart')?.getContext('2d');
if(ctx) {
if (valueChart) valueChart.destroy();
valueChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Scenario A', 'Scenario B'],
datasets: [{
label: 'Estimated Property Value',
data: [results.scenarioA.estimatedValue, results.scenarioB.estimatedValue],
backgroundColor: ['#4338ca', '#16a34a'],
borderRadius: 4,
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: { y: { beginAtZero: true, ticks: { callback: value => formatCurrency(value) } } }
}
});
}
}
function downloadPDF() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const contentToPrint = document.getElementById('dashboard-content');
if (!contentToPrint) return;
html2canvas(contentToPrint, {
scale: 2,
useCORS: true,
onclone: (doc) => {
const chartCanvas = doc.getElementById('valueChart');
if (chartCanvas && valueChart) {
const img = new Image();
img.src = valueChart.toBase64Image();
img.style.maxWidth = '100%';
img.style.height = 'auto';
chartCanvas.parentNode.replaceChild(img, chartCanvas);
}
}
}).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (canvas.height * pdfWidth) / canvas.width;
pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth - 20, pdfHeight > 277 ? 277 : pdfHeight - 20);
pdf.save('Rent-Scenario-Analysis.pdf');
});
}