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. |
|
A few more thoughts:
|
|
If we go from a full path to just node names, we should adjust the text repr, too. I like the full easily copied identification, though. The increased indentation for child nodes was an attempt to make it easier to identify child content! I'm definitely open to other ideas. Anyways if anyone wants to try their hand at iterating on this, please fill free to push commits to my branch. These CSS edits are pretty fiddly for me 😄. |
for more information, see https://pre-commit.ci
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
I've added unit tests, and restored the truncation for too many child nodes. I'm still open to suggestions, but in the interest of merging in marginal improvements rather than waiting for a perfect solution, this is ready for a final review! |
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks @benbovy for the re-review! I've fixed the styles as you've suggested (including the regression for DataTree!). I also figured out a way to restore the visual indications of focus without looking weird when using the mouse -- it turns out using the
|
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
jsignell
left a comment
There was a problem hiding this comment.
This looks so great! It's a real improvement over the current datatree.
|
Doc build failure looks entirely unrelated, so merging. Thanks everyone for the reviews! |


This PR adds a number of improvements and revisions to the Xarray's HTML reprs, especially for DataTree:
:activeselector doesn't always go away when focus is moved elsewhere)display_max_itemsanddisplay_max_html_elementsfor 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.rstCode to generate HTML previews:
Details
Revised (this PR)
Interactive preview
Baseline
Interactive preview