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
Question - How to plot a live data stream #39
Comments
Hi! What's your programming language? |
hello @kroitor I am using Javascript |
@alextran1502 assuming you can read the data points from your stream, you can add them to the set of most recent maxLength elements in your array of data upon reading, and then redraw the chart using the most recent elements. In the simplest form it would look like: const maxLength = 80
const numbers = []
while (true) {
const number = readFromStream () // your reading logic here
if (numbers.length >= maxLength) {
numbers.shift ()
}
numbers.push (number)
console.log (plot (numbers))
} Let me know if that does not answer the question. Feel free to reopen this if needed or just ask further questions, if any. |
@kroitor commented on Feb 28, 2020, 10:13 AM GMT+3:30:
I want to just plot the streaming data (each new line being the updated value) from stdin. How do I do that? |
@NightMachinary you could have the chat in a separate blessed window and redraw it when your data changes. In other words, you need to locate your chart in your output and redraw it, by overwriting it. |
Hello,
First of all, thank you for your wonderful job. This is a very good library.
I am trying to graph a stream of data, can you help to point me in the right direction.
Thanks
The text was updated successfully, but these errors were encountered: