Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart.js horizontal bar width

I have the following bar chart:

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?

like image 928
Marc Rasmussen Avatar asked Jan 11 '17 16:01

Marc Rasmussen


1 Answers

Simply increase the canvas height. For Example;

<canvas id="horizontalbar" height="1000px"></canvas>

like image 78
jaykwapong Avatar answered Oct 06 '22 19:10

jaykwapong