react-d3-tree icon indicating copy to clipboard operation
react-d3-tree copied to clipboard

a way to customize child node position?

Open brillantewang opened this issue 6 years ago • 0 comments

Thank you for taking the time to report an issue with react-d3-tree!

Feel free to delete any questions that do not apply.

Are you reporting a bug, or opening a feature request?

A question, possible feature request.

What is the actual behavior/output?

If a node has a single child, the child node is placed directly below its parent (given a vertical orientation).

What is the behavior/output you expect?

Would be sweet if there's a way to customize the position of a child node (in my case so it's offset to the left or right of it's parent, rather than directly below).

So instead of this: image

Have it like this: image

My hacky solution to this was inserting blank placeholder nodes (gave them a nodeSvgShape with shape: 'none') as siblings wherever there are single child nodes. This 'forces' the single child node either into the left or right. Then to not have a bunch of lines leading to no-where, I also wrote a custom pathFunc which returns null for the ones whose target is a blank node.

Hoping there's a less hacky way of doing this.

What version of react-d3-tree are you using?

1.16.1

brillantewang avatar Jun 12 '20 06:06 brillantewang