Chartjs-How to show only each 15th x-labels in line chart chart.js in angular 6?

1đź‘Ť

You can define a userCallback function for the scales.xAxes option…

   xAxes: [{
        ticks: {
            userCallback: function(item, index) {
              if (index===0) return item;
              if (((index+1)%15)===0) return item;
            },
            autoSkip: false
        },
        gridLines: {
          display: false
        }
   }]...

To hide the “legend” (not “legends”), use:

legend: {
    display: false
}

Demo: https://www.codeply.com/go/5QI8eVTPnY

Similar: Show only nth tick LINE on x-axis for Chart.js diagram

Leave a comment