[Chartjs]-Minimum value for x Axis doesn't work for horizontal bar chart | ChartJS

1๐Ÿ‘

I believe that this is a bug with the current Chart.js version.

As a workaround you could use a callback at the tick of you xAxes like this:

options: {
    scales: {
        xAxes: [{
            stacked: true,
            ticks: {
                min: 0,
                callback: function(value, index, values) {
                    return value + 7;
                }
            }
        }],
    ...

For more details on callbacks have a look at the documentation.

1๐Ÿ‘

options: {
  scales: {
      xAxes: [{
          display: true,
          ticks: {
              suggestedMin: 7
          }
      }]
  }
}

1๐Ÿ‘

This will work for both Vertical and Horizontal

options:{
  scales: {
    xAxes: [{
      ticks: {
          suggestedMin: 0,
          suggestedMax: 100
      }
    }],
    yAxes: [{
      ticks: {
          suggestedMin: 0,
          suggestedMax: 100
      }
    }],
  },
}

Leave a comment