mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal
MIT License
3.14k stars 165 forks source link

Progressive Graph on Reading Each Data #89

Open monsieurDuke opened 3 years ago

monsieurDuke commented 3 years ago

Hey there. So I was wondering if there are some way to make the graph become progressive, since it reads new data on the new next line in a file. Here is my snippet on the Bash script.

#!/bin/bash
while IFS= read -r each_stat; do
  echo "$each_stat" > "log/each_result.csv" & wait
  termgraph "log/each_result.csv" --color {cyan,red,yellow,green}; sleep 0.01s
  printf "\033[6A ";
done < "log/result.csv"

First I passed each line of the file to a temp file, so termgraph can read only one data at a time. then I return the cursor 6 line before and continue to read the next data. But its not updating the bar quite what I wanted to, which become overlapped with the previous bar. Are there any solution to overwrite the previous one, without clearing the screen ?

Thanks for the opportunity, really cool stuff !

image image image