Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Add maxLevels prop for the number of levels to display #3

Open
alexcjohnson opened this issue Dec 19, 2018 · 0 comments
Open

Add maxLevels prop for the number of levels to display #3

alexcjohnson opened this issue Dec 19, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@alexcjohnson
Copy link
Contributor

alexcjohnson commented Dec 19, 2018

If you have data with highly nested nodes, it might be preferable to only show a few levels at a time, diving deeper as you select inner nodes.

If the data were TOO big (so performance would lag if you send it all to the front end) you need to do something like usage_backend_update_via_selections to fetch the appropriate data whenever the selection changes. But for intermediate-size data, we should be able to simply restrict the number of visible levels by adding a prop called something like maxLevels.

The key to this will be altering the radial range, which is set by selectedY

d3.layout.partition (note we're using v3 here) sets node.y and node.dy for all nodes such that the root node has y=0 and the deepest level of nesting has y+dy=1, while dy is 1/(total number of levels)

So the main thing we need is to change selectedY from:

node => [node.y, 1]

to something like:

node => [node.y,  maxLevels ? Math.min(1, node.y + maxLevels * node.dy)] : 1]

ie if maxLevels is 0 or missing, keep the current behavior, otherwise restrict the end of the radial range to no more than the requested number.

Then maxLevels needs to be propagated up from the d3 component to the react wrapper component (the d3 component receives props from the react component as figure here)

It's possible that other things will be needed, like explicitly removing text and/or path elements that are collapsed against the outside edge... we'll have to see how it looks and performs to determine if this is needed.

@alexcjohnson alexcjohnson added the enhancement New feature or request label Dec 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant