Live-update line charts with new data
This commit is contained in:
parent
de49743182
commit
1fc06cc7c6
3 changed files with 36 additions and 1 deletions
13
lib/liveupdate.js
Normal file
13
lib/liveupdate.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export function subscribe(timeseries, callback) {
|
||||
const socket = new WebSocket('ws://openmct.cbrp3.c-base.org:8082/');
|
||||
socket.addEventListener('open', () => {
|
||||
timeseries.forEach((series) => {
|
||||
socket.send(`subscribe ${series}`);
|
||||
});
|
||||
});
|
||||
socket.addEventListener('message', (msg) => {
|
||||
callback(JSON.parse(msg.data));
|
||||
});
|
||||
}
|
||||
|
||||
export default subscribe;
|
||||
Loading…
Add table
Add a link
Reference in a new issue