I have data for different months as bellow
Jan : [1,5,3]
Feb : [10,5]
Mar : [4,8]
Apr : [7]
May : [3,1,5,0,7]
And I want to generate bar chart as bellow
Right now, I have the following code and I would like to know how can I generate the bar chart as above image.
new Chart(document.getElementById("bar-chart"), {
type: 'bar',
data: {
labels: ['Jan','Feb','Mar','Apr','May'],
datasets: [{
data: [1,5,3],
label: 'Jan',
backgroundColor: "#3e95cd",
}
, {
data: [10,5],
label: 'Feb',
backgroundColor: "#8e5ea2",
}, {
data: [4,8],
label: 'Mar',
backgroundColor: "#4287f5",
}
, {
data: [7],
label: 'Apr',
backgroundColor: "#23ebbc",
}
, {
data: [3,1,5,0,7],
label: 'May',
backgroundColor: "#e63057",
}
]
},
options: {
title: {
display: true,
text: 'This is title'
},
backgroundColor:'#cfcfcf',
scales: {
xAxes: [{ stacked: true }],
yAxes: [{ stacked: true }]
}
}
});
Thank you