question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collapsible tree example

See original GitHub issue

I derived a simple example from https://vx-demo.now.sh/trees available here: https://codesandbox.io/s/n3w687vmqj

I’m not overly happy with the forceUpdate() and would like to have it animate similar to https://bl.ocks.org/mbostock/4339083, but it’s a start

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
techniqcommented, Oct 6, 2017

@hshoff @sghall I’ve made some progress using react-move to animate the expand/collapse animations of a <Tree /> after the render prop was exposed (thanks again @hshoff )

vx_tree_react_move

There is still some work to do:

  • Animate the links (source, target)
  • Investigate using d3.linkVertical / d3.linkHorizontal as a custom interpolator for nodes so they slide along the link paths instead of a straight line
  • Cleanup the example and probably refine the approach (not using this.forceUpdate(), etc)

I currently have it running locally but can move it out to codesandbox.io once a new version of vx-hierarchy is released (I couldn’t figure out how to use a git sha version on codesandbox, and also struggled locally with the same, but ended up getting npm link to work and have been tweaking the vx-demo for Tree).

I don’t know if I’ll get much more time to iterate on this till next week so once I get it on codesandbox, feel free to fork and tweak if you want.

6reactions
techniqcommented, Oct 9, 2017

I created a radial tree example derived from the cartesian layout version and based on the Radial Tidy Tree d3 example

vx_tree_react_move_20171009_radial_example

The only changes needed to support this layout was to:

  • Translate the main group within Tree to the center (i.e <Group top={width / 2} left={height / 2}>)
  • Use LinkRadial from @vx/shape instead of LinkHorizontal for links
  • Use pointRadial from d3-shape to translate the each node’s x/y to the radial layout. I also used a simple function to return an {x, y} object instead of an array of [x, y]

This example also has the same quirks/issues as mentioned in previous comment, but so far I’m really enjoying using vx and react-move together.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collapsible Tree / D3 - Observable
Click a black node to expand or collapse the tree. ... const duration = d3.event && d3.event.altKey ? 2500 : 250;. const nodes...
Read more >
Collapsible Tree: Geography Example - Adeel Khan
collapsibleTree is an R htmlwidget that allows you to create interactive collapsible Reingold-Tilford tree diagrams using D3.js, adapted from ...
Read more >
Collapsible tree diagram in v4 - gists · GitHub
This is a d3.js tree diagram that incldes an interactive element as used as an example in the book D3 Tips and Tricks...
Read more >
Collapsible tree diagram in v7 - Popular Blocks - Mike Bostock
This is a d3.js tree diagram that incldes an interactive element as used as an example in the book D3 Tips and Tricks...
Read more >
collapsibleTree: inst/examples/01rmd/Example01.Rmd - Rdrr.io
Collapsible Tree Example 1: R Markdown. In collapsibleTree: Interactive Collapsible Tree Diagrams using 'D3.js'. knitr::opts_chunk$set(echo = TRUE) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found