-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve HTML reprs #10816
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
base: main
Are you sure you want to change the base?
Improve HTML reprs #10816
Conversation
The strategy I was using is counting the number of hidden items (at any level), with the idea being that it should be obvious if a large amount of data is hidden. Otherwise you could have a collapsed group marked as "(1)" that hides hundreds of data variables, which felt wrong to me.
Do you think this is common? I don't think we do this for the other Xarray HTML reprs. They get collapsed but nodes are not truncated at the top level.
I am currently displaying DataTree elements in priority order, based on showing the top-most levels as completely as possible (breadth-first). We could start by going deep (depth-first), but this would mean that some high-level nodes could be truncated. Maybe there's some compromise algorithm that could work better? |
This looks great @shoyer! I've always been confused by the collapsible "Groups" header so I think this is a nice improvement. I haven't tried this branch yet. I only looked at the JSFiddle previews linked above where I noticed some UI/UX regressions in the "new reprs" one (e.g., no pointer cursor for variable attrs / data icons) although the CSS code seem to be not exactly the same as in this PR so it may not be an issue. Regarding truncation of large objects I'm wondering whether we should use a same set of consistent rules across all objects for both the text and html reprs? It is tricky to find a solution that accommodates everyone so perhaps best would be to come up with a very basic solution (e.g., show the first and last n items for groups at any level, for variables, etc.) and provide a more flexible solution (pagination, etc.) via a 3rd-party widget with client-server communication.
I think we can be more specific for collapsed groups, e.g., show "(2 subgroups)" for groups with no variable, "(5 variables)" for leaf groups, "(3 subgroups, 10 variables)" for hybrid groups, etc. |
This PR adds a number of improvements and revisions to the Xarray's HTML reprs, especially for DataTree:
:active
selector doesn't always go away when focus is moved elsewhere)display_max_items
anddisplay_max_html_elements
for controlling at what point the DataTree HTML repr collapses and truncates nodes, instead of doing this all based ondisplay_max_children
.This needs a few more tests and release notes, but is ready for feedback! @jsignell @TomNicholas @benbovy
whats-new.rst
Code to generate HTML previews:
Revised (this PR)
Interactive preview
Baseline
Interactive preview