Skip to content
Snippets Groups Projects
Unverified Commit 9ee3a3f0 authored by Tom Robinson's avatar Tom Robinson
Browse files

Don't use 'Other' slice if there's only one. Resolves #2642

parent 0aa2df9e
Branches
Tags
No related merge requests found
......@@ -119,16 +119,20 @@ export default class PieChart extends Component<*, Props, *> {
.partition((d) => d.percentage > sliceThreshold)
.value();
let otherTotal = others.reduce((acc, o) => acc + o.value, 0);
let otherSlice;
if (otherTotal > 0) {
otherSlice = {
key: "Other",
value: otherTotal,
percentage: otherTotal / total,
color: "gray"
};
slices.push(otherSlice);
if (others.length > 1) {
let otherTotal = others.reduce((acc, o) => acc + o.value, 0);
if (otherTotal > 0) {
otherSlice = {
key: "Other",
value: otherTotal,
percentage: otherTotal / total,
color: "gray"
};
slices.push(otherSlice);
}
} else {
slices.push(...others);
}
// increase "other" slice so it's barely visible
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment