What does the syntax d._children = d.children; stand for in d3.js?

偶尔善良 提交于 2019-11-30 06:43:08

_children is just a temp variable that holds the children when they are hidden. When you click you are either taking children to null and storing the children in the temp variable, or, if children is already null, loading them from the temp variable.

Any temp variable could have been used. There is nothing special about _children. It is used to show an obvious relationship to children.

I was just testing this via this example below and found that if I replaced the word children with anything else the tree failed to load correctly. I believe children is a required keyword. https://bl.ocks.org/mbostock/4339083

I just verified this. In order to use another keyword to define children you must use the tree.children() function like this:

tree.children(function(d){ return d.dependencies; });

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!