red-data-tools / YouPlot

A command line tool that draw plots on the terminal.
MIT License
4.03k stars 60 forks source link

Progressive mode #2

Open kojix2 opened 3 years ago

kojix2 commented 3 years ago

It may not be a very practical idea. But I would like to see a progressive mode. Some programs take a long time to run and gradually output the results to standard output. In that case, waiting until all the output is finished would take a long time. I'd like to have a mechanism to pass the results to the next pipeline before all the outputs are finished. However, I think it would be very difficult to create such a mechanism.

kojix2 commented 3 years ago

Memo: https://github.com/Martin-Nyaga/termplot

kojix2 commented 3 years ago

Update: It's not perfect, but it's been implemented. https://github.com/kojix2/YouPlot#how-to-plot-real-time-data

kojix2 commented 3 years ago

scatter: xlim ylim does not change automatically in progress mode

expected behavior

ruby -rnumo/narray -e "puts Numo::Float32.new(1000,2).rand_norm.to_a.map{_1.join(\"\t\")}" | uplot s

image

actual behavior

https://user-images.githubusercontent.com/5798442/121475272-27b64700-ca00-11eb-9c1d-67403d1aa4c1.mp4

kojix2 commented 3 years ago

Progressive mode will work.

However, it can be very slow if there are many lines of data. YouPlot reads one new line of data from the standard input and passes all the previous data to UnicodePlot. This slows down the behavior. There are two solutions that come to mind right away.

I will consider the appropriate command line options. Idea:

joaociocca commented 7 months ago

I thought this could be a nice way to try and make an alert count histogram using the line charting... but progressive mode keeps the previous values, right? I notice that if I feed it an array with 10 items, shift the first and add a new one, instead of updating it'll add the new set along with the previous ones, instead of rewriting the whole set.

ah, now I understand the idea for the --window option, only the new item should be fed to it, and uplot itself would discard items over the window count. Can't wait to see if this ever comes to light =)