JSFiddle - React, Tailwind, and code Playground
by mujahid_102
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="div1" align="right" style="width: 90%; height:400px; margin-top:20px;">
</div>
<div id="div2" align="right" style="width: 90%; height:400px; margin-top:20px;">
</div>
JavaScript
var chart = new CanvasJS.Chart("div1",
{
theme: "theme3",
animationEnabled: false,
title:{
text: chartTitle,
fontSize: 20
},
toolTip: {
shared: true
},
axisY: {
title: "Scale",
labelFontSize: 12,
labelWrap: true,
labelMaxWidth:200,
interval: 1,
maximum: 5,
margin: 20
},
axisY2: {
title: "Scale",
interval: 1,
maximum: 5
},
axisX: {
labelFontSize: 12,
labelFontColor: "black",
interval:1,
labelWrap: true,
labelMaxWidth: 200,
margin: 20
},
data: [
{
type: "bar",
bevelEnabled: false,
dataPointWidth: 150,
lineThickness: 150,
name: "Self",
legendText: "Individual",
showInLegend: true,
indexLabel: "{y}",
dataPoints:[
{ label: "This is a Lable 1", y: 5},
{ label: "This is a Lable 2", y: 4},
]
},
{
type: "bar",
bevelEnabled: false,
dataPointWidth: 20,
name: "Supervisor",
legendText: "Reporting Supervisor",
axisYType: "secondary",
showInLegend: true,
indexLabel: "{y}",
dataPoints:[
{ label: "This is a Lable 1", y:3},
{ label: "This is a Lable 2", y: 4},
]
}
],
legend:{
cursor:"pointer",
itemclick: function(e){
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
//chart.render();
}
},
});
chart.render();