You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered:
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
locked and limited conversation to collaborators
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.
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 itselfd.visible
which defaults to true and be shown on the visualization ifd.visible == true
. but ifd.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
The text was updated successfully, but these errors were encountered: