jupyter-widgets / ipydatagrid

Fast Datagrid widget for the Jupyter Notebook and JupyterLab
BSD 3-Clause "New" or "Revised" License
579 stars 51 forks source link

Add logic for handling row transforms when row merging is applied #311

Closed ibdafna closed 1 year ago

ibdafna commented 2 years ago

Signed-off-by: Itay Dafna idafna@seas.upenn.edu

This PR disables any visual nested hierarchies on the row level when any transforms such as filter or sort are applied. It also fixes a bug (thanks @martinRenou for catching this!) where hierarchy validation for row-based groups was not applied correctly.

Code below used for testing:


import pandas as pd
import ipydatagrid as ipdg

df = pd.DataFrame([
    ['A', 'aaa', 3],
    ['A', 'bbb', 2],
    ['B', 'aaa', 0],
    ['B', 'aaa', 1],
    ['B', 'aaa', 4],
], columns=['col1', 'col2', 'col3']).set_index(['col1', 'col2'])

g = ipdg.DataGrid(df, layout={"height":"140px"})
g```
ibdafna commented 2 years ago

Will add visual regression tests shortly.

ibdafna commented 2 years ago

@martinRenou Here is a weird case:

image

Do we want to support something like that? We do not allow this on for columns. I would think that there should always be a line that divides the lower level (group 'bbb') based on the parent groups (the line between 'A' and 'B'). What do you think?

ibdafna commented 2 years ago

@retadlock would appreciate any feedback on hierarchy verification logic. Going through the data path in your head can be a bit of a mind bend so do let me know if you need any clarifications. Thanks!

retadlock commented 2 years ago

@retadlock would appreciate any feedback on hierarchy verification logic. Going through the data path in your head can be a bit of a mind bend so do let me know if you need any clarifications. Thanks!

Yup, bent my mind. :) I believe I see what you're doing and don't see a better way off the top of my (bent) mind, but let's go over this together tomorrow.