react-native-gifted-charts 1.4.20 → 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 (93) hide show
  1. package/README.md +4 -3
  2. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  3. package/dist/BarChart/Animated2DWithGradient.js +113 -0
  4. package/dist/BarChart/RenderBars.d.ts +3 -0
  5. package/dist/BarChart/RenderBars.js +264 -0
  6. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  7. package/dist/BarChart/RenderStackBars.js +172 -0
  8. package/dist/BarChart/index.d.ts +2 -0
  9. package/dist/BarChart/index.js +233 -0
  10. package/dist/BarChart/styles.d.ts +45 -0
  11. package/dist/BarChart/styles.js +46 -0
  12. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  13. package/dist/Components/AnimatedThreeDBar/index.js +129 -0
  14. package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.js +13 -0
  16. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.js +128 -0
  18. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -0
  30. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  31. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  32. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  33. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  34. package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
  35. package/dist/Components/BarSpecificComponents/tooltip.js +40 -0
  36. package/dist/Components/common/LinearGradient.d.ts +16 -0
  37. package/dist/Components/common/LinearGradient.js +15 -0
  38. package/dist/Components/common/Pointer.d.ts +1 -0
  39. package/dist/Components/common/Pointer.js +16 -0
  40. package/dist/Components/common/StripAndLabel.d.ts +1 -0
  41. package/dist/Components/common/StripAndLabel.js +43 -0
  42. package/dist/Components/lineSvg.d.ts +14 -0
  43. package/dist/Components/lineSvg.js +22 -0
  44. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  45. package/dist/LineChart/LineChartBicolor.js +294 -0
  46. package/dist/LineChart/index.d.ts +2 -0
  47. package/dist/LineChart/index.js +1089 -0
  48. package/dist/LineChart/styles.d.ts +43 -0
  49. package/dist/LineChart/styles.js +46 -0
  50. package/dist/PieChart/index.d.ts +2 -0
  51. package/dist/PieChart/index.js +99 -0
  52. package/dist/PieChart/main.d.ts +2 -0
  53. package/dist/PieChart/main.js +182 -0
  54. package/dist/PieChartPro/index.d.ts +2 -0
  55. package/dist/PieChartPro/index.js +124 -0
  56. package/dist/PopulationPyramid/index.d.ts +2 -0
  57. package/dist/PopulationPyramid/index.js +130 -0
  58. package/dist/index.d.ts +7 -0
  59. package/dist/index.js +7 -0
  60. package/dist/utils/index.d.ts +2 -0
  61. package/dist/utils/index.js +12 -0
  62. package/package.json +21 -20
  63. package/src/BarChart/Animated2DWithGradient.tsx +0 -197
  64. package/src/BarChart/RenderBars.tsx +0 -527
  65. package/src/BarChart/RenderStackBars.tsx +0 -359
  66. package/src/BarChart/index.tsx +0 -391
  67. package/src/BarChart/styles.tsx +0 -47
  68. package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
  69. package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
  70. package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
  71. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
  72. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
  73. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
  74. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
  75. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
  76. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
  77. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
  78. package/src/Components/BarSpecificComponents/cap.tsx +0 -34
  79. package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
  80. package/src/Components/common/LinearGradient.tsx +0 -27
  81. package/src/Components/common/Pointer.tsx +0 -37
  82. package/src/Components/common/StripAndLabel.tsx +0 -98
  83. package/src/Components/lineSvg.tsx +0 -42
  84. package/src/LineChart/LineChartBicolor.tsx +0 -740
  85. package/src/LineChart/index.tsx +0 -2231
  86. package/src/LineChart/styles.tsx +0 -47
  87. package/src/PieChart/index.tsx +0 -168
  88. package/src/PieChart/main.tsx +0 -363
  89. package/src/PieChartPro/index.tsx +0 -267
  90. package/src/PopulationPyramid/index.tsx +0 -603
  91. package/src/index.tsx +0 -26
  92. package/src/todos.md +0 -24
  93. 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
- };