Last active
May 11, 2020 09:22
-
-
Save leeoniya/e24543c48199ee79221d2a98b857e2ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let u; | |
const ws = new WebSocket("ws://127.0.0.1:6789/"); | |
ws.onmessage = function(event) { | |
const data = JSON.parse(event.data); | |
switch (data.type) { | |
case 'ohlc': | |
let ohlc = [data.ts, data.o, data.h, data.l, data.c]; | |
if (u == null) | |
u = new uPlot(opts, ohlc, document.body); | |
else | |
u.setData(ohlc); | |
break; | |
case 'askbid': | |
break; | |
default: | |
console.error("unsupported event", data); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
got even closer now. i prefer this scheme because i would not know the range of y scale before hand.
as a result of the above i am getting the following plot

edit:
when i checked the console, i get these errors / warnings. first i thought this is some rendering issue. i realised late that i am using a flat data for ohlc and not a realistic one. thats why i did not get a proper image.