How to Limit the Number of Labels on a Chart.js Line Chart
I am looking for a way to decrease the number of labels on my line chart only when it is viewed on a small device. The solution provided in the previous post suggests using the following code:
xAxes: [{
type: 'time',
ticks: {
autoSkip: true,
maxTicksLimit: 12
}
}]
While this solution works well, I would like to maintain all 24 labels when viewing the chart on a desktop screen (lg)
. However, I want to hide half of the labels when the chart is displayed on a smartphone (xs)
.
This is how my chart currently looks on both desktop and smartphone: https://i.sstatic.net/9kH4c.png