[Chartjs]-Display a limited number of labels only on X-Axis of Line Chart using Chart.js

15👍

This worked perfectly.

xAxes:[{
    ticks:{
        display: true,
        autoSkip: true,
        maxTicksLimit: 4
    }
}]

0👍

Above Char.js Version 4.21

xAxes was changed to x and array format was changed to object format

Example:

  scales: {
    x: {
      ticks: {
        display: true,
        autoSkip: true,
        maxTicksLimit: 15,
      },
    },
  },

Source: https://www.chartjs.org/docs/latest/axes/cartesian/linear.html#common-tick-options-to-all-cartesian-axes

Leave a comment