JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
JavaScript
window.onload = function () {
var data=[
{ label: "apple", y: Math.floor(Math.random() * 20)+5 },
{ label: "orange", y: Math.floor((Math.random() * 10) + 1) },
{ label: "banana", y: Math.floor((Math.random() * 50) + 10) },
{ label: "mango", y: Math.floor((Math.random() * 80) + 21) },
{ label: "grape", y: Math.floor((Math.random() * 100) + 1) }
];
var chart = new CanvasJS.Chart("chartContainer", {
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "pie",
indexLabel: "{label}: {y}",
dataPoints: data,
}
]
});
chart.render();
setInterval(function () {
chart.options.data[0].dataPoints[0] = {label: "apple", y: Math.floor(Math.random() * 20) + 5}
chart.render();
}, 3000);
}