score:0

i think for your question depends on the value or label you are showing on your chart. for number or string, you can set the min and max on ticks.min and ticks.max and it is working for me in chart.js 2.8. not sure if chart.js 2.5 will work though since i saw some posts about how this feature is enhance in chart.js 2.6 release.

if your x-axis label is showing datetime object, and you are using type: 'time' in your options.scales.xaxes. then you can include your time.min and time.max inside xaxes.

options: {
  scales: {
    xaxes: [
      {
        type: 'time',
        time: {
          displayformats: {
            week: 'd mmm yy'
          },
          unit: 'day',
          tooltipformat: 'll',
          min: moment('2019-06-30'),
          max: moment('2019-09-01')
        },
        display: true,
        ticks: {
          padding: 20,
          // set this min max if you are using number or string as your axis label
          // min: 10,
          // max: 30
        }
      }
    ],
    yaxes: [
      {
        display: true,
        ticks: {
          beginatzero: true,
          maxtickslimit: 8
        }
      }
    ]
  }
};

this is working for me and hopefully it helps you for your use case as well. let me know how it goes. cheers :)


Related Query

More Query from same tag