Skip to content
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

Zoom to selected is stored as a URL query #1321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jameshadfield
Copy link
Member

@jameshadfield jameshadfield commented Mar 30, 2021

When clicking "Zoom to selected" we now add a URL query
treeZoom=selected, which is cleared upon the next zoom action.
This allows us to load a page to a zoomed in view of the tree.
This behavior is similar to when zooming to a branch which a clade
label, which results in a query such as label=clade:A1. In the
situation where both are applicable, the clade label takes
priority.

Note that due to the current implementation of zooming in Auspice,
"zoom to selected" will zoom to different subtrees. As an example,
load each of the following datasets and click "zoom to selected":
/flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R,
/flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R&label=clade:A1b/131K.
The resulting subtrees will be different for each case, however both
result in a URL query treeZoom=selected. This is a shortcoming
of the implementation used in this PR, however one that is not easily
solved.

Closes #1284.

When clicking "Zoom to selected" we now add a URL query
`treeZoom=selected`, which is cleared upon the next zoom action.
This allows us to load a page to a zoomed in view of the tree.
This behavior is similar to when zooming to a branch which a clade
label, which results in a query such as `label=clade:A1`. In the
situation where both are applicable, the clade label takes
priority.

Note that due to the current implementation of zooming in Auspice,
"zoom to selected" will zoom to different subtrees. As an example,
load each of the following datasets and click "zoom to selected":
`/flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R`,
`/flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R&label=clade:A1b/131K`.
The resulting subtrees will be different for each case, however both
result in a URL query `treeZoom=selected`. This is a shortcoming
of the implementation used in this PR, however one that is not easily
solved.
@jameshadfield jameshadfield temporarily deployed to auspice-bug-narratives--sofri2 March 30, 2021 06:15 Inactive
@jameshadfield
Copy link
Member Author

jameshadfield commented Mar 30, 2021

@joverlee521 would you be able to review this? I can think of a solution where we calculate something like idxOfFilteredRootWhenTreeIsNotZoomed, and then use this as the comparison here, but I haven't tested this and we'd need to ensure it didn't affect performance. (I also think it's not worth it given that we are contemplating different methods of tree zoming / selection in the future.)

@joverlee521
Copy link
Contributor

@jameshadfield I might be missing something here, but why doesn't the query parameter&label=clade:A1b/131K stay in the the URL? I think that would help differentiate the two subtrees via the URL.

@jameshadfield jameshadfield temporarily deployed to auspice-bug-narratives--7d2cif April 6, 2021 23:10 Inactive
@jameshadfield
Copy link
Member Author

jameshadfield commented Apr 6, 2021

but why doesn't the query parameter &label=clade:A1b/131K stay in the the URL? I think that would help differentiate the two subtrees via the URL.

Am I right in thinking you are performing the following steps:

  1. Go to /flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R&label=clade:A1b/131K
  2. Click "zoom to selected"
  3. label=clade:A1b/131K is now removed?

This behaviour isn't different to master: as we are no longer zoomed to the branch annotated as clade:A1b/131K it is removed from the URL. You raise an interesting point, that if both were in the query we could interpret it as "first zoom to A1b/131K then zoom to selected", however this won't generalise as in many cases the tree interaction isn't recorded in the URL. For instance, take this example:

  1. Load https://auspice-bug-narratives--7d2cif.herokuapp.com/flu/seasonal/h3n2/ha/3y?f_clade_membership=A1b/137F,A1b/197R
  2. Click a branch without any clade labelling (see screenshot)
  3. Click "zoom to selected"
  4. Reload the page - notice that the view is different to that from step 3!

(The reason I chose a branch with clade labelling originally was to make reproduction of the bug easier so one didn't have to click too much 😉 )

image

@joverlee521
Copy link
Contributor

Ahhh, I see the no-name branches do make this trickier. Like you said, I don't see this getting easily solved.
Maybe we can just note this caveat in our documentation:

The treeZoom URL parameter will only zoom based on the URL filters on initial load.
Additional zoom filters through interactions with the tree that are not reflected in the URL will be lost on re-load of the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Narratives cannot zoom to selected (tree panel)
2 participants