asciichart icon indicating copy to clipboard operation
asciichart copied to clipboard

Graph characters not clearing on row change (asciichartpy)?

Open DoktorJ opened this issue 4 years ago • 7 comments

I didn't seem to have this problem with a previous version, but since dropping in 1.5.12 (thank you for reimplementing the user specification of characters!), I've got this issue where the graph doesn't clear adjacent rows when it shifts; see screenshot.

asciichartpy bug

When the graph is at its max width and redrawing over a previous graph, it no longer clears these characters when scrolling. I looked at the commit history, and determined this bug is caused by commit e9adb0d, with the addition of the .rstrip() call; when I edited my init.py and removed .rstrip() the graph behaves as it used to.

DoktorJ avatar Jun 16 '20 15:06 DoktorJ

(ignore the colors, that's just an artifact of my HDMI capture device; it's all one color on-screen)

DoktorJ avatar Jun 16 '20 15:06 DoktorJ

Opened PR #51 for this

DoktorJ avatar Jun 16 '20 15:06 DoktorJ

@DoktorJ thank you! Will check and merge shortly!

kroitor avatar Jun 16 '20 20:06 kroitor

@DoktorJ can you plz post the code you use to reproduce the above graph? Namely, the instantiation/configuration code and the series. It might be caused by a different issue (not related to rstrip(), possibly an encoding issue or something related).

kroitor avatar Jun 17 '20 00:06 kroitor

@DoktorJ also, it would help if you could post your result of test.py (run it from the cloned repo).

kroitor avatar Jun 17 '20 00:06 kroitor

@kroitor it's part of a bash loop that monitors system temperature. First the configuration is set up outside the loop, based on detected display parameters to try to maximize graph size and keep the Y-axis intervals clean, instead of weirdly-rounded decimal numbers...

scmin=30
scmax=100
scheight=35
graphcfg='{"min":'$scmin', "max":'$scmax', "height":'$scheight', "format":"{:6.1f} ", '\
'"symbols": ["┼", "┤", "╶", "╴", "─", "└", "┌", "┐", "┘", "│"]}'

and then the loop itself does this:

# code that fetches temperature via `sensors` and appends the value to a bash array variable named tgraph
tgraphstr=$(echo "${tgraph[@]}" | tr ' ' ,)
python -c "import asciichartpy; print(asciichartpy.plot([${tgraphstr}],${graphcfg}));"

I pulled my specific PR and ran test.py, then switched back to master and ran again, also checked the return value just for shiggles:

jess@Jess-N141ZU:~/git/asciichart$ git checkout PULL-51
Switched to branch 'PULL-51'
jess@Jess-N141ZU:~/git/asciichart$ python test.py
    7.00  ┼──╮                                       ╭────╮                                       ╭─ 
    6.00  ┤  ╰─╮                                   ╭─╯    ╰─╮                                   ╭─╯  
    5.00  ┤    ╰─╮                               ╭─╯        ╰─╮                               ╭─╯    
    4.00  ┤      ╰╮                             ╭╯            ╰╮                             ╭╯      
    3.00  ┤       ╰╮                           ╭╯              ╰╮                           ╭╯       
    2.00  ┤        ╰╮                         ╭╯                ╰╮                         ╭╯        
    1.00  ┤         ╰╮                       ╭╯                  ╰╮                       ╭╯         
    0.00  ┼          ╰╮                     ╭╯                    ╰╮                     ╭╯          
   -1.00  ┤           ╰╮                   ╭╯                      ╰╮                   ╭╯           
   -2.00  ┤            ╰╮                 ╭╯                        ╰╮                 ╭╯            
   -3.00  ┤             ╰╮               ╭╯                          ╰╮               ╭╯             
   -4.00  ┤              ╰─╮           ╭─╯                            ╰─╮           ╭─╯              
   -5.00  ┤                ╰╮         ╭╯                                ╰╮         ╭╯                
   -6.00  ┤                 ╰─╮     ╭─╯                                  ╰─╮     ╭─╯                 
   -7.00  ┤                   ╰─────╯                                      ╰─────╯                   
    2.00  ┼───────────────────────────────────────────────────────────────────────────────────────── 
    2.00  ┼───────────────────────────────────────────────────────────────────────────────────────── 
    0.00  ┼───────────────────────────────────────────────────────────────────────────────────────── 
    0.00  ┼───────────────────────────────────────────────────────────────────────────────────────── 
jess@Jess-N141ZU:~/git/asciichart$ echo $?
0
jess@Jess-N141ZU:~/git/asciichart$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
jess@Jess-N141ZU:~/git/asciichart$ python test.py
    7.00  ┼──╮                                       ╭────╮                                       ╭─
    6.00  ┤  ╰─╮                                   ╭─╯    ╰─╮                                   ╭─╯
    5.00  ┤    ╰─╮                               ╭─╯        ╰─╮                               ╭─╯
    4.00  ┤      ╰╮                             ╭╯            ╰╮                             ╭╯
    3.00  ┤       ╰╮                           ╭╯              ╰╮                           ╭╯
    2.00  ┤        ╰╮                         ╭╯                ╰╮                         ╭╯
    1.00  ┤         ╰╮                       ╭╯                  ╰╮                       ╭╯
    0.00  ┼          ╰╮                     ╭╯                    ╰╮                     ╭╯
   -1.00  ┤           ╰╮                   ╭╯                      ╰╮                   ╭╯
   -2.00  ┤            ╰╮                 ╭╯                        ╰╮                 ╭╯
   -3.00  ┤             ╰╮               ╭╯                          ╰╮               ╭╯
   -4.00  ┤              ╰─╮           ╭─╯                            ╰─╮           ╭─╯
   -5.00  ┤                ╰╮         ╭╯                                ╰╮         ╭╯
   -6.00  ┤                 ╰─╮     ╭─╯                                  ╰─╮     ╭─╯
   -7.00  ┤                   ╰─────╯                                      ╰─────╯
    2.00  ┼─────────────────────────────────────────────────────────────────────────────────────────
    2.00  ┼─────────────────────────────────────────────────────────────────────────────────────────
    0.00  ┼─────────────────────────────────────────────────────────────────────────────────────────
    0.00  ┼─────────────────────────────────────────────────────────────────────────────────────────
jess@Jess-N141ZU:~/git/asciichart$ echo $?
0

DoktorJ avatar Nov 13 '20 17:11 DoktorJ

BTW it may not be immediately apparent on the test.py runs, but the PR's graph pads with whitespace all the way out to the end of the graph; the master's graph has no trailing whitespace. You can see it if you highlight the lines.

DoktorJ avatar Nov 13 '20 17:11 DoktorJ