用小时代替日期的时间线图表

Timeline chart with hours instead of date

我想设置一个像这样的时间线图表https://apexcharts.com/javascript-chart-demos/timeline-charts/multi-series/但不是日期作为 x 标签只有几个小时。

我用时间戳定义了我的日期

data: [
        {
          x: 'Maintenance',
          y: [
               1601361625000, // for example 2020-09-29 08:14:32
               1601383225000  // for example 2020-09-29 13:25:01
             ]
         },
         { ... }
]

像这样的 xasis 标签

xaxis: {
                type: 'datetime',
                labels: {
                    formatter: function (value, timestamp) {
                        return moment(timestamp, "hh:mm");
                    },
                }
            }

但我得到的仍然是日期而不是时间。这可能吗?谢谢

事实证明,文档是不正确的,关于 formatter 函数是这样说的:

/**
* Allows users to apply a custom formatter function to xaxis labels.
*
* @param { String } value - The default value generated
* @param { Number } timestamp - In a datetime series, this is the raw timestamp 
* @param { index } index of the tick / currently executing iteration in xaxis labels array
*/

然而事实并非如此,第一个参数是timestamp,第二个是index,没有第三个。所以实际上这个会起作用:

return moment(value).format("HH:mm");