什么是语法d._children = d.children;代表d3.js? [英] What does the syntax d._children = d.children; stand for in d3.js?

查看:694
本文介绍了什么是语法d._children = d.children;代表d3.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是d3.js中的新手。

I'm a newbie in d3.js.

在树形视图的各种示例中,例如可折叠树示例使用语法 d._children = d.children; 。例如在上面示例的代码块中:

In various examples on tree visualizations such as this collapsible tree example the syntax d._children = d.children; is used. For example in this code block from the example above:

// Toggle children on click.  
function click(d) {
  if (d.children) {
    d._children = d.children;
    d.children = null;
  } else {
    d.children = d._children;
    d._children = null;
  }
  update(d);
}

语法 d._children 是什么意思?对我来说不清楚
这里被定义,如果它是d3.js具体或JavaScript语法一般。
任何涉及这种方案的树遍历教程的提示都是欢迎的!

What does the syntax d._children exactly mean? To me it was not clear where this is defined and if it's d3.js specific or javascript syntax in general. Any tips on tree traversal tutorials which involve such schemes are more then welcome!

best Herman

best Herman

推荐答案

_children只是一个临时变量,当子元素被隐藏时保存子元素。当你单击它要么使孩子null和存储的孩子在temp变量,或者,如果孩子已经为null,从temp变量加载它们。

_children is just a temp variable that holds the children when they are hidden. When you click it is 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.

任何可以使用temp变量。 _children没有什么特别的。它用于显示与孩子的明显关系。

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

这篇关于什么是语法d._children = d.children;代表d3.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆