JSFiddle - React, Tailwind, and code Playground
HTML
<div id="DrugUtilizationChart" style="height:420px;max-height:405px; margin-left:15px; width: 95%;text-align:center;">No data available.</div>
JavaScript
$.getJSON("https://api.myjson.com/bins/iks8t", function(result) {
var dataPlots = [];
if (result && result.length > 0) {
for (var i = 0; i < result.length; i++) {
var Values = result[i];
$.each(Values, function (index, item) {
var plot = {
y: item.TotalCalls,
label: item.MonthLabel,
name: item.ShortAnswer,
displaytext: '<table><tbody><tr><td>Short Answer: </td><td>' + item.ShortAnswer + '</td></tr>'
+ '<tr><td>Total Calls: </td><td>' + item.TotalCalls + '</td></tr>'
+ '<tr><td>Month: </td><td>' + item.MonthLabel + '</td></tr></tbody></table>'
};
if (i == 0) {
dataPlots.push({
type: "stackedColumn",
showInLegend: true,
legendText: "{name}",
indexLabelFontFamily: 'Helvetica',
indexLabelFontSize: 14,
toolTipContent: "{displaytext}",
dataPoints: [plot],
click: function (e) {
}
});
} else {
dataPlots[index].dataPoints.push(plot);
}
});
}
CanvasJS.addColorSet("colorShades",
[
"#F15A26",
"#597FAD",
"#7B858F",
...