Skip to content
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

command to freeze the current column directly #2660

Open
midichef opened this issue Dec 31, 2024 · 3 comments
Open

command to freeze the current column directly #2660

midichef opened this issue Dec 31, 2024 · 3 comments
Labels

Comments

@midichef
Copy link
Contributor

Often I want to replace the current column with a frozen copy. It would be convenient to have a command that does the equivalent of:
Sheet.addCommand("", 'setcol-freeze', 'i = cursorVisibleColIndex; name = cursorCol.name; fc = freeze_col(cursorCol); fc.name = name; addColumnAtCursor(fc); columns.pop(i)', 'replace current column with a frozen copy, with all cells evaluated')
(right now this command triggers a bug that's already been reported #2607)

I can't think of a good keyboard shortcut that is not yet taken.

Do other people want this feature?

@midichef midichef changed the title command to freeze the current column without needing a copy command to freeze the current column directly Dec 31, 2024
@saulpw
Copy link
Owner

saulpw commented Dec 31, 2024

z' currently resets the cache on a column, but it could freeze the column like this instead. This would be more in-line with the rest of the ' commands anyway. I'm fine with leaving cache-col without a binding since I think this new command might itself work in the rare instances I've needed it.

@frosencrantz
Copy link
Contributor

Many times I want to replace a column with it's frozen version, so it would be useful to me. This would save some steps. I haven't tried the sample code. Would the prefrozen column still exist as hidden? If not, it would be useful to rename it to something different, like with a suffix (uf -- unfrozen, pf - prefrozen, ...) I like that your example makes the frozen version the same name as the original column.

It would be nice if this command:

  • is undoable
  • handles the case when the original column is materializing such as when it is still async evaluating values.

This replace original column feature would be useful with other commands that return a new modified version of another column.

@midichef
Copy link
Contributor Author

midichef commented Jan 7, 2025

@frosencrantz
Here's a version that keeps the prefrozen column, as a hidden column with the suffix '_unfrozen'. It'll work if you add it to your .visidatarc.

It is undoable. But it does not handle the case of freezing a column that is still materializing. I'm not sure that can be done.

@BaseSheet.api
def setcol_freeze(sheet):
    unfrozen = sheet.cursorCol
    frozen = sheet.freeze_col(unfrozen)
    frozen.name = unfrozen.name
    unfrozen.hide()
    unfrozen.name = frozen.name + '_unfrozen'
    sheet.addColumnAtCursor(frozen)
Sheet.addCommand("z'", 'setcol-freeze', 'setcol_freeze()', 'replace current column with a frozen copy, with all cells evaluated')

Let me know if you have any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants