in ui/src/app/viewer/treemap/treemap.component.ts [85:119]
refreshTreeMapData(newDirs: MetadataObject[]) {
this.data = [];
const top3 = newDirs.slice(1, 4);
const otherSize = newDirs.slice(4).reduce((sum, dir) => sum + dir.size, 0);
const otherCount = newDirs
.slice(4)
.reduce((count, dir) => count + dir.count, 0);
const parentDir = newDirs[0].name;
const otherDir: MetadataObject = {
name: 'Other',
count: 0,
parent: parentDir,
size: otherSize,
};
// get the children of other
const otherChildren = newDirs
.slice(4)
.map((dir) => {
dir.parent = otherDir.name
return [dir.name, dir.parent, 0.1]
});
const top3Sizes = [60, 25, 10];
this.data = [
[newDirs[0].name, null, newDirs[0].size], // parent
...top3.map((dir, i) => [dir.name, parentDir, top3Sizes[i]] as Row), // top 3 directories in size
[otherDir.name, parentDir, 5] as Row, // group of other directories
...otherChildren,
];
}