[Chartjs]-Add different labels in a line chart – Chart.js

2👍

You can provide data as a list of x,y:

datasets: [{ 
        data: [{y:88,x:`${timestamp of 9:00}` },...],
        ...
    }, { 
        data: [{y:87, x:`${timestamp of 9:03}`},...],
        ...
    }]

like here https://www.chartjs.org/docs/latest/charts/line.html#point

And then in options define how to display the x value (timestamp) as hour:minutes

{
   scales: {
      xAxes: [{
         ticks: {
            callback = (label, index, labels) => {
               return moment.unix(label).format('HH:mm');
            }
         }
      }]
   }
}

Leave a comment