Skip to content
function drawSipDonut() {
var invested = getNumber("fieldname5"); // Invested Amount
var future = getNumber("fieldname6"); // Future Value
var growth = future - invested;
if (invested <= 0 || growth <= 0) return;
var canvas = document.getElementById("sipDonutChart");
if (!canvas) return;
if (window.sipChart) window.sipChart.destroy();
window.sipChart = new Chart(canvas, {
type: "doughnut",
data: {
labels: ["Invested Amount", "Growth"],
datasets: [{
data: [invested, growth],
backgroundColor: ["#2563eb", "#16a34a"],
borderWidth: 0
}]
},
options: {
cutout: "65%",
responsive: true,
plugins: {
legend: { position: "bottom" }
}
}
});
}
setTimeout(drawSipDonut, 1200);
document.addEventListener("input", function () {
setTimeout(drawSipDonut, 400);
});
});