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

Show transmission lines toggle should only appear if transmission lines can be drawn #1154

Open
jameshadfield opened this issue Jun 3, 2020 · 5 comments

Comments

@jameshadfield
Copy link
Member

Background

#1147 introduced a toggle to control whether we show transmissions on the map. This toggle is always present, regardless of whether the data is actually present in the tree. If transmissions are not defined by the tree, then the toggle has no real effect.

The presence of transmission lines are completely dependent on the geo-resolution. For a geo-resolution of “X” (e.g. X=division) to be drawn you need the internal nodes of the tree to have values for X assigned to them.

If a selected color-by Y (e.g. Y=clades) has also been inferred for internal nodes, then you get coloured transmission lines. Otherwise they’re grey.

This issue

The toggle shouldn't appear for geographic resolutions which don't have transmissions available.

Implementation details

We don't have an easy check for this at the moment. The only current way we know about this is within the <Map> component where we run setupTransmissionData which creates the transmissionData array. Note that this code is not run if the toggle (showTransmissionLines) is false.

One solution could be to define a piece of redux state (e.g. reduxState.controls.geoResDefinesTransmissions) which is recalculated when the geo-res changes. The value is determined by a return-early traversal of the tree looking for a non-terminal node with a value set for that geo-res.

Test data set

https://nextstrain.org/mumps/global (available for a local auspice build via npm run get-data). The geo-res "country" does not contain the information needed for transmission lines and therefore should not get the toggle. The geo res "region" does.

@TAM360
Copy link

TAM360 commented Jun 10, 2020

@jameshadfield I would like to work on this.

@sinloes
Copy link

sinloes commented Jun 16, 2020

I would also like to work on this if it is not already resolved. I was looking to implement this as part of a school project @jameshadfield. @TAM360 have you already implemented your changes?

@TAM360
Copy link

TAM360 commented Jun 23, 2020

@sinloes you can work on this issue.

@danherre
Copy link

@sinloes and I are working on this issue together. We are thinking of doing something similar to what setupTransmissionData does in mapHelpersatLong.js and cause showTransmissionsToggle to change as a result of change in georesolution. We are thinking of making the change in modifyControlsStateViaTree within recomputeReduxState.js but we're confused about what the tree in this function is referring to. Any thoughts?

@jameshadfield
Copy link
Member Author

jameshadfield commented Jul 16, 2020

Hi @danherre @sinloes -- I hope you were able to make some progress without me. Am I right in thinking your plan is to set this redux state such as reduxState.controls.currentGeoResDefinesTransmissions when the change in geo-res changes and during modifyControlsStateViaTree on initial load but using a algorithm similar to that found in setupTransmissionData?

we're confused about what the tree in this [modifyControlsStateViaTree] is referring to.

The following sketch may help understand the data transforms present when you load a dataset:

image

So the tree referred to in modifyControlsStateViaTree represents what will become the reduxState.tree object (which will be seen by rendering components etc). Please be aware that there are further steps in the the parent function, createStateFromQueryOrJSONs, which will modify this tree object before it makes it to the redux store -- e.g. these lines. For the purposes of the functionality wanted in this issue, the tree object observed by modifyControlsStateViaTree will be able to correctly identify whether values for the geo-resolution are present on internal nodes or not.

P.S. I know createStateFromQueryOrJSONs is rather complex -- we once contemplated turning it into a series of middleware steps, but I decided that it was conceptually simpler to keep it as a single pure function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

4 participants