score:0

the bar width is influenced through the options barpercentage and categorypercentage, which both need to be defined on the dataset.

to find out about the relationship between barpercentage and categorypercentage, see here.

in case you simply want to see the existing bars closer to each other, you need to change the height of the chart. this can be done directly on the canvas as follows:

<canvas id="canvas" height="40"></canvas>

please have a look at the following code snippet.

new chart(document.getelementbyid('canvas'), {
  type: 'horizontalbar',
  data: {
    labels: ['a', 'b'],
    datasets: [{
      label: 'data',
      data: [15, 8],
      backgroundcolor: 'rgba(0, 0, 255, 0.2)',
      bordercolor: 'rgb(0, 0, 255)',
      borderwidth: 1
    }]
  },
  options: {
    responsive: true,
    legend: {
      display: false
    },
    title: {
      display: false
    },
    scales: {
      xaxes: [{
        ticks: {
          beginatzero: true
        }
      }]
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.3/chart.min.js"></script>
<canvas id="canvas" height="40"></canvas>


Related Query

More Query from same tag