react-native-gifted-charts 1.4.20 → 1.4.21
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.
- package/README.md +4 -3
- package/dist/BarChart/Animated2DWithGradient.js +1 -0
- package/dist/BarChart/RenderBars.js +1 -0
- package/dist/BarChart/RenderStackBars.js +1 -0
- package/dist/BarChart/index.js +1 -0
- package/dist/BarChart/styles.js +1 -0
- package/dist/Components/AnimatedThreeDBar/index.js +1 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +1 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +1 -0
- package/dist/Components/BarSpecificComponents/cap.js +1 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +1 -0
- package/dist/Components/common/LinearGradient.js +1 -0
- package/dist/Components/common/Pointer.js +1 -0
- package/dist/Components/common/StripAndLabel.js +1 -0
- package/dist/Components/lineSvg.js +1 -0
- package/dist/LineChart/LineChartBicolor.js +1 -0
- package/dist/LineChart/index.js +1 -0
- package/dist/LineChart/styles.js +1 -0
- package/dist/PieChart/index.js +1 -0
- package/dist/PieChart/main.js +1 -0
- package/dist/PieChartPro/index.js +1 -0
- package/dist/PopulationPyramid/index.js +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +21 -20
- package/src/BarChart/Animated2DWithGradient.tsx +0 -197
- package/src/BarChart/RenderBars.tsx +0 -527
- package/src/BarChart/RenderStackBars.tsx +0 -359
- package/src/BarChart/index.tsx +0 -391
- package/src/BarChart/styles.tsx +0 -47
- package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
- package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
- package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
- package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
- package/src/Components/BarSpecificComponents/cap.tsx +0 -34
- package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
- package/src/Components/common/LinearGradient.tsx +0 -27
- package/src/Components/common/Pointer.tsx +0 -37
- package/src/Components/common/StripAndLabel.tsx +0 -98
- package/src/Components/lineSvg.tsx +0 -42
- package/src/LineChart/LineChartBicolor.tsx +0 -740
- package/src/LineChart/index.tsx +0 -2231
- package/src/LineChart/styles.tsx +0 -47
- package/src/PieChart/index.tsx +0 -168
- package/src/PieChart/main.tsx +0 -363
- package/src/PieChartPro/index.tsx +0 -267
- package/src/PopulationPyramid/index.tsx +0 -603
- package/src/index.tsx +0 -26
- package/src/todos.md +0 -24
- package/src/utils/index.ts +0 -16
package/src/LineChart/styles.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
|
|
3
|
-
export const styles = StyleSheet.create({
|
|
4
|
-
container: {
|
|
5
|
-
width: '100%',
|
|
6
|
-
marginBottom: 40,
|
|
7
|
-
marginRight: 40,
|
|
8
|
-
},
|
|
9
|
-
horizBar: {
|
|
10
|
-
flexDirection: 'row',
|
|
11
|
-
},
|
|
12
|
-
leftLabel: {
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
alignItems: 'center',
|
|
15
|
-
},
|
|
16
|
-
lastLeftLabel: {
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
},
|
|
20
|
-
leftPart: {
|
|
21
|
-
justifyContent: 'center',
|
|
22
|
-
// width: '100%',
|
|
23
|
-
},
|
|
24
|
-
lastLeftPart: {
|
|
25
|
-
justifyContent: 'flex-end',
|
|
26
|
-
// width: '100%',
|
|
27
|
-
},
|
|
28
|
-
line: {
|
|
29
|
-
width: '100%',
|
|
30
|
-
height: 1,
|
|
31
|
-
backgroundColor: 'gray',
|
|
32
|
-
opacity: 0.5,
|
|
33
|
-
},
|
|
34
|
-
lastLine: {
|
|
35
|
-
width: '100%',
|
|
36
|
-
height: 1,
|
|
37
|
-
backgroundColor: 'black',
|
|
38
|
-
},
|
|
39
|
-
bottomLabel: {
|
|
40
|
-
width: '100%',
|
|
41
|
-
},
|
|
42
|
-
customDataPointContainer: {
|
|
43
|
-
position: 'absolute',
|
|
44
|
-
justifyContent: 'center',
|
|
45
|
-
alignItems: 'center',
|
|
46
|
-
},
|
|
47
|
-
});
|
package/src/PieChart/index.tsx
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import {PieChartMain} from './main';
|
|
4
|
-
import {PieChartPropsType, pieColors, usePieChart} from 'gifted-charts-core';
|
|
5
|
-
|
|
6
|
-
export const PieChart = (props: PieChartPropsType) => {
|
|
7
|
-
const {
|
|
8
|
-
radius,
|
|
9
|
-
extraRadiusForFocused,
|
|
10
|
-
selectedIndex,
|
|
11
|
-
setSelectedIndex,
|
|
12
|
-
startAngle,
|
|
13
|
-
total,
|
|
14
|
-
donut,
|
|
15
|
-
isThreeD,
|
|
16
|
-
semiCircle,
|
|
17
|
-
inwardExtraLengthForFocused,
|
|
18
|
-
canvasWidth,
|
|
19
|
-
canvasHeight,
|
|
20
|
-
innerRadius,
|
|
21
|
-
innerCircleColor,
|
|
22
|
-
innerCircleBorderWidth,
|
|
23
|
-
innerCircleBorderColor,
|
|
24
|
-
shiftInnerCenterX,
|
|
25
|
-
shiftInnerCenterY,
|
|
26
|
-
tiltAngle,
|
|
27
|
-
isDataShifted,
|
|
28
|
-
paddingHorizontal,
|
|
29
|
-
paddingVertical,
|
|
30
|
-
} = usePieChart(props);
|
|
31
|
-
|
|
32
|
-
const renderInnerCircle = (
|
|
33
|
-
innerRadius: number,
|
|
34
|
-
innerCircleBorderWidth: number,
|
|
35
|
-
) => {
|
|
36
|
-
if (props.centerLabelComponent || (donut && !isDataShifted)) {
|
|
37
|
-
return (
|
|
38
|
-
<View
|
|
39
|
-
style={[
|
|
40
|
-
{
|
|
41
|
-
height: innerRadius * 2,
|
|
42
|
-
width: innerRadius * 2,
|
|
43
|
-
borderRadius: innerRadius,
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
// zIndex: 100,
|
|
46
|
-
alignSelf: 'center',
|
|
47
|
-
backgroundColor: innerCircleColor,
|
|
48
|
-
left:
|
|
49
|
-
canvasWidth / 2 -
|
|
50
|
-
innerRadius +
|
|
51
|
-
shiftInnerCenterX +
|
|
52
|
-
extraRadiusForFocused +
|
|
53
|
-
paddingHorizontal / 2,
|
|
54
|
-
top:
|
|
55
|
-
canvasHeight / 2 -
|
|
56
|
-
innerRadius +
|
|
57
|
-
shiftInnerCenterY +
|
|
58
|
-
extraRadiusForFocused +
|
|
59
|
-
paddingVertical / 2,
|
|
60
|
-
borderWidth: innerCircleBorderWidth,
|
|
61
|
-
borderColor: innerCircleBorderColor,
|
|
62
|
-
justifyContent: 'center',
|
|
63
|
-
alignItems: 'center',
|
|
64
|
-
},
|
|
65
|
-
isThreeD && {
|
|
66
|
-
borderTopWidth: innerCircleBorderWidth * 5,
|
|
67
|
-
borderLeftWidth: shiftInnerCenterX
|
|
68
|
-
? innerCircleBorderWidth * 2
|
|
69
|
-
: innerCircleBorderWidth,
|
|
70
|
-
transform: [{rotateX: tiltAngle}],
|
|
71
|
-
},
|
|
72
|
-
semiCircle &&
|
|
73
|
-
isThreeD && {
|
|
74
|
-
borderTopWidth: isThreeD
|
|
75
|
-
? innerCircleBorderWidth * 5
|
|
76
|
-
: innerCircleBorderWidth,
|
|
77
|
-
borderLeftWidth: 0.5,
|
|
78
|
-
borderLeftColor: innerCircleColor,
|
|
79
|
-
borderBottomWidth: 0,
|
|
80
|
-
borderRightWidth: 0.5,
|
|
81
|
-
borderRightColor: innerCircleColor,
|
|
82
|
-
},
|
|
83
|
-
]}>
|
|
84
|
-
<View style={{marginTop: semiCircle ? -0.5 * innerRadius : 0}}>
|
|
85
|
-
{props.centerLabelComponent ? props.centerLabelComponent() : null}
|
|
86
|
-
</View>
|
|
87
|
-
</View>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
if (!total) return null;
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<View
|
|
97
|
-
style={{
|
|
98
|
-
height:
|
|
99
|
-
(radius + extraRadiusForFocused + paddingVertical / 2) *
|
|
100
|
-
(props.semiCircle ? 1 : 2),
|
|
101
|
-
width: (radius + extraRadiusForFocused + paddingHorizontal / 2) * 2,
|
|
102
|
-
overflow: 'hidden',
|
|
103
|
-
}}>
|
|
104
|
-
<View style={{position: 'absolute'}}>
|
|
105
|
-
<PieChartMain
|
|
106
|
-
{...props}
|
|
107
|
-
selectedIndex={selectedIndex}
|
|
108
|
-
setSelectedIndex={setSelectedIndex}
|
|
109
|
-
paddingHorizontal={paddingHorizontal}
|
|
110
|
-
paddingVertical={paddingVertical}
|
|
111
|
-
extraRadiusForFocused={extraRadiusForFocused}
|
|
112
|
-
/>
|
|
113
|
-
</View>
|
|
114
|
-
{renderInnerCircle(innerRadius, innerCircleBorderWidth)}
|
|
115
|
-
{props.data.length > 1 &&
|
|
116
|
-
props.data[selectedIndex] && // don't forget to add this one so there are no errors when the data is empty / updating
|
|
117
|
-
(props.focusOnPress || props.sectionAutoFocus) &&
|
|
118
|
-
selectedIndex !== -1 && (
|
|
119
|
-
<View
|
|
120
|
-
pointerEvents="box-none"
|
|
121
|
-
style={{
|
|
122
|
-
position: 'absolute',
|
|
123
|
-
top: -extraRadiusForFocused,
|
|
124
|
-
left: -extraRadiusForFocused,
|
|
125
|
-
}}>
|
|
126
|
-
<PieChartMain
|
|
127
|
-
{...props}
|
|
128
|
-
data={[
|
|
129
|
-
{
|
|
130
|
-
value: props.data[selectedIndex].value,
|
|
131
|
-
text: props.data[selectedIndex].text,
|
|
132
|
-
color:
|
|
133
|
-
props.data[selectedIndex].color ||
|
|
134
|
-
pieColors[selectedIndex % 9],
|
|
135
|
-
strokeColor:
|
|
136
|
-
props.data[selectedIndex].strokeColor || undefined,
|
|
137
|
-
strokeWidth:
|
|
138
|
-
props.data[selectedIndex].strokeWidth || undefined,
|
|
139
|
-
gradientCenterColor:
|
|
140
|
-
props.data[selectedIndex].gradientCenterColor || undefined,
|
|
141
|
-
shiftTextX: props.data[selectedIndex].shiftTextX || undefined,
|
|
142
|
-
shiftTextY: props.data[selectedIndex].shiftTextY || undefined,
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
value: total - props.data[selectedIndex].value,
|
|
146
|
-
onPress: () => alert('black'),
|
|
147
|
-
peripheral: true,
|
|
148
|
-
strokeWidth: 0,
|
|
149
|
-
},
|
|
150
|
-
]}
|
|
151
|
-
radius={radius + extraRadiusForFocused}
|
|
152
|
-
initialAngle={startAngle}
|
|
153
|
-
innerRadius={props.innerRadius || radius / 2.5}
|
|
154
|
-
isBiggerPie
|
|
155
|
-
setSelectedIndex={setSelectedIndex}
|
|
156
|
-
paddingHorizontal={paddingHorizontal}
|
|
157
|
-
paddingVertical={paddingVertical}
|
|
158
|
-
extraRadiusForFocused={extraRadiusForFocused}
|
|
159
|
-
/>
|
|
160
|
-
</View>
|
|
161
|
-
)}
|
|
162
|
-
{renderInnerCircle(
|
|
163
|
-
innerRadius - inwardExtraLengthForFocused,
|
|
164
|
-
inwardExtraLengthForFocused ? 0 : innerCircleBorderWidth,
|
|
165
|
-
)}
|
|
166
|
-
</View>
|
|
167
|
-
);
|
|
168
|
-
};
|
package/src/PieChart/main.tsx
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import Svg, {
|
|
4
|
-
Path,
|
|
5
|
-
Circle,
|
|
6
|
-
Text as SvgText,
|
|
7
|
-
Defs,
|
|
8
|
-
RadialGradient,
|
|
9
|
-
Stop,
|
|
10
|
-
G,
|
|
11
|
-
} from 'react-native-svg';
|
|
12
|
-
import {
|
|
13
|
-
getPieChartMainProps,
|
|
14
|
-
PieChartMainProps,
|
|
15
|
-
pieColors,
|
|
16
|
-
} from 'gifted-charts-core';
|
|
17
|
-
import { rnVersion } from '../utils';
|
|
18
|
-
|
|
19
|
-
export const PieChartMain = (props: PieChartMainProps) => {
|
|
20
|
-
const {
|
|
21
|
-
isThreeD,
|
|
22
|
-
isBiggerPie,
|
|
23
|
-
data,
|
|
24
|
-
showInnerComponent,
|
|
25
|
-
radius,
|
|
26
|
-
canvasWidth,
|
|
27
|
-
canvasHeight,
|
|
28
|
-
shadowWidth,
|
|
29
|
-
backgroundColor,
|
|
30
|
-
shadowColor,
|
|
31
|
-
semiCircle,
|
|
32
|
-
pi,
|
|
33
|
-
initialAngle,
|
|
34
|
-
shadow,
|
|
35
|
-
donut,
|
|
36
|
-
strokeWidth,
|
|
37
|
-
strokeColor,
|
|
38
|
-
innerRadius,
|
|
39
|
-
showText,
|
|
40
|
-
textColor,
|
|
41
|
-
textSize,
|
|
42
|
-
tiltAngle,
|
|
43
|
-
labelsPosition,
|
|
44
|
-
showTextBackground,
|
|
45
|
-
textBackgroundColor,
|
|
46
|
-
showValuesAsLabels,
|
|
47
|
-
showGradient,
|
|
48
|
-
gradientCenterColor,
|
|
49
|
-
toggleFocusOnPress,
|
|
50
|
-
minShiftX,
|
|
51
|
-
minShiftY,
|
|
52
|
-
total,
|
|
53
|
-
horizAdjustment,
|
|
54
|
-
vertAdjustment,
|
|
55
|
-
cx,
|
|
56
|
-
cy,
|
|
57
|
-
pData,
|
|
58
|
-
mData,
|
|
59
|
-
paddingHorizontal,
|
|
60
|
-
paddingVertical,
|
|
61
|
-
extraRadiusForFocused,
|
|
62
|
-
} = getPieChartMainProps(props);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<View
|
|
66
|
-
pointerEvents="box-none"
|
|
67
|
-
style={[
|
|
68
|
-
{
|
|
69
|
-
backgroundColor: backgroundColor,
|
|
70
|
-
height: semiCircle
|
|
71
|
-
? (canvasHeight + paddingVertical) / 2 + extraRadiusForFocused
|
|
72
|
-
: canvasHeight + paddingVertical + extraRadiusForFocused * 2,
|
|
73
|
-
width: canvasWidth + paddingHorizontal + extraRadiusForFocused * 2,
|
|
74
|
-
overflow: 'hidden',
|
|
75
|
-
},
|
|
76
|
-
isThreeD && {transform: [{rotateX: tiltAngle}]},
|
|
77
|
-
]}>
|
|
78
|
-
<Svg
|
|
79
|
-
pointerEvents={rnVersion >= 720000 ? 'box-none' : 'auto'} // use 'box-none' react-native version 0.72 onwards
|
|
80
|
-
viewBox={`${strokeWidth / -2 + minShiftX - extraRadiusForFocused - paddingHorizontal / 2} ${
|
|
81
|
-
strokeWidth / -2 +
|
|
82
|
-
minShiftY -
|
|
83
|
-
extraRadiusForFocused -
|
|
84
|
-
paddingVertical / 2
|
|
85
|
-
} ${
|
|
86
|
-
(radius + extraRadiusForFocused + strokeWidth) * 2 +
|
|
87
|
-
paddingHorizontal +
|
|
88
|
-
horizAdjustment +
|
|
89
|
-
(horizAdjustment ? strokeWidth : 0)
|
|
90
|
-
} ${
|
|
91
|
-
(radius + extraRadiusForFocused + strokeWidth) * 2 +
|
|
92
|
-
paddingVertical +
|
|
93
|
-
vertAdjustment +
|
|
94
|
-
(vertAdjustment ? strokeWidth : 0)
|
|
95
|
-
}`}
|
|
96
|
-
height={
|
|
97
|
-
(radius + extraRadiusForFocused) * 2 + strokeWidth + paddingVertical
|
|
98
|
-
}
|
|
99
|
-
width={
|
|
100
|
-
(radius + extraRadiusForFocused) * 2 + strokeWidth + paddingHorizontal
|
|
101
|
-
}>
|
|
102
|
-
<Defs>
|
|
103
|
-
{data.map((item, index) => {
|
|
104
|
-
return (
|
|
105
|
-
<RadialGradient
|
|
106
|
-
key={index + ''}
|
|
107
|
-
id={'grad' + index}
|
|
108
|
-
cx="50%"
|
|
109
|
-
cy="50%"
|
|
110
|
-
rx="50%"
|
|
111
|
-
ry="50%"
|
|
112
|
-
fx="50%"
|
|
113
|
-
fy="50%"
|
|
114
|
-
gradientUnits="userSpaceOnUse">
|
|
115
|
-
<Stop
|
|
116
|
-
offset="0%"
|
|
117
|
-
stopColor={item.gradientCenterColor || gradientCenterColor}
|
|
118
|
-
stopOpacity="1"
|
|
119
|
-
/>
|
|
120
|
-
<Stop
|
|
121
|
-
offset="100%"
|
|
122
|
-
stopColor={item.color || pieColors[index % 9]}
|
|
123
|
-
stopOpacity="1"
|
|
124
|
-
/>
|
|
125
|
-
</RadialGradient>
|
|
126
|
-
);
|
|
127
|
-
})}
|
|
128
|
-
</Defs>
|
|
129
|
-
{data.length === 1 ? (
|
|
130
|
-
<>
|
|
131
|
-
<Circle
|
|
132
|
-
cx={cx}
|
|
133
|
-
cy={cy}
|
|
134
|
-
r={radius}
|
|
135
|
-
fill={
|
|
136
|
-
showGradient
|
|
137
|
-
? `url(#grad${0})`
|
|
138
|
-
: data[0].color || pieColors[0 % 9]
|
|
139
|
-
}
|
|
140
|
-
onPress={() => {
|
|
141
|
-
data[0].onPress
|
|
142
|
-
? data[0].onPress()
|
|
143
|
-
: props.onPress
|
|
144
|
-
? props.onPress(data[0], 0)
|
|
145
|
-
: null;
|
|
146
|
-
}}
|
|
147
|
-
/>
|
|
148
|
-
</>
|
|
149
|
-
) : (
|
|
150
|
-
data.map((item, index) => {
|
|
151
|
-
// console.log('index', index);
|
|
152
|
-
let nextItem;
|
|
153
|
-
if (index === pData.length - 1) nextItem = pData[0];
|
|
154
|
-
else nextItem = pData[index + 1];
|
|
155
|
-
let sx =
|
|
156
|
-
cx * (1 + Math.sin(2 * pi * pData[index] + initialAngle)) +
|
|
157
|
-
(item.shiftX || 0);
|
|
158
|
-
let sy =
|
|
159
|
-
cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
|
|
160
|
-
(item.shiftY || 0);
|
|
161
|
-
let ax =
|
|
162
|
-
cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
|
|
163
|
-
(item.shiftX || 0);
|
|
164
|
-
let ay =
|
|
165
|
-
cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
|
|
166
|
-
(item.shiftY || 0);
|
|
167
|
-
|
|
168
|
-
if (isBiggerPie && index) return null;
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<Path
|
|
172
|
-
key={index + 'a'}
|
|
173
|
-
d={`M ${cx + (item.shiftX || 0)} ${
|
|
174
|
-
cy + (item.shiftY || 0)
|
|
175
|
-
} L ${sx} ${sy} A ${radius} ${radius} 0 ${
|
|
176
|
-
semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0
|
|
177
|
-
} 1 ${ax} ${ay} L ${cx + (item.shiftX || 0)} ${
|
|
178
|
-
cy + (item.shiftY || 0)
|
|
179
|
-
}`}
|
|
180
|
-
stroke={item.strokeColor || strokeColor}
|
|
181
|
-
strokeWidth={
|
|
182
|
-
props.focusOnPress && props.selectedIndex === index
|
|
183
|
-
? 0
|
|
184
|
-
: item.strokeWidth === 0
|
|
185
|
-
? 0
|
|
186
|
-
: item.strokeWidth || strokeWidth
|
|
187
|
-
}
|
|
188
|
-
fill={
|
|
189
|
-
props.selectedIndex === index || item.peripheral
|
|
190
|
-
? 'transparent'
|
|
191
|
-
: showGradient
|
|
192
|
-
? `url(#grad${index})`
|
|
193
|
-
: item.color || pieColors[index % 9]
|
|
194
|
-
}
|
|
195
|
-
onPress={() => {
|
|
196
|
-
if (item.onPress) {
|
|
197
|
-
item.onPress();
|
|
198
|
-
} else if (props.onPress) {
|
|
199
|
-
props.onPress(item, index);
|
|
200
|
-
}
|
|
201
|
-
if (props.focusOnPress) {
|
|
202
|
-
if (props.selectedIndex === index || props.isBiggerPie) {
|
|
203
|
-
if (toggleFocusOnPress) {
|
|
204
|
-
props.setSelectedIndex(-1);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
props.setSelectedIndex(index);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}}
|
|
211
|
-
/>
|
|
212
|
-
);
|
|
213
|
-
})
|
|
214
|
-
)}
|
|
215
|
-
|
|
216
|
-
{(showText || showInnerComponent) &&
|
|
217
|
-
data.map((item, index) => {
|
|
218
|
-
const localPieInnerComponent =
|
|
219
|
-
item.pieInnerComponent ?? props.pieInnerComponent;
|
|
220
|
-
if (isBiggerPie && index) return null;
|
|
221
|
-
if (!props.data[index].value) return null;
|
|
222
|
-
let mx = cx * (1 + Math.sin(2 * pi * mData[index] + initialAngle));
|
|
223
|
-
let my = cy * (1 - Math.cos(2 * pi * mData[index] + initialAngle));
|
|
224
|
-
|
|
225
|
-
let midx = (mx + cx) / 2;
|
|
226
|
-
let midy = (my + cy) / 2;
|
|
227
|
-
|
|
228
|
-
let x = midx,
|
|
229
|
-
y = midy;
|
|
230
|
-
|
|
231
|
-
const labelPosition = item.labelPosition || labelsPosition;
|
|
232
|
-
|
|
233
|
-
if (labelPosition === 'onBorder') {
|
|
234
|
-
x = mx;
|
|
235
|
-
y = my;
|
|
236
|
-
} else if (labelPosition === 'outward') {
|
|
237
|
-
x = (midx + mx) / 2;
|
|
238
|
-
y = (midy + my) / 2;
|
|
239
|
-
} else if (labelPosition === 'inward') {
|
|
240
|
-
x = (midx + cx) / 2;
|
|
241
|
-
y = (midy + cy) / 2;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
x += item.shiftX || 0;
|
|
245
|
-
y += item.shiftY || 0;
|
|
246
|
-
|
|
247
|
-
if (data.length === 1) {
|
|
248
|
-
if (donut) {
|
|
249
|
-
y =
|
|
250
|
-
(radius -
|
|
251
|
-
innerRadius +
|
|
252
|
-
(item.textBackgroundRadius ||
|
|
253
|
-
props.textBackgroundRadius ||
|
|
254
|
-
item.textSize ||
|
|
255
|
-
textSize)) /
|
|
256
|
-
2;
|
|
257
|
-
} else {
|
|
258
|
-
y = cy;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return (
|
|
263
|
-
<React.Fragment key={index}>
|
|
264
|
-
{/* <Line x1={mx} x2={cx} y1={my} y2={cy} stroke="black" /> */}
|
|
265
|
-
{showTextBackground ? (
|
|
266
|
-
<Circle
|
|
267
|
-
cx={x + (item.shiftTextBackgroundX ?? item.shiftTextX ?? 0)}
|
|
268
|
-
cy={
|
|
269
|
-
y +
|
|
270
|
-
(item.shiftTextBackgroundY ?? item.shiftTextY ?? 0) -
|
|
271
|
-
(item.textSize || textSize) / 4
|
|
272
|
-
}
|
|
273
|
-
r={
|
|
274
|
-
item.textBackgroundRadius ||
|
|
275
|
-
props.textBackgroundRadius ||
|
|
276
|
-
item.textSize ||
|
|
277
|
-
textSize
|
|
278
|
-
}
|
|
279
|
-
fill={item.textBackgroundColor || textBackgroundColor}
|
|
280
|
-
onPress={() => {
|
|
281
|
-
item.onLabelPress
|
|
282
|
-
? item.onLabelPress()
|
|
283
|
-
: props.onLabelPress
|
|
284
|
-
? props.onLabelPress(item, index)
|
|
285
|
-
: item.onPress
|
|
286
|
-
? item.onPress()
|
|
287
|
-
: props.onPress
|
|
288
|
-
? props.onPress(item, index)
|
|
289
|
-
: null;
|
|
290
|
-
if (props.focusOnPress) {
|
|
291
|
-
if (props.selectedIndex === index) {
|
|
292
|
-
if (toggleFocusOnPress) {
|
|
293
|
-
props.setSelectedIndex(-1);
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
props.setSelectedIndex(index);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}}
|
|
300
|
-
/>
|
|
301
|
-
) : null}
|
|
302
|
-
<SvgText
|
|
303
|
-
fill={
|
|
304
|
-
item.textColor || textColor || pieColors[(index + 2) % 9]
|
|
305
|
-
}
|
|
306
|
-
fontSize={item.textSize || textSize}
|
|
307
|
-
fontFamily={item.font || props.font}
|
|
308
|
-
fontWeight={item.fontWeight || props.fontWeight}
|
|
309
|
-
fontStyle={item.fontStyle || props.fontStyle || 'normal'}
|
|
310
|
-
x={
|
|
311
|
-
x +
|
|
312
|
-
(item.shiftTextX || 0) -
|
|
313
|
-
(item.textSize || textSize) / 1.8
|
|
314
|
-
}
|
|
315
|
-
y={y + (item.shiftTextY || 0)}
|
|
316
|
-
onPress={() => {
|
|
317
|
-
item.onLabelPress
|
|
318
|
-
? item.onLabelPress()
|
|
319
|
-
: props.onLabelPress
|
|
320
|
-
? props.onLabelPress(item, index)
|
|
321
|
-
: item.onPress
|
|
322
|
-
? item.onPress()
|
|
323
|
-
: props.onPress
|
|
324
|
-
? props.onPress(item, index)
|
|
325
|
-
: null;
|
|
326
|
-
if (props.focusOnPress) {
|
|
327
|
-
if (props.selectedIndex === index) {
|
|
328
|
-
if (toggleFocusOnPress) {
|
|
329
|
-
props.setSelectedIndex(-1);
|
|
330
|
-
}
|
|
331
|
-
} else {
|
|
332
|
-
props.setSelectedIndex(index);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}}>
|
|
336
|
-
{item.text || (showValuesAsLabels ? item.value + '' : '')}
|
|
337
|
-
</SvgText>
|
|
338
|
-
{localPieInnerComponent ? (
|
|
339
|
-
<G x={x} y={y}>
|
|
340
|
-
{localPieInnerComponent?.(item, index) ?? null}
|
|
341
|
-
</G>
|
|
342
|
-
) : null}
|
|
343
|
-
</React.Fragment>
|
|
344
|
-
);
|
|
345
|
-
})}
|
|
346
|
-
</Svg>
|
|
347
|
-
{isThreeD && shadow && !semiCircle ? (
|
|
348
|
-
<View
|
|
349
|
-
style={{
|
|
350
|
-
width: radius * 2,
|
|
351
|
-
height: radius * 2,
|
|
352
|
-
backgroundColor: shadowColor,
|
|
353
|
-
borderRadius: radius,
|
|
354
|
-
position: 'absolute',
|
|
355
|
-
top: shadowWidth + paddingVertical / 2,
|
|
356
|
-
left: paddingHorizontal / 2,
|
|
357
|
-
zIndex: -1,
|
|
358
|
-
}}
|
|
359
|
-
/>
|
|
360
|
-
) : null}
|
|
361
|
-
</View>
|
|
362
|
-
);
|
|
363
|
-
};
|