react-native-gifted-charts 1.4.69 → 1.4.71
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 +8 -3
- package/dist/BarChart/RenderStackBars.js +10 -6
- package/dist/BarChart/index.js +7 -1
- package/dist/BubbleChart/index.d.ts +2 -0
- package/dist/BubbleChart/index.js +385 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +6 -5
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +9 -26
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +5 -4
- package/dist/Components/Rotatable.d.ts +9 -0
- package/dist/Components/Rotatable.js +132 -0
- package/dist/LineChart/index.js +18 -21
- package/dist/PieChart/index.js +32 -25
- package/dist/PieChart/main.js +5 -4
- package/dist/RadarChart/index.js +52 -48
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<img src="/demos/redditLogo.png" height="auto" width="32" height="32" />
|
|
21
21
|
</a>
|
|
22
22
|
</p>
|
|
23
|
-
The most
|
|
23
|
+
The most loved library for Bar, Line, Area, Pie, Donut, Stacked Bar, Population Pyramid, Radar and Bubble charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.
|
|
24
24
|
|
|
25
25
|
### Yet another chart library? Why?
|
|
26
26
|
|
|
@@ -94,7 +94,7 @@ Please note that `react-native-svg` and `react-native-linear-gradient`/`expo-lin
|
|
|
94
94
|
The simplest usage of various types of charts can be done as below-
|
|
95
95
|
|
|
96
96
|
```js
|
|
97
|
-
import { BarChart, LineChart, PieChart, PopulationPyramid, RadarChart } from "react-native-gifted-charts";
|
|
97
|
+
import { BarChart, LineChart, PieChart, PopulationPyramid, RadarChart, BubbleChart } from "react-native-gifted-charts";
|
|
98
98
|
|
|
99
99
|
// ...
|
|
100
100
|
const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
|
|
@@ -104,6 +104,10 @@ const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
|
|
|
104
104
|
<PieChart data = {data} />
|
|
105
105
|
<PopulationPyramid data = {[{left:10,right:12}, {left:9,right:8}]} />
|
|
106
106
|
<RadarChart data = {[50, 80, 90, 70]} />
|
|
107
|
+
<BubbleChart data = {
|
|
108
|
+
{x: 20, y: 4, r: 10},
|
|
109
|
+
{x: 40, y: 6, r: 20},
|
|
110
|
+
} />
|
|
107
111
|
|
|
108
112
|
// For Horizontal Bar chart, just add the prop horizontal to the <BarChart/> component
|
|
109
113
|
|
|
@@ -124,7 +128,8 @@ const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
|
|
|
124
128
|
**2. [LineChart and AreaChart props](docs/LineChart/LineChartProps.md)** \
|
|
125
129
|
**3. [PieChart and DonutChart props](docs/PieChart/PieChartProps.md)** \
|
|
126
130
|
**4. [Population Pyramid props](docs/PopulationPyramid/PopulationPyramid.md)** \
|
|
127
|
-
**5. [RadarChart props](docs/RadarChart/RadarChartProps.md)**
|
|
131
|
+
**5. [RadarChart props](docs/RadarChart/RadarChartProps.md)** \
|
|
132
|
+
**6. [BubbleChart props](docs/BubbleChart/BubbleChartProps.md)**
|
|
128
133
|
|
|
129
134
|
## 🤝 Contributing
|
|
130
135
|
|
|
@@ -18,11 +18,11 @@ import { useRenderStackBars, BarDefaults, } from 'gifted-charts-core';
|
|
|
18
18
|
import Tooltip from '../Components/BarSpecificComponents/tooltip';
|
|
19
19
|
var RenderStackBars = function (props) {
|
|
20
20
|
var _a;
|
|
21
|
-
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, stackData = props.stackData, 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, secondaryStepHeight = props.secondaryStepHeight, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight, secondaryNegativeStepValue = props.secondaryNegativeStepValue, barMarginBottom = props.barMarginBottom, highlightEnabled = props.highlightEnabled, highlightedBarIndex = props.highlightedBarIndex, lowlightOpacity = props.lowlightOpacity, stackHighlightEnabled = props.stackHighlightEnabled, selectedStackIndex = props.selectedStackIndex, setSelectedStackIndex = props.setSelectedStackIndex;
|
|
21
|
+
var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, stackData = props.stackData, item = props.item, index = props.index, containerHeight = props.containerHeight, spacing = props.spacing, rotateLabel = props.rotateLabel, label = props.label, rtl = props.rtl, 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, secondaryStepHeight = props.secondaryStepHeight, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight, secondaryNegativeStepValue = props.secondaryNegativeStepValue, barMarginBottom = props.barMarginBottom, highlightEnabled = props.highlightEnabled, highlightedBarIndex = props.highlightedBarIndex, lowlightOpacity = props.lowlightOpacity, stackHighlightEnabled = props.stackHighlightEnabled, selectedStackIndex = props.selectedStackIndex, setSelectedStackIndex = props.setSelectedStackIndex;
|
|
22
22
|
var _e = useRenderStackBars(__assign(__assign({}, props), { secondaryStepHeight: secondaryStepHeight, secondaryStepValue: secondaryStepValue, secondaryNegativeStepHeight: secondaryNegativeStepHeight, secondaryNegativeStepValue: secondaryNegativeStepValue })), containsNegativeValue = _e.containsNegativeValue, 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;
|
|
23
23
|
var renderLabel = function (label, labelTextStyle) {
|
|
24
24
|
return (_jsx(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
|
|
25
|
-
setSelectedIndex(index);
|
|
25
|
+
setSelectedIndex([index]);
|
|
26
26
|
if (item.onPress) {
|
|
27
27
|
item.onPress();
|
|
28
28
|
}
|
|
@@ -49,8 +49,8 @@ var RenderStackBars = function (props) {
|
|
|
49
49
|
props.labelWidth ||
|
|
50
50
|
item.stacks[0].barWidth ||
|
|
51
51
|
props.barWidth ||
|
|
52
|
-
30) +
|
|
53
|
-
|
|
52
|
+
30) + spacing,
|
|
53
|
+
left: spacing / -2,
|
|
54
54
|
position: 'absolute',
|
|
55
55
|
bottom: !labelsDistanceFromXaxis && autoShiftLabelsForNegativeStacks
|
|
56
56
|
? containsNegativeValue
|
|
@@ -65,7 +65,11 @@ var RenderStackBars = function (props) {
|
|
|
65
65
|
: horizontal
|
|
66
66
|
? { transform: [{ rotate: '-90deg' }] }
|
|
67
67
|
: {},
|
|
68
|
-
], children: item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
|
|
68
|
+
], children: item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
|
|
69
|
+
{ textAlign: 'center' },
|
|
70
|
+
rtl && horizontal && { transform: [{ rotate: '180deg' }] },
|
|
71
|
+
labelTextStyle,
|
|
72
|
+
], numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
|
|
69
73
|
};
|
|
70
74
|
var animatedHeight = useRef(new Animated.Value(0)).current;
|
|
71
75
|
var elevate = function () {
|
|
@@ -84,7 +88,7 @@ var RenderStackBars = function (props) {
|
|
|
84
88
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
85
89
|
var remainingBarMarginBottom = barMarginBottom;
|
|
86
90
|
return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
|
|
87
|
-
setSelectedIndex(index);
|
|
91
|
+
setSelectedIndex([index]);
|
|
88
92
|
if (item.onPress) {
|
|
89
93
|
item.onPress();
|
|
90
94
|
}
|
package/dist/BarChart/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export var BarChart = function (props) {
|
|
|
47
47
|
bounces: props.bounces,
|
|
48
48
|
overScrollMode: (_b = props.overScrollMode) !== null && _b !== void 0 ? _b : 'auto',
|
|
49
49
|
};
|
|
50
|
-
var _d = useBarChart(__assign(__assign({}, props), { heightValue: heightValue, widthValue: widthValue, opacityValue: opacityValue, parentWidth: (_c = props.parentWidth) !== null && _c !== void 0 ? _c : screenWidth })), lineConfig = _d.lineConfig, hidePointer1 = _d.hidePointer1, pointerItem = _d.pointerItem, pointerY = _d.pointerY, pointerConfig = _d.pointerConfig, pointerColor = _d.pointerColor, pointerX = _d.pointerX, pointerComponent = _d.pointerComponent, pointerHeight = _d.pointerHeight, pointerRadius = _d.pointerRadius, pointerWidth = _d.pointerWidth, autoAdjustPointerLabelPosition = _d.autoAdjustPointerLabelPosition, pointerLabelWidth = _d.pointerLabelWidth, activatePointersOnLongPress = _d.activatePointersOnLongPress, yAxisLabelWidth = _d.yAxisLabelWidth, shiftPointerLabelX = _d.shiftPointerLabelX, pointerLabelHeight = _d.pointerLabelHeight, pointerStripUptoDataPoint = _d.pointerStripUptoDataPoint, pointerStripHeight = _d.pointerStripHeight, shiftPointerLabelY = _d.shiftPointerLabelY, showPointerStrip = _d.showPointerStrip, pointerStripWidth = _d.pointerStripWidth, containerHeight = _d.containerHeight, xAxisThickness = _d.xAxisThickness, pointerStripColor = _d.pointerStripColor, pointerEvents = _d.pointerEvents, setResponderStartTime = _d.setResponderStartTime, setPointerY = _d.setPointerY, setPointerItem = _d.setPointerItem, initialSpacing = _d.initialSpacing, spacing = _d.spacing, data = _d.data, barWidth = _d.barWidth, setPointerX = _d.setPointerX, pointerIndex = _d.pointerIndex, setPointerIndex = _d.setPointerIndex, maxValue = _d.maxValue, responderStartTime = _d.responderStartTime, setResponderActive = _d.setResponderActive, activatePointersDelay = _d.activatePointersDelay, persistPointer = _d.persistPointer, pointerVanishDelay = _d.pointerVanishDelay, containerHeightIncludingBelowXAxis = _d.containerHeightIncludingBelowXAxis, extendedContainerHeight = _d.extendedContainerHeight, totalWidth = _d.totalWidth, stripBehindBars = _d.stripBehindBars, noOfSectionsBelowXAxis = _d.noOfSectionsBelowXAxis, stepHeight = _d.stepHeight, xAxisLabelsVerticalShift = _d.xAxisLabelsVerticalShift, labelsExtraHeight = _d.labelsExtraHeight, stripOverPointer = _d.stripOverPointer, pointerLabelComponent = _d.pointerLabelComponent, selectedIndex = _d.selectedIndex, setSelectedIndex = _d.setSelectedIndex, selectedStackIndex = _d.selectedStackIndex, setSelectedStackIndex = _d.setSelectedStackIndex, isAnimated = _d.isAnimated, animationDuration = _d.animationDuration, side = _d.side, labelWidth = _d.labelWidth, isThreeD = _d.isThreeD, animatedHeight = _d.animatedHeight, appearingOpacity = _d.appearingOpacity, autoShiftLabels = _d.autoShiftLabels, getPropsCommonForBarAndStack = _d.getPropsCommonForBarAndStack, barAndLineChartsWrapperProps = _d.barAndLineChartsWrapperProps, autoShiftLabelsForNegativeStacks = _d.autoShiftLabelsForNegativeStacks, showLine = _d.showLine, points2 = _d.points2;
|
|
50
|
+
var _d = useBarChart(__assign(__assign({}, props), { heightValue: heightValue, widthValue: widthValue, opacityValue: opacityValue, parentWidth: (_c = props.parentWidth) !== null && _c !== void 0 ? _c : screenWidth })), lineConfig = _d.lineConfig, lineConfig2 = _d.lineConfig2, hidePointer1 = _d.hidePointer1, pointerItem = _d.pointerItem, pointerY = _d.pointerY, pointerConfig = _d.pointerConfig, pointerColor = _d.pointerColor, pointerX = _d.pointerX, pointerComponent = _d.pointerComponent, pointerHeight = _d.pointerHeight, pointerRadius = _d.pointerRadius, pointerWidth = _d.pointerWidth, autoAdjustPointerLabelPosition = _d.autoAdjustPointerLabelPosition, pointerLabelWidth = _d.pointerLabelWidth, activatePointersOnLongPress = _d.activatePointersOnLongPress, yAxisLabelWidth = _d.yAxisLabelWidth, shiftPointerLabelX = _d.shiftPointerLabelX, pointerLabelHeight = _d.pointerLabelHeight, pointerStripUptoDataPoint = _d.pointerStripUptoDataPoint, pointerStripHeight = _d.pointerStripHeight, shiftPointerLabelY = _d.shiftPointerLabelY, showPointerStrip = _d.showPointerStrip, pointerStripWidth = _d.pointerStripWidth, containerHeight = _d.containerHeight, xAxisThickness = _d.xAxisThickness, pointerStripColor = _d.pointerStripColor, pointerEvents = _d.pointerEvents, setResponderStartTime = _d.setResponderStartTime, setPointerY = _d.setPointerY, setPointerItem = _d.setPointerItem, initialSpacing = _d.initialSpacing, spacing = _d.spacing, data = _d.data, barWidth = _d.barWidth, setPointerX = _d.setPointerX, pointerIndex = _d.pointerIndex, setPointerIndex = _d.setPointerIndex, maxValue = _d.maxValue, responderStartTime = _d.responderStartTime, setResponderActive = _d.setResponderActive, activatePointersDelay = _d.activatePointersDelay, persistPointer = _d.persistPointer, pointerVanishDelay = _d.pointerVanishDelay, containerHeightIncludingBelowXAxis = _d.containerHeightIncludingBelowXAxis, extendedContainerHeight = _d.extendedContainerHeight, totalWidth = _d.totalWidth, stripBehindBars = _d.stripBehindBars, noOfSectionsBelowXAxis = _d.noOfSectionsBelowXAxis, stepHeight = _d.stepHeight, xAxisLabelsVerticalShift = _d.xAxisLabelsVerticalShift, labelsExtraHeight = _d.labelsExtraHeight, stripOverPointer = _d.stripOverPointer, pointerLabelComponent = _d.pointerLabelComponent, selectedIndex = _d.selectedIndex, setSelectedIndex = _d.setSelectedIndex, selectedStackIndex = _d.selectedStackIndex, setSelectedStackIndex = _d.setSelectedStackIndex, isAnimated = _d.isAnimated, animationDuration = _d.animationDuration, side = _d.side, labelWidth = _d.labelWidth, isThreeD = _d.isThreeD, animatedHeight = _d.animatedHeight, appearingOpacity = _d.appearingOpacity, autoShiftLabels = _d.autoShiftLabels, getPropsCommonForBarAndStack = _d.getPropsCommonForBarAndStack, barAndLineChartsWrapperProps = _d.barAndLineChartsWrapperProps, autoShiftLabelsForNegativeStacks = _d.autoShiftLabelsForNegativeStacks, showLine = _d.showLine, points2 = _d.points2;
|
|
51
51
|
var _e = useBarAndLineChartsWrapper(__assign(__assign({}, barAndLineChartsWrapperProps), { isRTL: I18nManager.isRTL })), lineInBarChartProps = _e.lineInBarChartProps, lineInBarChartProps2 = _e.lineInBarChartProps2;
|
|
52
52
|
var stackData = barAndLineChartsWrapperProps.stackData;
|
|
53
53
|
var labelsAppear = useCallback(function () {
|
|
@@ -228,6 +228,12 @@ export var BarChart = function (props) {
|
|
|
228
228
|
setSelectedStackIndex(-1);
|
|
229
229
|
// props.setHighlightedStackIndex?.(-1)
|
|
230
230
|
}
|
|
231
|
+
if (lineConfig.focusEnabled) {
|
|
232
|
+
lineConfig.setFocusedDataPointIndex(-1);
|
|
233
|
+
}
|
|
234
|
+
if (lineConfig2.focusEnabled) {
|
|
235
|
+
lineConfig2.setFocusedDataPointIndex(-1);
|
|
236
|
+
}
|
|
231
237
|
(_b = props.onBackgroundPress) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
232
238
|
}, children: [renderChart(),
|
|
233
239
|
// Only For Bar Charts-
|
|
@@ -0,0 +1,385 @@
|
|
|
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 { LineDefaults, useBubbleChart, } from 'gifted-charts-core';
|
|
14
|
+
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
15
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
16
|
+
import { Animated, Easing, I18nManager, Text, View, } from 'react-native';
|
|
17
|
+
import { Circle, ForeignObject, Rect, Svg, Text as CanvasText, } from 'react-native-svg';
|
|
18
|
+
import { isWebApp, screenWidth } from '../utils';
|
|
19
|
+
var AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
20
|
+
var AnimatedRect = Animated.createAnimatedComponent(Rect);
|
|
21
|
+
export var BubbleChart = function (props) {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
24
|
+
var pointsOpacityValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
25
|
+
var secondaryXAxis = props.secondaryXAxis;
|
|
26
|
+
var _e = useBubbleChart(__assign(__assign({}, props), { parentWidth: (_a = props.parentWidth) !== null && _a !== void 0 ? _a : screenWidth })), barAndLineChartsWrapperProps = _e.barAndLineChartsWrapperProps, totalWidth = _e.totalWidth, animationDuration = _e.animationDuration, _f = _e.containerHeightIncludingBelowXAxis, containerHeightIncludingBelowXAxis = _f === void 0 ? 0 : _f, getY = _e.getY, getX = _e.getX, maxValue = _e.maxValue, selectedIndex = _e.selectedIndex, setSelectedIndex = _e.setSelectedIndex, showTextOnFocus = _e.showTextOnFocus, focusEnabled = _e.focusEnabled, focusTogether = _e.focusTogether, selectedLineNumber = _e.selectedLineNumber, lastLineNumber = _e.lastLineNumber, initialSpacing = _e.initialSpacing, spacing = _e.spacing, containerHeight = _e.containerHeight, handleFocus = _e.handleFocus, handleUnFocus = _e.handleUnFocus, isAnimated = _e.isAnimated, showDataPointOnFocus = _e.showDataPointOnFocus, showDataPointLabelOnFocus = _e.showDataPointLabelOnFocus, dataPointsShape = _e.dataPointsShape, dataPointsWidth = _e.dataPointsWidth, dataPointsHeight = _e.dataPointsHeight, dataPointsColor = _e.dataPointsColor, dataPointsRadius = _e.dataPointsRadius, textColor = _e.textColor, textFontSize = _e.textFontSize, startIndex = _e.startIndex, endIndex = _e.endIndex, showValuesAsDataPointsText = _e.showValuesAsDataPointsText, cumulativeSpacing = _e.cumulativeSpacing, hideDataPoints = _e.hideDataPoints, xAxisLabelsVerticalShift = _e.xAxisLabelsVerticalShift, labelsExtraHeight = _e.labelsExtraHeight, xAxisThickness = _e.xAxisThickness, xAxisTextNumberOfLines = _e.xAxisTextNumberOfLines, rotateLabel = _e.rotateLabel, allowFontScaling = _e.allowFontScaling, borderColor = _e.borderColor, borderWidth = _e.borderWidth, opacity = _e.opacity;
|
|
27
|
+
var radiiValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
|
|
28
|
+
var pointsHeightValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
|
|
29
|
+
var pointsWidthValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
|
|
30
|
+
var scrollRef = (_b = props.scrollRef) !== null && _b !== void 0 ? _b : useRef(null);
|
|
31
|
+
var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
32
|
+
var appearingOpacity = opacityValue.interpolate({
|
|
33
|
+
inputRange: [0, 1],
|
|
34
|
+
outputRange: [0, 1],
|
|
35
|
+
});
|
|
36
|
+
var growingRadii = radiiValues.map(function (r, i) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return r.interpolate({
|
|
39
|
+
inputRange: [0, 1],
|
|
40
|
+
outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].r) !== null && _b !== void 0 ? _b : dataPointsRadius],
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
var growingHeight = pointsHeightValues.map(function (h, i) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return h.interpolate({
|
|
46
|
+
inputRange: [0, 1],
|
|
47
|
+
outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].dataPointHeight) !== null && _b !== void 0 ? _b : dataPointsHeight],
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var growingWidth = pointsHeightValues.map(function (w, i) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return w.interpolate({
|
|
53
|
+
inputRange: [0, 1],
|
|
54
|
+
outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].dataPointWidth) !== null && _b !== void 0 ? _b : dataPointsWidth],
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
var appearingDataPoints = pointsOpacityValue.interpolate({
|
|
58
|
+
inputRange: [0, 1],
|
|
59
|
+
outputRange: [0, opacity],
|
|
60
|
+
});
|
|
61
|
+
var decreaseWidth = useCallback(function () {
|
|
62
|
+
widthValue.setValue(0);
|
|
63
|
+
Animated.timing(widthValue, {
|
|
64
|
+
toValue: totalWidth,
|
|
65
|
+
duration: animationDuration,
|
|
66
|
+
easing: Easing.linear,
|
|
67
|
+
useNativeDriver: false,
|
|
68
|
+
}).start();
|
|
69
|
+
}, [animationDuration, widthValue]);
|
|
70
|
+
var labelsAppear = useCallback(function () {
|
|
71
|
+
opacityValue.setValue(0);
|
|
72
|
+
Animated.timing(opacityValue, {
|
|
73
|
+
toValue: 1,
|
|
74
|
+
duration: 500,
|
|
75
|
+
easing: Easing.ease,
|
|
76
|
+
useNativeDriver: false,
|
|
77
|
+
}).start();
|
|
78
|
+
}, [opacityValue]);
|
|
79
|
+
var radiiGrow = useCallback(function () {
|
|
80
|
+
radiiValues.forEach(function (radiusValue) {
|
|
81
|
+
radiusValue.setValue(0);
|
|
82
|
+
Animated.timing(radiusValue, {
|
|
83
|
+
toValue: 1,
|
|
84
|
+
duration: animationDuration,
|
|
85
|
+
easing: Easing.ease,
|
|
86
|
+
useNativeDriver: false,
|
|
87
|
+
}).start();
|
|
88
|
+
});
|
|
89
|
+
}, [radiiValues]);
|
|
90
|
+
var dataPointsHeightsGrow = useCallback(function () {
|
|
91
|
+
pointsHeightValues.forEach(function (h) {
|
|
92
|
+
h.setValue(0);
|
|
93
|
+
Animated.timing(h, {
|
|
94
|
+
toValue: 1,
|
|
95
|
+
duration: animationDuration,
|
|
96
|
+
easing: Easing.ease,
|
|
97
|
+
useNativeDriver: false,
|
|
98
|
+
}).start();
|
|
99
|
+
});
|
|
100
|
+
}, [pointsHeightValues]);
|
|
101
|
+
var dataPointsWidthsGrow = useCallback(function () {
|
|
102
|
+
pointsWidthValues.forEach(function (w) {
|
|
103
|
+
w.setValue(0);
|
|
104
|
+
Animated.timing(w, {
|
|
105
|
+
toValue: 1,
|
|
106
|
+
duration: animationDuration,
|
|
107
|
+
easing: Easing.ease,
|
|
108
|
+
useNativeDriver: false,
|
|
109
|
+
}).start();
|
|
110
|
+
});
|
|
111
|
+
}, [pointsWidthValues]);
|
|
112
|
+
// const dataPointsHeightGrow
|
|
113
|
+
var dataPointsAppear = useCallback(function () {
|
|
114
|
+
pointsOpacityValue.setValue(0);
|
|
115
|
+
Animated.timing(pointsOpacityValue, {
|
|
116
|
+
toValue: 1,
|
|
117
|
+
duration: animationDuration,
|
|
118
|
+
easing: Easing.ease,
|
|
119
|
+
useNativeDriver: false,
|
|
120
|
+
}).start();
|
|
121
|
+
}, [pointsOpacityValue]);
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
if (isAnimated) {
|
|
124
|
+
decreaseWidth();
|
|
125
|
+
labelsAppear();
|
|
126
|
+
radiiGrow();
|
|
127
|
+
dataPointsAppear();
|
|
128
|
+
if (dataPointsShape === 'rectangular') {
|
|
129
|
+
dataPointsHeightsGrow();
|
|
130
|
+
dataPointsWidthsGrow();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, [isAnimated, dataPointsShape]);
|
|
134
|
+
var svgHeight = containerHeightIncludingBelowXAxis + ((_c = props.overflowBottom) !== null && _c !== void 0 ? _c : 0);
|
|
135
|
+
var onStripPress = function (item, index) {
|
|
136
|
+
if (props.focusedDataPointIndex === undefined || !props.onFocus) {
|
|
137
|
+
setSelectedIndex(index);
|
|
138
|
+
}
|
|
139
|
+
if (props.onFocus) {
|
|
140
|
+
props.onFocus(item, index);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var renderLabel = function (top, index, label, labelTextStyle, labelComponent) {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
return (_jsx(View, { style: [
|
|
146
|
+
{
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
bottom: top
|
|
149
|
+
? containerHeight +
|
|
150
|
+
60 +
|
|
151
|
+
((_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _a !== void 0 ? _a : 15)
|
|
152
|
+
: -xAxisTextNumberOfLines * 18,
|
|
153
|
+
zIndex: 10,
|
|
154
|
+
width: spacing + labelsExtraHeight,
|
|
155
|
+
left: initialSpacing + spacing * index - spacing / 2,
|
|
156
|
+
height: (_b = props.xAxisLabelsHeight) !== null && _b !== void 0 ? _b : xAxisTextNumberOfLines * 18,
|
|
157
|
+
},
|
|
158
|
+
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
159
|
+
], children: labelComponent ? (labelComponent()) : (_jsx(Text, { style: [{ textAlign: 'center' }, labelTextStyle], allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
160
|
+
};
|
|
161
|
+
var renderAnimatedLabel = function (top, index, label, labelTextStyle, labelComponent) {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return (_jsx(Animated.View, { style: [
|
|
164
|
+
{
|
|
165
|
+
height: rotateLabel
|
|
166
|
+
? 40
|
|
167
|
+
: ((_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18),
|
|
168
|
+
position: 'absolute',
|
|
169
|
+
bottom: top
|
|
170
|
+
? containerHeight +
|
|
171
|
+
60 +
|
|
172
|
+
((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
|
|
173
|
+
: rotateLabel
|
|
174
|
+
? 10
|
|
175
|
+
: -xAxisTextNumberOfLines * 18,
|
|
176
|
+
zIndex: 10,
|
|
177
|
+
width: spacing,
|
|
178
|
+
left: initialSpacing + spacing * index - spacing / 2,
|
|
179
|
+
opacity: appearingOpacity,
|
|
180
|
+
},
|
|
181
|
+
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
182
|
+
], children: labelComponent ? (labelComponent()) : (_jsx(Text, { allowFontScaling: allowFontScaling, style: [{ textAlign: 'center' }, labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
183
|
+
};
|
|
184
|
+
var renderDataPoints = function (hideDataPoints, dataForRender, originalDataFromProps, dataPtsShape, dataPtsWidth, dataPtsHeight, dataPtsColor, dataPtsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
185
|
+
var getYOrSecondaryY = getY; //isSecondary ? getSecondaryY : getY;
|
|
186
|
+
return dataForRender.map(function (item, index) {
|
|
187
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
188
|
+
if (index < startIndex || index > endIndex)
|
|
189
|
+
return null;
|
|
190
|
+
if (item.hideDataPoint) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
var dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, text, customDataPoint, dataPointLabelComponent;
|
|
194
|
+
if (index === selectedIndex &&
|
|
195
|
+
(focusTogether || key === selectedLineNumber)) {
|
|
196
|
+
dataPointsShape =
|
|
197
|
+
item.focusedDataPointShape ||
|
|
198
|
+
props.focusedDataPointShape ||
|
|
199
|
+
item.dataPointShape ||
|
|
200
|
+
dataPtsShape;
|
|
201
|
+
dataPointsWidth =
|
|
202
|
+
item.focusedDataPointWidth ||
|
|
203
|
+
props.focusedDataPointWidth ||
|
|
204
|
+
item.dataPointWidth ||
|
|
205
|
+
dataPtsWidth;
|
|
206
|
+
dataPointsHeight =
|
|
207
|
+
item.focusedDataPointHeight ||
|
|
208
|
+
props.focusedDataPointHeight ||
|
|
209
|
+
item.dataPointHeight ||
|
|
210
|
+
dataPtsHeight;
|
|
211
|
+
dataPointsColor =
|
|
212
|
+
item.focusedDataPointColor ||
|
|
213
|
+
props.focusedDataPointColor ||
|
|
214
|
+
LineDefaults.focusedDataPointColor;
|
|
215
|
+
dataPointsRadius =
|
|
216
|
+
(_c = (_b = (_a = item.focusedDataPointRadius) !== null && _a !== void 0 ? _a : props.focusedDataPointRadius) !== null && _b !== void 0 ? _b : item.r) !== null && _c !== void 0 ? _c : dataPtsRadius;
|
|
217
|
+
if (showTextOnFocus) {
|
|
218
|
+
text = item.dataPointText;
|
|
219
|
+
}
|
|
220
|
+
customDataPoint =
|
|
221
|
+
item.focusedCustomDataPoint ||
|
|
222
|
+
props.focusedCustomDataPoint ||
|
|
223
|
+
item.customDataPoint ||
|
|
224
|
+
props.customDataPoint;
|
|
225
|
+
dataPointLabelComponent =
|
|
226
|
+
item.focusedDataPointLabelComponent ||
|
|
227
|
+
item.dataPointLabelComponent ||
|
|
228
|
+
props.focusedDataPointLabelComponent ||
|
|
229
|
+
props.dataPointLabelComponent;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
dataPointsShape = item.dataPointShape || dataPtsShape;
|
|
233
|
+
dataPointsWidth = item.dataPointWidth || dataPtsWidth;
|
|
234
|
+
dataPointsHeight = item.dataPointHeight || dataPtsHeight;
|
|
235
|
+
dataPointsColor = item.dataPointColor || dataPtsColor;
|
|
236
|
+
dataPointsRadius = (_d = item.r) !== null && _d !== void 0 ? _d : dataPtsRadius;
|
|
237
|
+
if (showTextOnFocus) {
|
|
238
|
+
text = '';
|
|
239
|
+
}
|
|
240
|
+
customDataPoint = item.customDataPoint || props.customDataPoint;
|
|
241
|
+
dataPointLabelComponent =
|
|
242
|
+
item.dataPointLabelComponent || props.dataPointLabelComponent;
|
|
243
|
+
}
|
|
244
|
+
if (showValuesAsDataPointsText) {
|
|
245
|
+
text = originalDataFromProps[index].y;
|
|
246
|
+
}
|
|
247
|
+
var dataPointLabelWidth = item.dataPointLabelWidth
|
|
248
|
+
? item.dataPointLabelWidth
|
|
249
|
+
: props.dataPointLabelWidth
|
|
250
|
+
? props.dataPointLabelWidth
|
|
251
|
+
: 30;
|
|
252
|
+
return (_jsxs(Fragment, { children: [focusEnabled ? (_jsx(_Fragment, { children: key === lastLineNumber - 1 ? (_jsx(Rect, { x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight - 0, fill: 'none', onPressIn: function (evt) {
|
|
253
|
+
var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
|
|
254
|
+
handleFocus(index);
|
|
255
|
+
}, onPressOut: handleUnFocus })) : null })) : null, hideDataPoints ? null : (_jsxs(_Fragment, { children: [customDataPoint ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: initialSpacing -
|
|
256
|
+
dataPointsWidth / 2 +
|
|
257
|
+
((_e = spacingArray[index - 1]) !== null && _e !== void 0 ? _e : 0), y: getYOrSecondaryY(item.y) - dataPointsHeight / 2, children: customDataPoint(item, index) })) : (_jsx(Animated.View, { style: {
|
|
258
|
+
position: 'absolute',
|
|
259
|
+
// height: svgHeight,
|
|
260
|
+
// width: totalWidth,
|
|
261
|
+
left: initialSpacing -
|
|
262
|
+
dataPointsWidth / 2 +
|
|
263
|
+
((_f = spacingArray[index - 1]) !== null && _f !== void 0 ? _f : 0),
|
|
264
|
+
top: getYOrSecondaryY(item.y) - dataPointsHeight / 2,
|
|
265
|
+
opacity: isAnimated ? appearingOpacity : 1,
|
|
266
|
+
}, children: customDataPoint(item, index) }))) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(AnimatedRect, { x: getX(spacingArray, index) - dataPointsWidth / 2, y: getYOrSecondaryY(item.y) - dataPointsHeight / 2, width: isAnimated ? growingWidth[index] : dataPointsWidth, height: isAnimated ? growingHeight[index] : dataPointsHeight, opacity: isAnimated ? appearingDataPoints : opacity, fill: showDataPointOnFocus
|
|
267
|
+
? index === selectedIndex
|
|
268
|
+
? dataPointsColor
|
|
269
|
+
: 'none'
|
|
270
|
+
: dataPointsColor, onPress: function () {
|
|
271
|
+
item.onPress
|
|
272
|
+
? item.onPress(item, index)
|
|
273
|
+
: props.onPress
|
|
274
|
+
? props.onPress(item, index)
|
|
275
|
+
: focusEnabled
|
|
276
|
+
? handleFocus(index)
|
|
277
|
+
: null;
|
|
278
|
+
}, onPressOut: function () {
|
|
279
|
+
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
280
|
+
handleUnFocus();
|
|
281
|
+
}
|
|
282
|
+
} })) }, index)) : (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(AnimatedCircle, { cx: getX(spacingArray, index), cy: getYOrSecondaryY(item.y), r: isAnimated ? growingRadii[index] : dataPointsRadius, fill: showDataPointOnFocus
|
|
283
|
+
? index === selectedIndex
|
|
284
|
+
? dataPointsColor
|
|
285
|
+
: 'none'
|
|
286
|
+
: dataPointsColor, opacity: isAnimated ? appearingDataPoints : opacity, stroke: (_g = item.borderColor) !== null && _g !== void 0 ? _g : borderColor, strokeWidth: (_h = item.borderWidth) !== null && _h !== void 0 ? _h : borderWidth, onPress: function () {
|
|
287
|
+
item.onPress
|
|
288
|
+
? item.onPress(item, index)
|
|
289
|
+
: props.onPress
|
|
290
|
+
? props.onPress(item, index)
|
|
291
|
+
: focusEnabled
|
|
292
|
+
? handleFocus(index)
|
|
293
|
+
: null;
|
|
294
|
+
}, onPressOut: function () {
|
|
295
|
+
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
296
|
+
handleUnFocus();
|
|
297
|
+
}
|
|
298
|
+
} })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: dataPointLabelWidth, x: initialSpacing +
|
|
299
|
+
(item.dataPointLabelShiftX ||
|
|
300
|
+
props.dataPointLabelShiftX ||
|
|
301
|
+
0) -
|
|
302
|
+
dataPointLabelWidth / 2 +
|
|
303
|
+
spacing * index, y: containerHeight +
|
|
304
|
+
(item.dataPointLabelShiftY ||
|
|
305
|
+
props.dataPointLabelShiftY ||
|
|
306
|
+
0) -
|
|
307
|
+
(item.y * containerHeight) / maxValue, children: showDataPointLabelOnFocus
|
|
308
|
+
? index === selectedIndex &&
|
|
309
|
+
(focusTogether || key == selectedLineNumber)
|
|
310
|
+
? dataPointLabelComponent(item, index) // not pushed in latest release
|
|
311
|
+
: null
|
|
312
|
+
: dataPointLabelComponent(item, index) })) : (_jsx(View, { style: {
|
|
313
|
+
position: 'absolute',
|
|
314
|
+
height: svgHeight,
|
|
315
|
+
width: dataPointLabelWidth,
|
|
316
|
+
left: initialSpacing +
|
|
317
|
+
(item.dataPointLabelShiftX ||
|
|
318
|
+
props.dataPointLabelShiftX ||
|
|
319
|
+
0) -
|
|
320
|
+
dataPointLabelWidth / 2 +
|
|
321
|
+
spacing * index,
|
|
322
|
+
top: containerHeight +
|
|
323
|
+
(item.dataPointLabelShiftY ||
|
|
324
|
+
props.dataPointLabelShiftY ||
|
|
325
|
+
0) -
|
|
326
|
+
(item.y * containerHeight) / maxValue,
|
|
327
|
+
}, children: showDataPointLabelOnFocus
|
|
328
|
+
? index === selectedIndex &&
|
|
329
|
+
(focusTogether || key == selectedLineNumber)
|
|
330
|
+
? dataPointLabelComponent(item, index) // not pushed in latest release
|
|
331
|
+
: null
|
|
332
|
+
: dataPointLabelComponent(item, index) }))) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: getX(spacingArray, index) -
|
|
333
|
+
dataPointsWidth +
|
|
334
|
+
(item.textShiftX || props.textShiftX || 0), y: getYOrSecondaryY(item.y) -
|
|
335
|
+
dataPointsHeight / 2 +
|
|
336
|
+
(item.textShiftY || props.textShiftY || 0), children: !showTextOnFocus && !showValuesAsDataPointsText
|
|
337
|
+
? item.dataPointText
|
|
338
|
+
: text })) : null) : null, index === selectedIndex ? _jsx(Text, { children: '' }) : null] }))] }, index));
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
var svgWrapperViewStyle = {
|
|
342
|
+
position: 'absolute',
|
|
343
|
+
top: 0, // 281 + xAxisLabelsVerticalShift + labelsExtraHeight - xAxisThickness,
|
|
344
|
+
left: 0,
|
|
345
|
+
zIndex: 1,
|
|
346
|
+
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
|
347
|
+
};
|
|
348
|
+
var renderChartContent = function () {
|
|
349
|
+
var _a;
|
|
350
|
+
return (_jsxs(View, { style: [
|
|
351
|
+
svgWrapperViewStyle,
|
|
352
|
+
{
|
|
353
|
+
width: totalWidth,
|
|
354
|
+
height: containerHeightIncludingBelowXAxis,
|
|
355
|
+
// zIndex,
|
|
356
|
+
},
|
|
357
|
+
], children: [_jsx(Svg, { height: svgHeight, width: totalWidth, onPress: props.onBackgroundPress, children: renderDataPoints(hideDataPoints, props.data, props.data, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, false, showValuesAsDataPointsText, cumulativeSpacing, 0) }), (_a = props.data) === null || _a === void 0 ? void 0 : _a.map(function (item, index) {
|
|
358
|
+
var _a, _b, _c, _d, _e, _f;
|
|
359
|
+
var secondaryLabel = (_c = (_a = item.secondaryLabel) !== null && _a !== void 0 ? _a : (_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelTexts) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : '';
|
|
360
|
+
var secondaryLabelTextStyle = (_f = (_e = (_d = item.secondaryLabelTextStyle) !== null && _d !== void 0 ? _d : secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsTextStyle) !== null && _e !== void 0 ? _e : item.labelTextStyle) !== null && _f !== void 0 ? _f : props.xAxisLabelTextStyle;
|
|
361
|
+
return (_jsxs(View, { children: [isAnimated
|
|
362
|
+
? renderAnimatedLabel(false, index, item.label ||
|
|
363
|
+
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
364
|
+
? props.xAxisLabelTexts[index]
|
|
365
|
+
: ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent)
|
|
366
|
+
: renderLabel(false, index, item.label ||
|
|
367
|
+
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
368
|
+
? props.xAxisLabelTexts[index]
|
|
369
|
+
: ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent), secondaryXAxis
|
|
370
|
+
? isAnimated
|
|
371
|
+
? renderAnimatedLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
|
|
372
|
+
: renderLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
|
|
373
|
+
: null] }, index));
|
|
374
|
+
})] }));
|
|
375
|
+
};
|
|
376
|
+
var remainingScrollViewProps = {
|
|
377
|
+
onScroll: function (ev) {
|
|
378
|
+
var _a;
|
|
379
|
+
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev);
|
|
380
|
+
},
|
|
381
|
+
bounces: props.bounces,
|
|
382
|
+
overScrollMode: (_d = props.overScrollMode) !== null && _d !== void 0 ? _d : 'auto',
|
|
383
|
+
};
|
|
384
|
+
return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled })));
|
|
385
|
+
};
|
|
@@ -4,7 +4,7 @@ import Svg, { Path } from 'react-native-svg';
|
|
|
4
4
|
import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
|
|
5
5
|
import { renderDataPoints } from './renderDataPoints';
|
|
6
6
|
import { renderSpecificDataPoints } from './renderSpecificDataPoints';
|
|
7
|
-
import { isIos } from '../../../utils';
|
|
7
|
+
import { isIos, isWebApp } from '../../../utils';
|
|
8
8
|
var RenderLineInBarChart = function (props) {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
var yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, arrowPoints = props.arrowPoints, data = props.data, totalWidth = props.totalWidth, barWidth = props.barWidth, labelsExtraHeight = props.labelsExtraHeight, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, selectedIndex = props.selectedIndex, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, yAxisOffset = props.yAxisOffset, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity;
|
|
@@ -15,6 +15,7 @@ var RenderLineInBarChart = function (props) {
|
|
|
15
15
|
: lowlightOpacity
|
|
16
16
|
: 1;
|
|
17
17
|
var svgHeight = containerHeightIncludingBelowXAxis + labelsExtraHeight;
|
|
18
|
+
var svgHeightProp = isWebApp ? svgHeight : undefined;
|
|
18
19
|
var dataPointsProps = {
|
|
19
20
|
data: data,
|
|
20
21
|
lineConfig: lineConfig,
|
|
@@ -57,11 +58,11 @@ var RenderLineInBarChart = function (props) {
|
|
|
57
58
|
position: 'absolute',
|
|
58
59
|
height: svgHeight,
|
|
59
60
|
left: 6 - yAxisLabelWidth,
|
|
60
|
-
bottom:
|
|
61
|
+
bottom: -10 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
61
62
|
width: animatedWidth,
|
|
62
63
|
zIndex: lineBehindBars ? -1 : 100000,
|
|
63
64
|
// backgroundColor: 'wheat',
|
|
64
|
-
}, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
65
|
+
}, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', height: svgHeightProp, width: isWebApp ? animatedWidth : undefined, children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
65
66
|
? renderDataPoints(dataPointsProps)
|
|
66
67
|
: renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
|
|
67
68
|
};
|
|
@@ -69,13 +70,13 @@ var RenderLineInBarChart = function (props) {
|
|
|
69
70
|
var _a, _b, _c;
|
|
70
71
|
return (_jsx(View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
|
|
71
72
|
position: 'absolute',
|
|
72
|
-
height:
|
|
73
|
+
height: svgHeight,
|
|
73
74
|
left: 6 - yAxisLabelWidth,
|
|
74
75
|
bottom: -10 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
75
76
|
width: totalWidth,
|
|
76
77
|
zIndex: lineBehindBars ? -1 : 100000,
|
|
77
78
|
// backgroundColor: 'rgba(200,150,150,0.1)'
|
|
78
|
-
}, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
79
|
+
}, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', height: svgHeightProp, width: isWebApp ? totalWidth : undefined, children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
79
80
|
? renderDataPoints(dataPointsProps)
|
|
80
81
|
: renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
|
|
81
82
|
};
|