Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Aug 8, 2024
1 parent 9807a99 commit 4ea7b6d
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const flattenSeries = (
});
};

const flattenHierarchy = (data, parentId = null, parentValue = null, level = 0) => {
const flattenHierarchy = (data, split = null, parentId = null, parentValue = null, level = 0) => {
let result = [];

data.forEach((item, index) => {
Expand All @@ -92,10 +92,13 @@ const flattenHierarchy = (data, parentId = null, parentValue = null, level = 0)
value: item.value,
parentValue,
level,
split,
});

if (item.children && item.children.length > 0) {
result = result.concat(flattenHierarchy(item.children, currentId, item.value, level + 1));
result = result.concat(
flattenHierarchy(item.children, split, currentId, item.value, level + 1)
);
}
});

Expand Down Expand Up @@ -123,13 +126,11 @@ export const flattenDataHandler = (context, dimensions, handlerType = 'series')
converted.series = flattenSeries(converted.series);
}
} else if (handlerType === 'slices') {
// if (group && group.length !== 0) {
// converted.series = group.slices.children.map(slice => ({
// name: slice.name,
// size: slice.size
// }));
// } else {
converted.slices = flattenHierarchy(converted.slices);
if (group && group.length !== 0) {
// TODO:
} else {
converted.slices = flattenHierarchy(converted.slices);
}
}

return converted;
Expand Down

0 comments on commit 4ea7b6d

Please sign in to comment.