Description
Context
I'm using Plotly's treemap in real-time web application where data is updated frequently.
The visualization represents a hierarchical dataset, and I allow users to interact with it by clicking on a bloc to focus on a specific branch
Problem
Currently, every time I update the data (specifically the ids, parents, and labels arrays), the focus resets back to the root of the treemap. This breaks the user experience since the user is forced back to the top level, even if they were navigating deeper into the tree.
Expected Behavior
Ideally, I want the treemap to preserve the current focus when the tree is updated (as long as the selected node and its children are still present in the data). I haven't found a configuration like rootId / focusId option that persists focus across updates in treemaps.
Current workaround
One potential workaround I'm exploring is to reconstruct a filtered version of the tree manually, by :
- Extracting the clicked node and all of its descendants
- Overidding their parents fields so the focused node become the new root
- Updating the plot with this "subtree" only
That should works, but it adds quite a bit complexity to the data processing. In addition, I don't know how to manage pathbar
Request
Is there currently a configuration way to preserve the focus state across data updates in a treemap plot ?
Environment
- Library : Plotly.js (with react class)
- Plot type : treemap
- Use case : real-time updates + interactive navigation