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,359 +0,0 @@
1
- import React, {useEffect} from 'react';
2
- import {
3
- View,
4
- TouchableOpacity,
5
- Text,
6
- LayoutAnimation,
7
- Platform,
8
- UIManager,
9
- } from 'react-native';
10
- import Svg, {Defs, Rect} from 'react-native-svg';
11
- import LinearGradient from '../Components/common/LinearGradient';
12
- import {
13
- useRenderStackBars,
14
- BarDefaults,
15
- StackedBarChartPropsType,
16
- } from 'gifted-charts-core';
17
- import Tooltip from '../Components/BarSpecificComponents/tooltip';
18
-
19
- if (Platform.OS === 'android') {
20
- UIManager.setLayoutAnimationEnabledExperimental &&
21
- UIManager.setLayoutAnimationEnabledExperimental(true);
22
- }
23
-
24
- const RenderStackBars = (props: StackedBarChartPropsType) => {
25
- const {
26
- barBackgroundPattern,
27
- patternId,
28
- item,
29
- index,
30
- containerHeight,
31
- spacing,
32
- rotateLabel,
33
- label,
34
- labelTextStyle,
35
- xAxisTextNumberOfLines,
36
- xAxisLabelsVerticalShift,
37
- renderTooltip,
38
- selectedIndex,
39
- setSelectedIndex,
40
- activeOpacity,
41
- animationDuration = BarDefaults.animationDuration,
42
- barBorderWidth,
43
- barBorderColor,
44
- stackBorderRadius,
45
- stackBorderTopLeftRadius,
46
- stackBorderTopRightRadius,
47
- stackBorderBottomLeftRadius,
48
- stackBorderBottomRightRadius,
49
- showValuesAsTopLabel,
50
- autoShiftLabelsForNegativeStacks = true,
51
- labelsDistanceFromXaxis = 0,
52
- horizontal,
53
- } = props;
54
- const {
55
- cotainsNegative,
56
- noAnimation,
57
- localBarInnerComponent,
58
- borderRadius,
59
- borderTopLeftRadius,
60
- borderTopRightRadius,
61
- borderBottomLeftRadius,
62
- borderBottomRightRadius,
63
- disablePress,
64
- totalHeight,
65
- height,
66
- setHeight,
67
- getBarHeight,
68
- getPosition,
69
- lowestBarPosition,
70
- getStackBorderRadii,
71
- tooltipProps,
72
- } = useRenderStackBars(props);
73
-
74
- const renderLabel = (label: String, labelTextStyle: any) => {
75
- return (
76
- <View
77
- style={[
78
- {
79
- width:
80
- (item.stacks[0].barWidth || props.barWidth || 30) + spacing / 2,
81
- position: 'absolute',
82
- bottom: autoShiftLabelsForNegativeStacks
83
- ? -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition
84
- : -labelsDistanceFromXaxis,
85
- },
86
- rotateLabel
87
- ? horizontal
88
- ? {transform: [{rotate: '330deg'}]}
89
- : {transform: [{rotate: '60deg'}]}
90
- : horizontal
91
- ? {transform: [{rotate: '-90deg'}]}
92
- : {},
93
- ]}>
94
- {item.labelComponent ? (
95
- item.labelComponent()
96
- ) : (
97
- <Text style={[labelTextStyle]} numberOfLines={xAxisTextNumberOfLines}>
98
- {label || ''}
99
- </Text>
100
- )}
101
- </View>
102
- );
103
- };
104
-
105
- useEffect(() => {
106
- if (!noAnimation) {
107
- layoutAppear();
108
- }
109
- }, [totalHeight]);
110
-
111
- const elevate = () => {
112
- LayoutAnimation.configureNext({
113
- duration: animationDuration,
114
- update: {type: 'linear', property: 'scaleXY'},
115
- });
116
- setHeight(totalHeight);
117
- };
118
-
119
- const layoutAppear = () => {
120
- LayoutAnimation.configureNext({
121
- duration: Platform.OS == 'ios' ? animationDuration : 20,
122
- create: {type: 'linear', property: 'opacity'},
123
- update: {type: 'linear', property: 'scaleXY'},
124
- });
125
- setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
126
- };
127
-
128
- const static2DSimple = () => {
129
- return (
130
- <>
131
- <TouchableOpacity
132
- disabled={disablePress}
133
- activeOpacity={activeOpacity}
134
- onPress={() => {
135
- setSelectedIndex(index);
136
- if (item.onPress) {
137
- item.onPress();
138
- } else if (props.onPress) {
139
- props.onPress(item, index);
140
- }
141
- }}
142
- onLongPress={() => {
143
- if (item.onLongPress) {
144
- item.onLongPress();
145
- } else if (props.onLongPress) {
146
- props.onLongPress(item, index);
147
- }
148
- }}
149
- onPressOut={() => {
150
- if (item.onPressOut) {
151
- item.onPressOut();
152
- } else if (props.onPressOut) {
153
- props.onPressOut(item, index);
154
- }
155
- }}
156
- style={[
157
- {
158
- position: 'absolute',
159
- width: item.stacks[0].barWidth || props.barWidth || 30,
160
- height: '100%',
161
- borderTopLeftRadius:
162
- borderTopLeftRadius ??
163
- borderRadius ??
164
- stackBorderTopLeftRadius ??
165
- stackBorderRadius,
166
- borderTopRightRadius:
167
- borderTopRightRadius ??
168
- borderRadius ??
169
- stackBorderTopRightRadius ??
170
- stackBorderRadius,
171
- borderBottomLeftRadius:
172
- borderBottomLeftRadius ??
173
- borderRadius ??
174
- stackBorderBottomLeftRadius ??
175
- stackBorderRadius,
176
- borderBottomRightRadius:
177
- borderBottomRightRadius ??
178
- borderRadius ??
179
- stackBorderBottomRightRadius ??
180
- stackBorderRadius,
181
- overflow: lowestBarPosition ? 'visible' : 'hidden',
182
- },
183
- ]}>
184
- {item.stacks.map((stackItem, index) => {
185
- const borderRadii = getStackBorderRadii(item, index);
186
- const barHeight = getBarHeight(
187
- stackItem.value,
188
- stackItem.marginBottom,
189
- );
190
-
191
- return (
192
- <TouchableOpacity
193
- key={index}
194
- onPress={stackItem.onPress}
195
- activeOpacity={activeOpacity}
196
- disabled={disablePress || !stackItem.onPress}
197
- style={{
198
- position: 'absolute',
199
- bottom: getPosition(index) + (stackItem.marginBottom || 0),
200
- width: '100%',
201
- height: barHeight,
202
- backgroundColor:
203
- stackItem.color || item.color || props.color || 'black',
204
- borderWidth: barBorderWidth ?? 0,
205
- borderColor: barBorderColor,
206
- ...borderRadii,
207
- }}>
208
- {stackItem.showGradient ||
209
- item.showGradient ||
210
- props.showGradient ? (
211
- <LinearGradient
212
- style={{
213
- position: 'absolute',
214
- width: '100%',
215
- height: '100%',
216
- ...borderRadii,
217
- }}
218
- start={{x: 0, y: 0}}
219
- end={{x: 0, y: 1}}
220
- colors={[
221
- stackItem.gradientColor ||
222
- item.gradientColor ||
223
- props.gradientColor ||
224
- 'white',
225
- stackItem.color || item.color || props.color || 'black',
226
- ]}
227
- />
228
- ) : null}
229
- {stackItem.innerBarComponent && stackItem.innerBarComponent()}
230
- </TouchableOpacity>
231
- );
232
- })}
233
- {(item.barBackgroundPattern || barBackgroundPattern) && (
234
- <Svg>
235
- <Defs>
236
- {item.barBackgroundPattern
237
- ? item.barBackgroundPattern()
238
- : barBackgroundPattern?.()}
239
- </Defs>
240
- <Rect
241
- stroke="transparent"
242
- x="1"
243
- y="1"
244
- width="100%"
245
- height="100%"
246
- fill={`url(#${item.patternId || patternId})`}
247
- />
248
- </Svg>
249
- )}
250
- </TouchableOpacity>
251
- {localBarInnerComponent ? (
252
- <View style={{height: '100%', width: '100%'}}>
253
- {localBarInnerComponent(item, index)}
254
- </View>
255
- ) : null}
256
- {(item.topLabelComponent || showValuesAsTopLabel) && (
257
- <View
258
- style={[
259
- {
260
- position: 'absolute',
261
- top: cotainsNegative
262
- ? 0
263
- : (item.barWidth || props.barWidth || 30) * -1,
264
- height: item.barWidth || props.barWidth || 30,
265
- width: item.barWidth || props.barWidth || 30,
266
- justifyContent: 'center',
267
- alignItems: 'center',
268
- },
269
- cotainsNegative && {transform: [{translateY: totalHeight * 2}]},
270
- horizontal &&
271
- !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
272
- item.topLabelContainerStyle,
273
- ]}>
274
- {showValuesAsTopLabel ? (
275
- <Text style={item.topLabelTextStyle}>
276
- {item.stacks.reduce((acc, stack) => acc + stack.value, 0)}
277
- </Text>
278
- ) : (
279
- item.topLabelComponent?.()
280
- )}
281
- </View>
282
- )}
283
- </>
284
- );
285
- };
286
-
287
- const barWrapper = () => {
288
- return noAnimation ? (
289
- static2DSimple()
290
- ) : (
291
- <View
292
- style={{
293
- position: 'absolute',
294
- bottom: 0,
295
- height: height,
296
- width: '100%',
297
- overflow: 'hidden',
298
- }}>
299
- {static2DSimple()}
300
- </View>
301
- );
302
- };
303
-
304
- return (
305
- <>
306
- <View
307
- pointerEvents={
308
- props.pointerConfig
309
- ? props.pointerConfig.pointerEvents ?? 'none'
310
- : 'auto'
311
- }
312
- style={[
313
- {
314
- // overflow: 'visible',
315
- marginBottom: 60 + xAxisLabelsVerticalShift,
316
- width: item.stacks[0].barWidth || props.barWidth || 30,
317
- height: totalHeight,
318
- marginRight: spacing,
319
- },
320
-
321
- props.pointerConfig
322
- ? {
323
- transform: [
324
- {
325
- translateY:
326
- (containerHeight || 200) -
327
- (totalHeight - 10 + xAxisLabelsVerticalShift),
328
- },
329
- ],
330
- }
331
- : null,
332
- ]}>
333
- {(props.showXAxisIndices || item.showXAxisIndex) && (
334
- <View
335
- style={{
336
- zIndex: 2,
337
- position: 'absolute',
338
- height: props.xAxisIndicesHeight,
339
- width: props.xAxisIndicesWidth,
340
- bottom: props.xAxisIndicesHeight / -2,
341
- left:
342
- ((item.barWidth || props.barWidth || 30) -
343
- props.xAxisIndicesWidth) /
344
- 2,
345
- backgroundColor: props.xAxisIndicesColor,
346
- }}
347
- />
348
- )}
349
- {barWrapper()}
350
- {renderLabel(label || '', labelTextStyle)}
351
- </View>
352
- {renderTooltip && selectedIndex === index && (
353
- <Tooltip {...tooltipProps} />
354
- )}
355
- </>
356
- );
357
- };
358
-
359
- export default RenderStackBars;