[Chartjs]-Charts.js Dynamic Ticks

1👍

If I understand your question correctly, you will need to add ticks under scales and in you case xAxes. In ticks you can specify the step size. The step size is how much it increments each time. In the step size you can make a call to a function that determines the step size you need. So you could make a function called calcualteStepSize and pass in the dates if it is over over 2 months then return a step size of 1. Below is just some pseudocode

ticks: {
        stepSize: calcualteStepSize(data)
       }

function calcualteStepSize(data) {
  if data range is greater than 2 months
    return 1 
  else return some other calculation
}

Leave a comment