Don't resize legend when changing non-color-related things?
- Dominant language
- JavaScript
- Stars
- 56
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
This isn't really a bug, but I think some users might get annoyed by this.
The changes I added in #512 automatically resize the tree coloring legend whenever sample/feature metadata coloring is updated. This is usually a good thing, since it means the legend will adjust to the size of its contents (so it'll get small if the tree is only colored by a few categories, and it'll expand -- up to its maximum size -- if the tree includes lots of categories).
However, a minor problem with this is that the legend is also resized when the tree coloring assignments aren't actually changed but when other things about tree coloring are changed: e.g. toggling clade collapsing, reversing the color map, adjusting the `tip` vs.`all` option for feature metadata coloring\*, adjusting line width. This can get annoying if we're coloring the tree by a field, we've resized the legend, and we're adjusting other things about the tree -- because the legend will keep snapping back to its default size. This is especially noticeable in EMPire plots when the available screen space is small:

There are probably a few different ways we can handle this, but maybe the most straightforward would be something analogous to what @ElDeveloper proposed (albeit in a different context) in #526 -- where we make note of the currently selected field for tree coloring and don't call `Empress.resizeLegend()` from `Empress.updateLegendCategorical()` unless the currently selected field differs from the previously selected field.
__\* Note:__ Adjusting the legend size does actually make sense for this case -- since changing the `tip` vs. `all` thing can change the unique values shown in the legend. But for e.g. clade collapsing or color map reversing, I think it'd be better if the legend size wasn't adjusted here.
Contributor guide
Research direction
Start by tracing Empress.updateLegendCategorical() and its call to Empress.resizeLegend(). Check how tree-coloring changes such as clade collapsing, color-map reversing, line-width adjustment, and tip versus all selection reach these methods. Done means non-color-related changes preserve a manually resized legend while changes that alter its categories still resize it appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100