Fixed bug- Reduce of empty array with no initial value in piechart

This commit is contained in:
Abhinandan-Kushwaha 2022-04-26 19:25:32 +05:30
parent 27ebfd3adf
commit 331c76b69e
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "react-native-gifted-charts",
"version": "1.2.11",
"version": "1.2.12",
"description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
"main": "src/index.tsx",
"files": [

View File

@ -164,7 +164,10 @@ export const PieChart = (props: propTypes) => {
let cx = radius,
cy = radius;
let total = data.map(item => item.value).reduce((v, a) => v + a);
let total =
data && data.length
? data.map(item => item.value).reduce((v, a) => v + a)
: 0;
let acc = 0;
let pData = data.map(item => {
acc += item.value / total;