react-native-gifted-charts 1.4.21 → 1.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  2. package/dist/BarChart/Animated2DWithGradient.js +113 -1
  3. package/dist/BarChart/RenderBars.d.ts +3 -0
  4. package/dist/BarChart/RenderBars.js +264 -1
  5. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  6. package/dist/BarChart/RenderStackBars.js +172 -1
  7. package/dist/BarChart/index.d.ts +2 -0
  8. package/dist/BarChart/index.js +233 -1
  9. package/dist/BarChart/styles.d.ts +45 -0
  10. package/dist/BarChart/styles.js +46 -1
  11. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  12. package/dist/Components/AnimatedThreeDBar/index.js +129 -1
  13. package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
  14. package/dist/Components/AnimatedThreeDBar/styles.js +13 -1
  15. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  16. package/dist/Components/BarAndLineChartsWrapper/index.js +128 -1
  17. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  18. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -1
  19. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -1
  21. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -1
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -1
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -1
  27. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -1
  29. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  30. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -1
  31. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  32. package/dist/Components/BarSpecificComponents/cap.js +16 -1
  33. package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
  34. package/dist/Components/BarSpecificComponents/tooltip.js +40 -1
  35. package/dist/Components/common/LinearGradient.d.ts +16 -0
  36. package/dist/Components/common/LinearGradient.js +15 -1
  37. package/dist/Components/common/Pointer.d.ts +1 -0
  38. package/dist/Components/common/Pointer.js +16 -1
  39. package/dist/Components/common/StripAndLabel.d.ts +1 -0
  40. package/dist/Components/common/StripAndLabel.js +43 -1
  41. package/dist/Components/lineSvg.d.ts +14 -0
  42. package/dist/Components/lineSvg.js +22 -1
  43. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  44. package/dist/LineChart/LineChartBicolor.js +294 -1
  45. package/dist/LineChart/index.d.ts +2 -0
  46. package/dist/LineChart/index.js +1089 -1
  47. package/dist/LineChart/styles.d.ts +43 -0
  48. package/dist/LineChart/styles.js +46 -1
  49. package/dist/PieChart/index.d.ts +2 -0
  50. package/dist/PieChart/index.js +99 -1
  51. package/dist/PieChart/main.d.ts +2 -0
  52. package/dist/PieChart/main.js +182 -1
  53. package/dist/PieChartPro/index.d.ts +2 -0
  54. package/dist/PieChartPro/index.js +124 -1
  55. package/dist/PopulationPyramid/index.d.ts +2 -0
  56. package/dist/PopulationPyramid/index.js +130 -1
  57. package/dist/index.d.ts +7 -0
  58. package/dist/index.js +7 -1
  59. package/dist/utils/index.d.ts +2 -0
  60. package/dist/utils/index.js +12 -1
  61. package/package.json +3 -3
@@ -0,0 +1,43 @@
1
+ export declare const styles: {
2
+ container: {
3
+ width: "100%";
4
+ marginBottom: number;
5
+ marginRight: number;
6
+ };
7
+ horizBar: {
8
+ flexDirection: "row";
9
+ };
10
+ leftLabel: {
11
+ justifyContent: "center";
12
+ alignItems: "center";
13
+ };
14
+ lastLeftLabel: {
15
+ justifyContent: "center";
16
+ alignItems: "center";
17
+ };
18
+ leftPart: {
19
+ justifyContent: "center";
20
+ };
21
+ lastLeftPart: {
22
+ justifyContent: "flex-end";
23
+ };
24
+ line: {
25
+ width: "100%";
26
+ height: number;
27
+ backgroundColor: string;
28
+ opacity: number;
29
+ };
30
+ lastLine: {
31
+ width: "100%";
32
+ height: number;
33
+ backgroundColor: string;
34
+ };
35
+ bottomLabel: {
36
+ width: "100%";
37
+ };
38
+ customDataPointContainer: {
39
+ position: "absolute";
40
+ justifyContent: "center";
41
+ alignItems: "center";
42
+ };
43
+ };
@@ -1 +1,46 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var styles=exports.styles=_reactNative.StyleSheet.create({container:{width:'100%',marginBottom:40,marginRight:40},horizBar:{flexDirection:'row'},leftLabel:{justifyContent:'center',alignItems:'center'},lastLeftLabel:{justifyContent:'center',alignItems:'center'},leftPart:{justifyContent:'center'},lastLeftPart:{justifyContent:'flex-end'},line:{width:'100%',height:1,backgroundColor:'gray',opacity:0.5},lastLine:{width:'100%',height:1,backgroundColor:'black'},bottomLabel:{width:'100%'},customDataPointContainer:{position:'absolute',justifyContent:'center',alignItems:'center'}});
1
+ import { StyleSheet } from 'react-native';
2
+ export var styles = StyleSheet.create({
3
+ container: {
4
+ width: '100%',
5
+ marginBottom: 40,
6
+ marginRight: 40,
7
+ },
8
+ horizBar: {
9
+ flexDirection: 'row',
10
+ },
11
+ leftLabel: {
12
+ justifyContent: 'center',
13
+ alignItems: 'center',
14
+ },
15
+ lastLeftLabel: {
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ },
19
+ leftPart: {
20
+ justifyContent: 'center',
21
+ // width: '100%',
22
+ },
23
+ lastLeftPart: {
24
+ justifyContent: 'flex-end',
25
+ // width: '100%',
26
+ },
27
+ line: {
28
+ width: '100%',
29
+ height: 1,
30
+ backgroundColor: 'gray',
31
+ opacity: 0.5,
32
+ },
33
+ lastLine: {
34
+ width: '100%',
35
+ height: 1,
36
+ backgroundColor: 'black',
37
+ },
38
+ bottomLabel: {
39
+ width: '100%',
40
+ },
41
+ customDataPointContainer: {
42
+ position: 'absolute',
43
+ justifyContent: 'center',
44
+ alignItems: 'center',
45
+ },
46
+ });
@@ -0,0 +1,2 @@
1
+ import { PieChartPropsType } from 'gifted-charts-core';
2
+ export declare const PieChart: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element | null;
@@ -1 +1,99 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PieChart=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _main=require("./main");var _giftedChartsCore=require("gifted-charts-core");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/abhinandankushwaha/sites/projects/react-native-gifted-charts/src/PieChart/index.tsx";var PieChart=exports.PieChart=function PieChart(props){var _usePieChart=(0,_giftedChartsCore.usePieChart)(props),radius=_usePieChart.radius,extraRadiusForFocused=_usePieChart.extraRadiusForFocused,selectedIndex=_usePieChart.selectedIndex,setSelectedIndex=_usePieChart.setSelectedIndex,startAngle=_usePieChart.startAngle,total=_usePieChart.total,donut=_usePieChart.donut,isThreeD=_usePieChart.isThreeD,semiCircle=_usePieChart.semiCircle,inwardExtraLengthForFocused=_usePieChart.inwardExtraLengthForFocused,canvasWidth=_usePieChart.canvasWidth,canvasHeight=_usePieChart.canvasHeight,innerRadius=_usePieChart.innerRadius,innerCircleColor=_usePieChart.innerCircleColor,innerCircleBorderWidth=_usePieChart.innerCircleBorderWidth,innerCircleBorderColor=_usePieChart.innerCircleBorderColor,shiftInnerCenterX=_usePieChart.shiftInnerCenterX,shiftInnerCenterY=_usePieChart.shiftInnerCenterY,tiltAngle=_usePieChart.tiltAngle,isDataShifted=_usePieChart.isDataShifted,paddingHorizontal=_usePieChart.paddingHorizontal,paddingVertical=_usePieChart.paddingVertical;var renderInnerCircle=function renderInnerCircle(innerRadius,innerCircleBorderWidth){if(props.centerLabelComponent||donut&&!isDataShifted){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{height:innerRadius*2,width:innerRadius*2,borderRadius:innerRadius,position:'absolute',alignSelf:'center',backgroundColor:innerCircleColor,left:canvasWidth/2-innerRadius+shiftInnerCenterX+extraRadiusForFocused+paddingHorizontal/2,top:canvasHeight/2-innerRadius+shiftInnerCenterY+extraRadiusForFocused+paddingVertical/2,borderWidth:innerCircleBorderWidth,borderColor:innerCircleBorderColor,justifyContent:'center',alignItems:'center'},isThreeD&&{borderTopWidth:innerCircleBorderWidth*5,borderLeftWidth:shiftInnerCenterX?innerCircleBorderWidth*2:innerCircleBorderWidth,transform:[{rotateX:tiltAngle}]},semiCircle&&isThreeD&&{borderTopWidth:isThreeD?innerCircleBorderWidth*5:innerCircleBorderWidth,borderLeftWidth:0.5,borderLeftColor:innerCircleColor,borderBottomWidth:0,borderRightWidth:0.5,borderRightColor:innerCircleColor}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:semiCircle?-0.5*innerRadius:0},children:props.centerLabelComponent?props.centerLabelComponent():null})});}return null;};if(!total)return null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:(radius+extraRadiusForFocused+paddingVertical/2)*(props.semiCircle?1:2),width:(radius+extraRadiusForFocused+paddingHorizontal/2)*2,overflow:'hidden'},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:'absolute'},children:(0,_jsxRuntime.jsx)(_main.PieChartMain,Object.assign({},props,{selectedIndex:selectedIndex,setSelectedIndex:setSelectedIndex,paddingHorizontal:paddingHorizontal,paddingVertical:paddingVertical,extraRadiusForFocused:extraRadiusForFocused}))}),renderInnerCircle(innerRadius,innerCircleBorderWidth),props.data.length>1&&props.data[selectedIndex]&&(props.focusOnPress||props.sectionAutoFocus)&&selectedIndex!==-1&&(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:{position:'absolute',top:-extraRadiusForFocused,left:-extraRadiusForFocused},children:(0,_jsxRuntime.jsx)(_main.PieChartMain,Object.assign({},props,{data:[{value:props.data[selectedIndex].value,text:props.data[selectedIndex].text,color:props.data[selectedIndex].color||_giftedChartsCore.pieColors[selectedIndex%9],strokeColor:props.data[selectedIndex].strokeColor||undefined,strokeWidth:props.data[selectedIndex].strokeWidth||undefined,gradientCenterColor:props.data[selectedIndex].gradientCenterColor||undefined,shiftTextX:props.data[selectedIndex].shiftTextX||undefined,shiftTextY:props.data[selectedIndex].shiftTextY||undefined},{value:total-props.data[selectedIndex].value,onPress:function onPress(){return alert('black');},peripheral:true,strokeWidth:0}],radius:radius+extraRadiusForFocused,initialAngle:startAngle,innerRadius:props.innerRadius||radius/2.5,isBiggerPie:true,setSelectedIndex:setSelectedIndex,paddingHorizontal:paddingHorizontal,paddingVertical:paddingVertical,extraRadiusForFocused:extraRadiusForFocused}))}),renderInnerCircle(innerRadius-inwardExtraLengthForFocused,inwardExtraLengthForFocused?0:innerCircleBorderWidth)]});};
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { View } from 'react-native';
14
+ import { PieChartMain } from './main';
15
+ import { pieColors, usePieChart } from 'gifted-charts-core';
16
+ export var PieChart = function (props) {
17
+ var _a = usePieChart(props), radius = _a.radius, extraRadiusForFocused = _a.extraRadiusForFocused, selectedIndex = _a.selectedIndex, setSelectedIndex = _a.setSelectedIndex, startAngle = _a.startAngle, total = _a.total, donut = _a.donut, isThreeD = _a.isThreeD, semiCircle = _a.semiCircle, inwardExtraLengthForFocused = _a.inwardExtraLengthForFocused, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight, innerRadius = _a.innerRadius, innerCircleColor = _a.innerCircleColor, innerCircleBorderWidth = _a.innerCircleBorderWidth, innerCircleBorderColor = _a.innerCircleBorderColor, shiftInnerCenterX = _a.shiftInnerCenterX, shiftInnerCenterY = _a.shiftInnerCenterY, tiltAngle = _a.tiltAngle, isDataShifted = _a.isDataShifted, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical;
18
+ var renderInnerCircle = function (innerRadius, innerCircleBorderWidth) {
19
+ if (props.centerLabelComponent || (donut && !isDataShifted)) {
20
+ return (_jsx(View, { style: [
21
+ {
22
+ height: innerRadius * 2,
23
+ width: innerRadius * 2,
24
+ borderRadius: innerRadius,
25
+ position: 'absolute',
26
+ // zIndex: 100,
27
+ alignSelf: 'center',
28
+ backgroundColor: innerCircleColor,
29
+ left: canvasWidth / 2 -
30
+ innerRadius +
31
+ shiftInnerCenterX +
32
+ extraRadiusForFocused +
33
+ paddingHorizontal / 2,
34
+ top: canvasHeight / 2 -
35
+ innerRadius +
36
+ shiftInnerCenterY +
37
+ extraRadiusForFocused +
38
+ paddingVertical / 2,
39
+ borderWidth: innerCircleBorderWidth,
40
+ borderColor: innerCircleBorderColor,
41
+ justifyContent: 'center',
42
+ alignItems: 'center',
43
+ },
44
+ isThreeD && {
45
+ borderTopWidth: innerCircleBorderWidth * 5,
46
+ borderLeftWidth: shiftInnerCenterX
47
+ ? innerCircleBorderWidth * 2
48
+ : innerCircleBorderWidth,
49
+ transform: [{ rotateX: tiltAngle }],
50
+ },
51
+ semiCircle &&
52
+ isThreeD && {
53
+ borderTopWidth: isThreeD
54
+ ? innerCircleBorderWidth * 5
55
+ : innerCircleBorderWidth,
56
+ borderLeftWidth: 0.5,
57
+ borderLeftColor: innerCircleColor,
58
+ borderBottomWidth: 0,
59
+ borderRightWidth: 0.5,
60
+ borderRightColor: innerCircleColor,
61
+ },
62
+ ], children: _jsx(View, { style: { marginTop: semiCircle ? -0.5 * innerRadius : 0 }, children: props.centerLabelComponent ? props.centerLabelComponent() : null }) }));
63
+ }
64
+ return null;
65
+ };
66
+ if (!total)
67
+ return null;
68
+ return (_jsxs(View, { style: {
69
+ height: (radius + extraRadiusForFocused + paddingVertical / 2) *
70
+ (props.semiCircle ? 1 : 2),
71
+ width: (radius + extraRadiusForFocused + paddingHorizontal / 2) * 2,
72
+ overflow: 'hidden',
73
+ }, children: [_jsx(View, { style: { position: 'absolute' }, children: _jsx(PieChartMain, __assign({}, props, { selectedIndex: selectedIndex, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadiusForFocused: extraRadiusForFocused })) }), renderInnerCircle(innerRadius, innerCircleBorderWidth), props.data.length > 1 &&
74
+ props.data[selectedIndex] && // don't forget to add this one so there are no errors when the data is empty / updating
75
+ (props.focusOnPress || props.sectionAutoFocus) &&
76
+ selectedIndex !== -1 && (_jsx(View, { pointerEvents: "box-none", style: {
77
+ position: 'absolute',
78
+ top: -extraRadiusForFocused,
79
+ left: -extraRadiusForFocused,
80
+ }, children: _jsx(PieChartMain, __assign({}, props, { data: [
81
+ {
82
+ value: props.data[selectedIndex].value,
83
+ text: props.data[selectedIndex].text,
84
+ color: props.data[selectedIndex].color ||
85
+ pieColors[selectedIndex % 9],
86
+ strokeColor: props.data[selectedIndex].strokeColor || undefined,
87
+ strokeWidth: props.data[selectedIndex].strokeWidth || undefined,
88
+ gradientCenterColor: props.data[selectedIndex].gradientCenterColor || undefined,
89
+ shiftTextX: props.data[selectedIndex].shiftTextX || undefined,
90
+ shiftTextY: props.data[selectedIndex].shiftTextY || undefined,
91
+ },
92
+ {
93
+ value: total - props.data[selectedIndex].value,
94
+ onPress: function () { return alert('black'); },
95
+ peripheral: true,
96
+ strokeWidth: 0,
97
+ },
98
+ ], radius: radius + extraRadiusForFocused, initialAngle: startAngle, innerRadius: props.innerRadius || radius / 2.5, isBiggerPie: true, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadiusForFocused: extraRadiusForFocused })) })), renderInnerCircle(innerRadius - inwardExtraLengthForFocused, inwardExtraLengthForFocused ? 0 : innerCircleBorderWidth)] }));
99
+ };
@@ -0,0 +1,2 @@
1
+ import { PieChartMainProps } from 'gifted-charts-core';
2
+ export declare const PieChartMain: (props: PieChartMainProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1,182 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PieChartMain=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _reactNativeSvg=_interopRequireWildcard(require("react-native-svg"));var _giftedChartsCore=require("gifted-charts-core");var _utils=require("../utils");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/abhinandankushwaha/sites/projects/react-native-gifted-charts/src/PieChart/main.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var PieChartMain=exports.PieChartMain=function PieChartMain(props){var _getPieChartMainProps=(0,_giftedChartsCore.getPieChartMainProps)(props),isThreeD=_getPieChartMainProps.isThreeD,isBiggerPie=_getPieChartMainProps.isBiggerPie,data=_getPieChartMainProps.data,showInnerComponent=_getPieChartMainProps.showInnerComponent,radius=_getPieChartMainProps.radius,canvasWidth=_getPieChartMainProps.canvasWidth,canvasHeight=_getPieChartMainProps.canvasHeight,shadowWidth=_getPieChartMainProps.shadowWidth,backgroundColor=_getPieChartMainProps.backgroundColor,shadowColor=_getPieChartMainProps.shadowColor,semiCircle=_getPieChartMainProps.semiCircle,pi=_getPieChartMainProps.pi,initialAngle=_getPieChartMainProps.initialAngle,shadow=_getPieChartMainProps.shadow,donut=_getPieChartMainProps.donut,strokeWidth=_getPieChartMainProps.strokeWidth,strokeColor=_getPieChartMainProps.strokeColor,innerRadius=_getPieChartMainProps.innerRadius,showText=_getPieChartMainProps.showText,textColor=_getPieChartMainProps.textColor,textSize=_getPieChartMainProps.textSize,tiltAngle=_getPieChartMainProps.tiltAngle,labelsPosition=_getPieChartMainProps.labelsPosition,showTextBackground=_getPieChartMainProps.showTextBackground,textBackgroundColor=_getPieChartMainProps.textBackgroundColor,showValuesAsLabels=_getPieChartMainProps.showValuesAsLabels,showGradient=_getPieChartMainProps.showGradient,gradientCenterColor=_getPieChartMainProps.gradientCenterColor,toggleFocusOnPress=_getPieChartMainProps.toggleFocusOnPress,minShiftX=_getPieChartMainProps.minShiftX,minShiftY=_getPieChartMainProps.minShiftY,total=_getPieChartMainProps.total,horizAdjustment=_getPieChartMainProps.horizAdjustment,vertAdjustment=_getPieChartMainProps.vertAdjustment,cx=_getPieChartMainProps.cx,cy=_getPieChartMainProps.cy,pData=_getPieChartMainProps.pData,mData=_getPieChartMainProps.mData,paddingHorizontal=_getPieChartMainProps.paddingHorizontal,paddingVertical=_getPieChartMainProps.paddingVertical,extraRadiusForFocused=_getPieChartMainProps.extraRadiusForFocused;return(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"box-none",style:[{backgroundColor:backgroundColor,height:semiCircle?(canvasHeight+paddingVertical)/2+extraRadiusForFocused:canvasHeight+paddingVertical+extraRadiusForFocused*2,width:canvasWidth+paddingHorizontal+extraRadiusForFocused*2,overflow:'hidden'},isThreeD&&{transform:[{rotateX:tiltAngle}]}],children:[(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{pointerEvents:_utils.rnVersion>=720000?'box-none':'auto',viewBox:`${strokeWidth/-2+minShiftX-extraRadiusForFocused-paddingHorizontal/2} ${strokeWidth/-2+minShiftY-extraRadiusForFocused-paddingVertical/2} ${(radius+extraRadiusForFocused+strokeWidth)*2+paddingHorizontal+horizAdjustment+(horizAdjustment?strokeWidth:0)} ${(radius+extraRadiusForFocused+strokeWidth)*2+paddingVertical+vertAdjustment+(vertAdjustment?strokeWidth:0)}`,height:(radius+extraRadiusForFocused)*2+strokeWidth+paddingVertical,width:(radius+extraRadiusForFocused)*2+strokeWidth+paddingHorizontal,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Defs,{children:data.map(function(item,index){return(0,_jsxRuntime.jsxs)(_reactNativeSvg.RadialGradient,{id:'grad'+index,cx:"50%",cy:"50%",rx:"50%",ry:"50%",fx:"50%",fy:"50%",gradientUnits:"userSpaceOnUse",children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"0%",stopColor:item.gradientCenterColor||gradientCenterColor,stopOpacity:"1"}),(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"100%",stopColor:item.color||_giftedChartsCore.pieColors[index%9],stopOpacity:"1"})]},index+'');})}),data.length===1?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Circle,{cx:cx,cy:cy,r:radius,fill:showGradient?`url(#grad${0})`:data[0].color||_giftedChartsCore.pieColors[0%9],onPress:function onPress(){data[0].onPress?data[0].onPress():props.onPress?props.onPress(data[0],0):null;}})}):data.map(function(item,index){var nextItem;if(index===pData.length-1)nextItem=pData[0];else nextItem=pData[index+1];var sx=cx*(1+Math.sin(2*pi*pData[index]+initialAngle))+(item.shiftX||0);var sy=cy*(1-Math.cos(2*pi*pData[index]+initialAngle))+(item.shiftY||0);var ax=cx*(1+Math.sin(2*pi*nextItem+initialAngle))+(item.shiftX||0);var ay=cy*(1-Math.cos(2*pi*nextItem+initialAngle))+(item.shiftY||0);if(isBiggerPie&&index)return null;return(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:`M ${cx+(item.shiftX||0)} ${cy+(item.shiftY||0)} L ${sx} ${sy} A ${radius} ${radius} 0 ${semiCircle?0:data[index].value>total/2?1:0} 1 ${ax} ${ay} L ${cx+(item.shiftX||0)} ${cy+(item.shiftY||0)}`,stroke:item.strokeColor||strokeColor,strokeWidth:props.focusOnPress&&props.selectedIndex===index?0:item.strokeWidth===0?0:item.strokeWidth||strokeWidth,fill:props.selectedIndex===index||item.peripheral?'transparent':showGradient?`url(#grad${index})`:item.color||_giftedChartsCore.pieColors[index%9],onPress:function onPress(){if(item.onPress){item.onPress();}else if(props.onPress){props.onPress(item,index);}if(props.focusOnPress){if(props.selectedIndex===index||props.isBiggerPie){if(toggleFocusOnPress){props.setSelectedIndex(-1);}}else{props.setSelectedIndex(index);}}}},index+'a');}),(showText||showInnerComponent)&&data.map(function(item,index){var _item$pieInnerCompone,_ref,_item$shiftTextBackgr,_ref2,_item$shiftTextBackgr2,_localPieInnerCompone;var localPieInnerComponent=(_item$pieInnerCompone=item.pieInnerComponent)!=null?_item$pieInnerCompone:props.pieInnerComponent;if(isBiggerPie&&index)return null;if(!props.data[index].value)return null;var mx=cx*(1+Math.sin(2*pi*mData[index]+initialAngle));var my=cy*(1-Math.cos(2*pi*mData[index]+initialAngle));var midx=(mx+cx)/2;var midy=(my+cy)/2;var x=midx,y=midy;var labelPosition=item.labelPosition||labelsPosition;if(labelPosition==='onBorder'){x=mx;y=my;}else if(labelPosition==='outward'){x=(midx+mx)/2;y=(midy+my)/2;}else if(labelPosition==='inward'){x=(midx+cx)/2;y=(midy+cy)/2;}x+=item.shiftX||0;y+=item.shiftY||0;if(data.length===1){if(donut){y=(radius-innerRadius+(item.textBackgroundRadius||props.textBackgroundRadius||item.textSize||textSize))/2;}else{y=cy;}}return(0,_jsxRuntime.jsxs)(_react.default.Fragment,{children:[showTextBackground?(0,_jsxRuntime.jsx)(_reactNativeSvg.Circle,{cx:x+((_ref=(_item$shiftTextBackgr=item.shiftTextBackgroundX)!=null?_item$shiftTextBackgr:item.shiftTextX)!=null?_ref:0),cy:y+((_ref2=(_item$shiftTextBackgr2=item.shiftTextBackgroundY)!=null?_item$shiftTextBackgr2:item.shiftTextY)!=null?_ref2:0)-(item.textSize||textSize)/4,r:item.textBackgroundRadius||props.textBackgroundRadius||item.textSize||textSize,fill:item.textBackgroundColor||textBackgroundColor,onPress:function onPress(){item.onLabelPress?item.onLabelPress():props.onLabelPress?props.onLabelPress(item,index):item.onPress?item.onPress():props.onPress?props.onPress(item,index):null;if(props.focusOnPress){if(props.selectedIndex===index){if(toggleFocusOnPress){props.setSelectedIndex(-1);}}else{props.setSelectedIndex(index);}}}}):null,(0,_jsxRuntime.jsx)(_reactNativeSvg.Text,{fill:item.textColor||textColor||_giftedChartsCore.pieColors[(index+2)%9],fontSize:item.textSize||textSize,fontFamily:item.font||props.font,fontWeight:item.fontWeight||props.fontWeight,fontStyle:item.fontStyle||props.fontStyle||'normal',x:x+(item.shiftTextX||0)-(item.textSize||textSize)/1.8,y:y+(item.shiftTextY||0),onPress:function onPress(){item.onLabelPress?item.onLabelPress():props.onLabelPress?props.onLabelPress(item,index):item.onPress?item.onPress():props.onPress?props.onPress(item,index):null;if(props.focusOnPress){if(props.selectedIndex===index){if(toggleFocusOnPress){props.setSelectedIndex(-1);}}else{props.setSelectedIndex(index);}}},children:item.text||(showValuesAsLabels?item.value+'':'')}),localPieInnerComponent?(0,_jsxRuntime.jsx)(_reactNativeSvg.G,{x:x,y:y,children:(_localPieInnerCompone=localPieInnerComponent==null?void 0:localPieInnerComponent(item,index))!=null?_localPieInnerCompone:null}):null]},index);})]}),isThreeD&&shadow&&!semiCircle?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:radius*2,height:radius*2,backgroundColor:shadowColor,borderRadius:radius,position:'absolute',top:shadowWidth+paddingVertical/2,left:paddingHorizontal/2,zIndex:-1}}):null]});};
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { View } from 'react-native';
4
+ import Svg, { Path, Circle, Text as SvgText, Defs, RadialGradient, Stop, G, } from 'react-native-svg';
5
+ import { getPieChartMainProps, pieColors, } from 'gifted-charts-core';
6
+ import { rnVersion } from '../utils';
7
+ export var PieChartMain = function (props) {
8
+ var _a = getPieChartMainProps(props), isThreeD = _a.isThreeD, isBiggerPie = _a.isBiggerPie, data = _a.data, showInnerComponent = _a.showInnerComponent, radius = _a.radius, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight, shadowWidth = _a.shadowWidth, backgroundColor = _a.backgroundColor, shadowColor = _a.shadowColor, semiCircle = _a.semiCircle, pi = _a.pi, initialAngle = _a.initialAngle, shadow = _a.shadow, donut = _a.donut, strokeWidth = _a.strokeWidth, strokeColor = _a.strokeColor, innerRadius = _a.innerRadius, showText = _a.showText, textColor = _a.textColor, textSize = _a.textSize, tiltAngle = _a.tiltAngle, labelsPosition = _a.labelsPosition, showTextBackground = _a.showTextBackground, textBackgroundColor = _a.textBackgroundColor, showValuesAsLabels = _a.showValuesAsLabels, showGradient = _a.showGradient, gradientCenterColor = _a.gradientCenterColor, toggleFocusOnPress = _a.toggleFocusOnPress, minShiftX = _a.minShiftX, minShiftY = _a.minShiftY, total = _a.total, horizAdjustment = _a.horizAdjustment, vertAdjustment = _a.vertAdjustment, cx = _a.cx, cy = _a.cy, pData = _a.pData, mData = _a.mData, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical, extraRadiusForFocused = _a.extraRadiusForFocused;
9
+ return (_jsxs(View, { pointerEvents: "box-none", style: [
10
+ {
11
+ backgroundColor: backgroundColor,
12
+ height: semiCircle
13
+ ? (canvasHeight + paddingVertical) / 2 + extraRadiusForFocused
14
+ : canvasHeight + paddingVertical + extraRadiusForFocused * 2,
15
+ width: canvasWidth + paddingHorizontal + extraRadiusForFocused * 2,
16
+ overflow: 'hidden',
17
+ },
18
+ isThreeD && { transform: [{ rotateX: tiltAngle }] },
19
+ ], children: [_jsxs(Svg, { pointerEvents: rnVersion >= 720000 ? 'box-none' : 'auto', viewBox: "".concat(strokeWidth / -2 + minShiftX - extraRadiusForFocused - paddingHorizontal / 2, " ").concat(strokeWidth / -2 +
20
+ minShiftY -
21
+ extraRadiusForFocused -
22
+ paddingVertical / 2, " ").concat((radius + extraRadiusForFocused + strokeWidth) * 2 +
23
+ paddingHorizontal +
24
+ horizAdjustment +
25
+ (horizAdjustment ? strokeWidth : 0), " ").concat((radius + extraRadiusForFocused + strokeWidth) * 2 +
26
+ paddingVertical +
27
+ vertAdjustment +
28
+ (vertAdjustment ? strokeWidth : 0)), height: (radius + extraRadiusForFocused) * 2 + strokeWidth + paddingVertical, width: (radius + extraRadiusForFocused) * 2 + strokeWidth + paddingHorizontal, children: [_jsx(Defs, { children: data.map(function (item, index) {
29
+ return (_jsxs(RadialGradient, { id: 'grad' + index, cx: "50%", cy: "50%", rx: "50%", ry: "50%", fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: item.gradientCenterColor || gradientCenterColor, stopOpacity: "1" }), _jsx(Stop, { offset: "100%", stopColor: item.color || pieColors[index % 9], stopOpacity: "1" })] }, index + ''));
30
+ }) }), data.length === 1 ? (_jsx(_Fragment, { children: _jsx(Circle, { cx: cx, cy: cy, r: radius, fill: showGradient
31
+ ? "url(#grad".concat(0, ")")
32
+ : data[0].color || pieColors[0 % 9], onPress: function () {
33
+ data[0].onPress
34
+ ? data[0].onPress()
35
+ : props.onPress
36
+ ? props.onPress(data[0], 0)
37
+ : null;
38
+ } }) })) : (data.map(function (item, index) {
39
+ // console.log('index', index);
40
+ var nextItem;
41
+ if (index === pData.length - 1)
42
+ nextItem = pData[0];
43
+ else
44
+ nextItem = pData[index + 1];
45
+ var sx = cx * (1 + Math.sin(2 * pi * pData[index] + initialAngle)) +
46
+ (item.shiftX || 0);
47
+ var sy = cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
48
+ (item.shiftY || 0);
49
+ var ax = cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
50
+ (item.shiftX || 0);
51
+ var ay = cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
52
+ (item.shiftY || 0);
53
+ if (isBiggerPie && index)
54
+ return null;
55
+ return (_jsx(Path, { d: "M ".concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0), " L ").concat(sx, " ").concat(sy, " A ").concat(radius, " ").concat(radius, " 0 ").concat(semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0, " 1 ").concat(ax, " ").concat(ay, " L ").concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0)), stroke: item.strokeColor || strokeColor, strokeWidth: props.focusOnPress && props.selectedIndex === index
56
+ ? 0
57
+ : item.strokeWidth === 0
58
+ ? 0
59
+ : item.strokeWidth || strokeWidth, fill: props.selectedIndex === index || item.peripheral
60
+ ? 'transparent'
61
+ : showGradient
62
+ ? "url(#grad".concat(index, ")")
63
+ : item.color || pieColors[index % 9], onPress: function () {
64
+ if (item.onPress) {
65
+ item.onPress();
66
+ }
67
+ else if (props.onPress) {
68
+ props.onPress(item, index);
69
+ }
70
+ if (props.focusOnPress) {
71
+ if (props.selectedIndex === index || props.isBiggerPie) {
72
+ if (toggleFocusOnPress) {
73
+ props.setSelectedIndex(-1);
74
+ }
75
+ }
76
+ else {
77
+ props.setSelectedIndex(index);
78
+ }
79
+ }
80
+ } }, index + 'a'));
81
+ })), (showText || showInnerComponent) &&
82
+ data.map(function (item, index) {
83
+ var _a, _b, _c, _d, _e, _f;
84
+ var localPieInnerComponent = (_a = item.pieInnerComponent) !== null && _a !== void 0 ? _a : props.pieInnerComponent;
85
+ if (isBiggerPie && index)
86
+ return null;
87
+ if (!props.data[index].value)
88
+ return null;
89
+ var mx = cx * (1 + Math.sin(2 * pi * mData[index] + initialAngle));
90
+ var my = cy * (1 - Math.cos(2 * pi * mData[index] + initialAngle));
91
+ var midx = (mx + cx) / 2;
92
+ var midy = (my + cy) / 2;
93
+ var x = midx, y = midy;
94
+ var labelPosition = item.labelPosition || labelsPosition;
95
+ if (labelPosition === 'onBorder') {
96
+ x = mx;
97
+ y = my;
98
+ }
99
+ else if (labelPosition === 'outward') {
100
+ x = (midx + mx) / 2;
101
+ y = (midy + my) / 2;
102
+ }
103
+ else if (labelPosition === 'inward') {
104
+ x = (midx + cx) / 2;
105
+ y = (midy + cy) / 2;
106
+ }
107
+ x += item.shiftX || 0;
108
+ y += item.shiftY || 0;
109
+ if (data.length === 1) {
110
+ if (donut) {
111
+ y =
112
+ (radius -
113
+ innerRadius +
114
+ (item.textBackgroundRadius ||
115
+ props.textBackgroundRadius ||
116
+ item.textSize ||
117
+ textSize)) /
118
+ 2;
119
+ }
120
+ else {
121
+ y = cy;
122
+ }
123
+ }
124
+ return (_jsxs(React.Fragment, { children: [showTextBackground ? (_jsx(Circle, { cx: x + ((_c = (_b = item.shiftTextBackgroundX) !== null && _b !== void 0 ? _b : item.shiftTextX) !== null && _c !== void 0 ? _c : 0), cy: y +
125
+ ((_e = (_d = item.shiftTextBackgroundY) !== null && _d !== void 0 ? _d : item.shiftTextY) !== null && _e !== void 0 ? _e : 0) -
126
+ (item.textSize || textSize) / 4, r: item.textBackgroundRadius ||
127
+ props.textBackgroundRadius ||
128
+ item.textSize ||
129
+ textSize, fill: item.textBackgroundColor || textBackgroundColor, onPress: function () {
130
+ item.onLabelPress
131
+ ? item.onLabelPress()
132
+ : props.onLabelPress
133
+ ? props.onLabelPress(item, index)
134
+ : item.onPress
135
+ ? item.onPress()
136
+ : props.onPress
137
+ ? props.onPress(item, index)
138
+ : null;
139
+ if (props.focusOnPress) {
140
+ if (props.selectedIndex === index) {
141
+ if (toggleFocusOnPress) {
142
+ props.setSelectedIndex(-1);
143
+ }
144
+ }
145
+ else {
146
+ props.setSelectedIndex(index);
147
+ }
148
+ }
149
+ } })) : null, _jsx(SvgText, { fill: item.textColor || textColor || pieColors[(index + 2) % 9], fontSize: item.textSize || textSize, fontFamily: item.font || props.font, fontWeight: item.fontWeight || props.fontWeight, fontStyle: item.fontStyle || props.fontStyle || 'normal', x: x +
150
+ (item.shiftTextX || 0) -
151
+ (item.textSize || textSize) / 1.8, y: y + (item.shiftTextY || 0), onPress: function () {
152
+ item.onLabelPress
153
+ ? item.onLabelPress()
154
+ : props.onLabelPress
155
+ ? props.onLabelPress(item, index)
156
+ : item.onPress
157
+ ? item.onPress()
158
+ : props.onPress
159
+ ? props.onPress(item, index)
160
+ : null;
161
+ if (props.focusOnPress) {
162
+ if (props.selectedIndex === index) {
163
+ if (toggleFocusOnPress) {
164
+ props.setSelectedIndex(-1);
165
+ }
166
+ }
167
+ else {
168
+ props.setSelectedIndex(index);
169
+ }
170
+ }
171
+ }, children: item.text || (showValuesAsLabels ? item.value + '' : '') }), localPieInnerComponent ? (_jsx(G, { x: x, y: y, children: (_f = localPieInnerComponent === null || localPieInnerComponent === void 0 ? void 0 : localPieInnerComponent(item, index)) !== null && _f !== void 0 ? _f : null })) : null] }, index));
172
+ })] }), isThreeD && shadow && !semiCircle ? (_jsx(View, { style: {
173
+ width: radius * 2,
174
+ height: radius * 2,
175
+ backgroundColor: shadowColor,
176
+ borderRadius: radius,
177
+ position: 'absolute',
178
+ top: shadowWidth + paddingVertical / 2,
179
+ left: paddingHorizontal / 2,
180
+ zIndex: -1,
181
+ } })) : null] }));
182
+ };
@@ -0,0 +1,2 @@
1
+ import { PieChartPropsType } from 'gifted-charts-core';
2
+ export declare const PieChartPro: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1,124 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.PieChartPro=void 0;var _react=_interopRequireWildcard(require("react"));var _giftedChartsCore=require("gifted-charts-core");var _reactNativeSvg=require("react-native-svg");var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/abhinandankushwaha/sites/projects/react-native-gifted-charts/src/PieChartPro/index.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var PieChartPro=exports.PieChartPro=function PieChartPro(props){var _usePiePro=(0,_giftedChartsCore.usePiePro)(props),radius=_usePiePro.radius,total=_usePiePro.total,donut=_usePiePro.donut,strokeWidth=_usePiePro.strokeWidth,maxStrokeWidth=_usePiePro.maxStrokeWidth,animationDuration=_usePiePro.animationDuration,initial=_usePiePro.initial,dInitial=_usePiePro.dInitial,dFinal=_usePiePro.dFinal,getStartCaps=_usePiePro.getStartCaps,getEndCaps=_usePiePro.getEndCaps,getTextCoordinates=_usePiePro.getTextCoordinates,height=_usePiePro.height,heightFactor=_usePiePro.heightFactor,svgProps=_usePiePro.svgProps;var data=props.data,curvedStartEdges=props.curvedStartEdges,curvedEndEdges=props.curvedEndEdges,_props$edgesRadius=props.edgesRadius,edgesRadius=_props$edgesRadius===void 0?0:_props$edgesRadius,showGradient=props.showGradient,ring=props.ring,centerLabelComponent=props.centerLabelComponent,strokeDashArray=props.strokeDashArray,semiCircle=props.semiCircle;var isAnimated=props.isAnimated;if(!props.semiCircle&&data.some(function(dataItem){return dataItem.value>total/2;})){isAnimated=false;}var AnimatedPath=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Path);var AnimatedText=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Text);var animatedValues=data.map(function(i){return new _reactNative.Animated.Value(0);});var animatedOpacityValue=new _reactNative.Animated.Value(0);var animatedPaths=data.map(function(item,index){var _animatedValues$index;return(_animatedValues$index=animatedValues[index])==null?void 0:_animatedValues$index.interpolate({inputRange:[0,1],outputRange:[dInitial[index],dFinal[index]]});});var animatedOpacity=animatedOpacityValue.interpolate({inputRange:[0,1],outputRange:[0,1]});(0,_react.useEffect)(function(){_reactNative.Animated.timing(animatedOpacityValue,{toValue:1,duration:10,useNativeDriver:true,delay:animationDuration}).start();animatedValues.forEach(function(animatedValue){return _reactNative.Animated.timing(animatedValue,{toValue:1,duration:animationDuration,useNativeDriver:true}).start();});},[data]);var adjustHeight=height*heightFactor;var rnSvgProps=semiCircle?{}:svgProps;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{display:'flex',justifyContent:'center',alignItems:'center',height:adjustHeight,width:height*2},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:semiCircle?{position:'absolute',bottom:0}:{position:'absolute'},children:centerLabelComponent?centerLabelComponent():null}),(0,_jsxRuntime.jsx)(_reactNativeSvg.Svg,Object.assign({},rnSvgProps,{viewBox:semiCircle?``:`${-maxStrokeWidth*1.5} ${-maxStrokeWidth-(semiCircle?height/2:0)} ${adjustHeight} ${adjustHeight}`,transform:semiCircle?[]:[{scaleY:maxStrokeWidth?1+maxStrokeWidth/(radius*2):1}],children:total?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Defs,{children:data.map(function(item,index){return(0,_jsxRuntime.jsxs)(_reactNativeSvg.RadialGradient,{id:'grad'+index,cx:"50%",cy:"50%",rx:"50%",ry:"50%",fx:"50%",fy:"50%",gradientUnits:"userSpaceOnUse",children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"0%",stopColor:item.gradientCenterColor,stopOpacity:"1"}),(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"100%",stopColor:item.color||_giftedChartsCore.pieColors[index%9],stopOpacity:"1"})]},index+'');})}),data.map(function(item,index){var _item$strokeWidth,_ref,_item$strokeColor,_item$strokeDashArray;var borderWidth=(_item$strokeWidth=item.strokeWidth)!=null?_item$strokeWidth:strokeWidth;var borderColor=(_ref=(_item$strokeColor=item.strokeColor)!=null?_item$strokeColor:props.strokeColor)!=null?_ref:borderWidth?'black':'transparent';var strokeDashArrayLocal=(_item$strokeDashArray=item.strokeDashArray)!=null?_item$strokeDashArray:strokeDashArray;return(0,_jsxRuntime.jsx)(AnimatedPath,{id:"renderPath",d:isAnimated?animatedPaths[index]:dFinal[index],fill:ring?'transparent':showGradient?`url(#grad${index})`:data[index].color||_giftedChartsCore.pieColors[index%9],strokeWidth:borderWidth,strokeDasharray:strokeDashArrayLocal,stroke:borderColor},`path${index}`);}),donut?data.map(function(item,index){if(curvedStartEdges||edgesRadius||item.isStartEdgeCurved||item.startEdgeRadius)return(0,_jsxRuntime.jsx)(AnimatedPath,{d:`${initial} ${getStartCaps(index,item)}`,opacity:isAnimated?animatedOpacity:1,fill:showGradient?`url(#grad${index})`:data[index].color||_giftedChartsCore.pieColors[index%9]},`cap${index}`);return null;}):null,donut?data.map(function(item,index){if(curvedEndEdges||edgesRadius||item.isEndEdgeCurved||item.endEdgeRadius)return(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:`${initial} ${getEndCaps(index,item)}`,fill:showGradient?`url(#grad${index})`:data[index].color||_giftedChartsCore.pieColors[index%9]},`cap${index}`);return null;}):null,data.map(function(item,index){var _ref2,_item$textSize;var _getTextCoordinates=getTextCoordinates(index,item.labelPosition),x=_getTextCoordinates.x,y=_getTextCoordinates.y;return(0,_jsxRuntime.jsx)(AnimatedText,{fill:item.textColor||props.textColor||_giftedChartsCore.pieColors[(index+2)%9],opacity:isAnimated?animatedOpacity:1,fontSize:item.textSize||props.textSize,fontFamily:item.font||props.font,fontWeight:item.fontWeight||props.fontWeight,fontStyle:item.fontStyle||props.fontStyle||'normal',x:x+(item.shiftTextX||0)-((_ref2=(_item$textSize=item.textSize)!=null?_item$textSize:props.textSize)!=null?_ref2:0)/1.8,y:y+(item.shiftTextY||0),onPress:function onPress(){item.onLabelPress?item.onLabelPress():props.onLabelPress?props.onLabelPress(item,index):item.onPress?item.onPress():props.onPress==null?void 0:props.onPress(item,index);},children:item.text||(props.showValuesAsLabels?item.value+'':'')},`label${index}`);})]}):null}))]});};
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useEffect } from 'react';
14
+ import { pieColors, usePiePro, } from 'gifted-charts-core';
15
+ import { Defs, Path, Stop, Svg, Text as SvgText, RadialGradient, } from 'react-native-svg';
16
+ import { Animated, View } from 'react-native';
17
+ export var PieChartPro = function (props) {
18
+ var _a = usePiePro(props), radius = _a.radius, total = _a.total, donut = _a.donut, strokeWidth = _a.strokeWidth, maxStrokeWidth = _a.maxStrokeWidth, animationDuration = _a.animationDuration, initial = _a.initial, dInitial = _a.dInitial, dFinal = _a.dFinal, getStartCaps = _a.getStartCaps, getEndCaps = _a.getEndCaps, getTextCoordinates = _a.getTextCoordinates, height = _a.height, heightFactor = _a.heightFactor, svgProps = _a.svgProps;
19
+ var data = props.data, curvedStartEdges = props.curvedStartEdges, curvedEndEdges = props.curvedEndEdges, _b = props.edgesRadius, edgesRadius = _b === void 0 ? 0 : _b, showGradient = props.showGradient, ring = props.ring, centerLabelComponent = props.centerLabelComponent, strokeDashArray = props.strokeDashArray, semiCircle = props.semiCircle;
20
+ var isAnimated = props.isAnimated;
21
+ if (!props.semiCircle && data.some(function (dataItem) { return dataItem.value > total / 2; })) {
22
+ // if we have an obtuse arc, we cant animate
23
+ isAnimated = false;
24
+ }
25
+ var AnimatedPath = Animated.createAnimatedComponent(Path);
26
+ var AnimatedText = Animated.createAnimatedComponent(SvgText);
27
+ var animatedValues = data.map(function (i) { return new Animated.Value(0); });
28
+ var animatedOpacityValue = new Animated.Value(0);
29
+ var animatedPaths = data.map(function (item, index) {
30
+ var _a;
31
+ return (_a = animatedValues[index]) === null || _a === void 0 ? void 0 : _a.interpolate({
32
+ inputRange: [0, 1],
33
+ outputRange: [dInitial[index], dFinal[index]],
34
+ });
35
+ });
36
+ var animatedOpacity = animatedOpacityValue.interpolate({
37
+ inputRange: [0, 1],
38
+ outputRange: [0, 1],
39
+ });
40
+ useEffect(function () {
41
+ Animated.timing(animatedOpacityValue, {
42
+ toValue: 1,
43
+ duration: 10,
44
+ useNativeDriver: true,
45
+ delay: animationDuration,
46
+ }).start();
47
+ animatedValues.forEach(function (animatedValue) {
48
+ return Animated.timing(animatedValue, {
49
+ toValue: 1,
50
+ duration: animationDuration,
51
+ useNativeDriver: true,
52
+ }).start();
53
+ });
54
+ }, [data]);
55
+ var adjustHeight = height * heightFactor;
56
+ var rnSvgProps = semiCircle ? {} : svgProps;
57
+ return (_jsxs(View, { style: {
58
+ display: 'flex',
59
+ justifyContent: 'center',
60
+ alignItems: 'center',
61
+ height: adjustHeight,
62
+ width: height * 2,
63
+ }, children: [_jsx(View, { style: semiCircle
64
+ ? { position: 'absolute', bottom: 0 }
65
+ : { position: 'absolute' }, children: centerLabelComponent ? centerLabelComponent() : null }), _jsx(Svg, __assign({}, rnSvgProps, { viewBox: semiCircle
66
+ ? ""
67
+ : "".concat(-maxStrokeWidth * 1.5, " ").concat(-maxStrokeWidth - (semiCircle ? height / 2 : 0), " ").concat(adjustHeight, " ").concat(adjustHeight), transform: semiCircle
68
+ ? []
69
+ : [{ scaleY: maxStrokeWidth ? 1 + maxStrokeWidth / (radius * 2) : 1 }], children: total ? (_jsxs(_Fragment, { children: [_jsx(Defs, { children: data.map(function (item, index) {
70
+ return (_jsxs(RadialGradient, { id: 'grad' + index, cx: "50%", cy: "50%", rx: "50%", ry: "50%", fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: item.gradientCenterColor, stopOpacity: "1" }), _jsx(Stop, { offset: "100%", stopColor: item.color || pieColors[index % 9], stopOpacity: "1" })] }, index + ''));
71
+ }) }), data.map(function (item, index) {
72
+ var _a, _b, _c, _d;
73
+ var borderWidth = (_a = item.strokeWidth) !== null && _a !== void 0 ? _a : strokeWidth;
74
+ var borderColor = (_c = (_b = item.strokeColor) !== null && _b !== void 0 ? _b : props.strokeColor) !== null && _c !== void 0 ? _c : (borderWidth ? 'black' : 'transparent');
75
+ var strokeDashArrayLocal = (_d = item.strokeDashArray) !== null && _d !== void 0 ? _d : strokeDashArray;
76
+ return (_jsx(AnimatedPath, { id: "renderPath", d: isAnimated ? animatedPaths[index] : dFinal[index], fill: ring
77
+ ? 'transparent'
78
+ : showGradient
79
+ ? "url(#grad".concat(index, ")")
80
+ : data[index].color || pieColors[index % 9], strokeWidth: borderWidth, strokeDasharray: strokeDashArrayLocal, stroke: borderColor }, "path".concat(index)));
81
+ }), donut
82
+ ? data.map(function (item, index) {
83
+ if (curvedStartEdges ||
84
+ edgesRadius ||
85
+ item.isStartEdgeCurved ||
86
+ item.startEdgeRadius)
87
+ return (_jsx(AnimatedPath, { d: "".concat(initial, " ").concat(getStartCaps(index, item)), opacity: isAnimated ? animatedOpacity : 1, fill: showGradient
88
+ ? "url(#grad".concat(index, ")")
89
+ : data[index].color || pieColors[index % 9] }, "cap".concat(index)));
90
+ return null;
91
+ })
92
+ : null, donut
93
+ ? data.map(function (item, index) {
94
+ if (curvedEndEdges ||
95
+ edgesRadius ||
96
+ item.isEndEdgeCurved ||
97
+ item.endEdgeRadius)
98
+ return (_jsx(Path, { d: "".concat(initial, " ").concat(getEndCaps(index, item)), fill: showGradient
99
+ ? "url(#grad".concat(index, ")")
100
+ : data[index].color || pieColors[index % 9] }, "cap".concat(index)));
101
+ return null;
102
+ })
103
+ : null, data.map(function (item, index) {
104
+ var _a, _b;
105
+ var _c = getTextCoordinates(index, item.labelPosition), x = _c.x, y = _c.y;
106
+ return (_jsx(AnimatedText, {
107
+ // style={{ pointerEvents: 'all' }}
108
+ fill: item.textColor ||
109
+ props.textColor ||
110
+ pieColors[(index + 2) % 9], opacity: isAnimated ? animatedOpacity : 1, fontSize: item.textSize || props.textSize, fontFamily: item.font || props.font, fontWeight: item.fontWeight || props.fontWeight, fontStyle: item.fontStyle || props.fontStyle || 'normal', x: x +
111
+ (item.shiftTextX || 0) -
112
+ ((_b = (_a = item.textSize) !== null && _a !== void 0 ? _a : props.textSize) !== null && _b !== void 0 ? _b : 0) / 1.8, y: y + (item.shiftTextY || 0), onPress: function () {
113
+ var _a;
114
+ item.onLabelPress
115
+ ? item.onLabelPress()
116
+ : props.onLabelPress
117
+ ? props.onLabelPress(item, index)
118
+ : item.onPress
119
+ ? item.onPress()
120
+ : (_a = props.onPress) === null || _a === void 0 ? void 0 : _a.call(props, item, index);
121
+ }, children: item.text ||
122
+ (props.showValuesAsLabels ? item.value + '' : '') }, "label".concat(index)));
123
+ })] })) : null }))] }));
124
+ };
@@ -0,0 +1,2 @@
1
+ import { PopulationPyramidPropsType } from 'gifted-charts-core';
2
+ export declare const PopulationPyramid: (props: PopulationPyramidPropsType) => import("react/jsx-runtime").JSX.Element;