react-native-gifted-charts 1.2.34 → 1.2.37
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 +1 -1
- package/src/BarChart/Animated2DWithGradient.tsx +11 -4
- package/src/BarChart/RenderBars.tsx +35 -18
- package/src/BarChart/RenderStackBars.tsx +48 -4
- package/src/BarChart/index.tsx +15 -0
- package/src/Components/AnimatedBar/index.tsx +1 -1
- package/src/Components/ThreeDBar/index.tsx +1 -1
- package/src/todos.md +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.37",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -17,6 +17,7 @@ if (Platform.OS === 'android') {
|
|
|
17
17
|
type propTypes = {
|
|
18
18
|
item: itemType;
|
|
19
19
|
height: number;
|
|
20
|
+
minHeight: number;
|
|
20
21
|
opacity?: number;
|
|
21
22
|
animationDuration: number;
|
|
22
23
|
roundedTop: Boolean;
|
|
@@ -119,8 +120,11 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
119
120
|
width: '100%',
|
|
120
121
|
height:
|
|
121
122
|
(noAnimation
|
|
122
|
-
?
|
|
123
|
-
|
|
123
|
+
? Math.max(
|
|
124
|
+
props.minHeight,
|
|
125
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
126
|
+
(maxValue || 200),
|
|
127
|
+
)
|
|
124
128
|
: height) - (barMarginBottom || 0),
|
|
125
129
|
}}>
|
|
126
130
|
<View
|
|
@@ -128,8 +132,11 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
128
132
|
width: '100%',
|
|
129
133
|
height:
|
|
130
134
|
(noAnimation
|
|
131
|
-
?
|
|
132
|
-
|
|
135
|
+
? Math.max(
|
|
136
|
+
props.minHeight,
|
|
137
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
138
|
+
(maxValue || 200),
|
|
139
|
+
)
|
|
133
140
|
: height) - (barMarginBottom || 0),
|
|
134
141
|
}}>
|
|
135
142
|
{noGradient ? (
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
style?: any;
|
|
12
12
|
width?: number;
|
|
13
13
|
height?: number;
|
|
14
|
+
minHeight?: number;
|
|
14
15
|
color?: ColorValue;
|
|
15
16
|
showGradient?: Boolean;
|
|
16
17
|
gradientColor?: any;
|
|
@@ -63,6 +64,7 @@ type Props = {
|
|
|
63
64
|
onPress?: Function;
|
|
64
65
|
xAxisTextNumberOfLines: number;
|
|
65
66
|
renderTooltip: Function;
|
|
67
|
+
leftShiftForLastIndexTooltip: number;
|
|
66
68
|
initialSpacing: number;
|
|
67
69
|
selectedIndex: number;
|
|
68
70
|
setSelectedIndex: Function;
|
|
@@ -100,6 +102,7 @@ const RenderBars = (props: Props) => {
|
|
|
100
102
|
index,
|
|
101
103
|
containerHeight,
|
|
102
104
|
maxValue,
|
|
105
|
+
minHeight,
|
|
103
106
|
spacing,
|
|
104
107
|
propSpacing,
|
|
105
108
|
side,
|
|
@@ -117,6 +120,7 @@ const RenderBars = (props: Props) => {
|
|
|
117
120
|
labelTextStyle,
|
|
118
121
|
xAxisTextNumberOfLines,
|
|
119
122
|
renderTooltip,
|
|
123
|
+
leftShiftForLastIndexTooltip,
|
|
120
124
|
initialSpacing,
|
|
121
125
|
selectedIndex,
|
|
122
126
|
setSelectedIndex,
|
|
@@ -324,12 +328,14 @@ const RenderBars = (props: Props) => {
|
|
|
324
328
|
);
|
|
325
329
|
};
|
|
326
330
|
|
|
327
|
-
const barHeight =
|
|
331
|
+
const barHeight = Math.max(
|
|
332
|
+
minHeight,
|
|
328
333
|
(item.value >= 0 && (!isThreeD || isAnimated) && item.topLabelComponent
|
|
329
334
|
? (item.topLabelComponentHeight || 30) +
|
|
330
335
|
(Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200)
|
|
331
336
|
: (Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200)) -
|
|
332
|
-
|
|
337
|
+
barMarginBottom,
|
|
338
|
+
);
|
|
333
339
|
|
|
334
340
|
let leftSpacing = initialSpacing;
|
|
335
341
|
for (let i = 0; i < index; i++) {
|
|
@@ -424,11 +430,12 @@ const RenderBars = (props: Props) => {
|
|
|
424
430
|
topLabelComponent={item.topLabelComponent}
|
|
425
431
|
opacity={opacity || 1}
|
|
426
432
|
animationDuration={animationDuration || 800}
|
|
427
|
-
height={
|
|
433
|
+
height={Math.max(
|
|
434
|
+
minHeight,
|
|
428
435
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
429
436
|
(maxValue || 200) -
|
|
430
|
-
|
|
431
|
-
}
|
|
437
|
+
barMarginBottom,
|
|
438
|
+
)}
|
|
432
439
|
intactTopLabel={props.intactTopLabel}
|
|
433
440
|
horizontal={props.horizontal}
|
|
434
441
|
/>
|
|
@@ -457,11 +464,12 @@ const RenderBars = (props: Props) => {
|
|
|
457
464
|
opacity={opacity || 1}
|
|
458
465
|
horizontal={props.horizontal}
|
|
459
466
|
intactTopLabel={props.intactTopLabel}
|
|
460
|
-
height={
|
|
467
|
+
height={Math.max(
|
|
468
|
+
minHeight,
|
|
461
469
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
462
470
|
(maxValue || 200) -
|
|
463
|
-
|
|
464
|
-
}
|
|
471
|
+
barMarginBottom,
|
|
472
|
+
)}
|
|
465
473
|
value={item.value}
|
|
466
474
|
/>
|
|
467
475
|
)
|
|
@@ -480,10 +488,12 @@ const RenderBars = (props: Props) => {
|
|
|
480
488
|
frontColor={props.frontColor || 'black'}
|
|
481
489
|
containerHeight={containerHeight}
|
|
482
490
|
maxValue={maxValue}
|
|
483
|
-
height={
|
|
491
|
+
height={Math.max(
|
|
492
|
+
minHeight,
|
|
484
493
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
485
|
-
|
|
486
|
-
}
|
|
494
|
+
(maxValue || 200),
|
|
495
|
+
)}
|
|
496
|
+
minHeight={minHeight}
|
|
487
497
|
barMarginBottom={barMarginBottom}
|
|
488
498
|
cappedBars={props.cappedBars}
|
|
489
499
|
capThickness={props.capThickness}
|
|
@@ -511,10 +521,12 @@ const RenderBars = (props: Props) => {
|
|
|
511
521
|
frontColor={props.frontColor || 'black'}
|
|
512
522
|
containerHeight={containerHeight}
|
|
513
523
|
maxValue={maxValue}
|
|
514
|
-
height={
|
|
524
|
+
height={Math.max(
|
|
525
|
+
minHeight,
|
|
515
526
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
516
|
-
|
|
517
|
-
}
|
|
527
|
+
(maxValue || 200),
|
|
528
|
+
)}
|
|
529
|
+
minHeight={minHeight}
|
|
518
530
|
barMarginBottom={barMarginBottom}
|
|
519
531
|
cappedBars={props.cappedBars}
|
|
520
532
|
capThickness={props.capThickness}
|
|
@@ -540,10 +552,12 @@ const RenderBars = (props: Props) => {
|
|
|
540
552
|
frontColor={props.frontColor || 'black'}
|
|
541
553
|
containerHeight={containerHeight}
|
|
542
554
|
maxValue={maxValue}
|
|
543
|
-
height={
|
|
555
|
+
height={Math.max(
|
|
556
|
+
minHeight,
|
|
544
557
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
545
|
-
|
|
546
|
-
}
|
|
558
|
+
(maxValue || 200),
|
|
559
|
+
)}
|
|
560
|
+
minHeight={minHeight}
|
|
547
561
|
barMarginBottom={barMarginBottom}
|
|
548
562
|
cappedBars={props.cappedBars}
|
|
549
563
|
capThickness={props.capThickness}
|
|
@@ -563,7 +577,10 @@ const RenderBars = (props: Props) => {
|
|
|
563
577
|
style={{
|
|
564
578
|
position: 'absolute',
|
|
565
579
|
bottom: barHeight + 60,
|
|
566
|
-
left:
|
|
580
|
+
left:
|
|
581
|
+
index === data.length - 1
|
|
582
|
+
? leftSpacing - leftShiftForLastIndexTooltip
|
|
583
|
+
: leftSpacing,
|
|
567
584
|
zIndex: 1000,
|
|
568
585
|
}}>
|
|
569
586
|
{renderTooltip(item, index)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {View, TouchableOpacity, Text, ColorValue} from 'react-native';
|
|
3
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
3
4
|
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
4
5
|
import {Style} from 'util';
|
|
5
6
|
|
|
@@ -23,6 +24,7 @@ type Props = {
|
|
|
23
24
|
propSpacing?: number;
|
|
24
25
|
data?: any;
|
|
25
26
|
barWidth?: number;
|
|
27
|
+
onPress?: Function;
|
|
26
28
|
|
|
27
29
|
rotateLabel?: Boolean;
|
|
28
30
|
showXAxisIndices: Boolean;
|
|
@@ -37,10 +39,13 @@ type Props = {
|
|
|
37
39
|
patternId?: String;
|
|
38
40
|
xAxisTextNumberOfLines: number;
|
|
39
41
|
renderTooltip: Function;
|
|
42
|
+
leftShiftForLastIndexTooltip: number;
|
|
40
43
|
initialSpacing: number;
|
|
41
44
|
selectedIndex: number;
|
|
42
45
|
setSelectedIndex: Function;
|
|
43
46
|
activeOpacity: number;
|
|
47
|
+
showGradient?: Boolean;
|
|
48
|
+
gradientColor?: any;
|
|
44
49
|
stackData: Array<itemType>;
|
|
45
50
|
};
|
|
46
51
|
type itemType = {
|
|
@@ -53,6 +58,9 @@ type itemType = {
|
|
|
53
58
|
topLabelComponent?: Function;
|
|
54
59
|
topLabelContainerStyle?: any;
|
|
55
60
|
disablePress?: any;
|
|
61
|
+
color?: ColorValue;
|
|
62
|
+
showGradient?: Boolean;
|
|
63
|
+
gradientColor?: any;
|
|
56
64
|
capThickness?: number;
|
|
57
65
|
capColor?: ColorValue;
|
|
58
66
|
capRadius?: number;
|
|
@@ -60,6 +68,7 @@ type itemType = {
|
|
|
60
68
|
borderRadius?: number;
|
|
61
69
|
stacks?: Array<any>;
|
|
62
70
|
barBackgroundPattern?: Function;
|
|
71
|
+
barBorderRadius?: Number;
|
|
63
72
|
patternId?: String;
|
|
64
73
|
};
|
|
65
74
|
const RenderStackBars = (props: Props) => {
|
|
@@ -78,11 +87,13 @@ const RenderStackBars = (props: Props) => {
|
|
|
78
87
|
labelTextStyle,
|
|
79
88
|
xAxisTextNumberOfLines,
|
|
80
89
|
renderTooltip,
|
|
90
|
+
leftShiftForLastIndexTooltip,
|
|
81
91
|
initialSpacing,
|
|
82
92
|
selectedIndex,
|
|
83
93
|
setSelectedIndex,
|
|
84
94
|
activeOpacity,
|
|
85
95
|
stackData,
|
|
96
|
+
data,
|
|
86
97
|
} = props;
|
|
87
98
|
let leftSpacing = initialSpacing;
|
|
88
99
|
for (let i = 0; i < index; i++) {
|
|
@@ -137,7 +148,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
137
148
|
0,
|
|
138
149
|
);
|
|
139
150
|
|
|
140
|
-
const static2DSimple = (item: itemType) => {
|
|
151
|
+
const static2DSimple = (item: itemType, index: number) => {
|
|
141
152
|
const cotainsNegative = item.stacks.some(item => item.value < 0);
|
|
142
153
|
return (
|
|
143
154
|
<>
|
|
@@ -148,6 +159,8 @@ const RenderStackBars = (props: Props) => {
|
|
|
148
159
|
setSelectedIndex(index);
|
|
149
160
|
if (item.onPress) {
|
|
150
161
|
item.onPress();
|
|
162
|
+
} else if (props.onPress) {
|
|
163
|
+
props.onPress(item, index);
|
|
151
164
|
}
|
|
152
165
|
}}
|
|
153
166
|
style={[
|
|
@@ -179,7 +192,8 @@ const RenderStackBars = (props: Props) => {
|
|
|
179
192
|
(Math.abs(stackItem.value) * (containerHeight || 200)) /
|
|
180
193
|
(maxValue || 200) -
|
|
181
194
|
(stackItem.marginBottom || 0),
|
|
182
|
-
backgroundColor:
|
|
195
|
+
backgroundColor:
|
|
196
|
+
stackItem.color || item.color || props.color || 'black',
|
|
183
197
|
borderRadius:
|
|
184
198
|
stackItem.borderRadius || props.barBorderRadius || 0,
|
|
185
199
|
},
|
|
@@ -193,6 +207,33 @@ const RenderStackBars = (props: Props) => {
|
|
|
193
207
|
stackItem.borderBottomRightRadius || 0,
|
|
194
208
|
},
|
|
195
209
|
]}>
|
|
210
|
+
{stackItem.showGradient ||
|
|
211
|
+
item.showGradient ||
|
|
212
|
+
props.showGradient ? (
|
|
213
|
+
<LinearGradient
|
|
214
|
+
style={[
|
|
215
|
+
{
|
|
216
|
+
position: 'absolute',
|
|
217
|
+
width: '100%',
|
|
218
|
+
height: '100%',
|
|
219
|
+
borderRadius:
|
|
220
|
+
stackItem.barBorderRadius ||
|
|
221
|
+
item.barBorderRadius ||
|
|
222
|
+
props.barBorderRadius ||
|
|
223
|
+
0,
|
|
224
|
+
},
|
|
225
|
+
]}
|
|
226
|
+
start={{x: 0, y: 0}}
|
|
227
|
+
end={{x: 0, y: 1}}
|
|
228
|
+
colors={[
|
|
229
|
+
stackItem.gradientColor ||
|
|
230
|
+
item.gradientColor ||
|
|
231
|
+
props.gradientColor ||
|
|
232
|
+
'white',
|
|
233
|
+
stackItem.color || item.color || props.color || 'black',
|
|
234
|
+
]}
|
|
235
|
+
/>
|
|
236
|
+
) : null}
|
|
196
237
|
{stackItem.innerBarComponent && stackItem.innerBarComponent()}
|
|
197
238
|
</TouchableOpacity>
|
|
198
239
|
);
|
|
@@ -278,7 +319,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
278
319
|
}}
|
|
279
320
|
/>
|
|
280
321
|
)}
|
|
281
|
-
{static2DSimple(item)}
|
|
322
|
+
{static2DSimple(item, index)}
|
|
282
323
|
{renderLabel(label || '', labelTextStyle)}
|
|
283
324
|
</View>
|
|
284
325
|
{renderTooltip && selectedIndex === index && (
|
|
@@ -286,7 +327,10 @@ const RenderStackBars = (props: Props) => {
|
|
|
286
327
|
style={{
|
|
287
328
|
position: 'absolute',
|
|
288
329
|
bottom: totalHeight + 60,
|
|
289
|
-
left:
|
|
330
|
+
left:
|
|
331
|
+
index === data.length - 1
|
|
332
|
+
? leftSpacing - leftShiftForLastIndexTooltip
|
|
333
|
+
: leftSpacing,
|
|
290
334
|
zIndex: 1000,
|
|
291
335
|
}}>
|
|
292
336
|
{renderTooltip(item, index)}
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import Svg, {Circle, Path, Rect, Text as CanvasText} from 'react-native-svg';
|
|
|
24
24
|
type PropTypes = {
|
|
25
25
|
width?: number;
|
|
26
26
|
height?: number;
|
|
27
|
+
minHeight?: number;
|
|
27
28
|
noOfSections?: number;
|
|
28
29
|
noOfSectionsBelowXAxis?: number;
|
|
29
30
|
maxValue?: number;
|
|
@@ -113,6 +114,7 @@ type PropTypes = {
|
|
|
113
114
|
disablePress?: boolean;
|
|
114
115
|
|
|
115
116
|
frontColor?: ColorValue;
|
|
117
|
+
color?: ColorValue;
|
|
116
118
|
sideColor?: ColorValue;
|
|
117
119
|
topColor?: ColorValue;
|
|
118
120
|
gradientColor?: ColorValue;
|
|
@@ -142,6 +144,7 @@ type PropTypes = {
|
|
|
142
144
|
barMarginBottom?: number;
|
|
143
145
|
onPress?: Function;
|
|
144
146
|
renderTooltip?: Function;
|
|
147
|
+
leftShiftForLastIndexTooltip?: number;
|
|
145
148
|
};
|
|
146
149
|
type lineConfigType = {
|
|
147
150
|
initialSpacing?: number;
|
|
@@ -1505,6 +1508,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1505
1508
|
stackData={props.stackData}
|
|
1506
1509
|
item={item}
|
|
1507
1510
|
index={index}
|
|
1511
|
+
data={data}
|
|
1508
1512
|
containerHeight={containerHeight}
|
|
1509
1513
|
maxValue={maxValue}
|
|
1510
1514
|
spacing={item.spacing === 0 ? 0 : item.spacing || spacing}
|
|
@@ -1521,6 +1525,9 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1521
1525
|
horizontal={horizontal}
|
|
1522
1526
|
intactTopLabel={intactTopLabel}
|
|
1523
1527
|
barBorderRadius={props.barBorderRadius}
|
|
1528
|
+
color={props.color}
|
|
1529
|
+
showGradient={props.showGradient}
|
|
1530
|
+
gradientColor={props.gradientColor}
|
|
1524
1531
|
barBackgroundPattern={props.barBackgroundPattern}
|
|
1525
1532
|
patternId={props.patternId}
|
|
1526
1533
|
label={
|
|
@@ -1532,8 +1539,12 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1532
1539
|
labelTextStyle={
|
|
1533
1540
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
|
1534
1541
|
}
|
|
1542
|
+
onPress={props.onPress}
|
|
1535
1543
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1536
1544
|
renderTooltip={props.renderTooltip}
|
|
1545
|
+
leftShiftForLastIndexTooltip={
|
|
1546
|
+
props.leftShiftForLastIndexTooltip || 0
|
|
1547
|
+
}
|
|
1537
1548
|
initialSpacing={initialSpacing}
|
|
1538
1549
|
selectedIndex={selectedIndex}
|
|
1539
1550
|
setSelectedIndex={setSelectedIndex}
|
|
@@ -1552,6 +1563,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1552
1563
|
propSpacing={spacing}
|
|
1553
1564
|
side={side}
|
|
1554
1565
|
data={data}
|
|
1566
|
+
minHeight={props.minHeight || 0}
|
|
1555
1567
|
barWidth={props.barWidth}
|
|
1556
1568
|
sideWidth={props.sideWidth}
|
|
1557
1569
|
labelWidth={labelWidth}
|
|
@@ -1598,6 +1610,9 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1598
1610
|
onPress={props.onPress}
|
|
1599
1611
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1600
1612
|
renderTooltip={props.renderTooltip}
|
|
1613
|
+
leftShiftForLastIndexTooltip={
|
|
1614
|
+
props.leftShiftForLastIndexTooltip || 0
|
|
1615
|
+
}
|
|
1601
1616
|
initialSpacing={initialSpacing}
|
|
1602
1617
|
selectedIndex={selectedIndex}
|
|
1603
1618
|
setSelectedIndex={setSelectedIndex}
|
package/src/todos.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
## Features
|
|
2
2
|
|
|
3
3
|
1. Fix the issue with pointers in Line/Area charts on Android https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/177
|
|
4
|
+
2. Issue with eslint - tsc https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/222
|
|
4
5
|
|
|
5
6
|
## To-dos in documentation-
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
8. Prepare a doc for xAxisLabelTexts and xAxisLabelTextStyle in Bar, Line And Area Charts
|
|
15
16
|
9. Prepare a doc for vertical lines to explain noOfVerticalLines and verticalLinesSpacing props. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/205
|
|
16
17
|
10. Prepare a doc for negative marginBottom instead of marginTop for x axis labels. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/190
|
|
18
|
+
11. Prepare a doc for LineChartBicolor https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/221
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
## Architecture Enhancement
|