amCharts dateFormatter.inputDateFormat 没有正确读取 Unix AKA 纪元时间戳

amCharts dateFormatter.inputDateFormat not reading Unix AKA Epoch timestamps Correctly

我需要为我的 amChart 源 (1608713282) 使用 Unix 时间应该是 12/23/20 04:30:00,但是它似乎正在读取它作为 01/19/70 00:00:00工具提示。

我尝试使用以下代码行在图表和我的 dateAxis 上正确设置格式...

chart.dateFormatter.inputDateFormat = 'x';
chart.dataSource.parser.options.dateFormat = 'x';
chart.dateFormatter.utc = true;

dateAxis.dateFormatter.inputDateFormat = 'x';
dateAxis.dataSource.parser.options.dateFormat = 'x';
dateAxis.dateFormatter.utc = true;

这是与我的 dateAxis 相关的代码:

// TimeStamp Axes
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.renderer.grid.template.location = 0;
dateAxis.renderer.minGridDistance = 100;
dateAxis.tooltipDateFormat = 'MM/dd/yy H:mm:ss';

我通过一些调试发现有趣的是,将我的 JSON 源中的时间戳值用引号括起来会将显示日期从 01/19/70 00:00:00 更改为 11/16/13 23:59:58,不同但仍然不正确。

这是我的数据示例:

{
    "tstamp": 1608697800,
    "vol": 144,
    "staff": 61,
    "avail": 0
}

'x' 格式以 毫秒 per the docs 为单位查找 Unix 时间戳。您在几秒钟内提供值,这将无法正确解析。