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 drawBarChart() {
console.log(jdata)
var opts = {
chart: {
heading: "Barseries",
chartIndex: 2,
//width: 800,
height: 270,
margin: {
top: 40,
right: 15,
bottom: 50,
left: 15
},
chartResize: true,
chartType: "barseries"
},
data: jdata,
xAxis: {
bottom: {
rotateText: "slant",
scalePadding: 0.3,
scaleType: "scaleBand",
textLimit: 10,
tickNumber: 5,
unit: "Names"
}
},
yAxis: {
left: {
unit: 'Count',
tickNumber: 5,
}
},
zoom: {
visible: false
},
series: {
bar: [{
barOrderMembers: [{
color: "#1d8378",
name: "Count"
}, {
color: "#cbffea",
name: "Count 2"
}],
name: "Bar_Chart",
plotAxis: ["left", "bottom"],
events: {
click: function(dtArr, dtPos) {
console.log(dtArr, dtPos)
}
}
}],
stack: []
}
};
// myChart = vc.plotChart('#container3', opts)
myChart = vc.plotChart('#container', opts)
}
const jdata = {
"barseries": {
"columns": [
"Names",
"Count",
"Count 2"
],
"values": [
[
"Series A",
250,
350
],
[
"Series B",
150,
250
],
[
"Series C",
357,
450
],
[
"Series D",
410,
250
],
[
"Series E",
250,
350
]
]
}
}
drawBarChart()