nylen / d3-process-map

Web application to illustrate the relationships between objects in a process using d3.js.
MIT License
416 stars 196 forks source link

Hide orphan nodes #13

Closed epinapala closed 9 years ago

epinapala commented 9 years ago

Is there a way to hide the nodes which don't have at least one child or isn't a parent to at least one child?

Please help, thanks!

nylen commented 9 years ago

@epinapala I'd start with something like this, inserted at script.js#L54:

for (var name in graph.data) {
    var obj = graph.data[name];
    if (!obj.depends.length && !obj.dependedOnBy.length) {
        delete graph.data[name];
    }
}

Beware of bugs in the above code; I have only proved it correct, not tried it. [#]

Closing since to me this is a pretty uncommon use-case.