score:1

Accepted answer

you can add an empty data and field to the dataset or you can use the padding.

extra field:

var options = {
  type: 'bar',
  data: {
    labels: ["", "red", "blue", "yellow", "green", "purple", "orange"],
    datasets: [{
      label: '# of votes',
      data: [null, 12, 19, 3, 5, 2, 3],
      backgroundcolor: 'pink'
    }]
  },
  options: {}
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.5.1/chart.js"></script>
</body>

padding with cros alight start:

var options = {
  type: 'bar',
  data: {
    labels: ["red", "blue", "yellow", "green", "purple", "orange"],
    datasets: [{
      label: '# of votes',
      data: [12, 19, 3, 5, 2, 3],
      backgroundcolor: 'orange'
    }]
  },
  options: {
    scales: {
      y: {
        ticks: {
          padding: 20,
          crossalign: 'start'
        }
      }
    }
  }
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.5.1/chart.js"></script>
</body>


Related Query

More Query from same tag