I have come across an interesting challenge while working on a project involving a zoomable treemap. I am currently exploring how to pass and aggregate multiple parameters within the treemap, similar to what is typically done in a zoomable treemap visualization.
The provided code snippet for this task is as follows:
// Aggregate the values for internal nodes. This is normally done by the
// treemap layout, but not here because of our custom implementation.
function accumulate(d) {
return d.children
? d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)
: d.value;
}
In my approach, I need to sum up two parameters - 'value' and 'count'. Although I attempted to modify the code to accommodate both parameters, it did not produce the desired outcome. Would anyone be able to provide assistance on this issue?
function accumulate(d) {
return d.children
? d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)
: d.value;
}
function accumulate1(d) {
return d.children
? d.count = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)
: d.count;
}
I tried implementing these functions separately and then calling them individually to aggregate both count and value as we move up the treemap hierarchy starting from the leaf nodes. However, this strategy did not yield the expected results. Any guidance on how to resolve this issue would be greatly appreciated.