Allow irregular time series to skip nights and weekends
It should be possible to remove sufficiently long empty time spans, such as nights and weekends, from the datetime xAxis. This is currently possible by using the "ordinal" feature, but in that case you need to have an evenly spaced time series (for example, sampled every minute or every hour).
Skipping empty time should also be possible for an arbitrarily timestamped time series. A simple way to implement this would be to set a time threshold. If this threshold is exceeded with no new points, the axis is cut and resumed from the next data point.
This, along with other suggestions, is discussed in this forum thread:
Completed as of Highstock 2.1. See http://www.highcharts.com/stock/demo/intraday-breaks
-
djh commented
That's great news! Can breaks be added dynamically?
-
David Kinnvall commented
This is indeed painful.
In the real world, with real stock data from real stock markets, separate sets of data are in general *not* evenly spaced in time. They might be so for quite a lot of points, but sooner or later given enough data, gaps and other irregularities inevitably arise.
I am currently struggling with exactly this issue, while evaluating Highstock as a replacement for our current Flash-based solution for stock charts.
I'm using an ordinal xAxis, in order to properly skip nights and weekends where there is *no* data in *any* dataset, by definition.
But the ordinal xAxis does *not* handle multiple datasets which are not strictly aligned (they have different number of points, as well as short gaps in different places) and the rendering thus breaks in several interesting ways, including a common grouped tooltip not having values for each dataset in each point and flickering wildly while hovering the chart, as well as the xAxis being confused as to where to place ticks over time. More things break, but these are very obvious to the viewer right off the bat.
The only way I've found that can in any shape or form produce a somewhat working solution is to somehow forcibly align all datasets before feeding them to Highstock, which is a *pain* to say the least, and it really shouldn't be necessary to begin with.
It's especially frustrating since many (most, I'd say) of the alternative charting solutions do handle this, including the Flash-based one we're desperately wanting to migrate away from.
I am 100% convinced that the (obviously) talented Highstock developers *can* solve this, since others already have.
The solution, which I suggest is to be implemented *inside* Highstock, is simple, in principle:
When rendering more than a single series; for each point in each series, ensure that a corresponding point exists in each other series. When no real such point exists, construct a virtual point, using these two rules:
1. If no real point earlier in time exists, construct the virtual point with the correct timestamp and null value(s). Null values, since no useful reference values exist in this case.
2. If a real point earlier in time exists, construct the virtual point with the correct timestamp and one or more of the values from the earlier point, based on what type of data it is.
The datatype dependency is per series, and dictates what values, if any, to "inherit" when constructing virtual points. The reason for this to be a varying thing is that only certain values should be inherited, while others should be (most commonly) zero in virtual points, depending on the type of data.
Examples (stock data):
- close price -> inherited, since the last known close price remains valid until a new one appears
- volume -> zero, since no trading has occurred in a missing point
- similarly for high/low (inherited from close price, due to no trades), and open price (also inherited from close price)Following these rules inside Highstock, where by definition all data to be plotted is available for this kind of rule-based processing, produces strictly aligned datasets with deterministic values for all points, whether they be real or virtual. A consistent rendering is thus possible.
Please consider and implement this!
-
Marty Sullens commented
We are currently in limbo of choosing a charting solution for this because Google charts allows you to do this, but they don't have the option to do vertical lines unless you use the date format which DOESN'T allow you to skip dates. So it's a catch 22 and both are needed for our application. Adding the ability to skip dates and use vertical lines would be very much appreciated! Please everyone vote this up!
-
sd commented
I have struggled for two days trying to set up highstock charts to chart irregularly sampled stock intraday data, and until i found the forum thread, I thought it was my problem. This is a must-have feature! Would the developer please bump this feature to the top of the to-do list!