Highstocks图表中的相对时间 [英] Relative time in Highstocks chart

查看:69
本文介绍了Highstocks图表中的相对时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Highstocks图表中的x轴上显示相对时间?据我了解,datetime类型仅用于格式化日期,而不以任何方式对其进行编辑.我要显示的数据结构按unix时间戳排序,如下所示,但是可以根据需要进行更改:

How do I show relative time on the x-axis in a Highstocks chart? From my understanding, the datetime type is only used to format dates, not edit them in any way. The data structure that I am trying to display is sorted by unix timestamps and looks like the following, but can be changed if needed:

[
    // [timestamp, value]
    [1416478472, 1],
    [1416478473, 1],
    [1416478474, 0.5],
    [1416478475, 0.25]
    ...
]

我的目标是让x轴使用适当的标签来显示自第一次输入以来经过的时间,例如放大时显示的时间:

My goal is to have the x-axis use appropriate labels that shows time elapsed since the first entry, such as this when zoomed in:

00.05    00.10    00.15    00.20    00.25    // hours.minutes

缩小时为

01.00    02.00    03.00    04.00    05.00    // hours.minutes

换句话说,就像默认行为一样,但是时间是相对的,而不是绝对的.

In other words, just like the default behaviour, but with the time being relative instead of absolute.

推荐答案

1)您需要将时间戳乘以1000,以获得javascript时间戳,而不是UNIX

1) You need to multiply your timestamps by 1000, to have javascript timestamps, instead of UNIX

2)使用 tickPositioner 可以准备自己的功能,该功能可以动态计算报价.

2) Use tickPositioner which allows to prepare own funciton, which calculate ticks dynamically.

这篇关于Highstocks图表中的相对时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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