0π
β
it is because the y axis start at 5.
let ctx = document.getElementById('myChart2').getContext('2d');
let colorHex = ['#870000', '#000f61', '#004f03'];
var barChartData = {
labels: ['Specialist1', 'Specialist2', 'Specialist3'],
datasets: [{
label: 'Dataset 1',
borderColor: '#FF0000',
borderWidth: 2,
data: [10, 12, 7]
}, {
label: 'Dataset 2',
borderColor: '#00FF00',
borderWidth: 2,
data: [9, 8, 5]
}]
};
let myChart2 = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
responsive: true,
legend: {
position: 'bottom'
},
title: {
display: true,
text: 'Cases Referred vs Cases Solved'
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
})
<div class="chart-wrapper">
<canvas id="myChart2"></canvas>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels"></script>
Source:stackexchange.com