Skip to content

Commit

Permalink
GUI Runs info charts: desc sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
rodichenko committed Jul 18, 2024
1 parent cd46125 commit 1f7d07f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions client/src/components/runs/runs-info/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,22 @@ function extractDatasetByField (field, data = {}) {
};
}
const categoriesKeys = Object.keys(dataField);
const getLabelSum = (label) => categoriesKeys
.reduce((sum, key) => sum + (dataField[key][label] || 0), 0);
const labels = [...new Set(Object
.values(dataField)
.reduce((acc, cur) => [...acc, ...Object.keys(cur)], [])
)];
const dataSets = categoriesKeys.reduce((acc, key) => {
acc[key] = labels.map(label => (dataField[key] || {})[label] || 0);
return acc;
}, {});
)]
.map((label) => ({
label,
value: getLabelSum(label)
}))
.sort((a, b) => b.value - a.value)
.map((a) => a.label);
const dataSets = categoriesKeys.reduce((acc, key) => ({
...acc,
[key]: labels.map(label => (dataField[key] || {})[label] || 0)
}), {});
return {
labels,
...dataSets
Expand Down

0 comments on commit 1f7d07f

Please sign in to comment.