Skip to content

Commit

Permalink
smoother handling for empty pie chart categories
Browse files Browse the repository at this point in the history
  • Loading branch information
gsfk committed Apr 20, 2022
1 parent 431e48e commit e91ca3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/mapNameValueFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export const mapNameValueFields = (data, otherThreshold) => {
const other = { name: "Other", value: 0, skipAutoquery: true };

Object.entries(data).forEach(([key, val]) => {
const categoryNotEmpty = val > 0;
if (val === 0) {
return; //continue
}
const categoryBelowThreshold = val / sumOfAllValues < otherThreshold;
if (multipleCategoriesBelowThreshold && categoryNotEmpty && categoryBelowThreshold) {
if (multipleCategoriesBelowThreshold && categoryBelowThreshold) {
other.value += val;
} else {
if (categoryNotEmpty) {
results.push({ name: key, value: val });
}
results.push({ name: key, value: val });
}
});

Expand Down

0 comments on commit e91ca3f

Please sign in to comment.