-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
[canvas-] draw lines at user-defined x or y #2489
Conversation
visidata/canvas.py
Outdated
@@ -808,6 +865,13 @@ def deleteSourceRows(self, rows): | |||
Canvas.addCommand('g'+ENTER, 'dive-visible', 'vs=copy(source); vs.rows=list(rowsWithin(plotterVisibleBox)); vd.push(vs)', 'open sheet of source rows visible on screen') | |||
Canvas.addCommand('gd', 'delete-visible', 'deleteSourceRows(rowsWithin(plotterVisibleBox))', 'delete rows on source sheet visible on screen') | |||
|
|||
Canvas.addCommand('', 'add-line-x', 'sheet.gridlines_x += [float(x) for x in input("add line(s) at x = ", value="0.0", defaultLast=True).split()]; sheet.refresh()', 'draw a vertical line at x-values (space-separated)') | |||
Canvas.addCommand('', 'add-line-y', 'sheet.gridlines_y += [float(y) for y in input("add line(s) at y = ", value="0.0", defaultLast=True).split()]; sheet.refresh()', 'draw a horizontal line at y-values (space-separated)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should use col.type()
(dates are a numeric type). Ideally the default value should be something reasonable, maybe the median of the data range? And let's use type="gridlinex"
/gridliney with both the add and remove, so people can scroll up to remove the most recently added gridline.
For the longnames, let's not use the 'add/remove/clear' verbs since current 'add-' commands are used to modify the data. What can we use to indicate this is an interface-only command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of 'add/remove/clear', how about 'draw/erase/erase'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me! draw-
especially is very clearly interface only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, @midichef! I think it looks nice. Maybe we could add the theme elements to the ascii themes with |
and -
?
Okay, the last commit addresses all the feedback on this feature so far. One choice that I'd like feedback on is the parsing of input for gridline values. It currently allows multiple values as a space-separated string. E.g. An alternative design would be to accept input in any form, but restrict the inputs for Another change in this commit, I moved the gridlines out of |
Hey, Thanks for implementing this.
I drew a line at 0.4 (I think): But when I zoom out I don't see it: Maybe it's because there are too many data points around that Y value. However, notice how there's clear space both on the left and on the right of the data. Could you extend the lines to there? As long as they don't clash with the tick numbers, of course. |
To change the color of the line you can add a line to your .visidatarc like I'm not sure why the y=0.4 line disappeared on zooming in your images. That looks like a bug to me. The refline should be drawn on the left and right of the data. I can't reproduce it in my limited testing. Can you find a way to consistently reproduce that, and post a sample data file, command log, and terminal dimensions in characters (such as 120x40)? |
Data file and command log: https://www.dropbox.com/scl/fo/5vpb430tpnyq9iinbcljk/AKPM09_NkdomvwodvrpyFCE?rlkey=ssbhjdqs8w92dblxzkhdmwne1&dl=0 Terminal size:
One thing that may not be clear in that command log is that the selected rows (i.e. columns) are |
Thanks for the data files. They reproduced the missing refline on my system. The problem was that certain kinds of zoom, like the ones used by I've also changed the command names to I believe that addresses all the feedback so far. Any other issues? |
Great, thank you. Yes, this addresses all my feedback. I'll probably start using this feature when the next release of visidata is made. Thanks for implementing this. |
@cool-RR After I do The error has existed since my commit abc9aff from June 2023, and I've submitted a fix here that will be in the next release of visidata. Please let me know if you ever notice any similar errors in the edges of ranges/boxes when using graphs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! @saulpw Any rough idea when the next release will be? A month, a year? |
Should be mid-October. |
This is a draft of a feature to draw vertical or horizontal lines on a
Canvas
.For now I used the command names:
add-line-x
,remove-line-x
,clear-lines-x
. Any better names I could use instead?When finalized, this PR closes #2482.