[Chartjs]-Trouble with graphing a function with chartjs

1๐Ÿ‘

โœ…

By default, for line chart, the X axis is a "category" axis therefore is expecting labels as strings. And the strings representations of the numbers are the values you are setting.

Change the X axis configuration as following which should fix it:

  scales: {
    y: {
      beginAtZero: true,
    },
    x:{
      type: 'linear', // <-- add this one
      beginAtZero : true, // <-- axis option, not ticks one
      ticks:{
        //maxTicksLimit : 1
      }
    }
  }

Be also aware that beginAtZero option is an axis option and not a ticks one therefore you should move it at upper level.

Leave a comment