react-native-gifted-charts 1.3.33 → 1.4.0
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 +9 -2
- package/package.json +2 -1
- package/src/BarChart/Animated2DWithGradient.tsx +13 -154
- package/src/BarChart/RenderBars.tsx +29 -179
- package/src/BarChart/RenderStackBars.tsx +22 -104
- package/src/BarChart/index.tsx +87 -686
- package/src/Components/AnimatedThreeDBar/index.tsx +16 -48
- package/src/Components/BarAndLineChartsWrapper/index.tsx +38 -283
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +17 -339
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +147 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +157 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +86 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +42 -0
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +1 -1
- package/src/Components/BarSpecificComponents/cap.tsx +1 -1
- package/src/Components/common/StripAndLabel.tsx +3 -56
- package/src/Components/lineSvg.tsx +1 -1
- package/src/LineChart/LineChartBicolor.tsx +80 -516
- package/src/LineChart/index.tsx +266 -1778
- package/src/PieChart/index.tsx +20 -84
- package/src/PieChart/main.tsx +47 -119
- package/src/PopulationPyramid/index.tsx +90 -203
- package/src/index.tsx +2 -14
- package/src/BarChart/types.ts +0 -394
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart.tsx +0 -402
- package/src/LineChart/types.ts +0 -575
- package/src/PieChart/types.ts +0 -77
- package/src/PopulationPyramid/types.ts +0 -200
- package/src/utils/constants.ts +0 -333
- package/src/utils/index.tsx +0 -1137
- package/src/utils/types.ts +0 -360
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Popul
|
|
|
15
15
|
7. Detailed [documentation](https://gifted-charts.web.app/) with examples
|
|
16
16
|
8. Support for **_combined_** Bar and Line charts
|
|
17
17
|
|
|
18
|
+
## [Release notes 🎉](release-notes/release-notes.md)
|
|
19
|
+
|
|
18
20
|
**Alert:**
|
|
19
21
|
|
|
20
22
|
This library doesn't support web apps yet. Use this library if you are planning mobile first.</br>
|
|
@@ -96,6 +98,13 @@ const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
|
|
|
96
98
|
|
|
97
99
|
## Contributing
|
|
98
100
|
|
|
101
|
+
This project exists thanks to all the people who contribute.
|
|
102
|
+
|
|
103
|
+
<a href="https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/graphs/contributors">
|
|
104
|
+
<img src="https://contrib.rocks/image?repo=Abhinandan-Kushwaha/react-native-gifted-charts" />
|
|
105
|
+
</a>
|
|
106
|
+
<br/><br/>
|
|
107
|
+
|
|
99
108
|
_Dear developers_! Your small contribution can make someone's day 😊
|
|
100
109
|
|
|
101
110
|
One of the ways you can contribute is to address an [open issue](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues).
|
|
@@ -104,8 +113,6 @@ Sometimes people report issues which don't exist, or request for features which
|
|
|
104
113
|
|
|
105
114
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
106
115
|
|
|
107
|
-
## [Release notes 🎉](release-notes/release-notes.md)
|
|
108
|
-
|
|
109
116
|
[To do list](./src/todos.md)
|
|
110
117
|
|
|
111
118
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"typescript": "^5.1.6"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
+
"gifted-charts-core": "*",
|
|
46
47
|
"react": "*",
|
|
47
48
|
"react-native": "*",
|
|
48
49
|
"react-native-linear-gradient": "*",
|
|
@@ -1,62 +1,23 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
|
-
ColorValue,
|
|
5
4
|
LayoutAnimation,
|
|
6
5
|
Platform,
|
|
7
6
|
UIManager,
|
|
8
7
|
Text,
|
|
8
|
+
ViewStyle,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import LinearGradient from 'react-native-linear-gradient';
|
|
11
11
|
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
12
12
|
import Cap from '../Components/BarSpecificComponents/cap';
|
|
13
|
-
import {
|
|
13
|
+
import {getPropsForAnimated2DWithGradient,Animated2DWithGradientPropsType} from 'gifted-charts-core';
|
|
14
14
|
|
|
15
15
|
if (Platform.OS === 'android') {
|
|
16
16
|
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
17
17
|
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
item: barDataItem;
|
|
22
|
-
index: number;
|
|
23
|
-
height: number;
|
|
24
|
-
minHeight: number;
|
|
25
|
-
opacity?: number;
|
|
26
|
-
animationDuration: number;
|
|
27
|
-
roundedTop: boolean;
|
|
28
|
-
roundedBottom: boolean;
|
|
29
|
-
barWidth: number;
|
|
30
|
-
gradientColor: ColorValue;
|
|
31
|
-
frontColor: ColorValue;
|
|
32
|
-
noGradient?: boolean;
|
|
33
|
-
noAnimation?: boolean;
|
|
34
|
-
cappedBars?: boolean;
|
|
35
|
-
capThickness?: number;
|
|
36
|
-
capColor?: ColorValue;
|
|
37
|
-
capRadius?: number;
|
|
38
|
-
horizontal: boolean;
|
|
39
|
-
intactTopLabel: boolean;
|
|
40
|
-
showValuesAsTopLabel: boolean;
|
|
41
|
-
topLabelContainerStyle?: any;
|
|
42
|
-
topLabelTextStyle?: any;
|
|
43
|
-
barBorderWidth?: number;
|
|
44
|
-
barBorderColor: ColorValue;
|
|
45
|
-
barBorderRadius?: number;
|
|
46
|
-
barBorderTopLeftRadius?: number;
|
|
47
|
-
barBorderTopRightRadius?: number;
|
|
48
|
-
barBorderBottomLeftRadius?: number;
|
|
49
|
-
barBorderBottomRightRadius?: number;
|
|
50
|
-
containerHeight?: number;
|
|
51
|
-
maxValue?: number;
|
|
52
|
-
barBackgroundPattern?: Function;
|
|
53
|
-
patternId?: String;
|
|
54
|
-
barMarginBottom?: number;
|
|
55
|
-
barStyle?: object;
|
|
56
|
-
barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const Animated2DWithGradient = (props: propTypes) => {
|
|
20
|
+
const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
|
|
60
21
|
const {
|
|
61
22
|
barBackgroundPattern,
|
|
62
23
|
patternId,
|
|
@@ -71,13 +32,6 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
71
32
|
containerHeight,
|
|
72
33
|
maxValue,
|
|
73
34
|
barMarginBottom,
|
|
74
|
-
barBorderWidth,
|
|
75
|
-
barBorderColor,
|
|
76
|
-
barBorderRadius,
|
|
77
|
-
barBorderTopLeftRadius,
|
|
78
|
-
barBorderTopRightRadius,
|
|
79
|
-
barBorderBottomLeftRadius,
|
|
80
|
-
barBorderBottomRightRadius,
|
|
81
35
|
barInnerComponent,
|
|
82
36
|
intactTopLabel,
|
|
83
37
|
showValuesAsTopLabel,
|
|
@@ -117,6 +71,11 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
117
71
|
setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
|
|
118
72
|
};
|
|
119
73
|
|
|
74
|
+
const{
|
|
75
|
+
commonStyleForBar,
|
|
76
|
+
barStyleWithBackground,
|
|
77
|
+
} = getPropsForAnimated2DWithGradient(props);
|
|
78
|
+
|
|
120
79
|
return (
|
|
121
80
|
<>
|
|
122
81
|
{!initialRender && (
|
|
@@ -125,7 +84,7 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
125
84
|
position: 'absolute',
|
|
126
85
|
bottom: 0,
|
|
127
86
|
width: '100%',
|
|
128
|
-
overflow:'hidden',
|
|
87
|
+
overflow: 'hidden',
|
|
129
88
|
height:
|
|
130
89
|
(noAnimation
|
|
131
90
|
? Math.max(
|
|
@@ -152,58 +111,7 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
152
111
|
]}>
|
|
153
112
|
{noGradient ? (
|
|
154
113
|
<View
|
|
155
|
-
style={
|
|
156
|
-
{
|
|
157
|
-
position: 'absolute',
|
|
158
|
-
width: '100%',
|
|
159
|
-
height: '100%',
|
|
160
|
-
backgroundColor:
|
|
161
|
-
item.frontColor || props.frontColor || 'black',
|
|
162
|
-
borderWidth: barBorderWidth ?? 0,
|
|
163
|
-
borderColor: barBorderColor,
|
|
164
|
-
borderRadius: item.barBorderRadius ?? barBorderRadius ?? 0,
|
|
165
|
-
borderTopLeftRadius:
|
|
166
|
-
item.barBorderTopLeftRadius ??
|
|
167
|
-
barBorderTopLeftRadius ??
|
|
168
|
-
item.barBorderRadius ??
|
|
169
|
-
barBorderRadius,
|
|
170
|
-
borderTopRightRadius:
|
|
171
|
-
item.barBorderTopRightRadius ??
|
|
172
|
-
barBorderTopRightRadius ??
|
|
173
|
-
item.barBorderRadius ??
|
|
174
|
-
barBorderRadius,
|
|
175
|
-
borderBottomLeftRadius:
|
|
176
|
-
item.barBorderBottomLeftRadius ??
|
|
177
|
-
barBorderBottomLeftRadius ??
|
|
178
|
-
item.barBorderRadius ??
|
|
179
|
-
barBorderRadius,
|
|
180
|
-
borderBottomRightRadius:
|
|
181
|
-
item.barBorderBottomRightRadius ??
|
|
182
|
-
barBorderBottomRightRadius ??
|
|
183
|
-
item.barBorderRadius ??
|
|
184
|
-
barBorderRadius,
|
|
185
|
-
},
|
|
186
|
-
props.roundedBottom && {
|
|
187
|
-
borderBottomLeftRadius:
|
|
188
|
-
(item.barWidth || barWidth || 30) / 2,
|
|
189
|
-
borderBottomRightRadius:
|
|
190
|
-
(item.barWidth || barWidth || 30) / 2,
|
|
191
|
-
},
|
|
192
|
-
props.cappedBars && {
|
|
193
|
-
borderTopLeftRadius:
|
|
194
|
-
item.capRadius === 0
|
|
195
|
-
? 0
|
|
196
|
-
: item.capRadius || props.capRadius || 0,
|
|
197
|
-
borderTopRightRadius:
|
|
198
|
-
item.capRadius === 0
|
|
199
|
-
? 0
|
|
200
|
-
: item.capRadius || props.capRadius || 0,
|
|
201
|
-
},
|
|
202
|
-
props.roundedTop && {
|
|
203
|
-
borderTopLeftRadius: (item.barWidth || barWidth || 30) / 2,
|
|
204
|
-
borderTopRightRadius: (item.barWidth || barWidth || 30) / 2,
|
|
205
|
-
},
|
|
206
|
-
]}>
|
|
114
|
+
style={barStyleWithBackground}>
|
|
207
115
|
{props.cappedBars && item.value ? (
|
|
208
116
|
<Cap
|
|
209
117
|
capThicknessFromItem={item.capThickness}
|
|
@@ -217,56 +125,7 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
217
125
|
</View>
|
|
218
126
|
) : (
|
|
219
127
|
<LinearGradient
|
|
220
|
-
style={
|
|
221
|
-
{
|
|
222
|
-
position: 'absolute',
|
|
223
|
-
width: '100%',
|
|
224
|
-
height: '100%',
|
|
225
|
-
borderWidth: barBorderWidth ?? 0,
|
|
226
|
-
borderColor: barBorderColor,
|
|
227
|
-
borderRadius: item.barBorderRadius ?? barBorderRadius ?? 0,
|
|
228
|
-
borderTopLeftRadius:
|
|
229
|
-
item.barBorderTopLeftRadius ??
|
|
230
|
-
barBorderTopLeftRadius ??
|
|
231
|
-
item.barBorderRadius ??
|
|
232
|
-
barBorderRadius,
|
|
233
|
-
borderTopRightRadius:
|
|
234
|
-
item.barBorderTopRightRadius ??
|
|
235
|
-
barBorderTopRightRadius ??
|
|
236
|
-
item.barBorderRadius ??
|
|
237
|
-
barBorderRadius,
|
|
238
|
-
borderBottomLeftRadius:
|
|
239
|
-
item.barBorderBottomLeftRadius ??
|
|
240
|
-
barBorderBottomLeftRadius ??
|
|
241
|
-
item.barBorderRadius ??
|
|
242
|
-
barBorderRadius,
|
|
243
|
-
borderBottomRightRadius:
|
|
244
|
-
item.barBorderBottomRightRadius ??
|
|
245
|
-
barBorderBottomRightRadius ??
|
|
246
|
-
item.barBorderRadius ??
|
|
247
|
-
barBorderRadius,
|
|
248
|
-
},
|
|
249
|
-
props.roundedBottom && {
|
|
250
|
-
borderBottomLeftRadius:
|
|
251
|
-
(item.barWidth || barWidth || 30) / 2,
|
|
252
|
-
borderBottomRightRadius:
|
|
253
|
-
(item.barWidth || barWidth || 30) / 2,
|
|
254
|
-
},
|
|
255
|
-
props.cappedBars && {
|
|
256
|
-
borderTopLeftRadius:
|
|
257
|
-
item.capRadius === 0
|
|
258
|
-
? 0
|
|
259
|
-
: item.capRadius || props.capRadius || 0,
|
|
260
|
-
borderTopRightRadius:
|
|
261
|
-
item.capRadius === 0
|
|
262
|
-
? 0
|
|
263
|
-
: item.capRadius || props.capRadius || 0,
|
|
264
|
-
},
|
|
265
|
-
props.roundedTop && {
|
|
266
|
-
borderTopLeftRadius: (item.barWidth || barWidth || 30) / 2,
|
|
267
|
-
borderTopRightRadius: (item.barWidth || barWidth || 30) / 2,
|
|
268
|
-
},
|
|
269
|
-
]}
|
|
128
|
+
style={commonStyleForBar}
|
|
270
129
|
start={{x: 0, y: 0}}
|
|
271
130
|
end={{x: 1, y: 1}}
|
|
272
131
|
colors={[
|
|
@@ -321,7 +180,7 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
321
180
|
)}
|
|
322
181
|
{barInnerComponent ? (
|
|
323
182
|
<View style={{height: '100%', width: '100%'}}>
|
|
324
|
-
{barInnerComponent(item,index)}
|
|
183
|
+
{barInnerComponent(item, index)}
|
|
325
184
|
</View>
|
|
326
185
|
) : null}
|
|
327
186
|
</View>
|
|
@@ -1,92 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {View, TouchableOpacity, Animated, Text
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {View, TouchableOpacity, Animated, Text} from 'react-native';
|
|
3
3
|
import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
|
|
4
4
|
import LinearGradient from 'react-native-linear-gradient';
|
|
5
5
|
import Animated2DWithGradient from './Animated2DWithGradient';
|
|
6
6
|
import Cap from '../Components/BarSpecificComponents/cap';
|
|
7
7
|
import BarBackgroundPattern from '../Components/BarSpecificComponents/barBackgroundPattern';
|
|
8
|
-
import {barDataItem} from '
|
|
9
|
-
import {Pointer} from '../utils/types';
|
|
8
|
+
import { getPropsForAnimated2DWithGradient,RenderBarsPropsType, barDataItem } from 'gifted-charts-core';
|
|
10
9
|
|
|
11
|
-
type Props = {
|
|
12
|
-
style?: any;
|
|
13
|
-
width?: number;
|
|
14
|
-
height?: number;
|
|
15
|
-
minHeight: number;
|
|
16
|
-
color?: ColorValue;
|
|
17
|
-
showGradient?: boolean;
|
|
18
|
-
gradientColor?: any;
|
|
19
|
-
frontColor?: ColorValue;
|
|
20
|
-
sideColor?: ColorValue;
|
|
21
|
-
topColor?: ColorValue;
|
|
22
|
-
topLabelComponent?: Component;
|
|
23
|
-
topLabelContainerStyle?: any;
|
|
24
|
-
topLabelTextStyle?: any;
|
|
25
|
-
opacity?: number;
|
|
26
|
-
side?: String;
|
|
27
|
-
labelTextStyle?: any;
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
index: number;
|
|
31
|
-
label: String;
|
|
32
|
-
containerHeight?: number;
|
|
33
|
-
maxValue: number;
|
|
34
|
-
spacing: number;
|
|
35
|
-
propSpacing?: number;
|
|
36
|
-
data?: any;
|
|
37
|
-
barWidth?: number;
|
|
38
|
-
sideWidth?: number;
|
|
39
|
-
labelWidth?: number;
|
|
40
|
-
|
|
41
|
-
isThreeD?: boolean;
|
|
42
|
-
isAnimated?: boolean;
|
|
43
|
-
rotateLabel?: boolean;
|
|
44
|
-
animatedHeight?: any;
|
|
45
|
-
appearingOpacity?: any;
|
|
46
|
-
animationDuration?: number;
|
|
47
|
-
roundedTop?: boolean;
|
|
48
|
-
roundedBottom?: boolean;
|
|
49
|
-
disablePress?: boolean;
|
|
50
|
-
activeOpacity?: number;
|
|
51
|
-
cappedBars?: boolean;
|
|
52
|
-
capThickness?: number;
|
|
53
|
-
capColor?: ColorValue;
|
|
54
|
-
capRadius?: number;
|
|
55
|
-
showXAxisIndices: boolean;
|
|
56
|
-
xAxisIndicesHeight: number;
|
|
57
|
-
xAxisIndicesWidth: number;
|
|
58
|
-
xAxisIndicesColor: ColorValue;
|
|
59
|
-
horizontal: boolean;
|
|
60
|
-
rtl: boolean;
|
|
61
|
-
intactTopLabel: boolean;
|
|
62
|
-
showValuesAsTopLabel?: boolean;
|
|
63
|
-
barBorderWidth?: number;
|
|
64
|
-
barBorderColor: ColorValue;
|
|
65
|
-
barBorderRadius?: number;
|
|
66
|
-
barBorderTopLeftRadius?: number;
|
|
67
|
-
barBorderTopRightRadius?: number;
|
|
68
|
-
barBorderBottomLeftRadius?: number;
|
|
69
|
-
barBorderBottomRightRadius?: number;
|
|
70
|
-
barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
|
|
71
|
-
autoShiftLabels?: boolean;
|
|
72
|
-
barBackgroundPattern?: Function;
|
|
73
|
-
patternId?: String;
|
|
74
|
-
barMarginBottom?: number;
|
|
75
|
-
onPress?: Function;
|
|
76
|
-
xAxisTextNumberOfLines: number;
|
|
77
|
-
xAxisLabelsHeight?: number;
|
|
78
|
-
xAxisLabelsVerticalShift: number;
|
|
79
|
-
renderTooltip: Function | undefined;
|
|
80
|
-
leftShiftForTooltip?: number;
|
|
81
|
-
leftShiftForLastIndexTooltip: number;
|
|
82
|
-
initialSpacing: number;
|
|
83
|
-
selectedIndex: number;
|
|
84
|
-
setSelectedIndex: Function;
|
|
85
|
-
barStyle?: object;
|
|
86
|
-
xAxisThickness?: number;
|
|
87
|
-
pointerConfig?: Pointer;
|
|
88
|
-
};
|
|
89
|
-
const RenderBars = (props: Props) => {
|
|
11
|
+
const RenderBars = (props: RenderBarsPropsType) => {
|
|
90
12
|
const {
|
|
91
13
|
item,
|
|
92
14
|
index,
|
|
@@ -97,10 +19,8 @@ const RenderBars = (props: Props) => {
|
|
|
97
19
|
propSpacing,
|
|
98
20
|
side,
|
|
99
21
|
data,
|
|
100
|
-
barStyle,
|
|
101
22
|
barBorderWidth,
|
|
102
23
|
barBorderColor,
|
|
103
|
-
barBorderRadius,
|
|
104
24
|
barBorderTopLeftRadius,
|
|
105
25
|
barBorderTopRightRadius,
|
|
106
26
|
barBorderBottomLeftRadius,
|
|
@@ -111,7 +31,6 @@ const RenderBars = (props: Props) => {
|
|
|
111
31
|
isAnimated,
|
|
112
32
|
rotateLabel,
|
|
113
33
|
appearingOpacity,
|
|
114
|
-
opacity,
|
|
115
34
|
animationDuration,
|
|
116
35
|
autoShiftLabels,
|
|
117
36
|
label,
|
|
@@ -250,60 +169,26 @@ const RenderBars = (props: Props) => {
|
|
|
250
169
|
);
|
|
251
170
|
};
|
|
252
171
|
|
|
172
|
+
const barHeight = Math.max(
|
|
173
|
+
minHeight,
|
|
174
|
+
(Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200) -
|
|
175
|
+
(xAxisThickness ?? 0),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
let leftSpacing = initialSpacing;
|
|
179
|
+
for (let i = 0; i < index; i++) {
|
|
180
|
+
leftSpacing +=
|
|
181
|
+
(data[i].spacing ?? propSpacing) +
|
|
182
|
+
(data[i].barWidth || props.barWidth || 30);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const {commonStyleForBar, commonPropsFor2Dand3Dbars} = getPropsForAnimated2DWithGradient({...props, barHeight});
|
|
186
|
+
|
|
253
187
|
const static2DWithGradient = (item: barDataItem) => {
|
|
254
188
|
return (
|
|
255
189
|
<>
|
|
256
190
|
<LinearGradient
|
|
257
|
-
style={
|
|
258
|
-
{
|
|
259
|
-
position: 'absolute',
|
|
260
|
-
width: '100%',
|
|
261
|
-
height: '100%',
|
|
262
|
-
borderWidth: barBorderWidth ?? 0,
|
|
263
|
-
borderColor: barBorderColor,
|
|
264
|
-
borderRadius: item.barBorderRadius ?? barBorderRadius ?? 0,
|
|
265
|
-
borderTopLeftRadius:
|
|
266
|
-
item.barBorderTopLeftRadius ??
|
|
267
|
-
barBorderTopLeftRadius ??
|
|
268
|
-
item.barBorderRadius ??
|
|
269
|
-
barBorderRadius,
|
|
270
|
-
borderTopRightRadius:
|
|
271
|
-
item.barBorderTopRightRadius ??
|
|
272
|
-
barBorderTopRightRadius ??
|
|
273
|
-
item.barBorderRadius ??
|
|
274
|
-
barBorderRadius,
|
|
275
|
-
borderBottomLeftRadius:
|
|
276
|
-
item.barBorderBottomLeftRadius ??
|
|
277
|
-
barBorderBottomLeftRadius ??
|
|
278
|
-
item.barBorderRadius ??
|
|
279
|
-
barBorderRadius,
|
|
280
|
-
borderBottomRightRadius:
|
|
281
|
-
item.barBorderBottomRightRadius ??
|
|
282
|
-
barBorderBottomRightRadius ??
|
|
283
|
-
item.barBorderRadius ??
|
|
284
|
-
barBorderRadius,
|
|
285
|
-
},
|
|
286
|
-
props.roundedBottom && {
|
|
287
|
-
borderBottomLeftRadius:
|
|
288
|
-
(item.barWidth || props.barWidth || 30) / 2,
|
|
289
|
-
borderBottomRightRadius:
|
|
290
|
-
(item.barWidth || props.barWidth || 30) / 2,
|
|
291
|
-
},
|
|
292
|
-
props.cappedBars && {
|
|
293
|
-
borderTopLeftRadius:
|
|
294
|
-
item.capRadius === 0
|
|
295
|
-
? 0
|
|
296
|
-
: item.capRadius || props.capRadius || 0,
|
|
297
|
-
borderTopRightRadius:
|
|
298
|
-
item.capRadius === 0
|
|
299
|
-
? 0
|
|
300
|
-
: item.capRadius || props.capRadius || 0,
|
|
301
|
-
},
|
|
302
|
-
props.roundedTop && {
|
|
303
|
-
borderTopLeftRadius: (item.barWidth || props.barWidth || 30) / 2,
|
|
304
|
-
borderTopRightRadius: (item.barWidth || props.barWidth || 30) / 2,
|
|
305
|
-
},
|
|
306
|
-
]}
|
|
191
|
+
style={commonStyleForBar}
|
|
307
192
|
start={{x: 0, y: 0}}
|
|
308
193
|
end={{x: 0, y: 1}}
|
|
309
194
|
colors={[
|
|
@@ -364,19 +249,6 @@ const RenderBars = (props: Props) => {
|
|
|
364
249
|
);
|
|
365
250
|
};
|
|
366
251
|
|
|
367
|
-
const barHeight = Math.max(
|
|
368
|
-
minHeight,
|
|
369
|
-
(Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200) -
|
|
370
|
-
(xAxisThickness ?? 0),
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
let leftSpacing = initialSpacing;
|
|
374
|
-
for (let i = 0; i < index; i++) {
|
|
375
|
-
leftSpacing +=
|
|
376
|
-
(data[i].spacing ?? propSpacing) +
|
|
377
|
-
(data[i].barWidth || props.barWidth || 30);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
252
|
const barWrapperStyle = [
|
|
381
253
|
{
|
|
382
254
|
// overflow: 'visible',
|
|
@@ -420,23 +292,16 @@ const RenderBars = (props: Props) => {
|
|
|
420
292
|
const barContent = () => {
|
|
421
293
|
const animated2DWithGradient = (noGradient, noAnimation) => (
|
|
422
294
|
<Animated2DWithGradient
|
|
423
|
-
|
|
424
|
-
patternId={props.patternId}
|
|
295
|
+
{...commonPropsFor2Dand3Dbars}
|
|
425
296
|
barWidth={props.barWidth || 30}
|
|
426
|
-
barStyle={barStyle}
|
|
427
|
-
item={item}
|
|
428
|
-
index={index}
|
|
429
|
-
opacity={opacity}
|
|
430
297
|
animationDuration={animationDuration || 800}
|
|
431
298
|
roundedBottom={props.roundedBottom || false}
|
|
432
299
|
roundedTop={props.roundedTop || false}
|
|
433
300
|
noGradient={noGradient}
|
|
434
301
|
noAnimation={noAnimation}
|
|
435
302
|
gradientColor={noGradient ? undefined : props.gradientColor}
|
|
436
|
-
frontColor={props.frontColor || 'black'}
|
|
437
303
|
containerHeight={containerHeight}
|
|
438
304
|
maxValue={maxValue}
|
|
439
|
-
height={barHeight}
|
|
440
305
|
minHeight={minHeight ?? 0}
|
|
441
306
|
barMarginBottom={barMarginBottom}
|
|
442
307
|
cappedBars={props.cappedBars}
|
|
@@ -444,10 +309,6 @@ const RenderBars = (props: Props) => {
|
|
|
444
309
|
capColor={props.capColor}
|
|
445
310
|
capRadius={props.capRadius}
|
|
446
311
|
horizontal={horizontal}
|
|
447
|
-
intactTopLabel={intactTopLabel}
|
|
448
|
-
showValuesAsTopLabel={!!showValuesAsTopLabel}
|
|
449
|
-
topLabelContainerStyle={topLabelContainerStyle}
|
|
450
|
-
topLabelTextStyle={topLabelTextStyle}
|
|
451
312
|
barBorderWidth={barBorderWidth}
|
|
452
313
|
barBorderColor={barBorderColor}
|
|
453
314
|
barBorderRadius={props.barBorderRadius || 0}
|
|
@@ -455,7 +316,6 @@ const RenderBars = (props: Props) => {
|
|
|
455
316
|
barBorderTopRightRadius={barBorderTopRightRadius}
|
|
456
317
|
barBorderBottomLeftRadius={barBorderBottomLeftRadius}
|
|
457
318
|
barBorderBottomRightRadius={barBorderBottomRightRadius}
|
|
458
|
-
barInnerComponent={localBarInnerComponent}
|
|
459
319
|
/>
|
|
460
320
|
);
|
|
461
321
|
return (
|
|
@@ -478,32 +338,15 @@ const RenderBars = (props: Props) => {
|
|
|
478
338
|
)}
|
|
479
339
|
{isThreeD ? (
|
|
480
340
|
<AnimatedThreeDBar
|
|
481
|
-
|
|
482
|
-
item.barBackgroundPattern || props.barBackgroundPattern
|
|
483
|
-
}
|
|
484
|
-
barInnerComponent={localBarInnerComponent}
|
|
485
|
-
patternId={item.patternId || props.patternId}
|
|
486
|
-
width={item.barWidth || props.barWidth || 30}
|
|
487
|
-
barStyle={barStyle}
|
|
488
|
-
item={item}
|
|
489
|
-
index={index}
|
|
341
|
+
{...commonPropsFor2Dand3Dbars}
|
|
490
342
|
sideWidth={
|
|
491
343
|
item.sideWidth ||
|
|
492
344
|
props.sideWidth ||
|
|
493
345
|
(item.barWidth || props.barWidth || 30) / 2
|
|
494
346
|
}
|
|
495
347
|
side={side || 'left'}
|
|
496
|
-
frontColor={item.frontColor || props.frontColor || ''}
|
|
497
348
|
sideColor={item.sideColor || props.sideColor || ''}
|
|
498
349
|
topColor={item.topColor || props.topColor || ''}
|
|
499
|
-
showGradient={item.showGradient || props.showGradient || false}
|
|
500
|
-
gradientColor={item.gradientColor || props.gradientColor}
|
|
501
|
-
opacity={opacity || 1}
|
|
502
|
-
height={barHeight}
|
|
503
|
-
intactTopLabel={intactTopLabel}
|
|
504
|
-
showValuesAsTopLabel={!!showValuesAsTopLabel}
|
|
505
|
-
topLabelContainerStyle={topLabelContainerStyle}
|
|
506
|
-
topLabelTextStyle={topLabelTextStyle}
|
|
507
350
|
horizontal={horizontal}
|
|
508
351
|
isAnimated={isAnimated}
|
|
509
352
|
animationDuration={animationDuration || 800}
|
|
@@ -545,6 +388,13 @@ const RenderBars = (props: Props) => {
|
|
|
545
388
|
? props.onPress(item, index)
|
|
546
389
|
: null;
|
|
547
390
|
}}
|
|
391
|
+
onLongPress={()=>{
|
|
392
|
+
item.onLongPress
|
|
393
|
+
? item.onLongPress()
|
|
394
|
+
: props.onLongPress
|
|
395
|
+
? props.onLongPress(item, index)
|
|
396
|
+
: null;
|
|
397
|
+
}}
|
|
548
398
|
style={barWrapperStyle}>
|
|
549
399
|
{barContent()}
|
|
550
400
|
</TouchableOpacity>
|