Highstock Data Grouping to Use Last Data Time as Index

只谈情不闲聊 提交于 2019-12-12 02:52:41

问题


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?


回答1:


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;
    }


来源:https://stackoverflow.com/questions/18754526/highstock-data-grouping-to-use-last-data-time-as-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!