How to make integer scale in Chartjs

前端 未结 1 1191
暗喜
暗喜 2020-12-20 13:04

I\'m trying to make a horizontal bar chart with an integer scale. As suggested in this question, I\'ve tried to set scaleOverride, scaleSteps etc,

相关标签:
1条回答
  • 2020-12-20 13:26

    The linked question is for Chart.js version 1.x. For the new version you need to use the ticks option. See http://www.chartjs.org/docs/#scales

       ...
       xAxes: [{
          ticks: {
            min: 0,
            stepSize: 1,
            max: 4
          },
          ...
    

    Fiddle - https://jsfiddle.net/jkufz1b9/

    0 讨论(0)
提交回复
热议问题