Chartjs-Chartjs Timestamp to Datetime labels

0👍

You can use the tick callback as described here: https://www.chartjs.org/docs/2.9.4/axes/labelling.html#creating-custom-tick-formats

scales: {
      yAxes: [
        {
          ticks:{
            callback: (val) => (new Date(val)) // or a different way to convert timestamp to date
           },
          display: true,
          scaleLabel: {
            display: true,
          },
        }
      ],
      xAxes: [
        {
          ticks:{
            callback: (val) => (new Date(val)) // or a different way to convert timestamp to date
           }
          display: true,
          scaleLabel: {
            display: false,
            labelString: "Date"
          },
        }
      ]
    }

Leave a comment