11👍
✅
This can be achieved using afterFit callback function of y-axis :
scales: {
yAxes: [{
afterFit: function(scale) {
scale.width = 80 //<-- set value as you wish
},
...
}]
}
ɪɴ ᴀᴄᴛɪᴏɴ
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar'],
datasets: [{
label: 'LINE',
data: [3, 2, 4],
backgroundColor: 'rgba(0, 119, 290, 0.2)',
borderColor: 'rgba(0, 119, 290, 0.6)'
}]
},
options: {
responsive: false,
scales: {
yAxes: [{
afterFit: function(scale) {
scale.width = 80 //<-- set value as you wish
},
scaleLabel: {
display: true,
labelString: 'y-axis label',
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="ctx" height="180"></canvas>
Source:stackexchange.com