react-native-gifted-charts 1.4.41 → 1.4.42
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
CHANGED
|
@@ -14,8 +14,7 @@ The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Popul
|
|
|
14
14
|
6. Fully customizable (see the [props](docs/docs.md))
|
|
15
15
|
7. Detailed [documentation](https://gifted-charts.web.app/) with examples
|
|
16
16
|
8. Support for **_combined_** Bar and Line charts
|
|
17
|
-
|
|
18
|
-
## 📣 Announcement
|
|
17
|
+
9. Tested to be pixel perfect using [react-native-screenshot-test](https://www.npmjs.com/package/react-native-screenshot-test). See [the screenshot tests here](https://abhinandan-kushwaha.github.io/TestingCharts/ss-test/test.html)
|
|
19
18
|
|
|
20
19
|
The web counterpart of this library is public now. Try out our new reactJS library- [react-gifted-charts](https://www.npmjs.com/package/react-gifted-charts) <br />
|
|
21
20
|
The exact same piece of code that you write to render charts in react-native, can be used to render charts in reactJS using this library!
|
|
@@ -122,6 +121,12 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
|
|
|
122
121
|
|
|
123
122
|
[To do list](./src/todos.md)
|
|
124
123
|
|
|
124
|
+
## Test cases
|
|
125
|
+
|
|
126
|
+
Test strategy and cases are discussed here- [TESTS.md](./TESTS.md) <br />
|
|
127
|
+
Pixel perfection is assured using [react-native-screenshot-test](https://www.npmjs.com/package/react-native-screenshot-test). <br/>
|
|
128
|
+
Around 200 screenshot tests have been written. See the [Reports here](https://abhinandan-kushwaha.github.io/TestingCharts/ss-test/test.html).
|
|
129
|
+
|
|
125
130
|
## License
|
|
126
131
|
|
|
127
132
|
MIT
|
|
@@ -25,11 +25,13 @@ if (Platform.OS === 'android') {
|
|
|
25
25
|
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
26
26
|
}
|
|
27
27
|
var Animated2DWithGradient = function (props) {
|
|
28
|
-
var _a;
|
|
29
|
-
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId,
|
|
30
|
-
var
|
|
31
|
-
var
|
|
28
|
+
var _a, _b;
|
|
29
|
+
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, bWidth = props.barWidth, barStyle = props.barStyle, item = props.item, index = props.index, opacity = props.opacity, animationDuration = props.animationDuration, noGradient = props.noGradient, noAnimation = props.noAnimation, barMarginBottom = props.barMarginBottom, barInnerComponent = props.barInnerComponent, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, commonStyleForBar = props.commonStyleForBar, barStyleWithBackground = props.barStyleWithBackground, yAxisOffset = props.yAxisOffset;
|
|
30
|
+
var _c = __read(useState(noAnimation ? props.height : 0.4), 2), height = _c[0], setHeight = _c[1]; // if animation fails, increase this constant value of 0.4
|
|
31
|
+
var _d = __read(useState(!noAnimation), 2), initialRender = _d[0], setInitialRender = _d[1];
|
|
32
|
+
var _e = __read(useState((_a = item.barWidth) !== null && _a !== void 0 ? _a : bWidth), 2), barWidth = _e[0], setBarWidth = _e[1]; // setting width in state for animation purpose
|
|
32
33
|
useEffect(function () {
|
|
34
|
+
var _a;
|
|
33
35
|
if (!noAnimation) {
|
|
34
36
|
if (initialRender) {
|
|
35
37
|
setTimeout(function () { return layoutAppear(); }, 20);
|
|
@@ -40,14 +42,17 @@ var Animated2DWithGradient = function (props) {
|
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
setHeight(props.height);
|
|
45
|
+
setBarWidth((_a = item.barWidth) !== null && _a !== void 0 ? _a : bWidth);
|
|
43
46
|
}
|
|
44
|
-
}, [props.height]);
|
|
47
|
+
}, [props.height, bWidth, item.barWidth]);
|
|
45
48
|
var elevate = function () {
|
|
49
|
+
var _a;
|
|
46
50
|
LayoutAnimation.configureNext({
|
|
47
51
|
duration: animationDuration,
|
|
48
52
|
update: { type: 'linear', property: 'scaleXY' },
|
|
49
53
|
});
|
|
50
54
|
setHeight(props.height);
|
|
55
|
+
setBarWidth((_a = item.barWidth) !== null && _a !== void 0 ? _a : bWidth);
|
|
51
56
|
};
|
|
52
57
|
var layoutAppear = function () {
|
|
53
58
|
LayoutAnimation.configureNext({
|
|
@@ -61,7 +66,7 @@ var Animated2DWithGradient = function (props) {
|
|
|
61
66
|
return (_jsxs(_Fragment, { children: [!initialRender && (_jsx(View, { style: {
|
|
62
67
|
position: 'absolute',
|
|
63
68
|
bottom: 0,
|
|
64
|
-
width:
|
|
69
|
+
width: barWidth,
|
|
65
70
|
overflow: 'hidden',
|
|
66
71
|
height: (noAnimation
|
|
67
72
|
? Math.max(props.minHeight, Math.abs(height))
|
|
@@ -92,7 +97,7 @@ var Animated2DWithGradient = function (props) {
|
|
|
92
97
|
: item.capRadius || props.capRadius || 0,
|
|
93
98
|
} })) })), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
|
|
94
99
|
? item.barBackgroundPattern()
|
|
95
|
-
: barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "1", y: "1", width: item.barWidth ||
|
|
100
|
+
: barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "1", y: "1", width: item.barWidth || barWidth || 30, height: noAnimation ? Math.abs(height) : height, fill: "url(#".concat(item.patternId || patternId, ")") })] })), barInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: barInnerComponent(item, index) })) : null] }) })), item.topLabelComponent || showValuesAsTopLabel ? (_jsx(View, { style: [
|
|
96
101
|
{
|
|
97
102
|
position: 'absolute',
|
|
98
103
|
top: (item.barWidth || barWidth || 30) * -1,
|
|
@@ -108,6 +113,6 @@ var Animated2DWithGradient = function (props) {
|
|
|
108
113
|
props.horizontal &&
|
|
109
114
|
!intactTopLabel && { transform: [{ rotate: '270deg' }] },
|
|
110
115
|
topLabelContainerStyle !== null && topLabelContainerStyle !== void 0 ? topLabelContainerStyle : item.topLabelContainerStyle,
|
|
111
|
-
], children: showValuesAsTopLabel ? (_jsx(Text, { style: topLabelTextStyle, children: item.value + yAxisOffset })) : ((
|
|
116
|
+
], children: showValuesAsTopLabel ? (_jsx(Text, { style: topLabelTextStyle, children: item.value + yAxisOffset })) : ((_b = item.topLabelComponent) === null || _b === void 0 ? void 0 : _b.call(item)) })) : null] }));
|
|
112
117
|
};
|
|
113
118
|
export default Animated2DWithGradient;
|
|
@@ -34,6 +34,8 @@ export var renderHorizSections = function (props) {
|
|
|
34
34
|
var _e = getHorizSectionVals(props), secondaryYAxisConfig = _e.secondaryYAxisConfig, horizSections = _e.horizSections, yAxisExtraHeightAtTop = _e.yAxisExtraHeightAtTop, secondaryHorizSections = _e.secondaryHorizSections, showReferenceLine1 = _e.showReferenceLine1, referenceLine1Config = _e.referenceLine1Config, referenceLine1Position = _e.referenceLine1Position, showReferenceLine2 = _e.showReferenceLine2, referenceLine2Config = _e.referenceLine2Config, referenceLine2Position = _e.referenceLine2Position, showReferenceLine3 = _e.showReferenceLine3, referenceLine3Config = _e.referenceLine3Config, referenceLine3Position = _e.referenceLine3Position, horizSectionsBelow = _e.horizSectionsBelow, secondaryHorizSectionsBelow = _e.secondaryHorizSectionsBelow, getLabelTexts = _e.getLabelTexts, getLabelTextsForSecondaryYAxis = _e.getLabelTextsForSecondaryYAxis;
|
|
35
35
|
var secondaryYAxisExtraHeightAtBottom = 10;
|
|
36
36
|
var negativeSectionsCountDiffPrimaryVsSecondary = secondaryHorizSectionsBelow.length - horizSectionsBelow.length;
|
|
37
|
+
var isLineChart = chartType === chartTypes.LINE;
|
|
38
|
+
var isLineBiColor = chartType === chartTypes.LINE_BI_COLOR;
|
|
37
39
|
var renderAxesAndRules = function (index) {
|
|
38
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
39
41
|
var invertedIndex = horizSections.length - index - 1;
|
|
@@ -213,10 +215,6 @@ export var renderHorizSections = function (props) {
|
|
|
213
215
|
{
|
|
214
216
|
marginLeft: yAxisThickness,
|
|
215
217
|
},
|
|
216
|
-
showBorder && {
|
|
217
|
-
borderRightWidth: yAxisThickness,
|
|
218
|
-
borderColor: yAxisColor,
|
|
219
|
-
},
|
|
220
218
|
{
|
|
221
219
|
height: index === 0
|
|
222
220
|
? localNegativeStepHeight * 1.5
|
|
@@ -224,7 +222,21 @@ export var renderHorizSections = function (props) {
|
|
|
224
222
|
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
225
223
|
},
|
|
226
224
|
index === 0 && { marginTop: -localNegativeStepHeight / 2 },
|
|
227
|
-
] }), _jsx(View, { style:
|
|
225
|
+
] }), _jsx(View, { style: {
|
|
226
|
+
position: 'absolute',
|
|
227
|
+
top: index === 0 ? -localNegativeStepHeight / 2 : 0,
|
|
228
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
229
|
+
? width
|
|
230
|
+
? width + 19
|
|
231
|
+
: totalWidth -
|
|
232
|
+
(isLineChart ? 31 : isLineBiColor ? spacing - 19 : 1)
|
|
233
|
+
: yAxisLabelWidth,
|
|
234
|
+
borderRightWidth: yAxisThickness,
|
|
235
|
+
borderColor: yAxisColor,
|
|
236
|
+
height: index === 0
|
|
237
|
+
? localNegativeStepHeight * 1.5
|
|
238
|
+
: localNegativeStepHeight,
|
|
239
|
+
} }), _jsx(View, { style: [styles.leftPart, { backgroundColor: backgroundColor }], children: hideRules ? null : (_jsx(Rule, { config: {
|
|
228
240
|
thickness: rulesThickness,
|
|
229
241
|
color: rulesColor,
|
|
230
242
|
width: rulesLength ||
|
|
@@ -234,10 +246,10 @@ export var renderHorizSections = function (props) {
|
|
|
234
246
|
type: rulesType,
|
|
235
247
|
} })) })] }, index));
|
|
236
248
|
};
|
|
237
|
-
var leftShiftForRIghtYaxis = (width ? width + 20 : totalWidth) +
|
|
249
|
+
var leftShiftForRIghtYaxis = (width ? width + (isLineChart ? 50 : 20) : totalWidth) +
|
|
238
250
|
yAxisLabelWidth / 2 +
|
|
239
251
|
endSpacing -
|
|
240
|
-
(
|
|
252
|
+
(isLineChart ? 70 : 40);
|
|
241
253
|
return (_jsx(_Fragment, { children: onlyReferenceLines ? (_jsx(View, { style: {
|
|
242
254
|
flexDirection: 'row',
|
|
243
255
|
}, children: _jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: referenceLines() }) })) : (_jsxs(View, { pointerEvents: "none", style: {
|
|
@@ -343,7 +355,10 @@ export var renderHorizSections = function (props) {
|
|
|
343
355
|
: negativeStepHeight,
|
|
344
356
|
},
|
|
345
357
|
yAxisSide === yAxisSides.RIGHT && {
|
|
346
|
-
left: (width
|
|
358
|
+
left: (width
|
|
359
|
+
? width - 15
|
|
360
|
+
: totalWidth - (isLineChart ? 65 : 35)) +
|
|
361
|
+
yAxisLabelWidth,
|
|
347
362
|
},
|
|
348
363
|
yAxisLabelContainerStyle,
|
|
349
364
|
], children: _jsx(Text, { numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
|
package/dist/LineChart/index.js
CHANGED
|
@@ -62,13 +62,16 @@ export var LineChart = function (props) {
|
|
|
62
62
|
var animatedFillPoints = new Animated.Value(0);
|
|
63
63
|
var oldPoints = usePrevious(points);
|
|
64
64
|
var oldFillPoints = usePrevious(fillPoints);
|
|
65
|
-
var animatedPath = animateOnDataChange && points && oldPoints
|
|
65
|
+
var animatedPath = animateOnDataChange && points && oldPoints && points !== oldPoints
|
|
66
66
|
? animatedPoints.interpolate({
|
|
67
67
|
inputRange: [0, 1],
|
|
68
68
|
outputRange: pointsWithPaddedRepititions(oldPoints, points),
|
|
69
69
|
})
|
|
70
70
|
: '';
|
|
71
|
-
var animatedFillPath = animateOnDataChange &&
|
|
71
|
+
var animatedFillPath = animateOnDataChange &&
|
|
72
|
+
fillPoints &&
|
|
73
|
+
oldFillPoints &&
|
|
74
|
+
fillPoints !== oldFillPoints
|
|
72
75
|
? animatedFillPoints.interpolate({
|
|
73
76
|
inputRange: [0, 1],
|
|
74
77
|
outputRange: pointsWithPaddedRepititions(oldFillPoints, fillPoints),
|
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.42",
|
|
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": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
10
|
"android": "react-native run-android",
|
|
11
|
-
"build": "tsc -p . && ./build.sh",
|
|
11
|
+
"build": "rm -rf ./dist && tsc -p . && ./build.sh",
|
|
12
12
|
"ios": "react-native run-ios",
|
|
13
13
|
"start": "react-native start",
|
|
14
14
|
"test": "jest",
|
|
@@ -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.42"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/cli": "^7.24.8",
|