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.
Files changed (63) hide show
  1. package/README.md +4 -3
  2. package/dist/BarChart/Animated2DWithGradient.js +1 -0
  3. package/dist/BarChart/RenderBars.js +1 -0
  4. package/dist/BarChart/RenderStackBars.js +1 -0
  5. package/dist/BarChart/index.js +1 -0
  6. package/dist/BarChart/styles.js +1 -0
  7. package/dist/Components/AnimatedThreeDBar/index.js +1 -0
  8. package/dist/Components/AnimatedThreeDBar/styles.js +1 -0
  9. package/dist/Components/BarAndLineChartsWrapper/index.js +1 -0
  10. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +1 -0
  11. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +1 -0
  12. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +1 -0
  13. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +1 -0
  14. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +1 -0
  15. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +1 -0
  16. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +1 -0
  17. package/dist/Components/BarSpecificComponents/cap.js +1 -0
  18. package/dist/Components/BarSpecificComponents/tooltip.js +1 -0
  19. package/dist/Components/common/LinearGradient.js +1 -0
  20. package/dist/Components/common/Pointer.js +1 -0
  21. package/dist/Components/common/StripAndLabel.js +1 -0
  22. package/dist/Components/lineSvg.js +1 -0
  23. package/dist/LineChart/LineChartBicolor.js +1 -0
  24. package/dist/LineChart/index.js +1 -0
  25. package/dist/LineChart/styles.js +1 -0
  26. package/dist/PieChart/index.js +1 -0
  27. package/dist/PieChart/main.js +1 -0
  28. package/dist/PieChartPro/index.js +1 -0
  29. package/dist/PopulationPyramid/index.js +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/utils/index.js +1 -0
  32. package/package.json +21 -20
  33. package/src/BarChart/Animated2DWithGradient.tsx +0 -197
  34. package/src/BarChart/RenderBars.tsx +0 -527
  35. package/src/BarChart/RenderStackBars.tsx +0 -359
  36. package/src/BarChart/index.tsx +0 -391
  37. package/src/BarChart/styles.tsx +0 -47
  38. package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
  39. package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
  40. package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
  41. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
  42. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
  43. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
  44. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
  45. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
  46. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
  47. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
  48. package/src/Components/BarSpecificComponents/cap.tsx +0 -34
  49. package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
  50. package/src/Components/common/LinearGradient.tsx +0 -27
  51. package/src/Components/common/Pointer.tsx +0 -37
  52. package/src/Components/common/StripAndLabel.tsx +0 -98
  53. package/src/Components/lineSvg.tsx +0 -42
  54. package/src/LineChart/LineChartBicolor.tsx +0 -740
  55. package/src/LineChart/index.tsx +0 -2231
  56. package/src/LineChart/styles.tsx +0 -47
  57. package/src/PieChart/index.tsx +0 -168
  58. package/src/PieChart/main.tsx +0 -363
  59. package/src/PieChartPro/index.tsx +0 -267
  60. package/src/PopulationPyramid/index.tsx +0 -603
  61. package/src/index.tsx +0 -26
  62. package/src/todos.md +0 -24
  63. package/src/utils/index.ts +0 -16
@@ -1,267 +0,0 @@
1
- import React, {useEffect} from 'react';
2
- import {
3
- PieChartPropsType,
4
- pieColors,
5
- usePiePro,
6
- } from 'gifted-charts-core';
7
- import {
8
- Defs,
9
- Path,
10
- Stop,
11
- Svg,
12
- Text as SvgText,
13
- RadialGradient,
14
- } from 'react-native-svg';
15
- import {Animated, View} from 'react-native';
16
-
17
- export const PieChartPro = (props: PieChartPropsType) => {
18
- const {
19
- radius,
20
- total,
21
- donut,
22
- strokeWidth,
23
- maxStrokeWidth,
24
- animationDuration,
25
- initial,
26
- dInitial,
27
- dFinal,
28
- getStartCaps,
29
- getEndCaps,
30
- getTextCoordinates,
31
- height,
32
- heightFactor,
33
- svgProps,
34
- } = usePiePro(props);
35
-
36
- const {
37
- data,
38
- curvedStartEdges,
39
- curvedEndEdges,
40
- edgesRadius = 0,
41
- showGradient,
42
- ring,
43
- centerLabelComponent,
44
- strokeDashArray,
45
- semiCircle,
46
- } = props;
47
-
48
- let {isAnimated} = props;
49
-
50
- if (!props.semiCircle && data.some(dataItem => dataItem.value > total / 2)) {
51
- // if we have an obtuse arc, we cant animate
52
- isAnimated = false;
53
- }
54
-
55
- const AnimatedPath = Animated.createAnimatedComponent(Path);
56
- const AnimatedText = Animated.createAnimatedComponent(SvgText);
57
-
58
- const animatedValues = data.map(i => new Animated.Value(0));
59
- const animatedOpacityValue = new Animated.Value(0);
60
- const animatedPaths = data.map((item, index) =>
61
- animatedValues[index]?.interpolate({
62
- inputRange: [0, 1],
63
- outputRange: [dInitial[index], dFinal[index]],
64
- }),
65
- );
66
-
67
- const animatedOpacity = animatedOpacityValue.interpolate({
68
- inputRange: [0, 1],
69
- outputRange: [0, 1],
70
- });
71
-
72
- useEffect(() => {
73
- Animated.timing(animatedOpacityValue, {
74
- toValue: 1,
75
- duration: 10,
76
- useNativeDriver: true,
77
- delay: animationDuration,
78
- }).start();
79
- animatedValues.forEach(animatedValue =>
80
- Animated.timing(animatedValue, {
81
- toValue: 1,
82
- duration: animationDuration,
83
- useNativeDriver: true,
84
- }).start(),
85
- );
86
- }, [data]);
87
-
88
- const adjustHeight = height * heightFactor;
89
- const rnSvgProps = semiCircle ? {} : svgProps;
90
-
91
- return (
92
- <View
93
- style={{
94
- display: 'flex',
95
- justifyContent: 'center',
96
- alignItems: 'center',
97
- height: adjustHeight,
98
- width: height * 2,
99
- }}>
100
- <View
101
- style={
102
- semiCircle
103
- ? {position: 'absolute', bottom: 0}
104
- : {position: 'absolute'}
105
- }>
106
- {centerLabelComponent ? centerLabelComponent() : null}
107
- </View>
108
- <Svg
109
- {...rnSvgProps}
110
- viewBox={
111
- semiCircle
112
- ? ``
113
- : `${-maxStrokeWidth * 1.5} ${
114
- -maxStrokeWidth - (semiCircle ? height / 2 : 0)
115
- } ${adjustHeight} ${adjustHeight}`
116
- }
117
- transform={
118
- semiCircle
119
- ? []
120
- : [{scaleY: maxStrokeWidth ? 1 + maxStrokeWidth / (radius * 2) : 1}]
121
- }>
122
- {total ? (
123
- <>
124
- <Defs>
125
- {data.map((item, index) => {
126
- return (
127
- <RadialGradient
128
- key={index + ''}
129
- id={'grad' + index}
130
- cx="50%"
131
- cy="50%"
132
- rx="50%"
133
- ry="50%"
134
- fx="50%"
135
- fy="50%"
136
- gradientUnits="userSpaceOnUse">
137
- <Stop
138
- offset="0%"
139
- stopColor={item.gradientCenterColor}
140
- stopOpacity="1"
141
- />
142
- <Stop
143
- offset="100%"
144
- stopColor={item.color || pieColors[index % 9]}
145
- stopOpacity="1"
146
- />
147
- </RadialGradient>
148
- );
149
- })}
150
- </Defs>
151
- {data.map((item, index) => {
152
- const borderWidth = item.strokeWidth ?? strokeWidth;
153
- const borderColor =
154
- item.strokeColor ??
155
- props.strokeColor ??
156
- (borderWidth ? 'black' : 'transparent');
157
- const strokeDashArrayLocal =
158
- item.strokeDashArray ?? strokeDashArray;
159
- return (
160
- <AnimatedPath
161
- key={`path${index}`}
162
- id="renderPath"
163
- d={isAnimated ? animatedPaths[index] : dFinal[index]}
164
- fill={
165
- ring
166
- ? 'transparent'
167
- : showGradient
168
- ? `url(#grad${index})`
169
- : data[index].color || pieColors[index % 9]
170
- }
171
- strokeWidth={borderWidth}
172
- strokeDasharray={strokeDashArrayLocal}
173
- stroke={borderColor}
174
- />
175
- );
176
- })}
177
-
178
- {donut
179
- ? data.map((item, index) => {
180
- if (
181
- curvedStartEdges ||
182
- edgesRadius ||
183
- item.isStartEdgeCurved ||
184
- item.startEdgeRadius
185
- )
186
- return (
187
- <AnimatedPath
188
- key={`cap${index}`}
189
- d={`${initial} ${getStartCaps(index, item)}`}
190
- opacity={isAnimated ? animatedOpacity : 1}
191
- fill={
192
- showGradient
193
- ? `url(#grad${index})`
194
- : data[index].color || pieColors[index % 9]
195
- }
196
- />
197
- );
198
- return null;
199
- })
200
- : null}
201
-
202
- {donut
203
- ? data.map((item, index) => {
204
- if (
205
- curvedEndEdges ||
206
- edgesRadius ||
207
- item.isEndEdgeCurved ||
208
- item.endEdgeRadius
209
- )
210
- return (
211
- <Path
212
- key={`cap${index}`}
213
- d={`${initial} ${getEndCaps(index, item)}`}
214
- fill={
215
- showGradient
216
- ? `url(#grad${index})`
217
- : data[index].color || pieColors[index % 9]
218
- }
219
- />
220
- );
221
- return null;
222
- })
223
- : null}
224
-
225
- {data.map((item, index) => {
226
- const {x, y} = getTextCoordinates(index, item.labelPosition);
227
-
228
- return (
229
- <AnimatedText
230
- key={`label${index}`}
231
- // style={{ pointerEvents: 'all' }}
232
- fill={
233
- item.textColor ||
234
- props.textColor ||
235
- pieColors[(index + 2) % 9]
236
- }
237
- opacity={isAnimated ? animatedOpacity : 1}
238
- fontSize={item.textSize || props.textSize}
239
- fontFamily={item.font || props.font}
240
- fontWeight={item.fontWeight || props.fontWeight}
241
- fontStyle={item.fontStyle || props.fontStyle || 'normal'}
242
- x={
243
- x +
244
- (item.shiftTextX || 0) -
245
- (item.textSize ?? props.textSize ?? 0) / 1.8
246
- }
247
- y={y + (item.shiftTextY || 0)}
248
- onPress={() => {
249
- item.onLabelPress
250
- ? item.onLabelPress()
251
- : props.onLabelPress
252
- ? props.onLabelPress(item, index)
253
- : item.onPress
254
- ? item.onPress()
255
- : props.onPress?.(item, index);
256
- }}>
257
- {item.text ||
258
- (props.showValuesAsLabels ? item.value + '' : '')}
259
- </AnimatedText>
260
- );
261
- })}
262
- </>
263
- ) : null}
264
- </Svg>
265
- </View>
266
- );
267
- };