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.
This discussion was converted from issue #3827 on February 24, 2024 12:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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
Beta Was this translation helpful? Give feedback.
All reactions