react-native-gifted-charts 1.4.20 → 1.4.22
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 +4 -3
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +113 -0
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +264 -0
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +172 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +233 -0
- package/dist/BarChart/styles.d.ts +45 -0
- package/dist/BarChart/styles.js +46 -0
- package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
- package/dist/Components/AnimatedThreeDBar/index.js +129 -0
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +13 -0
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +128 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
- package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/cap.js +16 -0
- package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +40 -0
- package/dist/Components/common/LinearGradient.d.ts +16 -0
- package/dist/Components/common/LinearGradient.js +15 -0
- package/dist/Components/common/Pointer.d.ts +1 -0
- package/dist/Components/common/Pointer.js +16 -0
- package/dist/Components/common/StripAndLabel.d.ts +1 -0
- package/dist/Components/common/StripAndLabel.js +43 -0
- package/dist/Components/lineSvg.d.ts +14 -0
- package/dist/Components/lineSvg.js +22 -0
- package/dist/LineChart/LineChartBicolor.d.ts +2 -0
- package/dist/LineChart/LineChartBicolor.js +294 -0
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1089 -0
- package/dist/LineChart/styles.d.ts +43 -0
- package/dist/LineChart/styles.js +46 -0
- package/dist/PieChart/index.d.ts +2 -0
- package/dist/PieChart/index.js +99 -0
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +182 -0
- package/dist/PieChartPro/index.d.ts +2 -0
- package/dist/PieChartPro/index.js +124 -0
- package/dist/PopulationPyramid/index.d.ts +2 -0
- package/dist/PopulationPyramid/index.js +130 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +12 -0
- package/package.json +21 -20
- package/src/BarChart/Animated2DWithGradient.tsx +0 -197
- package/src/BarChart/RenderBars.tsx +0 -527
- package/src/BarChart/RenderStackBars.tsx +0 -359
- package/src/BarChart/index.tsx +0 -391
- package/src/BarChart/styles.tsx +0 -47
- package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
- package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
- package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
- package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
- package/src/Components/BarSpecificComponents/cap.tsx +0 -34
- package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
- package/src/Components/common/LinearGradient.tsx +0 -27
- package/src/Components/common/Pointer.tsx +0 -37
- package/src/Components/common/StripAndLabel.tsx +0 -98
- package/src/Components/lineSvg.tsx +0 -42
- package/src/LineChart/LineChartBicolor.tsx +0 -740
- package/src/LineChart/index.tsx +0 -2231
- package/src/LineChart/styles.tsx +0 -47
- package/src/PieChart/index.tsx +0 -168
- package/src/PieChart/main.tsx +0 -363
- package/src/PieChartPro/index.tsx +0 -267
- package/src/PopulationPyramid/index.tsx +0 -603
- package/src/index.tsx +0 -26
- package/src/todos.md +0 -24
- package/src/utils/index.ts +0 -16
package/README.md
CHANGED
|
@@ -52,16 +52,17 @@ See the **[release changes by version here.](release-notes/release-notes.md)**
|
|
|
52
52
|
### React Native CLI
|
|
53
53
|
|
|
54
54
|
```sh
|
|
55
|
-
npm install react-native-gifted-charts react-native-linear-gradient react-native-svg
|
|
55
|
+
npm install react-native-gifted-charts gifted-charts-core react-native-linear-gradient react-native-svg
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
### Expo
|
|
59
59
|
|
|
60
60
|
```sh
|
|
61
|
-
npx expo install react-native-gifted-charts expo-linear-gradient react-native-svg
|
|
61
|
+
npx expo install react-native-gifted-charts gifted-charts-core expo-linear-gradient react-native-svg
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Please note that `react-native-svg` and `react-native-linear-gradient`/`expo-linear-gradient` are needed for the library to work, so make sure they are installed in your project.
|
|
64
|
+
Please note that `gifted-charts-core`, `react-native-svg` and `react-native-linear-gradient`/`expo-linear-gradient` are needed for the library to work, so make sure they are installed in your project. <br />
|
|
65
|
+
**[gifted-charts-core](https://www.npmjs.com/package/gifted-charts-core)** contains the mathematical and logical utilities used by this library.
|
|
65
66
|
|
|
66
67
|
# Docs
|
|
67
68
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { useEffect, useState } from 'react';
|
|
19
|
+
import { View, LayoutAnimation, Platform, UIManager, Text } from 'react-native';
|
|
20
|
+
import Svg, { Defs, Rect } from 'react-native-svg';
|
|
21
|
+
import Cap from '../Components/BarSpecificComponents/cap';
|
|
22
|
+
import LinearGradient from '../Components/common/LinearGradient';
|
|
23
|
+
if (Platform.OS === 'android') {
|
|
24
|
+
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
25
|
+
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
26
|
+
}
|
|
27
|
+
var Animated2DWithGradient = function (props) {
|
|
28
|
+
var _a;
|
|
29
|
+
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, barWidth = 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 _b = __read(useState(noAnimation ? props.height : 0.2), 2), height = _b[0], setHeight = _b[1];
|
|
31
|
+
var _c = __read(useState(noAnimation ? false : true), 2), initialRender = _c[0], setInitialRender = _c[1];
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (!noAnimation) {
|
|
34
|
+
if (initialRender) {
|
|
35
|
+
setTimeout(function () { return layoutAppear(); }, 20);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
elevate();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setHeight(props.height);
|
|
43
|
+
}
|
|
44
|
+
}, [props.height]);
|
|
45
|
+
var elevate = function () {
|
|
46
|
+
LayoutAnimation.configureNext({
|
|
47
|
+
duration: animationDuration,
|
|
48
|
+
update: { type: 'linear', property: 'scaleXY' },
|
|
49
|
+
});
|
|
50
|
+
setHeight(props.height);
|
|
51
|
+
};
|
|
52
|
+
var layoutAppear = function () {
|
|
53
|
+
LayoutAnimation.configureNext({
|
|
54
|
+
duration: Platform.OS == 'ios' ? animationDuration : 20,
|
|
55
|
+
create: { type: 'linear', property: 'opacity' },
|
|
56
|
+
update: { type: 'linear', property: 'scaleXY' },
|
|
57
|
+
});
|
|
58
|
+
setInitialRender(false);
|
|
59
|
+
setTimeout(function () { return elevate(); }, Platform.OS == 'ios' ? 10 : 100);
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs(_Fragment, { children: [!initialRender && (_jsx(View, { style: {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
bottom: 0,
|
|
64
|
+
width: '100%',
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
height: (noAnimation
|
|
67
|
+
? Math.max(props.minHeight, Math.abs(height))
|
|
68
|
+
: height) - (barMarginBottom || 0),
|
|
69
|
+
}, children: _jsxs(View, { style: [
|
|
70
|
+
{
|
|
71
|
+
width: '100%',
|
|
72
|
+
height: (noAnimation
|
|
73
|
+
? Math.max(props.minHeight, Math.abs(height))
|
|
74
|
+
: height) - (barMarginBottom || 0),
|
|
75
|
+
},
|
|
76
|
+
item.barStyle || barStyle,
|
|
77
|
+
], children: [noGradient ? (_jsx(View, { style: barStyleWithBackground, children: props.cappedBars && item.value ? (_jsx(Cap, { capThicknessFromItem: item.capThickness, capThicknessFromProps: props.capThickness, capColorFromItem: item.capColor, capColorFromProps: props.capColor, capRadiusFromItem: item.capRadius, capRadiusFromProps: props.capRadius })) : null })) : (_jsx(LinearGradient, { style: commonStyleForBar, start: { x: 0, y: 0 }, end: { x: 1, y: 1 }, colors: [
|
|
78
|
+
item.gradientColor || props.gradientColor || 'white',
|
|
79
|
+
item.frontColor || props.frontColor || 'black',
|
|
80
|
+
], children: props.cappedBars && (_jsx(View, { style: {
|
|
81
|
+
position: 'absolute',
|
|
82
|
+
width: '100%',
|
|
83
|
+
height: item.capThickness === 0
|
|
84
|
+
? 0
|
|
85
|
+
: item.capThickness || props.capThickness || 6,
|
|
86
|
+
backgroundColor: item.capColor || props.capColor || 'black',
|
|
87
|
+
borderTopLeftRadius: item.capRadius === 0
|
|
88
|
+
? 0
|
|
89
|
+
: item.capRadius || props.capRadius || 0,
|
|
90
|
+
borderTopRightRadius: item.capRadius === 0
|
|
91
|
+
? 0
|
|
92
|
+
: item.capRadius || props.capRadius || 0,
|
|
93
|
+
} })) })), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
|
|
94
|
+
? item.barBackgroundPattern()
|
|
95
|
+
: barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "transparent", x: "1", y: "1", width: item.barWidth || props.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
|
+
{
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
top: (item.barWidth || barWidth || 30) * -1,
|
|
99
|
+
height: item.barWidth || barWidth || 30,
|
|
100
|
+
width: item.barWidth || barWidth || 30,
|
|
101
|
+
justifyContent: (props.horizontal && !intactTopLabel) || item.value < 0
|
|
102
|
+
? 'center'
|
|
103
|
+
: 'flex-end',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
opacity: opacity,
|
|
106
|
+
},
|
|
107
|
+
item.value < 0 && { transform: [{ rotate: '180deg' }] },
|
|
108
|
+
props.horizontal &&
|
|
109
|
+
!intactTopLabel && { transform: [{ rotate: '270deg' }] },
|
|
110
|
+
topLabelContainerStyle !== null && topLabelContainerStyle !== void 0 ? topLabelContainerStyle : item.topLabelContainerStyle,
|
|
111
|
+
], children: showValuesAsTopLabel ? (_jsx(Text, { style: topLabelTextStyle, children: item.value + yAxisOffset })) : ((_a = item.topLabelComponent) === null || _a === void 0 ? void 0 : _a.call(item)) })) : null] }));
|
|
112
|
+
};
|
|
113
|
+
export default Animated2DWithGradient;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { View, TouchableOpacity, Animated, Text } from 'react-native';
|
|
14
|
+
import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
|
|
15
|
+
import Animated2DWithGradient from './Animated2DWithGradient';
|
|
16
|
+
import Cap from '../Components/BarSpecificComponents/cap';
|
|
17
|
+
import BarBackgroundPattern from '../Components/BarSpecificComponents/barBackgroundPattern';
|
|
18
|
+
import LinearGradient from '../Components/common/LinearGradient';
|
|
19
|
+
import { getPropsForAnimated2DWithGradient, AxesAndRulesDefaults, } from 'gifted-charts-core';
|
|
20
|
+
import Tooltip from '../Components/BarSpecificComponents/tooltip';
|
|
21
|
+
var RenderBars = function (props) {
|
|
22
|
+
var _a, _b, _c, _d, _e;
|
|
23
|
+
var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, propSpacing = props.propSpacing, side = props.side, data = props.data, barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, isThreeD = props.isThreeD, isAnimated = props.isAnimated, rotateLabel = props.rotateLabel, appearingOpacity = props.appearingOpacity, animationDuration = props.animationDuration, autoShiftLabels = props.autoShiftLabels, label = props.label, secondaryLabel = props.secondaryLabel, labelTextStyle = props.labelTextStyle, secondaryLabelTextStyle = props.secondaryLabelTextStyle, xAxisTextNumberOfLines = props.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, renderTooltip = props.renderTooltip, leftShiftForTooltip = props.leftShiftForTooltip, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, initialSpacing = props.initialSpacing, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, _f = props.xAxisThickness, xAxisThickness = _f === void 0 ? AxesAndRulesDefaults.xAxisThickness : _f, horizontal = props.horizontal, rtl = props.rtl, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, yAxisOffset = props.yAxisOffset, barWidth = props.barWidth, _g = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _g === void 0 ? 0 : _g, stepHeight = props.stepHeight, stepValue = props.stepValue, negativeStepHeight = props.negativeStepHeight, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip, secondaryXAxis = props.secondaryXAxis;
|
|
24
|
+
var heightFactor = item.value < 0
|
|
25
|
+
? negativeStepHeight / negativeStepValue
|
|
26
|
+
: stepHeight / stepValue;
|
|
27
|
+
var barHeight = Math.max(minHeight, Math.abs(item.value) * heightFactor - xAxisThickness);
|
|
28
|
+
var _h = getPropsForAnimated2DWithGradient(__assign(__assign({}, props), { barHeight: barHeight })), commonStyleForBar = _h.commonStyleForBar, barStyleWithBackground = _h.barStyleWithBackground, commonPropsFor2Dand3Dbars = _h.commonPropsFor2Dand3Dbars, isFocused = _h.isFocused, focusedBarConfig = _h.focusedBarConfig, localFrontColor = _h.localFrontColor;
|
|
29
|
+
var itemOrPropsBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
|
|
30
|
+
var localBarInnerComponent = isFocused
|
|
31
|
+
? (_b = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.barInnerComponent) !== null && _b !== void 0 ? _b : itemOrPropsBarInnerComponent
|
|
32
|
+
: itemOrPropsBarInnerComponent;
|
|
33
|
+
var barMarginBottom = item.barMarginBottom === 0
|
|
34
|
+
? 0
|
|
35
|
+
: item.barMarginBottom || props.barMarginBottom || 0;
|
|
36
|
+
var renderLabel = function (top, label, labelTextStyle, value) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return (_jsx(View, { style: [
|
|
39
|
+
{
|
|
40
|
+
width: (item.labelWidth ||
|
|
41
|
+
props.labelWidth ||
|
|
42
|
+
item.barWidth ||
|
|
43
|
+
barWidth) + spacing,
|
|
44
|
+
left: spacing / -2,
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
height: (_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18,
|
|
47
|
+
bottom: top
|
|
48
|
+
? (containerHeight || 200) +
|
|
49
|
+
((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
|
|
50
|
+
: (rotateLabel
|
|
51
|
+
? -40
|
|
52
|
+
: -6 -
|
|
53
|
+
xAxisTextNumberOfLines * 18 -
|
|
54
|
+
xAxisLabelsVerticalShift) -
|
|
55
|
+
barMarginBottom -
|
|
56
|
+
labelsDistanceFromXaxis,
|
|
57
|
+
},
|
|
58
|
+
rotateLabel
|
|
59
|
+
? horizontal
|
|
60
|
+
? { transform: [{ rotate: '330deg' }] }
|
|
61
|
+
: {
|
|
62
|
+
transform: [
|
|
63
|
+
{ rotate: value < 0 ? '240deg' : '60deg' },
|
|
64
|
+
{ translateX: value < 0 ? 56 : 0 },
|
|
65
|
+
{ translateY: value < 0 ? 32 : 0 },
|
|
66
|
+
],
|
|
67
|
+
}
|
|
68
|
+
: horizontal
|
|
69
|
+
? { transform: [{ rotate: '-90deg' }] }
|
|
70
|
+
: value < 0
|
|
71
|
+
? {
|
|
72
|
+
transform: [
|
|
73
|
+
{ rotate: '180deg' },
|
|
74
|
+
{
|
|
75
|
+
translateY: autoShiftLabels
|
|
76
|
+
? 0
|
|
77
|
+
: 16.5 * xAxisTextNumberOfLines + 14,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
}
|
|
81
|
+
: {},
|
|
82
|
+
], children: top ? (item.secondaryLabelComponent ? (item.secondaryLabelComponent()) : (_jsx(Text, { style: [
|
|
83
|
+
{ textAlign: 'center' },
|
|
84
|
+
rtl && horizontal && { transform: [{ rotate: '180deg' }] },
|
|
85
|
+
labelTextStyle,
|
|
86
|
+
], numberOfLines: xAxisTextNumberOfLines, children: label }))) : item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
|
|
87
|
+
{ textAlign: 'center' },
|
|
88
|
+
rtl && horizontal && { transform: [{ rotate: '180deg' }] },
|
|
89
|
+
labelTextStyle,
|
|
90
|
+
], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
91
|
+
};
|
|
92
|
+
var renderAnimatedLabel = function (top, label, labelTextStyle, value) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
return (_jsx(Animated.View, { style: [
|
|
95
|
+
{
|
|
96
|
+
width: (item.labelWidth ||
|
|
97
|
+
props.labelWidth ||
|
|
98
|
+
item.barWidth ||
|
|
99
|
+
barWidth) + spacing,
|
|
100
|
+
left: spacing / -2,
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
height: (_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18,
|
|
103
|
+
bottom: top
|
|
104
|
+
? (containerHeight || 200) +
|
|
105
|
+
((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
|
|
106
|
+
: (rotateLabel
|
|
107
|
+
? -40
|
|
108
|
+
: -6 -
|
|
109
|
+
xAxisTextNumberOfLines * 18 -
|
|
110
|
+
xAxisLabelsVerticalShift) - barMarginBottom,
|
|
111
|
+
opacity: appearingOpacity,
|
|
112
|
+
},
|
|
113
|
+
value < 0 && { transform: [{ rotate: '180deg' }] },
|
|
114
|
+
rotateLabel
|
|
115
|
+
? horizontal
|
|
116
|
+
? { transform: [{ rotate: '330deg' }] }
|
|
117
|
+
: { transform: [{ rotate: '60deg' }] }
|
|
118
|
+
: horizontal
|
|
119
|
+
? { transform: [{ rotate: '-90deg' }] }
|
|
120
|
+
: value < 0
|
|
121
|
+
? {
|
|
122
|
+
transform: [
|
|
123
|
+
{ rotate: '180deg' },
|
|
124
|
+
{
|
|
125
|
+
translateY: autoShiftLabels
|
|
126
|
+
? 0
|
|
127
|
+
: 16.5 * xAxisTextNumberOfLines + 14,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
: {},
|
|
132
|
+
], children: top ? (item.secondaryLabelComponent ? (item.secondaryLabelComponent()) : (_jsx(Text, { style: [
|
|
133
|
+
{ textAlign: 'center' },
|
|
134
|
+
rtl && horizontal && { transform: [{ rotate: '180deg' }] },
|
|
135
|
+
labelTextStyle,
|
|
136
|
+
], numberOfLines: xAxisTextNumberOfLines, children: label }))) : item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
|
|
137
|
+
{ textAlign: 'center' },
|
|
138
|
+
rtl && horizontal && { transform: [{ rotate: '180deg' }] },
|
|
139
|
+
labelTextStyle,
|
|
140
|
+
], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
141
|
+
};
|
|
142
|
+
var leftSpacing = initialSpacing;
|
|
143
|
+
for (var i = 0; i < index; i++) {
|
|
144
|
+
leftSpacing +=
|
|
145
|
+
((_c = data[i].spacing) !== null && _c !== void 0 ? _c : propSpacing) + (data[i].barWidth || barWidth);
|
|
146
|
+
}
|
|
147
|
+
var static2DWithGradient = function (item) {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
var localGradientColor = item.gradientColor || props.gradientColor || 'white';
|
|
150
|
+
return (_jsxs(_Fragment, { children: [_jsx(LinearGradient, { style: commonStyleForBar, start: { x: 0, y: 0 }, end: { x: 0, y: 1 }, colors: [
|
|
151
|
+
isFocused
|
|
152
|
+
? (_a = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.gradientColor) !== null && _a !== void 0 ? _a : localGradientColor
|
|
153
|
+
: localGradientColor,
|
|
154
|
+
localFrontColor,
|
|
155
|
+
], children: props.cappedBars && item.value ? (_jsx(Cap, { capThicknessFromItem: item.capThickness, capThicknessFromProps: props.capThickness, capColorFromItem: item.capColor, capColorFromProps: props.capColor, capRadiusFromItem: item.capRadius, capRadiusFromProps: props.capRadius })) : null }), (item.barBackgroundPattern || props.barBackgroundPattern) && (_jsx(BarBackgroundPattern, { barBackgroundPatternFromItem: item.barBackgroundPattern, barBackgroundPatternFromProps: props.barBackgroundPattern, patternIdFromItem: item.patternId, patternIdFromProps: props.patternId })), (item.topLabelComponent || showValuesAsTopLabel) && (_jsx(View, { style: [
|
|
156
|
+
{
|
|
157
|
+
position: 'absolute',
|
|
158
|
+
top: (item.barWidth || barWidth) * -1,
|
|
159
|
+
height: item.barWidth || barWidth,
|
|
160
|
+
width: item.barWidth || barWidth,
|
|
161
|
+
justifyContent: (horizontal && !intactTopLabel) || item.value < 0
|
|
162
|
+
? 'center'
|
|
163
|
+
: 'flex-end',
|
|
164
|
+
alignItems: 'center',
|
|
165
|
+
},
|
|
166
|
+
item.value < 0 && { transform: [{ rotate: '180deg' }] },
|
|
167
|
+
horizontal &&
|
|
168
|
+
!intactTopLabel && { transform: [{ rotate: '270deg' }] },
|
|
169
|
+
topLabelContainerStyle !== null && topLabelContainerStyle !== void 0 ? topLabelContainerStyle : item.topLabelContainerStyle,
|
|
170
|
+
], children: showValuesAsTopLabel ? (_jsx(Text, { style: topLabelTextStyle, children: item.value + yAxisOffset })) : ((_b = item.topLabelComponent) === null || _b === void 0 ? void 0 : _b.call(item)) })), localBarInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: localBarInnerComponent(item, index) })) : null] }));
|
|
171
|
+
};
|
|
172
|
+
var barWrapperStyle = [
|
|
173
|
+
{
|
|
174
|
+
// overflow: 'visible',
|
|
175
|
+
marginBottom: 60 + barMarginBottom + xAxisLabelsVerticalShift - 0.5,
|
|
176
|
+
width: commonPropsFor2Dand3Dbars.barWidth,
|
|
177
|
+
height: barHeight,
|
|
178
|
+
marginRight: spacing,
|
|
179
|
+
},
|
|
180
|
+
pointerConfig
|
|
181
|
+
? {
|
|
182
|
+
transform: [
|
|
183
|
+
{
|
|
184
|
+
translateY: (containerHeight || 200) -
|
|
185
|
+
(barHeight - 10 + xAxisLabelsVerticalShift) +
|
|
186
|
+
(item.value < 0 ? Math.abs(item.value) * heightFactor : 0),
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
}
|
|
190
|
+
: item.value < 0
|
|
191
|
+
? {
|
|
192
|
+
transform: [
|
|
193
|
+
{
|
|
194
|
+
translateY: Math.abs(item.value) * heightFactor,
|
|
195
|
+
},
|
|
196
|
+
{ rotateZ: '180deg' },
|
|
197
|
+
],
|
|
198
|
+
}
|
|
199
|
+
: null,
|
|
200
|
+
side !== 'right' && { zIndex: data.length - index },
|
|
201
|
+
];
|
|
202
|
+
var pressDisabled = item.disablePress ||
|
|
203
|
+
props.disablePress ||
|
|
204
|
+
(pointerConfig && pointerConfig.barTouchable !== true);
|
|
205
|
+
var barContent = function () {
|
|
206
|
+
var isBarBelowXaxisAndInvisible = item.value < 0 && !noOfSectionsBelowXAxis;
|
|
207
|
+
var animated2DWithGradient = function (noGradient, noAnimation) { return (_jsx(Animated2DWithGradient, __assign({}, commonPropsFor2Dand3Dbars, { animationDuration: animationDuration || 800, roundedBottom: props.roundedBottom || false, roundedTop: props.roundedTop || false, noGradient: noGradient, noAnimation: noAnimation, containerHeight: containerHeight, maxValue: maxValue, minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : 0, barMarginBottom: barMarginBottom, cappedBars: props.cappedBars, capThickness: props.capThickness, capColor: props.capColor, capRadius: props.capRadius, horizontal: horizontal, barBorderWidth: barBorderWidth, barBorderColor: barBorderColor, commonStyleForBar: commonStyleForBar, barStyleWithBackground: barStyleWithBackground }))); };
|
|
208
|
+
return (_jsxs(_Fragment, { children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
|
|
209
|
+
zIndex: 2,
|
|
210
|
+
position: 'absolute',
|
|
211
|
+
height: props.xAxisIndicesHeight,
|
|
212
|
+
width: props.xAxisIndicesWidth,
|
|
213
|
+
bottom: props.xAxisIndicesHeight / -2,
|
|
214
|
+
left: ((item.barWidth || barWidth) - props.xAxisIndicesWidth) / 2,
|
|
215
|
+
backgroundColor: props.xAxisIndicesColor,
|
|
216
|
+
} })), isBarBelowXaxisAndInvisible ? null : isThreeD ? (_jsx(AnimatedThreeDBar, __assign({}, commonPropsFor2Dand3Dbars, { sideWidth: item.sideWidth ||
|
|
217
|
+
props.sideWidth ||
|
|
218
|
+
(item.barWidth || barWidth) / 2, side: side || 'left', sideColor: item.sideColor || props.sideColor || '', topColor: item.topColor || props.topColor || '', horizontal: horizontal, isAnimated: isAnimated, animationDuration: animationDuration || 800, selectedIndex: selectedIndex }))) : item.showGradient || props.showGradient ? (isAnimated ? (animated2DWithGradient(false, false)) : (static2DWithGradient(item))) : isAnimated ? (animated2DWithGradient(true, false)) : (animated2DWithGradient(true, true)), isAnimated
|
|
219
|
+
? renderAnimatedLabel(false, label, labelTextStyle, item.value)
|
|
220
|
+
: renderLabel(false, label, labelTextStyle, item.value), secondaryXAxis
|
|
221
|
+
? isAnimated
|
|
222
|
+
? renderAnimatedLabel(true, secondaryLabel, secondaryLabelTextStyle, item.value)
|
|
223
|
+
: renderLabel(true, secondaryLabel, secondaryLabelTextStyle, item.value)
|
|
224
|
+
: null] }));
|
|
225
|
+
};
|
|
226
|
+
var tooltipProps = {
|
|
227
|
+
barHeight: barHeight,
|
|
228
|
+
barWidth: item.barWidth || barWidth,
|
|
229
|
+
item: item,
|
|
230
|
+
index: index,
|
|
231
|
+
isLast: index === data.length - 1,
|
|
232
|
+
leftSpacing: leftSpacing,
|
|
233
|
+
leftShiftForLastIndexTooltip: leftShiftForLastIndexTooltip,
|
|
234
|
+
leftShiftForTooltip: (_e = (_d = item.leftShiftForTooltip) !== null && _d !== void 0 ? _d : leftShiftForTooltip) !== null && _e !== void 0 ? _e : 0,
|
|
235
|
+
renderTooltip: renderTooltip,
|
|
236
|
+
autoCenterTooltip: autoCenterTooltip,
|
|
237
|
+
horizontal: horizontal,
|
|
238
|
+
};
|
|
239
|
+
return (_jsxs(_Fragment, { children: [pressDisabled ? (_jsx(View, { pointerEvents: "none", style: barWrapperStyle, children: barContent() })) : (_jsx(TouchableOpacity, { activeOpacity: props.activeOpacity || 0.2, onPress: function () {
|
|
240
|
+
if (renderTooltip || props.focusBarOnPress) {
|
|
241
|
+
if (props.focusedBarIndex === undefined || !props.onPress) {
|
|
242
|
+
setSelectedIndex(index);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
item.onPress
|
|
246
|
+
? item.onPress()
|
|
247
|
+
: props.onPress
|
|
248
|
+
? props.onPress(item, index)
|
|
249
|
+
: null;
|
|
250
|
+
}, onLongPress: function () {
|
|
251
|
+
item.onLongPress
|
|
252
|
+
? item.onLongPress()
|
|
253
|
+
: props.onLongPress
|
|
254
|
+
? props.onLongPress(item, index)
|
|
255
|
+
: null;
|
|
256
|
+
}, onPressOut: function () {
|
|
257
|
+
item.onPressOut
|
|
258
|
+
? item.onPressOut()
|
|
259
|
+
: props.onPressOut
|
|
260
|
+
? props.onPressOut(item, index)
|
|
261
|
+
: null;
|
|
262
|
+
}, style: barWrapperStyle, children: barContent() })), renderTooltip && selectedIndex === index && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
|
|
263
|
+
};
|
|
264
|
+
export default RenderBars;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect } from 'react';
|
|
14
|
+
import { View, TouchableOpacity, Text, LayoutAnimation, Platform, UIManager, } from 'react-native';
|
|
15
|
+
import Svg, { Defs, Rect } from 'react-native-svg';
|
|
16
|
+
import LinearGradient from '../Components/common/LinearGradient';
|
|
17
|
+
import { useRenderStackBars, BarDefaults, } from 'gifted-charts-core';
|
|
18
|
+
import Tooltip from '../Components/BarSpecificComponents/tooltip';
|
|
19
|
+
if (Platform.OS === 'android') {
|
|
20
|
+
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
21
|
+
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
22
|
+
}
|
|
23
|
+
var RenderStackBars = function (props) {
|
|
24
|
+
var _a;
|
|
25
|
+
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, item = props.item, index = props.index, containerHeight = props.containerHeight, spacing = props.spacing, rotateLabel = props.rotateLabel, label = props.label, labelTextStyle = props.labelTextStyle, xAxisTextNumberOfLines = props.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, renderTooltip = props.renderTooltip, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, activeOpacity = props.activeOpacity, _b = props.animationDuration, animationDuration = _b === void 0 ? BarDefaults.animationDuration : _b, barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, stackBorderRadius = props.stackBorderRadius, stackBorderTopLeftRadius = props.stackBorderTopLeftRadius, stackBorderTopRightRadius = props.stackBorderTopRightRadius, stackBorderBottomLeftRadius = props.stackBorderBottomLeftRadius, stackBorderBottomRightRadius = props.stackBorderBottomRightRadius, showValuesAsTopLabel = props.showValuesAsTopLabel, _c = props.autoShiftLabelsForNegativeStacks, autoShiftLabelsForNegativeStacks = _c === void 0 ? true : _c, _d = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _d === void 0 ? 0 : _d, horizontal = props.horizontal;
|
|
26
|
+
var _e = useRenderStackBars(props), cotainsNegative = _e.cotainsNegative, noAnimation = _e.noAnimation, localBarInnerComponent = _e.localBarInnerComponent, borderRadius = _e.borderRadius, borderTopLeftRadius = _e.borderTopLeftRadius, borderTopRightRadius = _e.borderTopRightRadius, borderBottomLeftRadius = _e.borderBottomLeftRadius, borderBottomRightRadius = _e.borderBottomRightRadius, disablePress = _e.disablePress, totalHeight = _e.totalHeight, height = _e.height, setHeight = _e.setHeight, getBarHeight = _e.getBarHeight, getPosition = _e.getPosition, lowestBarPosition = _e.lowestBarPosition, getStackBorderRadii = _e.getStackBorderRadii, tooltipProps = _e.tooltipProps;
|
|
27
|
+
var renderLabel = function (label, labelTextStyle) {
|
|
28
|
+
return (_jsx(View, { style: [
|
|
29
|
+
{
|
|
30
|
+
width: (item.stacks[0].barWidth || props.barWidth || 30) + spacing / 2,
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
bottom: autoShiftLabelsForNegativeStacks
|
|
33
|
+
? -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition
|
|
34
|
+
: -labelsDistanceFromXaxis,
|
|
35
|
+
},
|
|
36
|
+
rotateLabel
|
|
37
|
+
? horizontal
|
|
38
|
+
? { transform: [{ rotate: '330deg' }] }
|
|
39
|
+
: { transform: [{ rotate: '60deg' }] }
|
|
40
|
+
: horizontal
|
|
41
|
+
? { transform: [{ rotate: '-90deg' }] }
|
|
42
|
+
: {},
|
|
43
|
+
], children: item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
|
|
44
|
+
};
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (!noAnimation) {
|
|
47
|
+
layoutAppear();
|
|
48
|
+
}
|
|
49
|
+
}, [totalHeight]);
|
|
50
|
+
var elevate = function () {
|
|
51
|
+
LayoutAnimation.configureNext({
|
|
52
|
+
duration: animationDuration,
|
|
53
|
+
update: { type: 'linear', property: 'scaleXY' },
|
|
54
|
+
});
|
|
55
|
+
setHeight(totalHeight);
|
|
56
|
+
};
|
|
57
|
+
var layoutAppear = function () {
|
|
58
|
+
LayoutAnimation.configureNext({
|
|
59
|
+
duration: Platform.OS == 'ios' ? animationDuration : 20,
|
|
60
|
+
create: { type: 'linear', property: 'opacity' },
|
|
61
|
+
update: { type: 'linear', property: 'scaleXY' },
|
|
62
|
+
});
|
|
63
|
+
setTimeout(function () { return elevate(); }, Platform.OS == 'ios' ? 10 : 100);
|
|
64
|
+
};
|
|
65
|
+
var static2DSimple = function () {
|
|
66
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
67
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { disabled: disablePress, activeOpacity: activeOpacity, onPress: function () {
|
|
68
|
+
setSelectedIndex(index);
|
|
69
|
+
if (item.onPress) {
|
|
70
|
+
item.onPress();
|
|
71
|
+
}
|
|
72
|
+
else if (props.onPress) {
|
|
73
|
+
props.onPress(item, index);
|
|
74
|
+
}
|
|
75
|
+
}, onLongPress: function () {
|
|
76
|
+
if (item.onLongPress) {
|
|
77
|
+
item.onLongPress();
|
|
78
|
+
}
|
|
79
|
+
else if (props.onLongPress) {
|
|
80
|
+
props.onLongPress(item, index);
|
|
81
|
+
}
|
|
82
|
+
}, onPressOut: function () {
|
|
83
|
+
if (item.onPressOut) {
|
|
84
|
+
item.onPressOut();
|
|
85
|
+
}
|
|
86
|
+
else if (props.onPressOut) {
|
|
87
|
+
props.onPressOut(item, index);
|
|
88
|
+
}
|
|
89
|
+
}, style: [
|
|
90
|
+
{
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
width: item.stacks[0].barWidth || props.barWidth || 30,
|
|
93
|
+
height: '100%',
|
|
94
|
+
borderTopLeftRadius: (_b = (_a = borderTopLeftRadius !== null && borderTopLeftRadius !== void 0 ? borderTopLeftRadius : borderRadius) !== null && _a !== void 0 ? _a : stackBorderTopLeftRadius) !== null && _b !== void 0 ? _b : stackBorderRadius,
|
|
95
|
+
borderTopRightRadius: (_d = (_c = borderTopRightRadius !== null && borderTopRightRadius !== void 0 ? borderTopRightRadius : borderRadius) !== null && _c !== void 0 ? _c : stackBorderTopRightRadius) !== null && _d !== void 0 ? _d : stackBorderRadius,
|
|
96
|
+
borderBottomLeftRadius: (_f = (_e = borderBottomLeftRadius !== null && borderBottomLeftRadius !== void 0 ? borderBottomLeftRadius : borderRadius) !== null && _e !== void 0 ? _e : stackBorderBottomLeftRadius) !== null && _f !== void 0 ? _f : stackBorderRadius,
|
|
97
|
+
borderBottomRightRadius: (_h = (_g = borderBottomRightRadius !== null && borderBottomRightRadius !== void 0 ? borderBottomRightRadius : borderRadius) !== null && _g !== void 0 ? _g : stackBorderBottomRightRadius) !== null && _h !== void 0 ? _h : stackBorderRadius,
|
|
98
|
+
overflow: lowestBarPosition ? 'visible' : 'hidden',
|
|
99
|
+
},
|
|
100
|
+
], children: [item.stacks.map(function (stackItem, index) {
|
|
101
|
+
var borderRadii = getStackBorderRadii(item, index);
|
|
102
|
+
var barHeight = getBarHeight(stackItem.value, stackItem.marginBottom);
|
|
103
|
+
return (_jsxs(TouchableOpacity, { onPress: stackItem.onPress, activeOpacity: activeOpacity, disabled: disablePress || !stackItem.onPress, style: __assign({ position: 'absolute', bottom: getPosition(index) + (stackItem.marginBottom || 0), width: '100%', height: barHeight, backgroundColor: stackItem.color || item.color || props.color || 'black', borderWidth: barBorderWidth !== null && barBorderWidth !== void 0 ? barBorderWidth : 0, borderColor: barBorderColor }, borderRadii), children: [stackItem.showGradient ||
|
|
104
|
+
item.showGradient ||
|
|
105
|
+
props.showGradient ? (_jsx(LinearGradient, { style: __assign({ position: 'absolute', width: '100%', height: '100%' }, borderRadii), start: { x: 0, y: 0 }, end: { x: 0, y: 1 }, colors: [
|
|
106
|
+
stackItem.gradientColor ||
|
|
107
|
+
item.gradientColor ||
|
|
108
|
+
props.gradientColor ||
|
|
109
|
+
'white',
|
|
110
|
+
stackItem.color || item.color || props.color || 'black',
|
|
111
|
+
] })) : null, stackItem.innerBarComponent && stackItem.innerBarComponent()] }, index));
|
|
112
|
+
}), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
|
|
113
|
+
? item.barBackgroundPattern()
|
|
114
|
+
: barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "transparent", x: "1", y: "1", width: "100%", height: "100%", fill: "url(#".concat(item.patternId || patternId, ")") })] }))] }), localBarInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: localBarInnerComponent(item, index) })) : null, (item.topLabelComponent || showValuesAsTopLabel) && (_jsx(View, { style: [
|
|
115
|
+
{
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
top: cotainsNegative
|
|
118
|
+
? 0
|
|
119
|
+
: (item.barWidth || props.barWidth || 30) * -1,
|
|
120
|
+
height: item.barWidth || props.barWidth || 30,
|
|
121
|
+
width: item.barWidth || props.barWidth || 30,
|
|
122
|
+
justifyContent: 'center',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
},
|
|
125
|
+
cotainsNegative && { transform: [{ translateY: totalHeight * 2 }] },
|
|
126
|
+
horizontal &&
|
|
127
|
+
!props.intactTopLabel && { transform: [{ rotate: '270deg' }] },
|
|
128
|
+
item.topLabelContainerStyle,
|
|
129
|
+
], children: showValuesAsTopLabel ? (_jsx(Text, { style: item.topLabelTextStyle, children: item.stacks.reduce(function (acc, stack) { return acc + stack.value; }, 0) })) : ((_j = item.topLabelComponent) === null || _j === void 0 ? void 0 : _j.call(item)) }))] }));
|
|
130
|
+
};
|
|
131
|
+
var barWrapper = function () {
|
|
132
|
+
return noAnimation ? (static2DSimple()) : (_jsx(View, { style: {
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
bottom: 0,
|
|
135
|
+
height: height,
|
|
136
|
+
width: '100%',
|
|
137
|
+
overflow: 'hidden',
|
|
138
|
+
}, children: static2DSimple() }));
|
|
139
|
+
};
|
|
140
|
+
return (_jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: props.pointerConfig
|
|
141
|
+
? (_a = props.pointerConfig.pointerEvents) !== null && _a !== void 0 ? _a : 'none'
|
|
142
|
+
: 'auto', style: [
|
|
143
|
+
{
|
|
144
|
+
// overflow: 'visible',
|
|
145
|
+
marginBottom: 60 + xAxisLabelsVerticalShift,
|
|
146
|
+
width: item.stacks[0].barWidth || props.barWidth || 30,
|
|
147
|
+
height: totalHeight,
|
|
148
|
+
marginRight: spacing,
|
|
149
|
+
},
|
|
150
|
+
props.pointerConfig
|
|
151
|
+
? {
|
|
152
|
+
transform: [
|
|
153
|
+
{
|
|
154
|
+
translateY: (containerHeight || 200) -
|
|
155
|
+
(totalHeight - 10 + xAxisLabelsVerticalShift),
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
}
|
|
159
|
+
: null,
|
|
160
|
+
], children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
|
|
161
|
+
zIndex: 2,
|
|
162
|
+
position: 'absolute',
|
|
163
|
+
height: props.xAxisIndicesHeight,
|
|
164
|
+
width: props.xAxisIndicesWidth,
|
|
165
|
+
bottom: props.xAxisIndicesHeight / -2,
|
|
166
|
+
left: ((item.barWidth || props.barWidth || 30) -
|
|
167
|
+
props.xAxisIndicesWidth) /
|
|
168
|
+
2,
|
|
169
|
+
backgroundColor: props.xAxisIndicesColor,
|
|
170
|
+
} })), barWrapper(), renderLabel(label || '', labelTextStyle)] }), renderTooltip && selectedIndex === index && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
|
|
171
|
+
};
|
|
172
|
+
export default RenderStackBars;
|