react-native-gifted-charts 1.4.17 → 1.4.18
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
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": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"gifted-charts-core": "^0.1.
|
|
28
|
+
"gifted-charts-core": "^0.1.16"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/core": "^7.22.5",
|
|
@@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react';
|
|
|
2
2
|
import {View, LayoutAnimation, Platform, UIManager, Text} from 'react-native';
|
|
3
3
|
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
4
4
|
import Cap from '../Components/BarSpecificComponents/cap';
|
|
5
|
-
import LinearGradient from
|
|
5
|
+
import LinearGradient from '../Components/common/LinearGradient';
|
|
6
6
|
import {Animated2DWithGradientPropsType} from 'gifted-charts-core';
|
|
7
7
|
|
|
8
8
|
if (Platform.OS === 'android') {
|
|
@@ -22,8 +22,6 @@ const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
|
|
|
22
22
|
animationDuration,
|
|
23
23
|
noGradient,
|
|
24
24
|
noAnimation,
|
|
25
|
-
containerHeight,
|
|
26
|
-
maxValue,
|
|
27
25
|
barMarginBottom,
|
|
28
26
|
barInnerComponent,
|
|
29
27
|
intactTopLabel,
|
|
@@ -46,6 +44,8 @@ const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
|
|
|
46
44
|
} else {
|
|
47
45
|
elevate();
|
|
48
46
|
}
|
|
47
|
+
} else {
|
|
48
|
+
setHeight(props.height);
|
|
49
49
|
}
|
|
50
50
|
}, [props.height]);
|
|
51
51
|
|
|
@@ -33,7 +33,9 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
33
33
|
animationDuration,
|
|
34
34
|
autoShiftLabels,
|
|
35
35
|
label,
|
|
36
|
+
secondaryLabel,
|
|
36
37
|
labelTextStyle,
|
|
38
|
+
secondaryLabelTextStyle,
|
|
37
39
|
xAxisTextNumberOfLines,
|
|
38
40
|
xAxisLabelsVerticalShift,
|
|
39
41
|
renderTooltip,
|
|
@@ -59,6 +61,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
59
61
|
negativeStepHeight,
|
|
60
62
|
negativeStepValue,
|
|
61
63
|
autoCenterTooltip,
|
|
64
|
+
secondaryXAxis,
|
|
62
65
|
} = props;
|
|
63
66
|
|
|
64
67
|
const heightFactor =
|
|
@@ -91,7 +94,12 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
91
94
|
? 0
|
|
92
95
|
: item.barMarginBottom || props.barMarginBottom || 0;
|
|
93
96
|
|
|
94
|
-
const renderLabel = (
|
|
97
|
+
const renderLabel = (
|
|
98
|
+
top: boolean,
|
|
99
|
+
label: String,
|
|
100
|
+
labelTextStyle: any,
|
|
101
|
+
value: number,
|
|
102
|
+
) => {
|
|
95
103
|
return (
|
|
96
104
|
<View
|
|
97
105
|
style={[
|
|
@@ -104,12 +112,16 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
104
112
|
left: spacing / -2,
|
|
105
113
|
position: 'absolute',
|
|
106
114
|
height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
|
|
107
|
-
bottom:
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
bottom: top
|
|
116
|
+
? (containerHeight || 200) +
|
|
117
|
+
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
118
|
+
: (rotateLabel
|
|
119
|
+
? -40
|
|
120
|
+
: -6 -
|
|
121
|
+
xAxisTextNumberOfLines * 18 -
|
|
122
|
+
xAxisLabelsVerticalShift) -
|
|
123
|
+
barMarginBottom -
|
|
124
|
+
labelsDistanceFromXaxis,
|
|
113
125
|
},
|
|
114
126
|
rotateLabel
|
|
115
127
|
? horizontal
|
|
@@ -136,7 +148,21 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
136
148
|
}
|
|
137
149
|
: {},
|
|
138
150
|
]}>
|
|
139
|
-
{
|
|
151
|
+
{top ? (
|
|
152
|
+
item.secondaryLabelComponent ? (
|
|
153
|
+
item.secondaryLabelComponent()
|
|
154
|
+
) : (
|
|
155
|
+
<Text
|
|
156
|
+
style={[
|
|
157
|
+
{textAlign: 'center'},
|
|
158
|
+
rtl && horizontal && {transform: [{rotate: '180deg'}]},
|
|
159
|
+
labelTextStyle,
|
|
160
|
+
]}
|
|
161
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
162
|
+
{label}
|
|
163
|
+
</Text>
|
|
164
|
+
)
|
|
165
|
+
) : item.labelComponent ? (
|
|
140
166
|
item.labelComponent()
|
|
141
167
|
) : (
|
|
142
168
|
<Text
|
|
@@ -146,7 +172,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
146
172
|
labelTextStyle,
|
|
147
173
|
]}
|
|
148
174
|
numberOfLines={xAxisTextNumberOfLines}>
|
|
149
|
-
{label
|
|
175
|
+
{label}
|
|
150
176
|
</Text>
|
|
151
177
|
)}
|
|
152
178
|
</View>
|
|
@@ -154,6 +180,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
154
180
|
};
|
|
155
181
|
|
|
156
182
|
const renderAnimatedLabel = (
|
|
183
|
+
top: boolean,
|
|
157
184
|
label: String,
|
|
158
185
|
labelTextStyle: any,
|
|
159
186
|
value: number,
|
|
@@ -170,11 +197,14 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
170
197
|
left: spacing / -2,
|
|
171
198
|
position: 'absolute',
|
|
172
199
|
height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
|
|
173
|
-
bottom:
|
|
174
|
-
(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
200
|
+
bottom: top
|
|
201
|
+
? (containerHeight || 200) +
|
|
202
|
+
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
203
|
+
: (rotateLabel
|
|
204
|
+
? -40
|
|
205
|
+
: -6 -
|
|
206
|
+
xAxisTextNumberOfLines * 18 -
|
|
207
|
+
xAxisLabelsVerticalShift) - barMarginBottom,
|
|
178
208
|
opacity: appearingOpacity,
|
|
179
209
|
},
|
|
180
210
|
value < 0 && {transform: [{rotate: '180deg'}]},
|
|
@@ -197,7 +227,21 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
197
227
|
}
|
|
198
228
|
: {},
|
|
199
229
|
]}>
|
|
200
|
-
{
|
|
230
|
+
{top ? (
|
|
231
|
+
item.secondaryLabelComponent ? (
|
|
232
|
+
item.secondaryLabelComponent()
|
|
233
|
+
) : (
|
|
234
|
+
<Text
|
|
235
|
+
style={[
|
|
236
|
+
{textAlign: 'center'},
|
|
237
|
+
rtl && horizontal && {transform: [{rotate: '180deg'}]},
|
|
238
|
+
labelTextStyle,
|
|
239
|
+
]}
|
|
240
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
241
|
+
{label}
|
|
242
|
+
</Text>
|
|
243
|
+
)
|
|
244
|
+
) : item.labelComponent ? (
|
|
201
245
|
item.labelComponent()
|
|
202
246
|
) : (
|
|
203
247
|
<Text
|
|
@@ -207,7 +251,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
207
251
|
labelTextStyle,
|
|
208
252
|
]}
|
|
209
253
|
numberOfLines={xAxisTextNumberOfLines}>
|
|
210
|
-
{label
|
|
254
|
+
{label}
|
|
211
255
|
</Text>
|
|
212
256
|
)}
|
|
213
257
|
</Animated.View>
|
|
@@ -399,8 +443,23 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
399
443
|
animated2DWithGradient(true, true)
|
|
400
444
|
)}
|
|
401
445
|
{isAnimated
|
|
402
|
-
? renderAnimatedLabel(label, labelTextStyle, item.value)
|
|
403
|
-
: renderLabel(label, labelTextStyle, item.value)}
|
|
446
|
+
? renderAnimatedLabel(false, label, labelTextStyle, item.value)
|
|
447
|
+
: renderLabel(false, label, labelTextStyle, item.value)}
|
|
448
|
+
{secondaryXAxis
|
|
449
|
+
? isAnimated
|
|
450
|
+
? renderAnimatedLabel(
|
|
451
|
+
true,
|
|
452
|
+
secondaryLabel,
|
|
453
|
+
secondaryLabelTextStyle,
|
|
454
|
+
item.value,
|
|
455
|
+
)
|
|
456
|
+
: renderLabel(
|
|
457
|
+
true,
|
|
458
|
+
secondaryLabel,
|
|
459
|
+
secondaryLabelTextStyle,
|
|
460
|
+
item.value,
|
|
461
|
+
)
|
|
462
|
+
: null}
|
|
404
463
|
</>
|
|
405
464
|
);
|
|
406
465
|
};
|
|
@@ -62,6 +62,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
62
62
|
secondaryYAxis,
|
|
63
63
|
onlyReferenceLines,
|
|
64
64
|
renderReferenceLines,
|
|
65
|
+
secondaryXAxis,
|
|
65
66
|
} = props;
|
|
66
67
|
|
|
67
68
|
const {
|
|
@@ -183,7 +184,12 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
183
184
|
style={[
|
|
184
185
|
styles.leftPart,
|
|
185
186
|
{
|
|
186
|
-
|
|
187
|
+
borderLeftColor: yAxisColor,
|
|
188
|
+
borderRightColor: yAxisColor,
|
|
189
|
+
borderTopColor: secondaryXAxis?.color ?? xAxisColor,
|
|
190
|
+
borderTopWidth: secondaryXAxis
|
|
191
|
+
? secondaryXAxis.thickness ?? xAxisThickness
|
|
192
|
+
: 0,
|
|
187
193
|
backgroundColor: backgroundColor,
|
|
188
194
|
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
189
195
|
},
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -313,6 +313,8 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
313
313
|
parentWidth: props.parentWidth ?? screenWidth,
|
|
314
314
|
});
|
|
315
315
|
|
|
316
|
+
const {secondaryXAxis} = props;
|
|
317
|
+
|
|
316
318
|
const widthValuesFromSet = useMemo(
|
|
317
319
|
() => dataSet?.map(set => new Animated.Value(0)),
|
|
318
320
|
[],
|
|
@@ -458,6 +460,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
458
460
|
]);
|
|
459
461
|
|
|
460
462
|
const renderLabel = (
|
|
463
|
+
top: boolean,
|
|
461
464
|
index: number,
|
|
462
465
|
label: String,
|
|
463
466
|
labelTextStyle: any,
|
|
@@ -468,7 +471,11 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
468
471
|
style={[
|
|
469
472
|
{
|
|
470
473
|
position: 'absolute',
|
|
471
|
-
bottom:
|
|
474
|
+
bottom: top
|
|
475
|
+
? containerHeight +
|
|
476
|
+
60 +
|
|
477
|
+
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
478
|
+
: 54 - xAxisTextNumberOfLines * 18,
|
|
472
479
|
zIndex: 10,
|
|
473
480
|
width: spacing + labelsExtraHeight,
|
|
474
481
|
left:
|
|
@@ -485,7 +492,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
485
492
|
<Text
|
|
486
493
|
style={[{textAlign: 'center'}, labelTextStyle]}
|
|
487
494
|
numberOfLines={xAxisTextNumberOfLines}>
|
|
488
|
-
{label
|
|
495
|
+
{label}
|
|
489
496
|
</Text>
|
|
490
497
|
)}
|
|
491
498
|
</View>
|
|
@@ -493,6 +500,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
493
500
|
};
|
|
494
501
|
|
|
495
502
|
const renderAnimatedLabel = (
|
|
503
|
+
top: boolean,
|
|
496
504
|
index: number,
|
|
497
505
|
label: String,
|
|
498
506
|
labelTextStyle: any,
|
|
@@ -506,7 +514,13 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
506
514
|
? 40
|
|
507
515
|
: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
|
|
508
516
|
position: 'absolute',
|
|
509
|
-
bottom:
|
|
517
|
+
bottom: top
|
|
518
|
+
? containerHeight +
|
|
519
|
+
60 +
|
|
520
|
+
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
521
|
+
: rotateLabel
|
|
522
|
+
? 10
|
|
523
|
+
: 54 - xAxisTextNumberOfLines * 18,
|
|
510
524
|
zIndex: 10,
|
|
511
525
|
width: spacing,
|
|
512
526
|
left:
|
|
@@ -523,7 +537,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
523
537
|
<Text
|
|
524
538
|
style={[{textAlign: 'center'}, labelTextStyle]}
|
|
525
539
|
numberOfLines={xAxisTextNumberOfLines}>
|
|
526
|
-
{label
|
|
540
|
+
{label}
|
|
527
541
|
</Text>
|
|
528
542
|
)}
|
|
529
543
|
</Animated.View>
|
|
@@ -2142,10 +2156,18 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
2142
2156
|
</View>
|
|
2143
2157
|
) : null}
|
|
2144
2158
|
{(data0 ?? data).map((item: lineDataItem, index: number) => {
|
|
2159
|
+
const secondaryLabel =
|
|
2160
|
+
item.secondaryLabel ?? secondaryXAxis?.labelTexts?.[index] ?? '';
|
|
2161
|
+
const secondaryLabelTextStyle =
|
|
2162
|
+
item.secondaryLabelTextStyle ??
|
|
2163
|
+
secondaryXAxis?.labelsTextStyle ??
|
|
2164
|
+
item.labelTextStyle ??
|
|
2165
|
+
props.xAxisLabelTextStyle;
|
|
2145
2166
|
return (
|
|
2146
2167
|
<View key={index}>
|
|
2147
2168
|
{isAnimated
|
|
2148
2169
|
? renderAnimatedLabel(
|
|
2170
|
+
false,
|
|
2149
2171
|
index,
|
|
2150
2172
|
item.label ||
|
|
2151
2173
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
@@ -2155,6 +2177,7 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
2155
2177
|
item.labelComponent,
|
|
2156
2178
|
)
|
|
2157
2179
|
: renderLabel(
|
|
2180
|
+
false,
|
|
2158
2181
|
index,
|
|
2159
2182
|
item.label ||
|
|
2160
2183
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
@@ -2163,7 +2186,23 @@ export const LineChart = (props: LineChartPropsType) => {
|
|
|
2163
2186
|
item.labelTextStyle || props.xAxisLabelTextStyle,
|
|
2164
2187
|
item.labelComponent,
|
|
2165
2188
|
)}
|
|
2166
|
-
{
|
|
2189
|
+
{secondaryXAxis
|
|
2190
|
+
? isAnimated
|
|
2191
|
+
? renderAnimatedLabel(
|
|
2192
|
+
true,
|
|
2193
|
+
index,
|
|
2194
|
+
secondaryLabel,
|
|
2195
|
+
secondaryLabelTextStyle,
|
|
2196
|
+
item.secondaryLabelComponent,
|
|
2197
|
+
)
|
|
2198
|
+
: renderLabel(
|
|
2199
|
+
true,
|
|
2200
|
+
index,
|
|
2201
|
+
secondaryLabel,
|
|
2202
|
+
secondaryLabelTextStyle,
|
|
2203
|
+
item.secondaryLabelComponent,
|
|
2204
|
+
)
|
|
2205
|
+
: null}
|
|
2167
2206
|
</View>
|
|
2168
2207
|
);
|
|
2169
2208
|
})}
|