New Home Warranty Cost Estimator

New Home Warranty Cost Estimator

Enter your new home details to see the estimated warranty cost.

$${results.total.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}

`; // Chart html += `
`; html += `
`; outputDiv.innerHTML = html; // Prepare data for the chart, filtering out zero-cost components const chartLabels = []; const chartData = []; if (results.breakdown.workmanship > 0) { chartLabels.push('Workmanship'); chartData.push(results.breakdown.workmanship); } if (results.breakdown.systems > 0) { chartLabels.push('Systems'); chartData.push(results.breakdown.systems); } if (results.breakdown.structural > 0) { chartLabels.push('Structural'); chartData.push(results.breakdown.structural); } // Render Chart const ctx = document.getElementById('costChart').getContext('2d'); new Chart(ctx, { type: 'pie', data: { labels: chartLabels, datasets: [{ data: chartData, backgroundColor: ['#93C5FD', '#60A5FA', '#3B82F6'], }] }, options: { responsive: true, plugins: { legend: { position: 'top' }, title: { display: true, text: 'Cost Breakdown by Coverage Type' } } } }); } // --- PDF Download --- function downloadPDF() { const { jsPDF } = window.jspdf; const loader = document.getElementById('loader'); loader.style.display = 'block'; const content = document.getElementById('pdf-content'); html2canvas(content, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgWidth = pdfWidth - 20; const imgHeight = canvas.height * imgWidth / canvas.width; let heightLeft = imgHeight; let position = 10; pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdf.internal.pageSize.getHeight() - 20); while (heightLeft > 0) { position = heightLeft - imgHeight + 10; pdf.addPage(); pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= (pdf.internal.pageSize.getHeight() - 20); } pdf.save('New_Home_Warranty_Estimate.pdf'); loader.style.display = 'none'; }); }
Scroll to Top