@harveylx/react-native-gifted-charts 1.4.70

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  4. package/dist/BarChart/Animated2DWithGradient.js +78 -0
  5. package/dist/BarChart/RenderBars.d.ts +3 -0
  6. package/dist/BarChart/RenderBars.js +222 -0
  7. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  8. package/dist/BarChart/RenderStackBars.js +214 -0
  9. package/dist/BarChart/index.d.ts +2 -0
  10. package/dist/BarChart/index.js +256 -0
  11. package/dist/BarChart/styles.d.ts +45 -0
  12. package/dist/BarChart/styles.js +46 -0
  13. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  14. package/dist/Components/AnimatedThreeDBar/index.js +103 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
  16. package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  18. package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  30. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  31. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  32. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
  33. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  34. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  35. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  36. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  37. package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
  38. package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
  39. package/dist/Components/common/LinearGradient.d.ts +16 -0
  40. package/dist/Components/common/LinearGradient.js +15 -0
  41. package/dist/Components/common/Pointer.d.ts +1 -0
  42. package/dist/Components/common/Pointer.js +18 -0
  43. package/dist/Components/common/StripAndLabel.d.ts +2 -0
  44. package/dist/Components/common/StripAndLabel.js +60 -0
  45. package/dist/Components/lineSvg.d.ts +14 -0
  46. package/dist/Components/lineSvg.js +22 -0
  47. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  48. package/dist/LineChart/LineChartBicolor.js +298 -0
  49. package/dist/LineChart/index.d.ts +2 -0
  50. package/dist/LineChart/index.js +1137 -0
  51. package/dist/LineChart/styles.d.ts +43 -0
  52. package/dist/LineChart/styles.js +46 -0
  53. package/dist/PieChart/index.d.ts +2 -0
  54. package/dist/PieChart/index.js +146 -0
  55. package/dist/PieChart/main.d.ts +2 -0
  56. package/dist/PieChart/main.js +178 -0
  57. package/dist/PieChartPro/index.d.ts +2 -0
  58. package/dist/PieChartPro/index.js +124 -0
  59. package/dist/PopulationPyramid/index.d.ts +2 -0
  60. package/dist/PopulationPyramid/index.js +132 -0
  61. package/dist/RadarChart/index.d.ts +2 -0
  62. package/dist/RadarChart/index.js +113 -0
  63. package/dist/index.d.ts +8 -0
  64. package/dist/index.js +8 -0
  65. package/dist/utils/index.d.ts +5 -0
  66. package/dist/utils/index.js +22 -0
  67. package/package.json +89 -0
@@ -0,0 +1,214 @@
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, useRef } from 'react';
14
+ import { View, TouchableOpacity, Text, Animated } from 'react-native';
15
+ import Svg, { Defs, Rect } from 'react-native-svg';
16
+ import LinearGradient from '../Components/common/LinearGradient';
17
+ import { useRenderStackBars, BarDefaults, } from '@harveylx/gifted-charts-core';
18
+ import Tooltip from '../Components/BarSpecificComponents/tooltip';
19
+ var RenderStackBars = function (props) {
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;
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
+ var renderLabel = function (label, labelTextStyle) {
24
+ return (_jsx(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
25
+ setSelectedIndex(index);
26
+ if (item.onPress) {
27
+ item.onPress();
28
+ }
29
+ else if (props.onPress) {
30
+ props.onPress(item, index);
31
+ }
32
+ }, onLongPress: function () {
33
+ if (item.onLongPress) {
34
+ item.onLongPress();
35
+ }
36
+ else if (props.onLongPress) {
37
+ props.onLongPress(item, index);
38
+ }
39
+ }, onPressOut: function () {
40
+ if (item.onPressOut) {
41
+ item.onPressOut();
42
+ }
43
+ else if (props.onPressOut) {
44
+ props.onPressOut(item, index);
45
+ }
46
+ }, style: [
47
+ {
48
+ width: (item.labelWidth ||
49
+ props.labelWidth ||
50
+ item.stacks[0].barWidth ||
51
+ props.barWidth ||
52
+ 30) +
53
+ spacing / 2,
54
+ position: 'absolute',
55
+ bottom: !labelsDistanceFromXaxis && autoShiftLabelsForNegativeStacks
56
+ ? containsNegativeValue
57
+ ? -0
58
+ : -6 - xAxisTextNumberOfLines * 18
59
+ : -labelsDistanceFromXaxis - 6 - xAxisTextNumberOfLines * 18,
60
+ },
61
+ rotateLabel
62
+ ? horizontal
63
+ ? { transform: [{ rotate: '330deg' }] }
64
+ : { transform: [{ rotate: '60deg' }] }
65
+ : horizontal
66
+ ? { transform: [{ rotate: '-90deg' }] }
67
+ : {},
68
+ ], children: item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
69
+ };
70
+ var animatedHeight = useRef(new Animated.Value(0)).current;
71
+ var elevate = function () {
72
+ Animated.timing(animatedHeight, {
73
+ toValue: totalHeight,
74
+ duration: animationDuration,
75
+ useNativeDriver: false,
76
+ }).start();
77
+ };
78
+ useEffect(function () {
79
+ if (!noAnimation) {
80
+ elevate();
81
+ }
82
+ }, []);
83
+ var static2DSimple = function () {
84
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
85
+ var remainingBarMarginBottom = barMarginBottom;
86
+ return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
87
+ setSelectedIndex(index);
88
+ if (item.onPress) {
89
+ item.onPress();
90
+ }
91
+ else if (props.onPress) {
92
+ props.onPress(item, index);
93
+ }
94
+ }, onLongPress: function () {
95
+ if (item.onLongPress) {
96
+ item.onLongPress();
97
+ }
98
+ else if (props.onLongPress) {
99
+ props.onLongPress(item, index);
100
+ }
101
+ }, onPressOut: function () {
102
+ if (item.onPressOut) {
103
+ item.onPressOut();
104
+ }
105
+ else if (props.onPressOut) {
106
+ props.onPressOut(item, index);
107
+ }
108
+ }, style: [
109
+ {
110
+ position: 'absolute',
111
+ width: item.stacks[0].barWidth || props.barWidth || 30,
112
+ height: '100%',
113
+ borderTopLeftRadius: (_b = (_a = borderTopLeftRadius !== null && borderTopLeftRadius !== void 0 ? borderTopLeftRadius : borderRadius) !== null && _a !== void 0 ? _a : stackBorderTopLeftRadius) !== null && _b !== void 0 ? _b : stackBorderRadius,
114
+ borderTopRightRadius: (_d = (_c = borderTopRightRadius !== null && borderTopRightRadius !== void 0 ? borderTopRightRadius : borderRadius) !== null && _c !== void 0 ? _c : stackBorderTopRightRadius) !== null && _d !== void 0 ? _d : stackBorderRadius,
115
+ borderBottomLeftRadius: (_f = (_e = borderBottomLeftRadius !== null && borderBottomLeftRadius !== void 0 ? borderBottomLeftRadius : borderRadius) !== null && _e !== void 0 ? _e : stackBorderBottomLeftRadius) !== null && _f !== void 0 ? _f : stackBorderRadius,
116
+ borderBottomRightRadius: (_h = (_g = borderBottomRightRadius !== null && borderBottomRightRadius !== void 0 ? borderBottomRightRadius : borderRadius) !== null && _g !== void 0 ? _g : stackBorderBottomRightRadius) !== null && _h !== void 0 ? _h : stackBorderRadius,
117
+ overflow: lowestBarPosition ? 'visible' : 'hidden',
118
+ // bottom: barMarginBottom
119
+ },
120
+ ], children: [item.stacks.map(function (stackItem, index) {
121
+ var _a;
122
+ var borderRadii = getStackBorderRadii(item, index);
123
+ // compute marginBottom here
124
+ var barHeight = getBarHeight(stackItem.value, 0);
125
+ var marginBottom = Math.max((_a = stackItem.marginBottom) !== null && _a !== void 0 ? _a : 0, remainingBarMarginBottom);
126
+ var deductedMargin = Math.min(barHeight, marginBottom);
127
+ remainingBarMarginBottom = Math.max(0, remainingBarMarginBottom - deductedMargin);
128
+ barHeight -= deductedMargin;
129
+ return (_jsxs(TouchableOpacity, { onPress: function (e) {
130
+ var _a;
131
+ if (stackHighlightEnabled) {
132
+ setSelectedStackIndex(index);
133
+ }
134
+ (_a = stackItem.onPress) === null || _a === void 0 ? void 0 : _a.call(stackItem, e);
135
+ }, activeOpacity: activeOpacity, disabled: disablePress ||
136
+ highlightEnabled ||
137
+ (!stackHighlightEnabled && !stackItem.onPress), style: __assign({ opacity: stackHighlightEnabled
138
+ ? selectedStackIndex === index || selectedStackIndex === -1
139
+ ? 1
140
+ : lowlightOpacity
141
+ : 1, position: 'absolute', bottom: getPosition(index, barHeight) + deductedMargin, 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 ||
142
+ item.showGradient ||
143
+ props.showGradient ? (_jsx(LinearGradient, { style: __assign({ position: 'absolute', width: '100%', height: '100%' }, borderRadii), start: { x: 0, y: 0 }, end: { x: 0, y: 1 }, colors: [
144
+ stackItem.gradientColor ||
145
+ item.gradientColor ||
146
+ props.gradientColor ||
147
+ 'white',
148
+ stackItem.color || item.color || props.color || 'black',
149
+ ] })) : null, stackItem.innerBarComponent && stackItem.innerBarComponent()] }, index));
150
+ }), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
151
+ ? item.barBackgroundPattern()
152
+ : barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "0", y: "0", width: "100%", height: totalHeight, 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: [
153
+ {
154
+ position: 'absolute',
155
+ top: containsNegativeValue
156
+ ? 0
157
+ : (item.barWidth || props.barWidth || 30) * -1,
158
+ height: item.barWidth || props.barWidth || 30,
159
+ width: item.barWidth || props.barWidth || 30,
160
+ justifyContent: 'center',
161
+ alignItems: 'center',
162
+ },
163
+ containsNegativeValue && {
164
+ transform: [{ translateY: totalHeight * 2 }],
165
+ },
166
+ horizontal &&
167
+ !props.intactTopLabel && { transform: [{ rotate: '270deg' }] },
168
+ item.topLabelContainerStyle,
169
+ ], children: showValuesAsTopLabel ? (_jsx(Text, { style: (_j = item.topLabelTextStyle) !== null && _j !== void 0 ? _j : props.topLabelTextStyle, children: stackData[index].stacks.reduce(function (acc, stack) { return acc + stack.value; }, 0) })) : ((_k = item.topLabelComponent) === null || _k === void 0 ? void 0 : _k.call(item)) }))] }));
170
+ };
171
+ var barWrapper = function () {
172
+ return noAnimation ? (static2DSimple()) : (_jsx(Animated.View, { style: {
173
+ position: 'absolute',
174
+ bottom: 0,
175
+ height: animatedHeight,
176
+ width: '100%',
177
+ }, children: static2DSimple() }));
178
+ };
179
+ return (_jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: props.pointerConfig
180
+ ? ((_a = props.pointerConfig.pointerEvents) !== null && _a !== void 0 ? _a : 'none')
181
+ : 'auto', style: [
182
+ {
183
+ // overflow: 'visible',
184
+ opacity: highlightEnabled
185
+ ? highlightedBarIndex === -1
186
+ ? 1
187
+ : highlightedBarIndex === index
188
+ ? 1
189
+ : lowlightOpacity
190
+ : 1,
191
+ marginBottom: 60 + xAxisLabelsVerticalShift,
192
+ width: item.stacks[0].barWidth || props.barWidth || 30,
193
+ height: totalHeight,
194
+ marginRight: spacing,
195
+ transform: [
196
+ {
197
+ translateY: (containerHeight || 200) -
198
+ (totalHeight - 10 + xAxisLabelsVerticalShift),
199
+ },
200
+ ],
201
+ },
202
+ ], children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
203
+ zIndex: 2,
204
+ position: 'absolute',
205
+ height: props.xAxisIndicesHeight,
206
+ width: props.xAxisIndicesWidth,
207
+ bottom: props.xAxisIndicesHeight / -2,
208
+ left: ((item.barWidth || props.barWidth || 30) -
209
+ props.xAxisIndicesWidth) /
210
+ 2,
211
+ backgroundColor: props.xAxisIndicesColor,
212
+ } })), barWrapper(), renderLabel(label || '', labelTextStyle)] }), renderTooltip && selectedIndex === index && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
213
+ };
214
+ export default RenderStackBars;
@@ -0,0 +1,2 @@
1
+ import { BarChartPropsType } from '@harveylx/gifted-charts-core';
2
+ export declare const BarChart: (props: BarChartPropsType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,256 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
25
+ import { Animated, Easing, I18nManager, Pressable, View, } from 'react-native';
26
+ import RenderBars from './RenderBars';
27
+ import RenderStackBars from './RenderStackBars';
28
+ import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
29
+ import { useBarAndLineChartsWrapper, useBarChart, } from '@harveylx/gifted-charts-core';
30
+ import { StripAndLabel } from '../Components/common/StripAndLabel';
31
+ import { Pointer } from '../Components/common/Pointer';
32
+ import { screenWidth } from '../utils';
33
+ import RenderLineInBarChart from '../Components/BarAndLineChartsWrapper/renderLineInBarChart';
34
+ export var BarChart = function (props) {
35
+ var _a, _b, _c;
36
+ var heightValue = useMemo(function () { return new Animated.Value(0); }, []);
37
+ var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
38
+ var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
39
+ var scrollRef = (_a = props.scrollRef) !== null && _a !== void 0 ? _a : useRef(null);
40
+ var remainingScrollViewProps = {
41
+ onScroll: function (ev) { var _a; return (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev); },
42
+ onTouchStart: function (evt) {
43
+ if (props.renderTooltip) {
44
+ setSelectedIndex([-1]);
45
+ }
46
+ },
47
+ bounces: props.bounces,
48
+ overScrollMode: (_b = props.overScrollMode) !== null && _b !== void 0 ? _b : 'auto',
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;
51
+ var _e = useBarAndLineChartsWrapper(__assign(__assign({}, barAndLineChartsWrapperProps), { isRTL: I18nManager.isRTL })), lineInBarChartProps = _e.lineInBarChartProps, lineInBarChartProps2 = _e.lineInBarChartProps2;
52
+ var stackData = barAndLineChartsWrapperProps.stackData;
53
+ var labelsAppear = useCallback(function () {
54
+ opacityValue.setValue(0);
55
+ Animated.timing(opacityValue, {
56
+ toValue: 1,
57
+ duration: 500,
58
+ easing: Easing.ease,
59
+ useNativeDriver: false,
60
+ }).start();
61
+ }, [opacityValue]);
62
+ var decreaseWidth = useCallback(function () {
63
+ widthValue.setValue(0);
64
+ Animated.timing(widthValue, {
65
+ toValue: 1,
66
+ duration: lineConfig.animationDuration,
67
+ easing: Easing.linear,
68
+ useNativeDriver: false,
69
+ }).start();
70
+ }, [lineConfig.animationDuration, widthValue]);
71
+ useEffect(function () {
72
+ if (lineConfig.isAnimated) {
73
+ setTimeout(function () { return decreaseWidth(); }, lineConfig.delay || 0);
74
+ }
75
+ setTimeout(function () { return labelsAppear(); }, animationDuration);
76
+ }, [decreaseWidth, labelsAppear, animationDuration]);
77
+ var renderPointer = function (lineNumber) {
78
+ if (lineNumber === 1 && hidePointer1)
79
+ return;
80
+ var pointerItemLocal = pointerItem;
81
+ var pointerYLocal = pointerY;
82
+ var pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer1Color) || pointerColor;
83
+ return Pointer({
84
+ pointerX: pointerX,
85
+ pointerYLocal: pointerYLocal,
86
+ pointerComponent: pointerComponent,
87
+ pointerHeight: pointerHeight,
88
+ pointerRadius: pointerRadius,
89
+ pointerWidth: pointerWidth,
90
+ pointerItemLocal: pointerItemLocal,
91
+ pointerColorLocal: pointerColorLocal,
92
+ });
93
+ };
94
+ var renderStripAndLabel = function (pointerLabelComponent) {
95
+ var pointerItemLocal, pointerYLocal = pointerY;
96
+ pointerItemLocal = [pointerItem];
97
+ return StripAndLabel({
98
+ autoAdjustPointerLabelPosition: autoAdjustPointerLabelPosition,
99
+ pointerX: pointerX,
100
+ pointerLabelWidth: pointerLabelWidth,
101
+ activatePointersOnLongPress: activatePointersOnLongPress,
102
+ yAxisLabelWidth: yAxisLabelWidth,
103
+ pointerRadius: pointerRadius,
104
+ pointerWidth: pointerWidth,
105
+ shiftPointerLabelX: shiftPointerLabelX,
106
+ pointerLabelHeight: pointerLabelHeight,
107
+ pointerYLocal: pointerYLocal,
108
+ pointerStripUptoDataPoint: pointerStripUptoDataPoint,
109
+ pointerStripHeight: pointerStripHeight,
110
+ shiftPointerLabelY: shiftPointerLabelY,
111
+ pointerItemLocal: pointerItemLocal,
112
+ showPointerStrip: showPointerStrip,
113
+ pointerStripWidth: pointerStripWidth,
114
+ containerHeight: containerHeight,
115
+ xAxisThickness: xAxisThickness,
116
+ pointerStripColor: pointerStripColor,
117
+ pointerConfig: pointerConfig,
118
+ pointerLabelComponent: pointerLabelComponent,
119
+ scrollX: 0,
120
+ pointerEvents: pointerEvents,
121
+ isBarChart: true,
122
+ pointerIndex: pointerIndex,
123
+ width: totalWidth,
124
+ screenWidth: screenWidth,
125
+ containsNegative: false,
126
+ });
127
+ };
128
+ var contentContainerStyle = {
129
+ position: 'absolute',
130
+ height: containerHeightIncludingBelowXAxis,
131
+ bottom: 60 + labelsExtraHeight,
132
+ paddingLeft: initialSpacing,
133
+ width: totalWidth,
134
+ flexDirection: 'row',
135
+ };
136
+ var activatePointer = function (x) {
137
+ var _a;
138
+ var chartData = stackData !== null && stackData !== void 0 ? stackData : data;
139
+ var factor = (x - initialSpacing - barWidth / 2) / (spacing + barWidth);
140
+ factor = Math.round(factor);
141
+ factor = Math.min(factor, chartData.length - 1);
142
+ factor = Math.max(factor, 0);
143
+ var z = initialSpacing +
144
+ (spacing + barWidth) * factor -
145
+ (pointerRadius || pointerWidth / 2) +
146
+ barWidth / 2;
147
+ setPointerX(z);
148
+ setPointerIndex(factor);
149
+ var item, y;
150
+ item = chartData[factor];
151
+ var stackSum = 0;
152
+ if ('stacks' in item) {
153
+ stackSum = item.stacks.reduce(function (acc, stack) { var _a; return acc + ((_a = stack.value) !== null && _a !== void 0 ? _a : 0); }, 0);
154
+ }
155
+ y =
156
+ containerHeight -
157
+ ((stackSum !== null && stackSum !== void 0 ? stackSum : item.value) * containerHeight) / maxValue -
158
+ (pointerRadius || pointerHeight / 2) +
159
+ 10;
160
+ setPointerY(y);
161
+ setPointerItem(item);
162
+ (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderGrant) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
163
+ };
164
+ var renderChartContent = function () {
165
+ if (pointerConfig) {
166
+ return (_jsxs(View, { onPointerEnter: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerEnter) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onPointerLeave: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerLeave) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchStart: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchStart) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchEnd: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onStartShouldSetResponder: function () { return !!pointerConfig; }, onMoveShouldSetResponder: function () { return !!pointerConfig; }, onResponderGrant: function (evt) {
167
+ setResponderStartTime(evt.timeStamp);
168
+ if (activatePointersOnLongPress ||
169
+ !(pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersInstantlyOnTouch)) {
170
+ return;
171
+ }
172
+ var x = evt.nativeEvent.locationX;
173
+ if (!activatePointersOnLongPress &&
174
+ x > (props.width || screenWidth))
175
+ return;
176
+ setResponderActive(true);
177
+ activatePointer(x);
178
+ }, onResponderMove: function (evt) {
179
+ if (activatePointersOnLongPress &&
180
+ evt.timeStamp - responderStartTime < activatePointersDelay) {
181
+ return;
182
+ }
183
+ else {
184
+ setResponderActive(true);
185
+ }
186
+ var x = evt.nativeEvent.locationX;
187
+ if (!activatePointersOnLongPress &&
188
+ x > (props.width || screenWidth))
189
+ return;
190
+ activatePointer(x);
191
+ }, onResponderEnd: function (evt) {
192
+ var _a;
193
+ setResponderStartTime(0);
194
+ setPointerIndex(-1);
195
+ setResponderActive(false);
196
+ if (!persistPointer)
197
+ setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
198
+ (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
199
+ }, onResponderTerminationRequest: function (evt) { return false; }, style: contentContainerStyle, children: [pointerX > 0 && stripBehindBars ? (_jsx(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: {
200
+ position: 'absolute',
201
+ height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
202
+ bottom: xAxisLabelsVerticalShift,
203
+ width: totalWidth,
204
+ }, children: renderStripAndLabel(null) })) : null, renderChart(),
205
+ // Only For Bar Charts-
206
+ showLine ? _jsx(RenderLineInBarChart, __assign({}, lineInBarChartProps)) : null,
207
+ // Only For Bar Charts-
208
+ showLine && (points2 === null || points2 === void 0 ? void 0 : points2.length) ? (_jsx(RenderLineInBarChart, __assign({}, lineInBarChartProps2))) : null, pointerX > 0 ? (_jsxs(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: {
209
+ position: 'absolute',
210
+ height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
211
+ bottom: xAxisLabelsVerticalShift,
212
+ width: totalWidth,
213
+ zIndex: 200000,
214
+ }, children: [!stripOverPointer &&
215
+ !stripBehindBars &&
216
+ renderStripAndLabel(null), renderPointer(1), stripOverPointer &&
217
+ !stripBehindBars &&
218
+ renderStripAndLabel(null), pointerLabelComponent &&
219
+ renderStripAndLabel(pointerLabelComponent) // no matter what, pointerLabelComponent will be rendered at last -> over the chart content
220
+ ] })) : null] }));
221
+ }
222
+ else {
223
+ return (_jsxs(Pressable, { style: contentContainerStyle, onPress: function () {
224
+ var _a, _b;
225
+ if (props.highlightEnabled && !((_a = selectedIndex.includes) === null || _a === void 0 ? void 0 : _a.call(selectedIndex, -1)))
226
+ setSelectedIndex([-1]);
227
+ if (props.stackHighlightEnabled && selectedStackIndex !== -1) {
228
+ setSelectedStackIndex(-1);
229
+ // props.setHighlightedStackIndex?.(-1)
230
+ }
231
+ (_b = props.onBackgroundPress) === null || _b === void 0 ? void 0 : _b.call(props);
232
+ }, children: [renderChart(),
233
+ // Only For Bar Charts-
234
+ showLine ? _jsx(RenderLineInBarChart, __assign({}, lineInBarChartProps)) : null,
235
+ // Only For Bar Charts-
236
+ showLine && (points2 === null || points2 === void 0 ? void 0 : points2.length) ? (_jsx(RenderLineInBarChart, __assign({}, lineInBarChartProps2))) : null] }));
237
+ }
238
+ };
239
+ var renderChart = function () {
240
+ if (stackData) {
241
+ return stackData.map(function (item, index) {
242
+ var _a = getPropsCommonForBarAndStack(item, index), selectedIndex = _a.selectedIndex, stackRestProps = __rest(_a, ["selectedIndex"]);
243
+ return (_jsx(RenderStackBars, __assign({ stackData: props.stackData || [], isAnimated: isAnimated, animationDuration: animationDuration, stackBorderRadius: props.stackBorderRadius, stackBorderTopLeftRadius: props.stackBorderTopLeftRadius, stackBorderTopRightRadius: props.stackBorderTopRightRadius, stackBorderBottomLeftRadius: props.stackBorderBottomLeftRadius, stackBorderBottomRightRadius: props.stackBorderBottomRightRadius, autoShiftLabelsForNegativeStacks: autoShiftLabelsForNegativeStacks, selectedStackIndex: selectedStackIndex, setSelectedStackIndex: setSelectedStackIndex,
244
+ // highlightedStackIndex={props.highlightedStackIndex??-1}
245
+ selectedIndex: selectedIndex[0] }, stackRestProps), index));
246
+ });
247
+ }
248
+ else {
249
+ return data.map(function (item, index) {
250
+ var _a;
251
+ return (_jsx(RenderBars, __assign({ data: data, side: side, minHeight: (_a = props.minHeight) !== null && _a !== void 0 ? _a : (isAnimated && !isThreeD ? 0.1 : 0), sideWidth: props.sideWidth, labelWidth: labelWidth, isThreeD: isThreeD, isAnimated: isAnimated, animationDuration: animationDuration, animatedHeight: animatedHeight, appearingOpacity: appearingOpacity, roundedTop: props.roundedTop, roundedBottom: props.roundedBottom, frontColor: props.frontColor, sideColor: props.sideColor, topColor: props.topColor, cappedBars: props.cappedBars, capThickness: props.capThickness, capColor: props.capColor, capRadius: props.capRadius, autoShiftLabels: autoShiftLabels, barStyle: props.barStyle }, getPropsCommonForBarAndStack(item, index)), index));
252
+ });
253
+ }
254
+ };
255
+ return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled, onScrollEndDrag: props.onScrollEndDrag })));
256
+ };
@@ -0,0 +1,45 @@
1
+ export declare const styles: {
2
+ container: {
3
+ width: "100%";
4
+ marginBottom: number;
5
+ marginRight: number;
6
+ };
7
+ horizBar: {
8
+ flexDirection: "row";
9
+ };
10
+ leftLabel: {
11
+ justifyContent: "center";
12
+ alignItems: "center";
13
+ };
14
+ lastLeftLabel: {
15
+ justifyContent: "center";
16
+ alignItems: "center";
17
+ };
18
+ leftPart: {
19
+ justifyContent: "center";
20
+ width: "100%";
21
+ };
22
+ lastLeftPart: {
23
+ justifyContent: "flex-end";
24
+ width: "100%";
25
+ };
26
+ line: {
27
+ width: "100%";
28
+ height: number;
29
+ backgroundColor: string;
30
+ opacity: number;
31
+ };
32
+ lastLine: {
33
+ width: "100%";
34
+ height: number;
35
+ backgroundColor: string;
36
+ };
37
+ bottomLabel: {
38
+ width: "100%";
39
+ };
40
+ customDataPointContainer: {
41
+ position: "absolute";
42
+ justifyContent: "center";
43
+ alignItems: "center";
44
+ };
45
+ };
@@ -0,0 +1,46 @@
1
+ import { StyleSheet } from 'react-native';
2
+ export var styles = StyleSheet.create({
3
+ container: {
4
+ width: '100%',
5
+ marginBottom: 40,
6
+ marginRight: 40,
7
+ },
8
+ horizBar: {
9
+ flexDirection: 'row',
10
+ },
11
+ leftLabel: {
12
+ justifyContent: 'center',
13
+ alignItems: 'center',
14
+ },
15
+ lastLeftLabel: {
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ },
19
+ leftPart: {
20
+ justifyContent: 'center',
21
+ width: '100%',
22
+ },
23
+ lastLeftPart: {
24
+ justifyContent: 'flex-end',
25
+ width: '100%',
26
+ },
27
+ line: {
28
+ width: '100%',
29
+ height: 1,
30
+ backgroundColor: 'gray',
31
+ opacity: 0.5,
32
+ },
33
+ lastLine: {
34
+ width: '100%',
35
+ height: 1,
36
+ backgroundColor: 'black',
37
+ },
38
+ bottomLabel: {
39
+ width: '100%',
40
+ },
41
+ customDataPointContainer: {
42
+ position: 'absolute',
43
+ justifyContent: 'center',
44
+ alignItems: 'center',
45
+ },
46
+ });
@@ -0,0 +1,3 @@
1
+ import { animatedBarPropTypes } from '@harveylx/gifted-charts-core';
2
+ declare const AnimatedThreeDBar: (props: animatedBarPropTypes) => import("react/jsx-runtime").JSX.Element;
3
+ export default AnimatedThreeDBar;