Plotly.js 为类型设置时区:"date"

Plotly.js setting timezone for type:"date"

我正在制作图表以显示一段时间内的状态。所有数据均采用 unix 格式。我使用 javascript (new Date(data)).toUTCString 在标题中显示数据。这与图表使用的数据相同,但图表提前 运行 1 小时。 Image

这是我的布局配置:

layout = {
    "showlegend": true,
    "title": new Date(min).toUTCString() + " to " + new Date(max).toUTCString(),
    "xaxis": {
        "autorange": true,
        "range": [
            min,
            max
        ],
        "title": "Time",
        "type": "date"    //if I change this to scatter, I get the unix values
    }

}
 Plotly.newPlot('graphMain', temp, layout); //temp contains the arrays

我目前居住在奥地利 (UTC+01:00)。 有人对此有想法吗?

剧情doesn't currently support timezones.

如果您需要将日期时间预先计算为本地时区或 UTC,您可能需要使用类似 moment.js timezone 的方法。或者,如果您愿意,也可以手动完成。