Chartjs-How to make ticks evenly spaced with Chart.js

1👍

Use “stepSize” to configure the ticks like this:

var ctx = document.getElementById('chartBarChart1').getContext('2d');

var myChart = new Chart(ctx, {
  type: 'horizontalBar',
  data: {
    labels: ['CI'],
    datasets: [{
      label: 'CI',
      data: [45],
      backgroundColor: 'Red'
    }]
  },
  options: {
    scales: {
      xAxes: [{
        ticks: {
          max: 70,
          beginAtZero: true,
          stepSize: 10
        }
      }]
    },
  },
});

https://jsfiddle.net/hdahle/zxdjqo82/

Leave a comment