From 463cb7c1b1d6beeca84082566c0e568212f1d933 Mon Sep 17 00:00:00 2001 From: Jardel Bordignon Date: Sun, 15 Jan 2023 03:31:45 -0300 Subject: [PATCH] Fix uninitialized total variable when using in web --- src/PieChart/main.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PieChart/main.tsx b/src/PieChart/main.tsx index d524aa1..09ea105 100644 --- a/src/PieChart/main.tsx +++ b/src/PieChart/main.tsx @@ -142,7 +142,9 @@ export const PieChartMain = (props: propTypes) => { let minShiftX = 0, maxShiftX = 0, minShiftY = 0, - maxShiftY = 0; + maxShiftY = 0, + total = 0; + data.forEach((item: any) => { total += item.value; if (item.shiftX || item.shiftY) { @@ -172,7 +174,7 @@ export const PieChartMain = (props: propTypes) => { let cx = radius, cy = radius; - let total = + total = data && data.length ? data.map(item => item.value).reduce((v, a) => v + a) : 0;