2๐
โ
I might be misunderstanding what you are trying to do, but it is possible to create a stacked bar chart with an un-stacked line chart combo on the same axis.
Here is an example configuration showing how do to it.
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
type: 'line',
label: 'Dataset 1',
borderColor: window.chartColors.blue,
borderWidth: 2,
fill: false,
data: [5, 3, 4, 10, 8, 9, 2]
}, {
type: 'bar',
label: 'Dataset 2',
backgroundColor: window.chartColors.red,
stack: 'Stack 0',
data: [2, 4, 1, 3, 7, 3, 6],
borderColor: 'white',
borderWidth: 2
}, {
type: 'bar',
label: 'Dataset 3',
backgroundColor: window.chartColors.green,
stack: 'Stack 0',
data: [7, 2, 4, 5, 6, 4, 2]
}]
},
options: {
responsive: true,
title: {
display: true,
text: 'Chart.js Stacked Bar and Unstacked Line Combo Chart'
},
tooltips: {
mode: 'index',
intersect: true
},
scales: {
xAxes: [{
stacked: true,
}]
}
}
});
Here is a working codepen example as well.
Source:stackexchange.com