This could be another question on improvement, i have made a directive with the help of Existing question
, which is working well.
这可能是另一个关于改进的问题,我在已有问题的帮助下做了一个指示,这个问题很有效。
now when the user creates this chart dynamically, when the data load exceeds, the browser becomes heavy and user interface gets stuck.
现在,当用户动态创建这个图表时,当数据负载超过时,浏览器就会变得沉重,用户界面就会被卡住。
how do i restrict the nodes level to be 2 , when the chart is loaded initially. i tried to make a service call one by one, but that does not work.
当最初加载图表时,如何将节点级别限制为2。我试着一个接一个地拨打服务电话,但这行不通。
Here is the code:
这是代码:
function click(d) {
if (d3.event.defaultPrevented) return; // ignore drag
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update();
}
应用程序和数据
1 个解决方案
#1
2
Hopefully this will help out. From this example : How can I start with all the nodes collapsed in d3js?
希望这能帮上忙。从这个示例开始:如何从d3js中折叠的所有节点开始?
I edited your fiddle : http://jsfiddle.net/thatOneGuy/yar5sco6/7/
我编辑了你的小提琴:http://jsfiddle.net/thatOneGuy/yar5sco6/7/
I removed the original call to update()
. So you have to press Load
then Start
.
我删除了更新()的原始调用。你需要按Load然后开始。
This collapses all nodes. From there you can open up the first two hierarchies fairly easy :)
这种崩溃所有节点。从那里你可以相当容易地打开前两个层次:
This is the main implementation :
这是主要的实施:
//HTML
/ / HTML
<button id='startForce'>START</button>
//JS
/ / JS
document.getElementById('startForce').addEventListener('click', function() {
console.log('start');
var nodes = flatten(root);
nodes.forEach(function(d) {
d._children = d.children;
d.children = null;
});
update();
})
#1
2
Hopefully this will help out. From this example : How can I start with all the nodes collapsed in d3js?
希望这能帮上忙。从这个示例开始:如何从d3js中折叠的所有节点开始?
I edited your fiddle : http://jsfiddle.net/thatOneGuy/yar5sco6/7/
我编辑了你的小提琴:http://jsfiddle.net/thatOneGuy/yar5sco6/7/
I removed the original call to update()
. So you have to press Load
then Start
.
我删除了更新()的原始调用。你需要按Load然后开始。
This collapses all nodes. From there you can open up the first two hierarchies fairly easy :)
这种崩溃所有节点。从那里你可以相当容易地打开前两个层次:
This is the main implementation :
这是主要的实施:
//HTML
/ / HTML
<button id='startForce'>START</button>
//JS
/ / JS
document.getElementById('startForce').addEventListener('click', function() {
console.log('start');
var nodes = flatten(root);
nodes.forEach(function(d) {
d._children = d.children;
d.children = null;
});
update();
})