react-native-gifted-charts 1.4.12 → 1.4.13

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 (60) hide show
  1. package/package.json +5 -9
  2. package/src/BarChart/Animated2DWithGradient.tsx +197 -0
  3. package/src/BarChart/RenderBars.tsx +454 -0
  4. package/src/BarChart/RenderStackBars.tsx +383 -0
  5. package/src/BarChart/index.tsx +373 -0
  6. package/src/BarChart/styles.tsx +47 -0
  7. package/src/Components/AnimatedThreeDBar/index.tsx +258 -0
  8. package/src/Components/AnimatedThreeDBar/styles.tsx +14 -0
  9. package/src/Components/BarAndLineChartsWrapper/index.tsx +244 -0
  10. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +590 -0
  11. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +147 -0
  12. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +157 -0
  13. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +86 -0
  14. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +42 -0
  15. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +131 -0
  16. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +30 -0
  17. package/src/Components/BarSpecificComponents/cap.tsx +34 -0
  18. package/src/Components/common/LinearGradient.tsx +27 -0
  19. package/src/Components/common/Pointer.tsx +37 -0
  20. package/src/Components/common/StripAndLabel.tsx +98 -0
  21. package/src/Components/lineSvg.tsx +42 -0
  22. package/src/LineChart/LineChartBicolor.tsx +740 -0
  23. package/src/LineChart/index.tsx +2158 -0
  24. package/src/LineChart/styles.tsx +47 -0
  25. package/src/PieChart/index.tsx +165 -0
  26. package/src/PieChart/main.tsx +363 -0
  27. package/src/PieChartPro/index.tsx +267 -0
  28. package/src/PopulationPyramid/index.tsx +603 -0
  29. package/src/index.tsx +25 -0
  30. package/src/todos.md +23 -0
  31. package/src/utils/index.ts +16 -0
  32. package/dist/BarChart/Animated2DWithGradient.js +0 -1
  33. package/dist/BarChart/RenderBars.js +0 -1
  34. package/dist/BarChart/RenderStackBars.js +0 -1
  35. package/dist/BarChart/index.js +0 -1
  36. package/dist/BarChart/styles.js +0 -1
  37. package/dist/Components/AnimatedThreeDBar/index.js +0 -1
  38. package/dist/Components/AnimatedThreeDBar/styles.js +0 -1
  39. package/dist/Components/BarAndLineChartsWrapper/index.js +0 -1
  40. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +0 -1
  41. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +0 -1
  42. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +0 -1
  43. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +0 -1
  44. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +0 -1
  45. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +0 -1
  46. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +0 -1
  47. package/dist/Components/BarSpecificComponents/cap.js +0 -1
  48. package/dist/Components/common/LinearGradient.js +0 -1
  49. package/dist/Components/common/Pointer.js +0 -1
  50. package/dist/Components/common/StripAndLabel.js +0 -1
  51. package/dist/Components/lineSvg.js +0 -1
  52. package/dist/LineChart/LineChartBicolor.js +0 -1
  53. package/dist/LineChart/index.js +0 -1
  54. package/dist/LineChart/styles.js +0 -1
  55. package/dist/PieChart/index.js +0 -1
  56. package/dist/PieChart/main.js +0 -1
  57. package/dist/PieChartPro/index.js +0 -1
  58. package/dist/PopulationPyramid/index.js +0 -1
  59. package/dist/index.js +0 -1
  60. package/dist/utils/index.js +0 -1
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
- "main": "dist/index.tsx",
5
+ "main": "src/index.tsx",
6
6
  "files": [
7
- "dist"
7
+ "src"
8
8
  ],
9
9
  "scripts": {
10
10
  "android": "react-native run-android",
11
- "build": "babel --extensions .ts,.tsx ./src -d ./dist",
11
+ "build": "tsc -p .",
12
12
  "ios": "react-native run-ios",
13
13
  "start": "react-native start",
14
14
  "test": "jest",
@@ -28,11 +28,7 @@
28
28
  "gifted-charts-core": "^0.1.8"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/cli": "^7.24.7",
32
- "@babel/core": "^7.24.7",
33
- "@babel/preset-env": "^7.24.7",
34
- "@babel/preset-react": "^7.24.7",
35
- "@babel/preset-typescript": "^7.24.7",
31
+ "@babel/core": "^7.22.5",
36
32
  "@babel/runtime": "^7.22.5",
37
33
  "@react-native-community/eslint-config": "^3.2.0",
38
34
  "@types/jest": "^29.5.2",
@@ -0,0 +1,197 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ import {View, LayoutAnimation, Platform, UIManager, Text} from 'react-native';
3
+ import Svg, {Defs, Rect} from 'react-native-svg';
4
+ import Cap from '../Components/BarSpecificComponents/cap';
5
+ import LinearGradient from "../Components/common/LinearGradient";
6
+ import {Animated2DWithGradientPropsType} from 'gifted-charts-core';
7
+
8
+ if (Platform.OS === 'android') {
9
+ UIManager.setLayoutAnimationEnabledExperimental &&
10
+ UIManager.setLayoutAnimationEnabledExperimental(true);
11
+ }
12
+
13
+ const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
14
+ const {
15
+ barBackgroundPattern,
16
+ patternId,
17
+ barWidth,
18
+ barStyle,
19
+ item,
20
+ index,
21
+ opacity,
22
+ animationDuration,
23
+ noGradient,
24
+ noAnimation,
25
+ containerHeight,
26
+ maxValue,
27
+ barMarginBottom,
28
+ barInnerComponent,
29
+ intactTopLabel,
30
+ showValuesAsTopLabel,
31
+ topLabelContainerStyle,
32
+ topLabelTextStyle,
33
+ commonStyleForBar,
34
+ barStyleWithBackground,
35
+ yAxisOffset,
36
+ } = props;
37
+ const [height, setHeight] = useState(noAnimation ? props.height : 0.2);
38
+ const [initialRender, setInitialRender] = useState(
39
+ noAnimation ? false : true,
40
+ );
41
+
42
+ useEffect(() => {
43
+ if (!noAnimation) {
44
+ if (initialRender) {
45
+ setTimeout(() => layoutAppear(), 20);
46
+ } else {
47
+ elevate();
48
+ }
49
+ }
50
+ }, [props.height]);
51
+
52
+ const elevate = () => {
53
+ LayoutAnimation.configureNext({
54
+ duration: animationDuration,
55
+ update: {type: 'linear', property: 'scaleXY'},
56
+ });
57
+ setHeight(props.height);
58
+ };
59
+
60
+ const layoutAppear = () => {
61
+ LayoutAnimation.configureNext({
62
+ duration: Platform.OS == 'ios' ? animationDuration : 20,
63
+ create: {type: 'linear', property: 'opacity'},
64
+ update: {type: 'linear', property: 'scaleXY'},
65
+ });
66
+ setInitialRender(false);
67
+ setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
68
+ };
69
+
70
+ return (
71
+ <>
72
+ {!initialRender && (
73
+ <View
74
+ style={{
75
+ position: 'absolute',
76
+ bottom: -0.5,
77
+ width: '100%',
78
+ overflow: 'hidden',
79
+ height:
80
+ (noAnimation
81
+ ? Math.max(props.minHeight, Math.abs(height))
82
+ : height) - (barMarginBottom || 0),
83
+ }}>
84
+ <View
85
+ style={[
86
+ {
87
+ width: '100%',
88
+ height:
89
+ (noAnimation
90
+ ? Math.max(props.minHeight, Math.abs(height))
91
+ : height) - (barMarginBottom || 0),
92
+ },
93
+ item.barStyle || barStyle,
94
+ ]}>
95
+ {noGradient ? (
96
+ <View style={barStyleWithBackground}>
97
+ {props.cappedBars && item.value ? (
98
+ <Cap
99
+ capThicknessFromItem={item.capThickness}
100
+ capThicknessFromProps={props.capThickness}
101
+ capColorFromItem={item.capColor}
102
+ capColorFromProps={props.capColor}
103
+ capRadiusFromItem={item.capRadius}
104
+ capRadiusFromProps={props.capRadius}
105
+ />
106
+ ) : null}
107
+ </View>
108
+ ) : (
109
+ <LinearGradient
110
+ style={commonStyleForBar}
111
+ start={{x: 0, y: 0}}
112
+ end={{x: 1, y: 1}}
113
+ colors={[
114
+ item.gradientColor || props.gradientColor || 'white',
115
+ item.frontColor || props.frontColor || 'black',
116
+ ]}>
117
+ {props.cappedBars && (
118
+ <View
119
+ style={{
120
+ position: 'absolute',
121
+ width: '100%',
122
+ height:
123
+ item.capThickness === 0
124
+ ? 0
125
+ : item.capThickness || props.capThickness || 6,
126
+ backgroundColor:
127
+ item.capColor || props.capColor || 'black',
128
+ borderTopLeftRadius:
129
+ item.capRadius === 0
130
+ ? 0
131
+ : item.capRadius || props.capRadius || 0,
132
+ borderTopRightRadius:
133
+ item.capRadius === 0
134
+ ? 0
135
+ : item.capRadius || props.capRadius || 0,
136
+ }}
137
+ />
138
+ )}
139
+ </LinearGradient>
140
+ )}
141
+ {(item.barBackgroundPattern || barBackgroundPattern) && (
142
+ <Svg>
143
+ <Defs>
144
+ {item.barBackgroundPattern
145
+ ? item.barBackgroundPattern()
146
+ : barBackgroundPattern?.()}
147
+ </Defs>
148
+ <Rect
149
+ stroke="transparent"
150
+ x="1"
151
+ y="1"
152
+ width={item.barWidth || props.barWidth || 30}
153
+ height={noAnimation ? Math.abs(height) : height}
154
+ fill={`url(#${item.patternId || patternId})`}
155
+ />
156
+ </Svg>
157
+ )}
158
+ {barInnerComponent ? (
159
+ <View style={{height: '100%', width: '100%'}}>
160
+ {barInnerComponent(item, index)}
161
+ </View>
162
+ ) : null}
163
+ </View>
164
+ </View>
165
+ )}
166
+ {item.topLabelComponent || showValuesAsTopLabel ? (
167
+ <View
168
+ style={[
169
+ {
170
+ position: 'absolute',
171
+ top: (item.barWidth || barWidth || 30) * -1,
172
+ height: item.barWidth || barWidth || 30,
173
+ width: item.barWidth || barWidth || 30,
174
+ justifyContent:
175
+ (props.horizontal && !intactTopLabel) || item.value < 0
176
+ ? 'center'
177
+ : 'flex-end',
178
+ alignItems: 'center',
179
+ opacity: opacity,
180
+ },
181
+ item.value < 0 && {transform: [{rotate: '180deg'}]},
182
+ props.horizontal &&
183
+ !intactTopLabel && {transform: [{rotate: '270deg'}]},
184
+ topLabelContainerStyle ?? item.topLabelContainerStyle,
185
+ ]}>
186
+ {showValuesAsTopLabel ? (
187
+ <Text style={topLabelTextStyle}>{item.value + yAxisOffset}</Text>
188
+ ) : (
189
+ item.topLabelComponent?.()
190
+ )}
191
+ </View>
192
+ ) : null}
193
+ </>
194
+ );
195
+ };
196
+
197
+ export default Animated2DWithGradient;
@@ -0,0 +1,454 @@
1
+ import React from 'react';
2
+ import {View, TouchableOpacity, Animated, Text} from 'react-native';
3
+ import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
4
+ import Animated2DWithGradient from './Animated2DWithGradient';
5
+ import Cap from '../Components/BarSpecificComponents/cap';
6
+ import BarBackgroundPattern from '../Components/BarSpecificComponents/barBackgroundPattern';
7
+ import LinearGradient from '../Components/common/LinearGradient';
8
+ import {
9
+ getPropsForAnimated2DWithGradient,
10
+ RenderBarsPropsType,
11
+ barDataItem,
12
+ AxesAndRulesDefaults,
13
+ } from 'gifted-charts-core';
14
+
15
+ const RenderBars = (props: RenderBarsPropsType) => {
16
+ const {
17
+ item,
18
+ index,
19
+ containerHeight,
20
+ maxValue,
21
+ minHeight,
22
+ spacing,
23
+ propSpacing,
24
+ side,
25
+ data,
26
+ barBorderWidth,
27
+ barBorderColor,
28
+ isThreeD,
29
+ isAnimated,
30
+ rotateLabel,
31
+ appearingOpacity,
32
+ animationDuration,
33
+ autoShiftLabels,
34
+ label,
35
+ labelTextStyle,
36
+ xAxisTextNumberOfLines,
37
+ xAxisLabelsVerticalShift,
38
+ renderTooltip,
39
+ leftShiftForTooltip,
40
+ leftShiftForLastIndexTooltip,
41
+ initialSpacing,
42
+ selectedIndex,
43
+ setSelectedIndex,
44
+ xAxisThickness = AxesAndRulesDefaults.xAxisThickness,
45
+ horizontal,
46
+ rtl,
47
+ intactTopLabel,
48
+ showValuesAsTopLabel,
49
+ topLabelContainerStyle,
50
+ topLabelTextStyle,
51
+ pointerConfig,
52
+ noOfSectionsBelowXAxis,
53
+ yAxisOffset,
54
+ barWidth,
55
+ } = props;
56
+
57
+ const barHeight = Math.max(
58
+ minHeight,
59
+ (Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200) -
60
+ xAxisThickness,
61
+ );
62
+
63
+ const {
64
+ commonStyleForBar,
65
+ barStyleWithBackground,
66
+ commonPropsFor2Dand3Dbars,
67
+ isFocused,
68
+ focusedBarConfig,
69
+ localFrontColor,
70
+ } = getPropsForAnimated2DWithGradient({...props, barHeight});
71
+
72
+ const itemOrPropsBarInnerComponent =
73
+ item.barInnerComponent ?? props.barInnerComponent;
74
+ const localBarInnerComponent = isFocused
75
+ ? focusedBarConfig?.barInnerComponent ?? itemOrPropsBarInnerComponent
76
+ : itemOrPropsBarInnerComponent;
77
+
78
+ const barMarginBottom =
79
+ item.barMarginBottom === 0
80
+ ? 0
81
+ : item.barMarginBottom || props.barMarginBottom || 0;
82
+
83
+ const renderLabel = (label: String, labelTextStyle: any, value: number) => {
84
+ return (
85
+ <View
86
+ style={[
87
+ {
88
+ width:
89
+ (item.labelWidth ||
90
+ props.labelWidth ||
91
+ item.barWidth ||
92
+ barWidth) + spacing,
93
+ left: spacing / -2,
94
+ position: 'absolute',
95
+ height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
96
+ bottom:
97
+ (rotateLabel
98
+ ? -40
99
+ : -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
100
+ barMarginBottom,
101
+ },
102
+ rotateLabel
103
+ ? horizontal
104
+ ? {transform: [{rotate: '330deg'}]}
105
+ : {
106
+ transform: [
107
+ {rotate: value < 0 ? '240deg' : '60deg'},
108
+ {translateX: value < 0 ? 56 : 0},
109
+ {translateY: value < 0 ? 32 : 0},
110
+ ],
111
+ }
112
+ : horizontal
113
+ ? {transform: [{rotate: '-90deg'}]}
114
+ : value < 0
115
+ ? {
116
+ transform: [
117
+ {rotate: '180deg'},
118
+ {
119
+ translateY: autoShiftLabels
120
+ ? 0
121
+ : 16.5 * xAxisTextNumberOfLines + 14,
122
+ },
123
+ ],
124
+ }
125
+ : {},
126
+ ]}>
127
+ {item.labelComponent ? (
128
+ item.labelComponent()
129
+ ) : (
130
+ <Text
131
+ style={[
132
+ {textAlign: 'center'},
133
+ rtl && horizontal && {transform: [{rotate: '180deg'}]},
134
+ labelTextStyle,
135
+ ]}
136
+ numberOfLines={xAxisTextNumberOfLines}>
137
+ {label || ''}
138
+ </Text>
139
+ )}
140
+ </View>
141
+ );
142
+ };
143
+
144
+ const renderAnimatedLabel = (
145
+ label: String,
146
+ labelTextStyle: any,
147
+ value: number,
148
+ ) => {
149
+ return (
150
+ <Animated.View
151
+ style={[
152
+ {
153
+ width:
154
+ (item.labelWidth ||
155
+ props.labelWidth ||
156
+ item.barWidth ||
157
+ barWidth) + spacing,
158
+ left: spacing / -2,
159
+ position: 'absolute',
160
+ height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
161
+ bottom:
162
+ (rotateLabel
163
+ ? -40
164
+ : -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
165
+ barMarginBottom,
166
+ opacity: appearingOpacity,
167
+ },
168
+ value < 0 && {transform: [{rotate: '180deg'}]},
169
+ rotateLabel
170
+ ? horizontal
171
+ ? {transform: [{rotate: '330deg'}]}
172
+ : {transform: [{rotate: '60deg'}]}
173
+ : horizontal
174
+ ? {transform: [{rotate: '-90deg'}]}
175
+ : value < 0
176
+ ? {
177
+ transform: [
178
+ {rotate: '180deg'},
179
+ {
180
+ translateY: autoShiftLabels
181
+ ? 0
182
+ : 16.5 * xAxisTextNumberOfLines + 14,
183
+ },
184
+ ],
185
+ }
186
+ : {},
187
+ ]}>
188
+ {item.labelComponent ? (
189
+ item.labelComponent()
190
+ ) : (
191
+ <Text
192
+ style={[
193
+ {textAlign: 'center'},
194
+ rtl && horizontal && {transform: [{rotate: '180deg'}]},
195
+ labelTextStyle,
196
+ ]}
197
+ numberOfLines={xAxisTextNumberOfLines}>
198
+ {label || ''}
199
+ </Text>
200
+ )}
201
+ </Animated.View>
202
+ );
203
+ };
204
+
205
+ let leftSpacing = initialSpacing;
206
+ for (let i = 0; i < index; i++) {
207
+ leftSpacing +=
208
+ (data[i].spacing ?? propSpacing) + (data[i].barWidth || barWidth);
209
+ }
210
+
211
+ const static2DWithGradient = (item: barDataItem) => {
212
+ const localGradientColor =
213
+ item.gradientColor || props.gradientColor || 'white';
214
+ return (
215
+ <>
216
+ <LinearGradient
217
+ style={commonStyleForBar}
218
+ start={{x: 0, y: 0}}
219
+ end={{x: 0, y: 1}}
220
+ colors={[
221
+ isFocused
222
+ ? focusedBarConfig?.gradientColor ?? localGradientColor
223
+ : localGradientColor,
224
+ localFrontColor,
225
+ ]}>
226
+ {props.cappedBars && item.value ? (
227
+ <Cap
228
+ capThicknessFromItem={item.capThickness}
229
+ capThicknessFromProps={props.capThickness}
230
+ capColorFromItem={item.capColor}
231
+ capColorFromProps={props.capColor}
232
+ capRadiusFromItem={item.capRadius}
233
+ capRadiusFromProps={props.capRadius}
234
+ />
235
+ ) : null}
236
+ </LinearGradient>
237
+ {(item.barBackgroundPattern || props.barBackgroundPattern) && (
238
+ <BarBackgroundPattern
239
+ barBackgroundPatternFromItem={item.barBackgroundPattern}
240
+ barBackgroundPatternFromProps={props.barBackgroundPattern}
241
+ patternIdFromItem={item.patternId}
242
+ patternIdFromProps={props.patternId}
243
+ />
244
+ )}
245
+ {(item.topLabelComponent || showValuesAsTopLabel) && (
246
+ <View
247
+ style={[
248
+ {
249
+ position: 'absolute',
250
+ top: (item.barWidth || barWidth) * -1,
251
+ height: item.barWidth || barWidth,
252
+ width: item.barWidth || barWidth,
253
+ justifyContent:
254
+ (horizontal && !intactTopLabel) || item.value < 0
255
+ ? 'center'
256
+ : 'flex-end',
257
+ alignItems: 'center',
258
+ },
259
+ item.value < 0 && {transform: [{rotate: '180deg'}]},
260
+ horizontal &&
261
+ !intactTopLabel && {transform: [{rotate: '270deg'}]},
262
+ topLabelContainerStyle ?? item.topLabelContainerStyle,
263
+ ]}>
264
+ {showValuesAsTopLabel ? (
265
+ <Text style={topLabelTextStyle}>{item.value + yAxisOffset}</Text>
266
+ ) : (
267
+ item.topLabelComponent?.()
268
+ )}
269
+ </View>
270
+ )}
271
+ {localBarInnerComponent ? (
272
+ <View style={{height: '100%', width: '100%'}}>
273
+ {localBarInnerComponent(item, index)}
274
+ </View>
275
+ ) : null}
276
+ </>
277
+ );
278
+ };
279
+
280
+ const barWrapperStyle = [
281
+ {
282
+ // overflow: 'visible',
283
+ marginBottom: 60 + barMarginBottom + xAxisLabelsVerticalShift - 0.5,
284
+ width: commonPropsFor2Dand3Dbars.barWidth,
285
+ height: barHeight,
286
+ marginRight: spacing,
287
+ },
288
+
289
+ pointerConfig
290
+ ? {
291
+ transform: [
292
+ {
293
+ translateY:
294
+ (containerHeight || 200) -
295
+ (barHeight - 10 + xAxisLabelsVerticalShift) +
296
+ (item.value < 0
297
+ ? (Math.abs(item.value) * (containerHeight || 200)) /
298
+ (maxValue || 200)
299
+ : 0),
300
+ },
301
+ ],
302
+ }
303
+ : item.value < 0
304
+ ? {
305
+ transform: [
306
+ {
307
+ translateY:
308
+ (Math.abs(item.value) * (containerHeight || 200)) /
309
+ (maxValue || 200),
310
+ },
311
+ {rotateZ: '180deg'},
312
+ ],
313
+ }
314
+ : null,
315
+ side !== 'right' && {zIndex: data.length - index},
316
+ ];
317
+
318
+ const pressDisabled =
319
+ item.disablePress ||
320
+ props.disablePress ||
321
+ (pointerConfig && pointerConfig.barTouchable !== true);
322
+
323
+ const barContent = () => {
324
+ const isBarBelowXaxisAndInvisible =
325
+ item.value < 0 && !noOfSectionsBelowXAxis;
326
+ const animated2DWithGradient = (noGradient, noAnimation) => (
327
+ <Animated2DWithGradient
328
+ {...commonPropsFor2Dand3Dbars}
329
+ animationDuration={animationDuration || 800}
330
+ roundedBottom={props.roundedBottom || false}
331
+ roundedTop={props.roundedTop || false}
332
+ noGradient={noGradient}
333
+ noAnimation={noAnimation}
334
+ containerHeight={containerHeight}
335
+ maxValue={maxValue}
336
+ minHeight={minHeight ?? 0}
337
+ barMarginBottom={barMarginBottom}
338
+ cappedBars={props.cappedBars}
339
+ capThickness={props.capThickness}
340
+ capColor={props.capColor}
341
+ capRadius={props.capRadius}
342
+ horizontal={horizontal}
343
+ barBorderWidth={barBorderWidth}
344
+ barBorderColor={barBorderColor}
345
+ commonStyleForBar={commonStyleForBar}
346
+ barStyleWithBackground={barStyleWithBackground}
347
+ />
348
+ );
349
+ return (
350
+ <>
351
+ {(props.showXAxisIndices || item.showXAxisIndex) && (
352
+ <View
353
+ style={{
354
+ zIndex: 2,
355
+ position: 'absolute',
356
+ height: props.xAxisIndicesHeight,
357
+ width: props.xAxisIndicesWidth,
358
+ bottom: props.xAxisIndicesHeight / -2,
359
+ left: ((item.barWidth || barWidth) - props.xAxisIndicesWidth) / 2,
360
+ backgroundColor: props.xAxisIndicesColor,
361
+ }}
362
+ />
363
+ )}
364
+ {isBarBelowXaxisAndInvisible ? null : isThreeD ? (
365
+ <AnimatedThreeDBar
366
+ {...commonPropsFor2Dand3Dbars}
367
+ sideWidth={
368
+ item.sideWidth ||
369
+ props.sideWidth ||
370
+ (item.barWidth || barWidth) / 2
371
+ }
372
+ side={side || 'left'}
373
+ sideColor={item.sideColor || props.sideColor || ''}
374
+ topColor={item.topColor || props.topColor || ''}
375
+ horizontal={horizontal}
376
+ isAnimated={isAnimated}
377
+ animationDuration={animationDuration || 800}
378
+ selectedIndex={selectedIndex}
379
+ />
380
+ ) : item.showGradient || props.showGradient ? (
381
+ isAnimated ? (
382
+ animated2DWithGradient(false, false)
383
+ ) : (
384
+ static2DWithGradient(item)
385
+ )
386
+ ) : isAnimated ? (
387
+ animated2DWithGradient(true, false)
388
+ ) : (
389
+ animated2DWithGradient(true, true)
390
+ )}
391
+ {isAnimated
392
+ ? renderAnimatedLabel(label, labelTextStyle, item.value)
393
+ : renderLabel(label, labelTextStyle, item.value)}
394
+ </>
395
+ );
396
+ };
397
+
398
+ return (
399
+ <>
400
+ {pressDisabled ? (
401
+ <View pointerEvents="none" style={barWrapperStyle}>
402
+ {barContent()}
403
+ </View>
404
+ ) : (
405
+ <TouchableOpacity
406
+ activeOpacity={props.activeOpacity || 0.2}
407
+ onPress={() => {
408
+ if (renderTooltip || props.focusBarOnPress) {
409
+ setSelectedIndex(index);
410
+ }
411
+ item.onPress
412
+ ? item.onPress()
413
+ : props.onPress
414
+ ? props.onPress(item, index)
415
+ : null;
416
+ }}
417
+ onLongPress={() => {
418
+ item.onLongPress
419
+ ? item.onLongPress()
420
+ : props.onLongPress
421
+ ? props.onLongPress(item, index)
422
+ : null;
423
+ }}
424
+ onPressOut={() => {
425
+ item.onPressOut
426
+ ? item.onPressOut()
427
+ : props.onPressOut
428
+ ? props.onPressOut(item, index)
429
+ : null;
430
+ }}
431
+ style={barWrapperStyle}>
432
+ {barContent()}
433
+ </TouchableOpacity>
434
+ )}
435
+ {renderTooltip && selectedIndex === index && (
436
+ <View
437
+ style={{
438
+ position: 'absolute',
439
+ bottom: barHeight + 60,
440
+ left:
441
+ index === data.length - 1
442
+ ? leftSpacing - leftShiftForLastIndexTooltip
443
+ : leftSpacing -
444
+ (item?.leftShiftForTooltip ?? leftShiftForTooltip ?? 0),
445
+ zIndex: 1000,
446
+ }}>
447
+ {renderTooltip(item, index)}
448
+ </View>
449
+ )}
450
+ </>
451
+ );
452
+ };
453
+
454
+ export default RenderBars;