MCPcopy Index your code
hub / github.com/plotly/plotly.js / countDescendants

Function countDescendants

src/traces/sunburst/calc.js:295–319  ·  view source on GitHub ↗
(node, trace, opts)

Source from the content-addressed store, hash-verified

293};
294
295function countDescendants(node, trace, opts) {
296 var nChild = 0;
297
298 var children = node.children;
299 if(children) {
300 var len = children.length;
301
302 for(var i = 0; i < len; i++) {
303 nChild += countDescendants(children[i], trace, opts);
304 }
305
306 if(opts.branches) nChild++; // count this branch
307 } else {
308 if(opts.leaves) nChild++; // count this leaf
309 }
310
311 // save to the node
312 node.value = node.data.data.value = nChild;
313
314 // save to the trace
315 if(!trace._values) trace._values = [];
316 trace._values[node.data.data.i] = nChild;
317
318 return nChild;
319}

Callers 1

calc.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…