react-native-gifted-charts 1.4.60 → 1.4.61
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.
|
@@ -15,11 +15,16 @@ import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
|
|
|
15
15
|
import Animated2DWithGradient from './Animated2DWithGradient';
|
|
16
16
|
import { getPropsForAnimated2DWithGradient, useRenderBars, } from 'gifted-charts-core';
|
|
17
17
|
import Tooltip from '../Components/BarSpecificComponents/tooltip';
|
|
18
|
+
var isIndexSelected = function (values, idx) {
|
|
19
|
+
if (Array.isArray(values))
|
|
20
|
+
return values.includes(idx);
|
|
21
|
+
return values === idx;
|
|
22
|
+
};
|
|
18
23
|
var RenderBars = function (props) {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, 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, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, horizontal = props.horizontal, rtl = props.rtl, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, barWidth = props.barWidth,
|
|
21
|
-
var
|
|
22
|
-
var
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, 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, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, horizontal = props.horizontal, rtl = props.rtl, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, barWidth = props.barWidth, _d = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _d === void 0 ? 0 : _d, secondaryXAxis = props.secondaryXAxis, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis, _e = props.barMarginBottom, barMarginBottom = _e === void 0 ? 0 : _e, highlightEnabled = props.highlightEnabled, highlightedBarIndex = props.highlightedBarIndex, lowlightOpacity = props.lowlightOpacity;
|
|
26
|
+
var _f = useRenderBars(props), heightFactor = _f.heightFactor, barHeight = _f.barHeight, tooltipProps = _f.tooltipProps;
|
|
27
|
+
var _g = getPropsForAnimated2DWithGradient(__assign(__assign({}, props), { barHeight: barHeight })), commonStyleForBar = _g.commonStyleForBar, barStyleWithBackground = _g.barStyleWithBackground, commonPropsFor2dAnd3dBars = _g.commonPropsFor2dAnd3dBars, isFocused = _g.isFocused, focusedBarConfig = _g.focusedBarConfig, localFrontColor = _g.localFrontColor;
|
|
23
28
|
var itemOrPropsBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
|
|
24
29
|
var localBarInnerComponent = isFocused
|
|
25
30
|
? ((_b = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.barInnerComponent) !== null && _b !== void 0 ? _b : itemOrPropsBarInnerComponent)
|
|
@@ -140,10 +145,10 @@ var RenderBars = function (props) {
|
|
|
140
145
|
var barWrapperStyle = [
|
|
141
146
|
{
|
|
142
147
|
// overflow: 'visible',
|
|
143
|
-
opacity: highlightEnabled
|
|
144
|
-
|
|
145
|
-
? 1
|
|
146
|
-
|
|
148
|
+
opacity: highlightEnabled ?
|
|
149
|
+
isIndexSelected(highlightedBarIndex, -1)
|
|
150
|
+
? 1 :
|
|
151
|
+
isIndexSelected(highlightedBarIndex, index)
|
|
147
152
|
? 1
|
|
148
153
|
: lowlightOpacity
|
|
149
154
|
: 1,
|
|
@@ -190,7 +195,7 @@ var RenderBars = function (props) {
|
|
|
190
195
|
return (_jsxs(_Fragment, { children: [pressDisabled ? (_jsx(View, { pointerEvents: "none", style: barWrapperStyle, children: barContent() })) : (_jsx(TouchableOpacity, { activeOpacity: props.activeOpacity || 0.2, onPress: function () {
|
|
191
196
|
if (renderTooltip || props.focusBarOnPress || highlightEnabled) {
|
|
192
197
|
if (props.focusedBarIndex === undefined || !props.onPress) {
|
|
193
|
-
setSelectedIndex(index);
|
|
198
|
+
setSelectedIndex([index]);
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
item.onPress
|
|
@@ -210,6 +215,6 @@ var RenderBars = function (props) {
|
|
|
210
215
|
: props.onPressOut
|
|
211
216
|
? props.onPressOut(item, index)
|
|
212
217
|
: null;
|
|
213
|
-
}, style: barWrapperStyle, children: barContent() })), renderTooltip && selectedIndex === index && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
|
|
218
|
+
}, style: barWrapperStyle, children: barContent() })), renderTooltip && ((_c = selectedIndex.includes) === null || _c === void 0 ? void 0 : _c.call(selectedIndex, index)) && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
|
|
214
219
|
};
|
|
215
220
|
export default RenderBars;
|
package/dist/BarChart/index.js
CHANGED
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
24
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
14
25
|
import { Animated, Easing, Pressable, View } from 'react-native';
|
|
@@ -29,7 +40,7 @@ export var BarChart = function (props) {
|
|
|
29
40
|
onScroll: function (ev) { var _a; return (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev); },
|
|
30
41
|
onTouchStart: function (evt) {
|
|
31
42
|
if (props.renderTooltip) {
|
|
32
|
-
setSelectedIndex(-1);
|
|
43
|
+
setSelectedIndex([-1]);
|
|
33
44
|
}
|
|
34
45
|
},
|
|
35
46
|
bounces: props.bounces,
|
|
@@ -203,21 +214,24 @@ export var BarChart = function (props) {
|
|
|
203
214
|
}
|
|
204
215
|
else {
|
|
205
216
|
return (_jsx(Pressable, { style: contentContainerStyle, onPress: function () {
|
|
206
|
-
var _a;
|
|
207
|
-
if (props.highlightEnabled && selectedIndex
|
|
208
|
-
setSelectedIndex(-1);
|
|
217
|
+
var _a, _b;
|
|
218
|
+
if (props.highlightEnabled && !((_a = selectedIndex.includes) === null || _a === void 0 ? void 0 : _a.call(selectedIndex, -1)))
|
|
219
|
+
setSelectedIndex([-1]);
|
|
209
220
|
if (props.stackHighlightEnabled && selectedStackIndex !== -1) {
|
|
210
221
|
setSelectedStackIndex(-1);
|
|
211
222
|
// props.setHighlightedStackIndex?.(-1)
|
|
212
223
|
}
|
|
213
|
-
(
|
|
224
|
+
(_b = props.onBackgroundPress) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
214
225
|
}, children: renderChart() }));
|
|
215
226
|
}
|
|
216
227
|
};
|
|
217
228
|
var renderChart = function () {
|
|
218
229
|
if (stackData) {
|
|
219
230
|
return stackData.map(function (item, index) {
|
|
220
|
-
|
|
231
|
+
var _a = getPropsCommonForBarAndStack(item, index), selectedIndex = _a.selectedIndex, stackRestProps = __rest(_a, ["selectedIndex"]);
|
|
232
|
+
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,
|
|
233
|
+
// highlightedStackIndex={props.highlightedStackIndex??-1}
|
|
234
|
+
selectedIndex: selectedIndex[0] }, stackRestProps), index));
|
|
221
235
|
});
|
|
222
236
|
}
|
|
223
237
|
else {
|
|
@@ -5,11 +5,11 @@ import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
|
|
|
5
5
|
import { renderDataPoints } from './renderDataPoints';
|
|
6
6
|
import { renderSpecificDataPoints } from './renderSpecificDataPoints';
|
|
7
7
|
var RenderLineInBarChart = function (props) {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b;
|
|
9
9
|
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;
|
|
10
10
|
var firstBarWidth = (_a = data[0].barWidth) !== null && _a !== void 0 ? _a : barWidth;
|
|
11
11
|
var opacity = highlightEnabled
|
|
12
|
-
? selectedIndex === -1
|
|
12
|
+
? ((_b = selectedIndex.includes) === null || _b === void 0 ? void 0 : _b.call(selectedIndex, -1))
|
|
13
13
|
? 1
|
|
14
14
|
: lowlightOpacity
|
|
15
15
|
: 1;
|
|
@@ -22,7 +22,7 @@ var RenderLineInBarChart = function (props) {
|
|
|
22
22
|
firstBarWidth: firstBarWidth,
|
|
23
23
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
24
24
|
spacing: spacing,
|
|
25
|
-
selectedIndex: selectedIndex,
|
|
25
|
+
selectedIndex: selectedIndex[0],
|
|
26
26
|
yAxisOffset: yAxisOffset,
|
|
27
27
|
opacity: opacity,
|
|
28
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.61",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar, Population Pyramid and Radar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"registry": "https://registry.npmjs.org/"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"gifted-charts-core": "0.1.
|
|
29
|
+
"gifted-charts-core": "0.1.63"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/cli": "^7.24.8",
|