diff --git a/caravel/assets/visualizations/treemap.js b/caravel/assets/visualizations/treemap.js index 88ed230060a85..d37108526af2b 100644 --- a/caravel/assets/visualizations/treemap.js +++ b/caravel/assets/visualizations/treemap.js @@ -72,11 +72,16 @@ function treemap(slice) { // We also take a snapshot of the original children (_children) to avoid // the children being overwritten when when layout is computed. var accumulate = function (d) { - return (d._children = d.children) - ? d.value = d.children.reduce(function (p, v) { return p + accumulate(v); }, 0) - : d.value; + var results; + if (d._children === d.children) { + results = d.children.reduce(function (p, v) { return p + accumulate(v); }, 0); + } else { + results = d.value; + } + return results; }; + // Compute the treemap layout recursively such that each group of siblings // uses the same size (1x1) rather than the dimensions of the parent cell. // This optimizes the layout for the current zoom state. Note that a wrapper