[Chartjs]-Custom labeling/fixed range on x-axis in Chart.js for horizontal bar chart?

0👍

ReAd ThE DoCuMEnTaTIoN

https://www.chartjs.org/docs/latest/axes/cartesian/linear.html

options: {
indexAxis: 'x',
  title: {
    display: false,
    text: 'Average SAT Score'
  },
  legend: {
    display: true
  },
   tooltips: {
    enabled: false
  },
  scales: {
        xAxes: [{
            ticks: {
                suggestedMin: 800,
                suggestedMax: 1600
            }
        }]
    }
}

0👍

This is what worked for me

options: {
    scales: {
        x: {
            min: 0,
            max: 100,
            display: false,
        },
    }
}

Display equals to false was set since if not it appears another scale bar below the one I had chosen for my data.
According to the docs:

min: User defined minimum number for the scale, overrides minimum value from data.

max: User defined maximum number for the scale, overrides maximum value from data.

Leave a comment