Chartjs-Chart.js timeseries x ticks overlapping due to weekend

0👍

You can achieve what you’re looking for by writing a callback function that checks if the value is a weekend day

new Date(Date.parse(value)).getDay() == 1 || new Date(Date.parse(value)).getDay() == 2

If it is we just don’t return it. Otherwise we return the value without changes.
This is how your config should look like:

x:{
   type: 'timeseries'
   time:{
         unit:'day',
   },
   ticks:{
        callback: function(value){
            //if weekend dont return the tick label
            if(new Date(Date.parse(value)).getDay() == 1 || new Date(Date.parse(value)).getDay() == 2 )
                return
            return value
        }
   }
}

Leave a comment