JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="pieGraph" style="height: 300px; width: 100%;"></div>
JavaScript
var dataPoints = [];
var pieGraph = new CanvasJS.Chart("pieGraph",{
animationEnabled: true,
title:{
text:"Pie Graph"
},
data: [{
type: "pie",
dataPoints : dataPoints,
}]
});
function addData(data) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
var val = data[key];
pieGraph.options.data[0].dataPoints.push({y: val, label: key})
}
}
pieGraph.render();
}
$.getJSON("https://api.npoint.io/0ec43c8bb89c10794571", addData);