[Vuejs]-How can I display time using ApexCharts?

0👍

You can create your own x-axis labels in the dataset using the chart’s xaxis categories option.

For example:

options: {
  chart: {
    id: 'mychart'
  },
  xaxis: {
    categories: ['8:00','9:00','10:00','11:00','12:00','1:00','2:00','3:00']
  }
}

0👍

Use the formatter on the axis: https://apexcharts.com/docs/options/xaxis/. It isn’t exactly the format you asked for, but will set you in the right direction. There are getMinutes() getSeconds() and GetHours() among other functions that can be used to then construct a format you want.

  xaxis: {
    type: 'datetime',
    labels: {
      formatter: function (val: number) {
        return new Date(val).toLocaleTimeString()
      }
    }
  },

Leave a comment