[Chartjs]-Display only certain labels with chart.js

1👍

If i understand correct, you want to show only 5 labels in your x-axis (1, 2, 3 ,4, second). Try this one:

var options =  {  
         scales: {
            xAxes: [{
                afterTickToLabelConversion: function(data){


                    var xLabels = data.ticks;

                    xLabels.forEach(function (labels, i) {
                        if (i % 1000 != 0){
                            xLabels[i] = '';
                        }
                    });
                } 
            }]   
        }
}

Leave a comment