react-native-gifted-charts 1.4.2 → 1.4.4
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/package.json +2 -2
- package/src/BarChart/Animated2DWithGradient.tsx +27 -27
- package/src/BarChart/RenderBars.tsx +28 -3
- package/src/BarChart/RenderStackBars.tsx +13 -3
- package/src/BarChart/index.tsx +2 -6
- package/src/Components/AnimatedThreeDBar/index.tsx +25 -23
- package/src/LineChart/index.tsx +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
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": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"gifted-charts-core": "^0.0.
|
|
27
|
+
"gifted-charts-core": "^0.0.14"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.22.5",
|
|
@@ -173,35 +173,35 @@ const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
|
|
|
173
173
|
</View>
|
|
174
174
|
) : null}
|
|
175
175
|
</View>
|
|
176
|
-
{(item.topLabelComponent || showValuesAsTopLabel) && (
|
|
177
|
-
<View
|
|
178
|
-
style={[
|
|
179
|
-
{
|
|
180
|
-
position: 'absolute',
|
|
181
|
-
top: (item.barWidth || barWidth || 30) * -1,
|
|
182
|
-
height: item.barWidth || barWidth || 30,
|
|
183
|
-
width: item.barWidth || barWidth || 30,
|
|
184
|
-
justifyContent:
|
|
185
|
-
(props.horizontal && !intactTopLabel) || item.value < 0
|
|
186
|
-
? 'center'
|
|
187
|
-
: 'flex-end',
|
|
188
|
-
alignItems: 'center',
|
|
189
|
-
opacity: opacity,
|
|
190
|
-
},
|
|
191
|
-
item.value < 0 && {transform: [{rotate: '180deg'}]},
|
|
192
|
-
props.horizontal &&
|
|
193
|
-
!intactTopLabel && {transform: [{rotate: '270deg'}]},
|
|
194
|
-
topLabelContainerStyle ?? item.topLabelContainerStyle,
|
|
195
|
-
]}>
|
|
196
|
-
{showValuesAsTopLabel ? (
|
|
197
|
-
<Text style={topLabelTextStyle}>{item.value}</Text>
|
|
198
|
-
) : (
|
|
199
|
-
item.topLabelComponent?.()
|
|
200
|
-
)}
|
|
201
|
-
</View>
|
|
202
|
-
)}
|
|
203
176
|
</View>
|
|
204
177
|
)}
|
|
178
|
+
{item.topLabelComponent || showValuesAsTopLabel ? (
|
|
179
|
+
<View
|
|
180
|
+
style={[
|
|
181
|
+
{
|
|
182
|
+
position: 'absolute',
|
|
183
|
+
top: (item.barWidth || barWidth || 30) * -1,
|
|
184
|
+
height: item.barWidth || barWidth || 30,
|
|
185
|
+
width: item.barWidth || barWidth || 30,
|
|
186
|
+
justifyContent:
|
|
187
|
+
(props.horizontal && !intactTopLabel) || item.value < 0
|
|
188
|
+
? 'center'
|
|
189
|
+
: 'flex-end',
|
|
190
|
+
alignItems: 'center',
|
|
191
|
+
opacity: opacity,
|
|
192
|
+
},
|
|
193
|
+
item.value < 0 && {transform: [{rotate: '180deg'}]},
|
|
194
|
+
props.horizontal &&
|
|
195
|
+
!intactTopLabel && {transform: [{rotate: '270deg'}]},
|
|
196
|
+
topLabelContainerStyle ?? item.topLabelContainerStyle,
|
|
197
|
+
]}>
|
|
198
|
+
{showValuesAsTopLabel ? (
|
|
199
|
+
<Text style={topLabelTextStyle}>{item.value}</Text>
|
|
200
|
+
) : (
|
|
201
|
+
item.topLabelComponent?.()
|
|
202
|
+
)}
|
|
203
|
+
</View>
|
|
204
|
+
) : null}
|
|
205
205
|
</>
|
|
206
206
|
);
|
|
207
207
|
};
|
|
@@ -48,6 +48,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
48
48
|
topLabelContainerStyle,
|
|
49
49
|
topLabelTextStyle,
|
|
50
50
|
pointerConfig,
|
|
51
|
+
noOfSectionsBelowXAxis,
|
|
51
52
|
} = props;
|
|
52
53
|
|
|
53
54
|
const barHeight = Math.max(
|
|
@@ -112,7 +113,11 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
112
113
|
? {
|
|
113
114
|
transform: [
|
|
114
115
|
{rotate: '180deg'},
|
|
115
|
-
{
|
|
116
|
+
{
|
|
117
|
+
translateY: autoShiftLabels
|
|
118
|
+
? 0
|
|
119
|
+
: 16.5 * xAxisTextNumberOfLines + 14,
|
|
120
|
+
},
|
|
116
121
|
],
|
|
117
122
|
}
|
|
118
123
|
: {},
|
|
@@ -166,7 +171,18 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
166
171
|
: {transform: [{rotate: '60deg'}]}
|
|
167
172
|
: horizontal
|
|
168
173
|
? {transform: [{rotate: '-90deg'}]}
|
|
169
|
-
:
|
|
174
|
+
: value < 0
|
|
175
|
+
? {
|
|
176
|
+
transform: [
|
|
177
|
+
{rotate: '180deg'},
|
|
178
|
+
{
|
|
179
|
+
translateY: autoShiftLabels
|
|
180
|
+
? 0
|
|
181
|
+
: 16.5 * xAxisTextNumberOfLines + 14,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
}
|
|
185
|
+
: {},
|
|
170
186
|
]}>
|
|
171
187
|
{item.labelComponent ? (
|
|
172
188
|
item.labelComponent()
|
|
@@ -300,6 +316,8 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
300
316
|
(pointerConfig && pointerConfig.barTouchable !== true);
|
|
301
317
|
|
|
302
318
|
const barContent = () => {
|
|
319
|
+
const isBarBelowXaxisAndInvisible =
|
|
320
|
+
item.value < 0 && !noOfSectionsBelowXAxis;
|
|
303
321
|
const animated2DWithGradient = (noGradient, noAnimation) => (
|
|
304
322
|
<Animated2DWithGradient
|
|
305
323
|
{...commonPropsFor2Dand3Dbars}
|
|
@@ -341,7 +359,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
341
359
|
}}
|
|
342
360
|
/>
|
|
343
361
|
)}
|
|
344
|
-
{isThreeD ? (
|
|
362
|
+
{isBarBelowXaxisAndInvisible ? null : isThreeD ? (
|
|
345
363
|
<AnimatedThreeDBar
|
|
346
364
|
{...commonPropsFor2Dand3Dbars}
|
|
347
365
|
sideWidth={
|
|
@@ -401,6 +419,13 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
401
419
|
? props.onLongPress(item, index)
|
|
402
420
|
: null;
|
|
403
421
|
}}
|
|
422
|
+
onPressOut={() => {
|
|
423
|
+
item.onPressOut
|
|
424
|
+
? item.onPressOut()
|
|
425
|
+
: props.onPressOut
|
|
426
|
+
? props.onPressOut(item, index)
|
|
427
|
+
: null;
|
|
428
|
+
}}
|
|
404
429
|
style={barWrapperStyle}>
|
|
405
430
|
{barContent()}
|
|
406
431
|
</TouchableOpacity>
|
|
@@ -9,7 +9,11 @@ import {
|
|
|
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
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
useRenderStackBars,
|
|
14
|
+
BarDefaults,
|
|
15
|
+
StackedBarChartPropsType,
|
|
16
|
+
} from 'gifted-charts-core';
|
|
13
17
|
|
|
14
18
|
if (Platform.OS === 'android') {
|
|
15
19
|
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
@@ -121,7 +125,6 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
|
|
|
121
125
|
};
|
|
122
126
|
|
|
123
127
|
const static2DSimple = () => {
|
|
124
|
-
|
|
125
128
|
return (
|
|
126
129
|
<>
|
|
127
130
|
<TouchableOpacity
|
|
@@ -135,13 +138,20 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
|
|
|
135
138
|
props.onPress(item, index);
|
|
136
139
|
}
|
|
137
140
|
}}
|
|
138
|
-
onLongPress={()=>{
|
|
141
|
+
onLongPress={() => {
|
|
139
142
|
if (item.onLongPress) {
|
|
140
143
|
item.onLongPress();
|
|
141
144
|
} else if (props.onLongPress) {
|
|
142
145
|
props.onLongPress(item, index);
|
|
143
146
|
}
|
|
144
147
|
}}
|
|
148
|
+
onPressOut={() => {
|
|
149
|
+
if (item.onPressOut) {
|
|
150
|
+
item.onPressOut();
|
|
151
|
+
} else if (props.onPressOut) {
|
|
152
|
+
props.onPressOut(item, index);
|
|
153
|
+
}
|
|
154
|
+
}}
|
|
145
155
|
style={[
|
|
146
156
|
{
|
|
147
157
|
position: 'absolute',
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -3,11 +3,7 @@ import {Animated, Easing, View} from 'react-native';
|
|
|
3
3
|
import RenderBars from './RenderBars';
|
|
4
4
|
import RenderStackBars from './RenderStackBars';
|
|
5
5
|
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
6
|
-
import {
|
|
7
|
-
BarChartPropsType,
|
|
8
|
-
useBarChart,
|
|
9
|
-
screenWidth,
|
|
10
|
-
} from 'gifted-charts-core';
|
|
6
|
+
import {BarChartPropsType, useBarChart, screenWidth} from 'gifted-charts-core';
|
|
11
7
|
import {StripAndLabel} from '../Components/common/StripAndLabel';
|
|
12
8
|
import {Pointer} from '../Components/common/Pointer';
|
|
13
9
|
|
|
@@ -338,7 +334,7 @@ export const BarChart = (props: BarChartPropsType) => {
|
|
|
338
334
|
<RenderBars
|
|
339
335
|
data={data}
|
|
340
336
|
side={side}
|
|
341
|
-
minHeight={props.minHeight
|
|
337
|
+
minHeight={props.minHeight ?? (isAnimated && !isThreeD ? 0.1 : 0)}
|
|
342
338
|
sideWidth={props.sideWidth}
|
|
343
339
|
labelWidth={labelWidth}
|
|
344
340
|
isThreeD={isThreeD}
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
import LinearGradient from 'react-native-linear-gradient';
|
|
11
11
|
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
12
12
|
import {styles} from './styles';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
useAnimatedThreeDBar,
|
|
15
|
+
animatedBarPropTypes,
|
|
16
|
+
trianglePropTypes,
|
|
17
|
+
} from 'gifted-charts-core';
|
|
14
18
|
|
|
15
19
|
if (Platform.OS === 'android') {
|
|
16
20
|
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
@@ -154,28 +158,26 @@ const AnimatedThreeDBar = (props: animatedBarPropTypes) => {
|
|
|
154
158
|
|
|
155
159
|
{/*******************************************************************/}
|
|
156
160
|
|
|
157
|
-
{
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
</View>
|
|
178
|
-
) : null}
|
|
161
|
+
<View style={{marginTop: sideWidth / -2}}>
|
|
162
|
+
<TriangleCorner
|
|
163
|
+
color={height ? sideColor : 'transparent'}
|
|
164
|
+
width={sideWidth}
|
|
165
|
+
style={{transform: [{rotate: '-90deg'}], opacity: opacity}}
|
|
166
|
+
/>
|
|
167
|
+
<View
|
|
168
|
+
style={{
|
|
169
|
+
width: sideWidth / 2,
|
|
170
|
+
height: height - sideWidth / 2, //animatedSideHeight
|
|
171
|
+
backgroundColor: sideColor,
|
|
172
|
+
opacity: opacity,
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
<TriangleCorner
|
|
176
|
+
color={height ? sideColor : 'transparent'}
|
|
177
|
+
width={sideWidth}
|
|
178
|
+
style={{transform: [{rotate: '90deg'}], opacity: opacity}}
|
|
179
|
+
/>
|
|
180
|
+
</View>
|
|
179
181
|
|
|
180
182
|
<View
|
|
181
183
|
style={[
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -104,7 +104,6 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
104
104
|
arrowPointsFromSet,
|
|
105
105
|
selectedIndex,
|
|
106
106
|
setSelectedIndex,
|
|
107
|
-
noOfSections,
|
|
108
107
|
containerHeight,
|
|
109
108
|
data,
|
|
110
109
|
data2,
|
|
@@ -298,7 +297,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
298
297
|
|
|
299
298
|
if (!initialData) {
|
|
300
299
|
initialData = data0 ?? [...data];
|
|
301
|
-
animations = initialData
|
|
300
|
+
animations = initialData?.map(item => new Animated.Value(item.value));
|
|
302
301
|
}
|
|
303
302
|
|
|
304
303
|
const widthValuesFromSet = useMemo(
|