JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawcdn.githack.com/skkart/vector-charts/88481d34f304f2c166200bf8935c96ff5e0614b1/dist/vector-charts.min.js"></script>
<link rel="stylesheet" href="https://rawcdn.githack.com/skkart/vector-charts/88481d34f304f2c166200bf8935c96ff5e0614b1/dist/vector-charts.css">
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="shortcut icon" href="#">
<body>
<h1 style="padding-bottom:10px;"> </h1>
<br /><br />
<div id="container" style="width: 90%;"><svg>
</svg></div>
<br /><br />
<br /><br />
</body>
JavaScript
function drawPieChart() {
console.log(jdata)
var opts = {
chart: {
heading: "Pieseries",
chartIndex: 2,
//width: 800,
height: 270,
margin: {
top: 40,
right: 15,
bottom: 50,
left: 15
},
chartResize: true,
chartType: "pieseries"
},
data: jdata,
series: {
pie: {
name: 'PieChart', // Name taken from timeseries.columns
visible: true,
unit: 'Count',
donutPercent: 40 // Add donut % to show donut
}
}
};
myChart = vc.plotChart('#container', opts)
}
const jdata = {
"pieseries": {
"values": [{
"color": "#339966",
"id": 737,
"name": "Slice 1",
"value": 500
}, {
"color": "#FFCC33",
"id": 3737,
"name": "Slice 2",
"value": 200
}, {
"color": "#33CCFF",
"id": 3773,
"name": "Slice 3",
"value": 600
}, {
"color": "#8866CC",
"id": 37037,
"name": "Slice 4",
"value": 800
}, {
"color": "#F47F72",
"id": 7737,
"name": "Slice 5",
"value": 300
}, {
"color": "#B4D56C",
"id": 37,
"name": "Slice 6",
"value": 100
}]
}
}
drawPieChart()