cms/app-client/app/components/visu-langues.js
changeset 142 86fcf0c837c0
parent 126 e87a340711a4
child 188 d2cb39155997
equal deleted inserted replaced
141:c0e8626a271c 142:86fcf0c837c0
    69       // Aggregate the values for internal nodes. This is normally done by the
    69       // Aggregate the values for internal nodes. This is normally done by the
    70       // treemap layout, but not here because of our custom implementation.
    70       // treemap layout, but not here because of our custom implementation.
    71       // We also take a snapshot of the original children (_children) to avoid
    71       // We also take a snapshot of the original children (_children) to avoid
    72       // the children being overwritten when when layout is computed.
    72       // the children being overwritten when when layout is computed.
    73       function accumulate(d) {
    73       function accumulate(d) {
    74         return (d._children = d.children) ? (d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)) : (d.value = (languages[d.id]?languages[d.id]:0));
    74         d._children = d.children;
       
    75         if(d.children) {
       
    76           d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0);
       
    77         } else if (_.isArray(d.id)) {
       
    78           d.value = d.id.reduce(
       
    79             function(s,lid) { return s + (languages[lid]?languages[lid]:0); },
       
    80             0
       
    81           );
       
    82         }
       
    83         else {
       
    84           d.value = languages[d.id]?languages[d.id]:0;
       
    85         }
       
    86         return d.value;
    75       }
    87       }
    76 
    88 
    77       // Compute the treemap layout recursively such that each group of siblings
    89       // Compute the treemap layout recursively such that each group of siblings
    78       // uses the same size (1×1) rather than the dimensions of the parent cell.
    90       // uses the same size (1×1) rather than the dimensions of the parent cell.
    79       // This optimizes the layout for the current zoom state. Note that a wrapper
    91       // This optimizes the layout for the current zoom state. Note that a wrapper