Plotly.js将时区设置为类型:"date" [英] Plotly.js setting timezone for type:"date"

查看:217
本文介绍了Plotly.js将时区设置为类型:"date"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a graph to display a status over time. All the data is in unix formatting. I display the data in my title using javascript (new Date(data)).toUTCString. This is the same data used for the graph but the graph is running 1 hour early. 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). 有人对此有想法吗?

I'm currently residing in Austria (UTC+01:00). Anyone have an idea for this?

推荐答案

密谋 doesn当前不支持时区.

如果您需要将日期时间预先计算为本地时区,则可能要使用 moment.js时区之类的方法.到UTC.或者,您也可以根据需要手动进行操作.

You might want to use something like moment.js timezone if you need to precompute datetime to a local timezone or to UTC. Or you can do it manually if you like.

这篇关于Plotly.js将时区设置为类型:"date"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆