chartjs-bar-stacked-issue
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<main>
<canvas id="chart"></canvas>
</main>
CSS
main {
max-width: 600px;
border: 1px solid red;
}
JavaScript
new Chart('chart', {
type: 'bar',
data: {
datasets: [{
"label": "facebook",
backgroundColor: "#3b5998",
"data": [{
"x": "2019-01-21",
"y": "3"
}, {
"x": "2019-01-28",
"y": "1"
}, {
"x": "2019-02-04",
"y": "4"
}, {
"x": "2019-02-11",
"y": "3"
}, {
"x": "2019-02-18",
"y": "4"
}, {
"x": "2019-02-25",
"y": "1"
}]
},
{
"label": "instagram",
backgroundColor: "#fb3958",
"data": [{
"x": "2019-01-28",
"y": "2"
}, {
"x": "2019-02-04",
"y": "3"
}, {
"x": "2019-02-11",
"y": "6"
}, {
"x": "2019-02-18",
"y": "5"
}, {
"x": "2019-02-25",
"y": "1"
}]
},
{
"label": "twitter",
backgroundColor: "#0084b4",
"data": [{
"x": "2019-01-21",
"y": "2"
}, {
"x": "2019-01-28",
"y": "1"
}, {
"x": "2019-02-04",
"y": "4"
}, {
"x": "2019-02-11",
"y": "5"
}, {
"x": "2019-02-18",
"y": "5"
}]
}
]
},
options: {
legend: {
display: false
},
scales: {
xAxes: [{
stacked: true,
gridLines: {
display: false
},
type: 'time'
}],
yAxes: [{
stacked: true,
gridLines: {
display: false
},
}]
}
}
});