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

Improve React-PhyloTree interface #501

Merged
merged 25 commits into from
Feb 23, 2018
Merged

Improve React-PhyloTree interface #501

merged 25 commits into from
Feb 23, 2018

Conversation

jameshadfield
Copy link
Member

@jameshadfield jameshadfield commented Feb 16, 2018

Instead of React reaching in and calling the appropriate prototype (updateDistance, updateMultipleArray, etc), a single prototype is available - phylotree.change() - which combines all requested changes (branch thicknesses, visibility, distance etc) into a single D3 call per class (".tip", ".branch" etc). This prevents bugs where multiple D3 update methods were called in quick succession and interfered with each other. It also improves the aesthetics of transitions as all changes are done in the same transition rather than using setTimeout to effectively queue them up.

phylotree.change() API examples

  • phylotree.change({newDistance: "num_date"})
  • phylotree.change({newLayout: "rect"})
  • phylotree.change({changeVisibility: true, visibility: <array>})
  • phylotree.change({changeColorBy: true, stroke: <array>, fill: <array>})

Furthermore, all of these can be combined into a single smooth transition, e.g.

  • phylotree.change({newDistance: "num_date", newLayout: "rect", changeVisibility: true, visibility: <array>, changeColorBy: true, stroke: <array>, fill: <array>})

Additional changes

  • The layout change transition has been improved (in my opinion)
  • url query changes via the narrative result in a single action (down from 5)
  • computeResponsive has been sped up as it no longer queries the DOM causing a forced reflow (stop computeResponsive causing a forced reflow #499)
  • There is 500 lines of deprecated phylotree code which can be removed at some point (it's not referenced anywhere so won't appear in the production bundle).

cc @trvrb @rneher. Online at auspice-dev.herokuapp.com.

@jameshadfield
Copy link
Member Author

here's an example of simultaneously changing the layout, tree metric & color-by:
transitions

@trvrb trvrb assigned trvrb and unassigned trvrb Feb 23, 2018
@trvrb
Copy link
Member

trvrb commented Feb 23, 2018

@jameshadfield: I like this direction a lot. I think this is much clearer than updateMultipleArray. Code looks good in general, though didn't do a comprehensive review. I did do a couple tests to confirm performance and this aspect looks great.

On master I'm getting a 215ms color change for Ebola and 45ms ticks for animation, while on react-d3-interface I'm getting a 185ms color change and 30ms animation ticks. This is a fantastic improvement.

This is ready to merge from my perspective. @rneher: Let us know if you have any issues; you're much closer to phyloTree.

@jameshadfield jameshadfield merged commit e7069e1 into master Feb 23, 2018
@jameshadfield
Copy link
Member Author

👍

@jameshadfield jameshadfield deleted the react-d3-interface branch February 23, 2018 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants