-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Handle rangebreak gaps in candlestick
& ohlc
#4814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
615757f
97f6b7b
8a4bae3
2f3b098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "candlestick", | ||
"x": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this mock, it would be great to see some data in the next visible range, like after 9am the next day, just to capture some of the tick labelling etc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"2020-01-02 17:00", | ||
"2020-01-02 17:10", | ||
"2020-01-02 17:20", | ||
"2020-01-02 17:30", | ||
"2020-01-02 17:40", | ||
"2020-01-02 17:50", | ||
"2020-01-02 18:00", | ||
"2020-01-02 18:10" | ||
], | ||
"open": [ | ||
10, | ||
10, | ||
10, | ||
10, | ||
10, | ||
10, | ||
10, | ||
10 | ||
], | ||
"high": [ | ||
12, | ||
12, | ||
12, | ||
12, | ||
12, | ||
12, | ||
12, | ||
14 | ||
], | ||
"low": [ | ||
8, | ||
8, | ||
8, | ||
8, | ||
8, | ||
8, | ||
3, | ||
8 | ||
], | ||
"close": [ | ||
12, | ||
7, | ||
11, | ||
10.5, | ||
9, | ||
8.5, | ||
3, | ||
14 | ||
] | ||
} | ||
], | ||
"layout": { | ||
"width": 600, | ||
"height": 400, | ||
"title": { | ||
"text": "Candlestick with rangebreaks" | ||
}, | ||
"xaxis": { | ||
"rangebreaks": [ | ||
{ | ||
"pattern": "hour", | ||
"bounds": [ | ||
18, | ||
9 | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, I wouldn't have guessed that the problem traced back to
distinctVals
, nice find!TIL:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
So perhaps all we need is the loop to find
last
and the rest of this can stay as it was, as we'll never haveundefined
anywhere else after asort
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe worth testing this in IE before relying on it. I've confirmed in Chrome, FF, Safari on my mac so seems robust on modern browsers.
If it were to fail on IE, I wouldn't trust that sorting works at all then with interspersed
undefined
values, and better would be to filter these out before even starting (instead of theslice()
call)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson good catch! Not working on IE11.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson Correction. It appear to be working on IE11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson correction number 2: It is sometimes working and sometime not.
So let's fix that for IE11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. The logic is modified by 2f3b098 & tested in IE11 and it works.