tenox7 / ttyplot Goto Github PK
View Code? Open in Web Editor NEWa realtime plotting utility for terminal/console with data input from stdin
License: Apache License 2.0
a realtime plotting utility for terminal/console with data input from stdin
License: Apache License 2.0
it would be nice to leave output after exiting with ^c or when there is no more data
this can be done by suing pad or newterm instead of initscr
references:
https://stackoverflow.com/questions/4772061/how-do-i-use-getch-from-curses-without-clearing-the-screen
https://stackoverflow.com/questions/14446311/make-curses-program-output-persist-in-terminal-scrollback-history-after-program
https://en.wikipedia.org/wiki/Braille_Patterns
check gotop
bashtop
etc
The ping example does not seem to work on mac terminal. Is it something related to buffered output ? also sed on mac does not have the option of -u .
Thanks in advance..
add option for coloring charts, eg closer to max = more red
also potentially axes, labels, etc to have different colors
default line and reverse line could also have configurable colors
An input of '1 2 3' displays a minimum of 0.0, and an average of 0.0. getminmax() is incorrectly calculating them over values[0..plotwidth] instead of [0..n].
# make
cc -Wall -Wextra ttyplot.c -lcurses -ltinfo -o ttyplot
/usr/lib/gcc/x86_64-pc-linux-gnu/11/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lcurses: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [<builtin>: ttyplot] Error 1
# pkg-config --libs ncurses
-lncurses -ltinfo
^
Pull request upcoming...
ttyplot-amd64-linux
aborts with "Error opening terminal: xterm-256color."
The system has xterm-256color
only at /usr/lib/terminfo/x/xterm-256color
(Lubuntu install).
A strings /usr/local/bin/ttyplot | grep terminfo
shows that the static binary expects it to be at /etc/terminfo:/lib/terminfo:/usr/share/terminfo
or ~/.terminfo
.
Workaround is to copy it to one of these locations.
Proposed fix: Please add usr/lib/terminfo
to the path where ncurses looks for the terminal definition.
hi, deb packages are not longer hosted here?
Regards,
clipbar should be clipping to value of max which is double instead of ph which is int
if max is set to 10 and value of 10.00001 is passed it should be clipped, but it's not
on modern systems resizeterm() should be called in sigwinch handler instead of endwin() && refresh()
on some systems getmaxyx doesn't work correctly, use TIOCGWINSZ instead see how old svr4 vi does it (ex_v.c)
Seeing if it would be possible for a Arm64 debian package for support of smaller computers such as the RPI.
Running into:
$ sudo dpkg -i ttyplot_1.4-1.deb
dpkg: error processing archive ttyplot_1.4-1.deb (--install):
package architecture (amd64) does not match system (arm64)
Errors were encountered while processing:
ttyplot_1.4-1.deb
Thanks!
I so love this project and already pointed half a dozen friends to it. (I own a command-line tool for R called littler which can work as a filter; I also pointed John Kerl of mlr fame to it.)
Two things are missing, both pretty trivial:
Makefile
? I know about -lcurses
but then I am also one of those guyssupport for Tektronix 4014/4010 or XTerm/Kermit Tek emulator graphics mode
I see the repo has a Makefile, but you may need to update with a new release, like 1.1, to include the Makefile.
it's because of this:
9be5bea
likely scanf()
gets interrupted by sigwinch and returns -1
Hey, first: amazing work on this tool! I'm using it to visualize memory pressure over time on my Mac.
v1.4 from Homebrew seems to have a problem with the -e
option -- e.g. this will fail (just prints the helptext and then pauses for 1 second, then exits):
while [0]; do memory_pressure | awk 'END {print $5/1}'; sleep 1; done | ttyplot -e+ -cx -m100 -t%free_mem -u%
but, cloning master
and compiling with make
outputs a version where the exact same command works fine (also says 1.4 but obviously something's different).
macOS 10.15.5
Any idea?
Drawing in terminal with Unicode Braille characters
Originally: https://github.com/asciimoo/drawille
C version: https://github.com/Huulivoide/libdrawille
support display postscript on sunos, nextstep etc
All uses cases where I would like to use ttyplot are with "limited" input. As it stands, ttyplot quits immediately on stdin EOF.
One simple solution that works is to replace the break statement in the if(r<0)
codepath with a sleep(10); continue;
.
I can open a PR, if this is desirable.
On macOS 12.5.1, plotting from stdin does not work:
echo "1 2 3 4 5" | ttyplot
immediately exits. With longer input, one can see the plot flashing by, before the program quits and nothing is left.
Any plans for .deb arm64 packages?
It seems the options does not work properly. please correct me if i am wrong.
The tested version is compiled from today's source. 1.4
PS: despite that a cool piece of software ;)
for these old systems have define to compile with poor's man line drawing -|<>^L etc
better support counter rewind
(check if curr < last)
Are there any plans on adding this to the Arch User Repository?
Hi and thanks for this useful tool!
I noticed the the following example is not working anymore
{ while true; do curl -sL https://coinbase.com/api/v1/prices/historical | head -1 | cut -d, -f2 ; sleep 600; done } | ttyplot -t "bitcoin price" -u usd
I had a quick glance over the current API (https://developers.coinbase.com/api/v2) and it seems there are no "historical" prices anymore (actually, i could not find "historical" within the old api (https://developers.coinbase.com/api/v1).
Greetings,
Chris
The function “endwin” does not belong to the list of async-signal-safe functions.
I guess that a different program design will be needed for your functions “finish” and “resize”.
This would be great to plot temperature, or other values that typically sometimes go negative.
Otherwise, the plot will look broken until the regular refresh timeout has occurred..
give examples with cut, (paste?), perl, python, etc in addition to bash
Just wanted to let you know, I added this as a package for Homebrew, so mac users can do:
brew install ttyplot
Hi!
From a user point of view, resizing ttyplot's window to small sizes and back can get ttyplot into a broken state, e.g. see video below.
From a code point of view, there are multiple places where a certain minimum size is assumed…
plotheight=height-4;
(width/2)-14
(width/2)-(strlen(title)/2)
…but not checked for. So the assumptions can be violated in practice, e.g. during a resize.
python-prompt-toolkit addresses this problem by displaying something like "window too small" whenever that's the case (and the window is big enough for that text still). I think that would be great to have here for robustness, too.
What do you think?
PS: This may or may not be related to #77.
float input still renders int lines, scales drawn correctly with decimal points
+sixel support
I suggest to reuse a higher level build system than your current make script so that powerful checks for software features will become easier.
...so that we know it's not just hanging or stopped
when ttyplot is run and no data has been received a message "waiting for data" should be displayed
scanf should go to separate thread so it doesn't block the display completely
display non-numeric inputs with a error line instead of just skipping them
# make deb
mkdir -p ttyplot_1.4-1/usr/local/bin
cp ttyplot ttyplot_1.4-1/usr/local/bin
dpkg-deb --build ttyplot_1.4-1
dpkg-deb: error: failed to open package info file 'ttyplot_1.4-1/DEBIAN/control' for reading: No such file or directory
Option to set vertical axis minimum.
Currently, the minimum on the vertical axis is 0. If the value plotted fluctuates around a high value, a lot of the resolution of the fluctuations is lost due to most of the graph representing the baseline.
This is a proposal to have a command-line parameter to set the minimum of the vertical scale (similar to the maximum value, I suppose)
Hi @tenox7,
thanks for sharing ttyplot as Software Libre! 👍 I noticed that there are 90+ commits on master
since release 1.4 and that Debian-based distros have packaged post-1.4 Git snapshots:
To my understanding both indicate, that there is lack for a more recent release.
Are there any plans to cut a release 1.5+ off master
? I'm considering packaging ttyplot for Gentoo, and that would be a great match.
Thanks and best, Sebastian
During real-life use, it turns out that having minimum options would be convenient. Could they be added?
For something exceeding the max and min values, I propose to have a full bar with some marker for max and not drawing anything at all for min, to distinguish them.
So while the examples work, the command output I want to plot doesn't. I have a line such as
find minicrane-scans/mrs/2020/11/02/ -name "*.pcd" | sort | xargs ./bin/pcl_icp | grep Yaw --line-buffered | cut -d" " -f 2
which runs and continuously outputs to stdout
-0
-0.000116325
-0.000274716
-0.000444506
-0.000536768
-0.000640014
-0.000762741
-0.000762741
-0.000997292
-0.00122629
-0.00153955
-0.00172964
-0.00172996
-0.00172996
-0.00180447
-0.00180986
...
However, piping this to ttyplot
only shows waiting for data from stdin
.
ttyplot
needs libncurses5 and libtinfo5 to be installed. I am running Lubuntu 19.04, which already uses libncurses6 and libtinfo6, so ttyplot
throws errors:
ttyplot: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
After trying to fix by running
sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
,
ttyplot
is still not happy:
ttyplot: /lib/x86_64-linux-gnu/libtinfo.so.5: version
NCURSES_TINFO_5.0.19991023' not found (required by ttyplot)
ttyplot: /lib/x86_64-linux-gnu/libncurses.so.5: version NCURSES_5.0.19991023' not found (required by ttyplot)
Could the binary ttyplot
version for linux (ttyplot-amd64-linux) please support the ncurses6 libraries as well? It should be enough to just compile it on a ncurses/tinfo6 system.
It was easy to compile ttyplot
after installation of libncurses-dev and libtinfo-dev, but since you supply all these binaries, it would be very comfortable to have out-of-the-box support as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.