Merge pull request #170 from Abhinandan-Kushwaha/abhi

Fixed bug- Reduce of empty array with no initial value in piechart
This commit is contained in:
Abhinandan Kushwaha 2022-04-26 19:26:26 +05:30 committed by GitHub
commit f025469653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;