From cec1f37d19e04dd265ac465afee6fed3427e67b7 Mon Sep 17 00:00:00 2001 From: larianum Date: Tue, 15 Feb 2022 19:19:13 +0200 Subject: [PATCH] Adjustment for avoidFalseZero option --- src/PieChart.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/PieChart.tsx b/src/PieChart.tsx index 3e498ddc..918ca7e5 100644 --- a/src/PieChart.tsx +++ b/src/PieChart.tsx @@ -56,14 +56,10 @@ class PieChart extends AbstractChart { if (total === 0) { value = 0 + "%"; } else { - const percentage = Math.round( - (100 / total) * c.item[this.props.accessor] - ); + const percentage = (100 / total) * c.item[this.props.accessor]; value = Math.round((100 / total) * c.item[this.props.accessor]) + "%"; - if (avoidFalseZero && percentage === 0) { + if (avoidFalseZero && percentage > 0 && percentage < 0.5) { value = "<1%"; - } else { - value = percentage + "%"; } } }