SIP calculator in javascript by Editorial Staff Output View Horizontal Vertical HTML CSS JS Tidy SIP Calculator with Bar Graph Monthly Investment Amount: Expected Annual Return (%): Investment Tenure (years): Calculate Result: Total Investment: Total Gain: Total Returns: HTML CSS JS Tidy .container { max-width: 400px; margin: 50px auto; text-align: center; } input, button { display: block; margin: 10px auto; padding: 10px; width: 80%; } button { background-color: #007bff; color: white; border: none; cursor: pointer; } button:hover { background-color: #0056b3; } canvas { margin-top: 20px; } HTML CSS JS Tidy function calculateSIP() { const investmentAmount = parseFloat(document.getElementById('investmentAmount').value); const interestRate = parseFloat(document.getElementById('interestRate').value); const tenure = parseFloat(document.getElementById('tenure').value); if (isNaN(investmentAmount) || isNaN(interestRate) || isNaN(tenure)) { alert('Please fill in all fields with valid numbers.'); return; } const monthlyRate = interestRate / 12 / 100; const totalMonths = tenure * 12; let totalInvestment = 0; let estimatedReturns = 0; let investmentData = []; let returnsData = []; let labels = []; for (let year = 1; year <= tenure; year++) { for (let month = 1; month <= 12; month++) { totalInvestment += investmentAmount; estimatedReturns = (estimatedReturns + investmentAmount) * (1 + monthlyRate); } investmentData.push(totalInvestment); returnsData.push(estimatedReturns-totalInvestment); labels.push(`Year ${year}`); } document.getElementById('totalInvestment').textContent = totalInvestment.toFixed(2); document.getElementById('totalGain').textContent = (estimatedReturns-totalInvestment).toFixed(2); document.getElementById('estimatedReturns').textContent = estimatedReturns.toFixed(2); document.getElementById('result').style.display = 'block'; const ctx = document.getElementById('sipChart').getContext('2d'); new Chart(ctx, { type: 'bar', data: { labels: labels, datasets: [ { label: 'Total Investment', data: investmentData, backgroundColor: 'rgba(0, 123, 255, 0.6)', borderColor: 'rgba(0, 123, 255, 1)', borderWidth: 1 }, { label: 'Total Gains', data: returnsData, backgroundColor: 'rgba(40, 167, 69, 0.6)', borderColor: 'rgba(40, 167, 69, 1)', borderWidth: 1 } ] }, options: { responsive: true, scales: { x: { stacked: true, title: { display: true, text: 'Year' } }, y: { stacked: true, title: { display: true, text: 'Amount' }, beginAtZero: true } } } }); } >_Console Clear Console >_Console File Setting HTML Code Playground Setting Title Description SIP calculator in javascript with BarGraph Catagory Javascript Tags Resource Add External Stylesheets and Script