Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3 hierarchy: node visibility parameter to control either to show node in visualization or hide it. #3827

Closed
rashidotm opened this issue Feb 24, 2024 · 0 comments

Comments

@rashidotm
Copy link

rashidotm commented Feb 24, 2024

Hi,

Thanks for the work maintaining d3 and making it more elegant. 馃挌馃挌

Consider the following example for toggling a node in a tree.

function toggleNode(d) {
  if (d.children) {
    d._children = d.children;
    d.children = null;
  } else if (d._children) {
    d.children = d._children;
    d._children = null;
  }
}

This kind of swapping leads to more customization to handle d._children so rather than dealing with one array of children you now have to deal with two. and in case you want to have partial hiding of nodes, then you will ultimately end up with 3 arrays to contain each list (toggled on, toggled off, hidden).

Rather than toggling between d.children & d._children & maintaining another array for hidden nodes, I suggest to have a parameter on the node itself d.visible which defaults to true and be shown on the visualization if d.visible == true. but if d.visible == false then it is not shown in visualization and all of that is built into the library in handling the hierarchy and tree calculation. this will definitely lead for simpler usage and less handling on client side of the d3 library.

I looked up the documentation and this feature is not built in d3 by default. there are some answers on SO but as I mentioned it leads to heavier customization on client side.

see this for example:
https://stackoverflow.com/questions/29873947/hide-unrelated-parent-nodes-but-child-node-in-d3-js

if this feature is already available or If I am missing a major thing that may help achieve this goal then please let me know. otherwise consider this as a feature request.

thanks

@rashidotm rashidotm changed the title d3 hierarchy: node visibility parameter to control either to show node in visualzation or hide it. d3 hierarchy: node visibility parameter to control either to show node in visualization or hide it. Feb 24, 2024
@d3 d3 locked and limited conversation to collaborators Feb 24, 2024
@Fil Fil converted this issue into discussion #3828 Feb 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

1 participant