HighStock如果时间惰性缺失显示红线或空白空间? [英] HighStock if time inertval missing shows red line or blank space?

查看:84
本文介绍了HighStock如果时间惰性缺失显示红线或空白空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我使用高股价图表以时间序列格式显示数据。我每5分钟收到一次数据,因为X轴我设置了每5分钟收到的时间戳。但如果一些数据不是来自5分钟,那么我想在红色空白下显示该行,我尝试过



)。



对于选项1(红色线条),您需要创建一个新的系列,其中包含前一个点和下一个围绕无数据点的点,并将其系列颜色设置为红色。这里的缺点是,如果你有很多数据缺口的情况,你将会创建许多2点系列。要添加的示例系列为:

  {
颜色:'red',
showInLegend:false ,
data:[
[1415787839488,0.5590000152587891],
[1415788494848,0.5139999985694885]
]
}
pre>

以及小提琴的示例。


Hi I used high stock chart for showing data in time series format. I received data every 5 minutes, for X-axis I set timestamp which I received on every 5 minutes. but in case some data not coming from 5 minutes then I want to display that line in red or blank below I tried

JsFiddle link

In this demo data come at 10:25 and after 10:35 so in between I want to shows red line or blank space. Following images shows expected output

Or

解决方案

I think the issue here is how is highcharts supposed to know that there is no data at 10:30? Your data timestamp intervals are not identical (meaning they don't occur every 5 minutes).

What you could do is put a watcher function in place that gets the data first. Inside of this put a timer that if 5 minutes go by without any data being retrieved, send out a data point like [<the time stamp>, null]. Now, you will also need to a property to not link null points called connectNulls. This is false by default so your 2nd option above is satisfied (see this fiddle).

For option 1 (the red line) you would need to create a new series containing the previous point and the next point surrounding your no-data point and set its series color to red. The drawback here is that if you have many cases with data gaps you will be creating many 2 point series. An example series to add would be:

{
    color: 'red',
    showInLegend: false,
    data: [
    [1415787839488, 0.5590000152587891],
    [1415788494848, 0.5139999985694885]
        ]
}

And an example fiddle.

这篇关于HighStock如果时间惰性缺失显示红线或空白空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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