I have the following bar chart:
The above chart is generated with the following code:
var myChart = new Chart(ctx, {
type: 'horizontalBar',
data: {
labels: labels,
datasets: [{
label: '# of Votes',
data: data,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
]
}]
},
options: {
responsive: true,
scales: {
yAxes: [{
borderWidth: 40,
ticks: {
beginAtZero:true
}
}]
}
}
});
As you can see, the bar width is fairly small.
My question is, how can I increase the width of each bar?
Simply increase the canvas height. For Example;
<canvas id="horizontalbar" height="1000px"></canvas>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With