D3js:力导向,内部节点崩溃
D3js: force directed, collapsing internal nodes
在 d3js http://bl.ocks.org/mbostock/1062288 的示例中,哪一部分代码处理单击它们的折叠内部节点。事件处理程序click
设置颜色的数据,但我看不到哪个部分正在处理折叠效果。当然,link.exit().remove()
和node.exit().remove()
删除点和链接。但是"退出"部分是如何创建的呢?
这部分完成了向 scriplet 添加注释的工作:
function click(d) {
if (!d3.event.defaultPrevented) {
if (d.children) {
//if the node is expanded the d.children will have nodes in it.
//we are moving the nodes into another variable d._children
d._children = d.children;
//making d.children as null so that the exit function will remove the nodes in update.
d.children = null;
} else {
//the node is collapsed state so moving the d._children back into variable d.children
d.children = d._children;
//making the d._children null
d._children = null;
}
//after resetting/setting the d.children call update for appending nodes in case of expand(d.children have values) or remove nodes and links when (d.children have no values)
update();
}
}
希望对您有所帮助!
相关文章:
- 如何使用jasmine节点监视依赖模块内部的方法
- redis服务器脱机使节点崩溃
- 强制布局内部 强制布局:如何拖动内部节点
- 访问节点js中对象内部的数组-未定义
- 获取节点的内部文本
- 从节点模块内部返回嵌套函数
- 如何在普通 JavaScript 中获取内部子节点的最外层父节点
- 我可以将 HTML 字符串分配给 HTML DOM 节点的内部 HTML 属性吗?
- 我们如何在外部的节点 js 中使用函数调用中的内部变量
- 如何在节点 js 中打破内部异步循环
- 节点:需要模块内部功能
- 节点.js - 事件.js:154 抛出错误写入 EPIPE;程序崩溃
- 在 dojo 中,我将如何擦除内部文本节点而不擦除元素内的其他节点
- 节点异步仅在 node-lambda 内部调用第一个函数
- 如何在java脚本中获取节点内部文本
- 如何限制节点对内部节点模块的访问
- 如何从函数节点内部使变量全局.js
- D3js:力导向,内部节点崩溃
- node .js -启动命令使节点崩溃,但index.js运行正常
- jQuery只替换节点的文本,忽略当前的内部节点