Highstock Data Grouping以最后数据时间为索引 [英] Highstock Data Grouping to Use Last Data Time as Index

查看:218
本文介绍了Highstock Data Grouping以最后数据时间为索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Highstock(1.3.1)dataGrouping group通过使用组中第一个数据的日期/时间来索引。



鉴于我们有以下1个分钟OHLC数据时间:


[08:59,09:00,09:01,09:02,09:03 ,09:04,09:05,09:06,09:07,09:08]


目前,如果我们将它分成5分钟... ...


  • 第一组将是 [08:59] 08:55 作为索引

  • 第二组将是 [09:00,09:01,09:02,09:03,09:04] 09:00 作为索引

  • 08] 09:05 作为索引



我想要的是...




  • 第一组应该是 [08:59,09:00] 09:00 strong>作为索引

  • 第二组应该是 [09:01,09:02,9:03,9:04,9:05] 09:05 作为索引

  • 第三组应该是 [09:06,09:07,09:08] 09:10 作为索引



我想我想要的与他们在Google Finance中实施分组的方式相同。 / p>

Highstock目前没有可用的选项来执行此操作。
也许实现这个的唯一方法是修改Highstock库中的几行代码。
但如何?

解决方案

您应该可以通过修改 seriesProto.groupData 函数。有分组和逼近应用。



您也可以更改平滑选项,因此将其设置为true,并且:

  if(dataGroupingOptions.smoothed){
i = groupedXData.length - 1;
groupedXData [i] = xMax;
while(i--& i> 0){
groupedXData [i] + = interval / 2; //删除'/ 2' - >它会创建延迟到最后一点

groupedXData [0] = xMin;
}


In Highstock (1.3.1) dataGrouping a group is indexed by using the date/time of the first data in the group.

Given we have the following 1 minute OHLC data time:

[08:59, 09:00, 09:01, 09:02, 09:03, 09:04, 09:05, 09:06, 09:07, 09:08]

Currently, if we group this into 5 minute...

  • 1st group will be [08:59] with 08:55 as index
  • 2nd group will be [09:00, 09:01, 09:02, 09:03, 09:04] with 09:00 as index
  • 3rd group will be [09:05, 09:06, 09:07, 09:08] with 09:05 as index

What I want is...

  • 1st group should be [08:59, 09:00] with 09:00 as index
  • 2nd group should be [09:01, 09:02, 09:03, 09:04, 09:05] with 09:05 as index
  • 3rd group should be [09:06, 09:07, 09:08] with 09:10 as index

I think what I want is the same with how they implemented grouping in Google Finance.

There is currently no available option in Highstock to do this. Maybe the only way to implement this is to modify a few line of codes in Highstock library. But how?

解决方案

You should be able to change this by modifying seriesProto.groupData function. There is grouping and approximation applied.

Also you can change smoothed option, so set it to true, and:

    if (dataGroupingOptions.smoothed) {
        i = groupedXData.length - 1;
        groupedXData[i] = xMax;
        while (i-- && i > 0) {
            groupedXData[i] += interval / 2; // remove '/2' -> it will create delay to group to last point
        }
        groupedXData[0] = xMin;
    }

这篇关于Highstock Data Grouping以最后数据时间为索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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