react-native-gifted-charts 1.4.72 → 1.4.74
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 +2 -2
- package/dist/BubbleChart/index.js +107 -57
- package/dist/Components/BarAndLineChartsWrapper/index.js +8 -6
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -104,10 +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 = {
|
|
107
|
+
<BubbleChart data = {[
|
|
108
108
|
{x: 20, y: 4, r: 10},
|
|
109
109
|
{x: 40, y: 6, r: 20},
|
|
110
|
-
} />
|
|
110
|
+
]} />
|
|
111
111
|
|
|
112
112
|
// For Horizontal Bar chart, just add the prop horizontal to the <BarChart/> component
|
|
113
113
|
|
|
@@ -9,22 +9,38 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
12
28
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { BubbleDefaults, useBubbleChart, } from 'gifted-charts-core';
|
|
29
|
+
import { BubbleDefaults, useBubbleChart, withinMinMaxRange, } from 'gifted-charts-core';
|
|
14
30
|
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
15
|
-
import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
31
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
16
32
|
import { Animated, Easing, I18nManager, Text, View, } from 'react-native';
|
|
17
|
-
import { Circle, ForeignObject, Rect, Svg, Line } from 'react-native-svg';
|
|
18
|
-
import { isWebApp, screenWidth } from '../utils';
|
|
33
|
+
import { Circle, ForeignObject, Rect, Svg, Line, RadialGradient, Stop, Defs, } from 'react-native-svg';
|
|
34
|
+
import { isAndroid, isWebApp, screenWidth } from '../utils';
|
|
19
35
|
var AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
20
36
|
var AnimatedRect = Animated.createAnimatedComponent(Rect);
|
|
21
37
|
var AnimatedLine = Animated.createAnimatedComponent(Line);
|
|
22
38
|
export var BubbleChart = function (props) {
|
|
23
|
-
var _a, _b, _c, _d
|
|
39
|
+
var _a, _b, _c, _d;
|
|
24
40
|
var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
25
41
|
var pointsOpacityValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
26
|
-
var secondaryXAxis = props.secondaryXAxis;
|
|
27
|
-
var
|
|
42
|
+
var secondaryXAxis = props.secondaryXAxis, xAxisLabelTextStyle = props.xAxisLabelTextStyle, formatBubbleLabel = props.formatBubbleLabel;
|
|
43
|
+
var _e = useBubbleChart(__assign(__assign({}, props), { parentWidth: (_a = props.parentWidth) !== null && _a !== void 0 ? _a : screenWidth })), data = _e.data, 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, showBubbleOnFocus = _e.showBubbleOnFocus, showBubbleLabelOnFocus = _e.showBubbleLabelOnFocus, bubblesShape = _e.bubblesShape, bubblesWidth = _e.bubblesWidth, bubblesHeight = _e.bubblesHeight, bubblesColor = _e.bubblesColor, bubblesRadius = _e.bubblesRadius, labelFontSize = _e.labelFontSize, labelTextStyle = _e.labelTextStyle, startIndex = _e.startIndex, endIndex = _e.endIndex, showValuesAsBubbleLabels = _e.showValuesAsBubbleLabels, hideBubbles = _e.hideBubbles, 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, borderOpacity = _e.borderOpacity, xAxisLabelTexts = _e.xAxisLabelTexts, showRegressionLine = _e.showRegressionLine, regressionLineX1 = _e.regressionLineX1, regressionLineY1 = _e.regressionLineY1, regressionLineX2 = _e.regressionLineX2, regressionLineY2 = _e.regressionLineY2, regressionLineConfig = _e.regressionLineConfig, scatterChart = _e.scatterChart, maxRadius = _e.maxRadius, minRadius = _e.minRadius, extraWidthDueToBubble = _e.extraWidthDueToBubble, showGradient = _e.showGradient, centerColorForGradient = _e.centerColorForGradient;
|
|
28
44
|
var progress = useRef(new Animated.Value(0)).current;
|
|
29
45
|
var AnimatedRegressionLineX = useRef(new Animated.Value(0)).current;
|
|
30
46
|
var AnimatedRegressionLineY = useRef(new Animated.Value(0)).current;
|
|
@@ -39,33 +55,43 @@ export var BubbleChart = function (props) {
|
|
|
39
55
|
// outputRange:[regressionLineX1,regressionLineX2]
|
|
40
56
|
// })
|
|
41
57
|
var growingRadii = useMemo(function () {
|
|
42
|
-
|
|
43
|
-
return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (item) {
|
|
58
|
+
return (data !== null && data !== void 0 ? data : []).map(function (item) {
|
|
44
59
|
var _a;
|
|
45
60
|
return progress.interpolate({
|
|
46
61
|
inputRange: [0, 1],
|
|
47
|
-
outputRange: [
|
|
62
|
+
outputRange: [
|
|
63
|
+
0,
|
|
64
|
+
withinMinMaxRange((_a = item.r) !== null && _a !== void 0 ? _a : bubblesRadius, maxRadius, minRadius),
|
|
65
|
+
],
|
|
48
66
|
});
|
|
49
67
|
});
|
|
50
|
-
}, [
|
|
51
|
-
var growingHeight = (
|
|
52
|
-
var _a
|
|
68
|
+
}, [data, progress]);
|
|
69
|
+
var growingHeight = (data !== null && data !== void 0 ? data : []).map(function (_, i) {
|
|
70
|
+
var _a;
|
|
53
71
|
return progress.interpolate({
|
|
54
72
|
inputRange: [0, 1],
|
|
55
|
-
outputRange: [0, (
|
|
73
|
+
outputRange: [0, (_a = data === null || data === void 0 ? void 0 : data[i].bubbleHeight) !== null && _a !== void 0 ? _a : bubblesHeight],
|
|
56
74
|
});
|
|
57
75
|
});
|
|
58
|
-
var growingWidth = (
|
|
59
|
-
var _a
|
|
76
|
+
var growingWidth = (data !== null && data !== void 0 ? data : []).map(function (_, i) {
|
|
77
|
+
var _a;
|
|
60
78
|
return progress.interpolate({
|
|
61
79
|
inputRange: [0, 1],
|
|
62
|
-
outputRange: [0, (
|
|
80
|
+
outputRange: [0, (_a = data === null || data === void 0 ? void 0 : data[i].bubbleWidth) !== null && _a !== void 0 ? _a : bubblesWidth],
|
|
63
81
|
});
|
|
64
82
|
});
|
|
65
83
|
var appearingDataPoints = pointsOpacityValue.interpolate({
|
|
66
84
|
inputRange: [0, 1],
|
|
67
85
|
outputRange: [0, opacity],
|
|
68
86
|
});
|
|
87
|
+
var appearingDataPointsAndroid = pointsOpacityValue.interpolate({
|
|
88
|
+
inputRange: [0, 1],
|
|
89
|
+
outputRange: [0, opacity / 2], // hack to show slightly transparent bubbles while animating, as gradient on Android can't be animated
|
|
90
|
+
});
|
|
91
|
+
var appearingBorder = pointsOpacityValue.interpolate({
|
|
92
|
+
inputRange: [0, 1],
|
|
93
|
+
outputRange: [0, borderOpacity],
|
|
94
|
+
});
|
|
69
95
|
var drawRegressionLine = useCallback(function () {
|
|
70
96
|
if (!regressionLineConfig.isAnimated)
|
|
71
97
|
return;
|
|
@@ -135,6 +161,7 @@ export var BubbleChart = function (props) {
|
|
|
135
161
|
useNativeDriver: false,
|
|
136
162
|
}).start();
|
|
137
163
|
}, [pointsOpacityValue]);
|
|
164
|
+
var _g = __read(useState(false), 2), isAnimationOver = _g[0], setIsAnimationOver = _g[1];
|
|
138
165
|
useEffect(function () {
|
|
139
166
|
if (isAnimated) {
|
|
140
167
|
decreaseWidth();
|
|
@@ -146,12 +173,17 @@ export var BubbleChart = function (props) {
|
|
|
146
173
|
else {
|
|
147
174
|
radiiGrow();
|
|
148
175
|
}
|
|
176
|
+
if (isAndroid) {
|
|
177
|
+
setTimeout(function () {
|
|
178
|
+
setIsAnimationOver(true);
|
|
179
|
+
}, animationDuration + 20);
|
|
180
|
+
}
|
|
149
181
|
}
|
|
150
182
|
if (regressionLineConfig.isAnimated) {
|
|
151
183
|
drawRegressionLine();
|
|
152
184
|
}
|
|
153
185
|
}, [isAnimated, bubblesShape]);
|
|
154
|
-
var svgHeight = containerHeightIncludingBelowXAxis + ((
|
|
186
|
+
var svgHeight = containerHeightIncludingBelowXAxis + ((_c = props.overflowBottom) !== null && _c !== void 0 ? _c : 0);
|
|
155
187
|
// const onStripPress = (item: any, index: number) => {
|
|
156
188
|
// if (props.focusedBubbleIndex === undefined || !props.onFocus) {
|
|
157
189
|
// setSelectedIndex(index);
|
|
@@ -162,6 +194,9 @@ export var BubbleChart = function (props) {
|
|
|
162
194
|
// };
|
|
163
195
|
var renderLabel = function (top, index, label) {
|
|
164
196
|
var _a, _b;
|
|
197
|
+
var left = index
|
|
198
|
+
? initialSpacing + spacing * index - spacing / 2
|
|
199
|
+
: initialSpacing / 2;
|
|
165
200
|
return (_jsx(View, { style: [
|
|
166
201
|
{
|
|
167
202
|
position: 'absolute',
|
|
@@ -172,14 +207,17 @@ export var BubbleChart = function (props) {
|
|
|
172
207
|
: -xAxisTextNumberOfLines * 18 - (containerHeight - 200) / 20,
|
|
173
208
|
zIndex: 10,
|
|
174
209
|
width: spacing + labelsExtraHeight,
|
|
175
|
-
left:
|
|
210
|
+
left: left,
|
|
176
211
|
height: (_b = props.xAxisLabelsHeight) !== null && _b !== void 0 ? _b : xAxisTextNumberOfLines * 18,
|
|
177
212
|
},
|
|
178
213
|
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
179
|
-
], children: _jsx(Text, { style: { textAlign: 'center' }, allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label }) }));
|
|
214
|
+
], children: _jsx(Text, { style: [{ textAlign: index ? 'center' : 'left' }, xAxisLabelTextStyle], allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label }) }));
|
|
180
215
|
};
|
|
181
216
|
var renderAnimatedLabel = function (top, index, label) {
|
|
182
217
|
var _a, _b;
|
|
218
|
+
var left = index
|
|
219
|
+
? initialSpacing + spacing * index - spacing / 2
|
|
220
|
+
: initialSpacing / 2;
|
|
183
221
|
return (_jsx(Animated.View, { style: [
|
|
184
222
|
{
|
|
185
223
|
height: rotateLabel
|
|
@@ -194,22 +232,17 @@ export var BubbleChart = function (props) {
|
|
|
194
232
|
? 10
|
|
195
233
|
: -xAxisTextNumberOfLines * 18,
|
|
196
234
|
zIndex: 10,
|
|
197
|
-
width: spacing,
|
|
198
|
-
left:
|
|
235
|
+
width: spacing + labelsExtraHeight,
|
|
236
|
+
left: left,
|
|
199
237
|
opacity: appearingOpacity,
|
|
200
238
|
},
|
|
201
239
|
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
202
|
-
], children: _jsx(Text, { allowFontScaling: allowFontScaling, style: { textAlign: 'center' }, numberOfLines: xAxisTextNumberOfLines, children: label }) }));
|
|
240
|
+
], children: _jsx(Text, { allowFontScaling: allowFontScaling, style: [{ textAlign: index ? 'center' : 'left' }, xAxisLabelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label }) }));
|
|
203
241
|
};
|
|
204
|
-
var
|
|
205
|
-
// textColor: any,
|
|
206
|
-
// textFontSize: any,
|
|
207
|
-
// textFontFamily: any,
|
|
208
|
-
// textFontWeight: any,
|
|
209
|
-
startIndex, endIndex, isSecondary, showValuesAsDataPointsText, key) {
|
|
242
|
+
var renderBubbles = function (hideBubbles, dataForRender, originalDataFromProps, bubsShape, bubsWidth, bubsHeight, bubsColor, bubsRadius, labelFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, key) {
|
|
210
243
|
var getYOrSecondaryY = getY; //isSecondary ? getSecondaryY : getY;
|
|
211
244
|
return dataForRender.map(function (item, index) {
|
|
212
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
245
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
213
246
|
if (index < startIndex || index > endIndex)
|
|
214
247
|
return null;
|
|
215
248
|
if (item.hideBubble) {
|
|
@@ -237,8 +270,7 @@ export var BubbleChart = function (props) {
|
|
|
237
270
|
item.focusedBubbleColor ||
|
|
238
271
|
props.focusedBubbleColor ||
|
|
239
272
|
BubbleDefaults.focusedBubbleColor;
|
|
240
|
-
bubblesRadius =
|
|
241
|
-
(_c = (_b = (_a = item.focusedBubbleRadius) !== null && _a !== void 0 ? _a : props.focusedBubbleRadius) !== null && _b !== void 0 ? _b : item.r) !== null && _c !== void 0 ? _c : bubsRadius;
|
|
273
|
+
bubblesRadius = withinMinMaxRange((_c = (_b = (_a = item.focusedBubbleRadius) !== null && _a !== void 0 ? _a : props.focusedBubbleRadius) !== null && _b !== void 0 ? _b : item.r) !== null && _c !== void 0 ? _c : bubsRadius, maxRadius, minRadius);
|
|
242
274
|
if (showTextOnFocus) {
|
|
243
275
|
text = item.label;
|
|
244
276
|
}
|
|
@@ -258,7 +290,7 @@ export var BubbleChart = function (props) {
|
|
|
258
290
|
bubblesWidth = item.bubbleWidth || bubsWidth;
|
|
259
291
|
bubblesHeight = item.bubbleHeight || bubsHeight;
|
|
260
292
|
dataPointsColor = item.bubbleColor || bubsColor;
|
|
261
|
-
bubblesRadius = (_d = item.r) !== null && _d !== void 0 ? _d : bubsRadius;
|
|
293
|
+
bubblesRadius = withinMinMaxRange((_d = item.r) !== null && _d !== void 0 ? _d : bubsRadius, maxRadius, minRadius);
|
|
262
294
|
if (showTextOnFocus) {
|
|
263
295
|
text = '';
|
|
264
296
|
}
|
|
@@ -276,9 +308,15 @@ export var BubbleChart = function (props) {
|
|
|
276
308
|
var textLabel = !showTextOnFocus && !showValuesAsDataPointsText
|
|
277
309
|
? item.label
|
|
278
310
|
: text.toString();
|
|
279
|
-
var
|
|
311
|
+
var formattedTextLabel = textLabel
|
|
312
|
+
? ((_e = formatBubbleLabel === null || formatBubbleLabel === void 0 ? void 0 : formatBubbleLabel(textLabel)) !== null && _e !== void 0 ? _e : textLabel)
|
|
313
|
+
: '';
|
|
314
|
+
var textStyle = ((_g = (_f = item.labelTextStyle) !== null && _f !== void 0 ? _f : labelTextStyle) !== null && _g !== void 0 ? _g : {});
|
|
280
315
|
var fontSize = textStyle.fontSize || item.labelFontSize || labelFontSize;
|
|
281
316
|
var defaultFontSize = 14;
|
|
317
|
+
var fillColorForAnimatedGradientOnAndroid = isAnimationOver
|
|
318
|
+
? "url(#radial".concat(index, ")")
|
|
319
|
+
: dataPointsColor;
|
|
282
320
|
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) {
|
|
283
321
|
var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
|
|
284
322
|
handleFocus(index);
|
|
@@ -293,7 +331,7 @@ export var BubbleChart = function (props) {
|
|
|
293
331
|
? index === selectedIndex
|
|
294
332
|
? dataPointsColor
|
|
295
333
|
: 'none'
|
|
296
|
-
: dataPointsColor, stroke: (
|
|
334
|
+
: dataPointsColor, fillOpacity: isAnimated ? appearingDataPoints : opacity, stroke: (_h = item.borderColor) !== null && _h !== void 0 ? _h : borderColor, strokeWidth: (_j = item.borderWidth) !== null && _j !== void 0 ? _j : borderWidth, strokeOpacity: (_l = (_k = item.borderOpacity) !== null && _k !== void 0 ? _k : props.borderOpacity) !== null && _l !== void 0 ? _l : (isAnimated ? appearingBorder : borderOpacity), onPress: function () {
|
|
297
335
|
item.onPress
|
|
298
336
|
? item.onPress(item, index)
|
|
299
337
|
: props.onPress
|
|
@@ -305,11 +343,17 @@ export var BubbleChart = function (props) {
|
|
|
305
343
|
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
306
344
|
handleUnFocus();
|
|
307
345
|
}
|
|
308
|
-
} })) }, index)) : (_jsx(Fragment, { children: customBubble ? null : (_jsx(AnimatedCircle, { cx: getX(index), cy: getYOrSecondaryY(item.y), r: isAnimated ? growingRadii[index] : bubblesRadius, fill:
|
|
309
|
-
?
|
|
310
|
-
?
|
|
311
|
-
:
|
|
312
|
-
: dataPointsColor,
|
|
346
|
+
} })) }, index)) : (_jsx(Fragment, { children: customBubble ? null : (_jsx(AnimatedCircle, { cx: getX(index), cy: getYOrSecondaryY(item.y), r: isAnimated ? growingRadii[index] : bubblesRadius, fill: ((_m = item.showGradient) !== null && _m !== void 0 ? _m : showGradient)
|
|
347
|
+
? isAndroid && isAnimated
|
|
348
|
+
? fillColorForAnimatedGradientOnAndroid
|
|
349
|
+
: "url(#radial".concat(index, ")")
|
|
350
|
+
: dataPointsColor, fillOpacity: isAnimated
|
|
351
|
+
? isAndroid && showGradient
|
|
352
|
+
? isAnimationOver
|
|
353
|
+
? opacity
|
|
354
|
+
: appearingDataPointsAndroid
|
|
355
|
+
: appearingDataPoints
|
|
356
|
+
: opacity, stroke: (_o = item.borderColor) !== null && _o !== void 0 ? _o : borderColor, strokeWidth: (_p = item.borderWidth) !== null && _p !== void 0 ? _p : borderWidth, strokeOpacity: (_r = (_q = item.borderOpacity) !== null && _q !== void 0 ? _q : props.borderOpacity) !== null && _r !== void 0 ? _r : (isAnimated ? appearingBorder : borderOpacity), onPress: function () {
|
|
313
357
|
item.onPress
|
|
314
358
|
? item.onPress(item, index)
|
|
315
359
|
: props.onPress
|
|
@@ -321,12 +365,13 @@ export var BubbleChart = function (props) {
|
|
|
321
365
|
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
322
366
|
handleUnFocus();
|
|
323
367
|
}
|
|
324
|
-
} })) }, index)), labelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width:
|
|
325
|
-
(item.labelShiftX || props.labelShiftX || 0) -
|
|
368
|
+
} })) }, index)), labelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: getX(index) -
|
|
326
369
|
labelWidth / 2 +
|
|
327
|
-
|
|
370
|
+
6 +
|
|
371
|
+
(item.labelShiftX || props.labelShiftX || 0), y: getYOrSecondaryY(item.y) -
|
|
372
|
+
10 +
|
|
328
373
|
(item.labelShiftY || props.labelShiftY || 0) -
|
|
329
|
-
(
|
|
374
|
+
(scatterChart ? bubblesRadius + 10 : 0), children: showBubbleLabelOnFocus
|
|
330
375
|
? index === selectedIndex &&
|
|
331
376
|
(focusTogether || key == selectedLineNumber)
|
|
332
377
|
? labelComponent(item, index) // not pushed in latest release
|
|
@@ -340,20 +385,27 @@ export var BubbleChart = function (props) {
|
|
|
340
385
|
(item.labelShiftX || props.labelShiftX || 0),
|
|
341
386
|
top: getYOrSecondaryY(item.y) -
|
|
342
387
|
defaultFontSize / 1.5 +
|
|
343
|
-
(item.labelShiftY || props.labelShiftY || 0)
|
|
388
|
+
(item.labelShiftY || props.labelShiftY || 0) -
|
|
389
|
+
(scatterChart ? bubblesRadius + 10 : 0),
|
|
344
390
|
opacity: isAnimated ? appearingDataPoints : 1,
|
|
345
391
|
}, children: showBubbleLabelOnFocus
|
|
346
392
|
? index === selectedIndex &&
|
|
347
393
|
(focusTogether || key == selectedLineNumber)
|
|
348
394
|
? labelComponent(item, index) // not pushed in latest release
|
|
349
395
|
: null
|
|
350
|
-
: labelComponent(item, index) }))) : null) :
|
|
351
|
-
|
|
396
|
+
: labelComponent(item, index) }))) : null) : formattedTextLabel ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: getX(index) -
|
|
397
|
+
Math.min(bubblesRadius, (formattedTextLabel.length * fontSize) / 3) +
|
|
398
|
+
(item.labelShiftX || props.labelShiftX || 0), y: getYOrSecondaryY(item.y) -
|
|
399
|
+
Math.max(10, fontSize / 1.5) +
|
|
400
|
+
(item.labelShiftY || props.labelShiftY || 0) -
|
|
401
|
+
(scatterChart ? bubblesRadius + 10 : 0), children: _jsx(Text, { style: __assign(__assign({}, textStyle), { fontSize: fontSize }), children: formattedTextLabel }) })) : (_jsx(Animated.Text, { style: __assign(__assign({}, textStyle), { position: 'absolute', left: getX(index) -
|
|
402
|
+
Math.min(bubblesRadius, (formattedTextLabel.length * fontSize) / 3) +
|
|
352
403
|
(item.labelShiftX || props.labelShiftX || 0), top: getYOrSecondaryY(item.y) -
|
|
353
404
|
fontSize / 1.5 +
|
|
354
|
-
(item.labelShiftY || props.labelShiftY || 0)
|
|
405
|
+
(item.labelShiftY || props.labelShiftY || 0) -
|
|
406
|
+
(scatterChart ? bubblesRadius + 10 : 0), fontSize: fontSize, opacity: isAnimated
|
|
355
407
|
? appearingDataPoints
|
|
356
|
-
: ((
|
|
408
|
+
: ((_s = textStyle.opacity) !== null && _s !== void 0 ? _s : 1) }), children: formattedTextLabel }))) : null) : null, index === selectedIndex ? _jsx(Text, { children: '' }) : null] }))] }, index));
|
|
357
409
|
});
|
|
358
410
|
};
|
|
359
411
|
var svgWrapperViewStyle = {
|
|
@@ -367,16 +419,14 @@ export var BubbleChart = function (props) {
|
|
|
367
419
|
return (_jsxs(View, { style: [
|
|
368
420
|
svgWrapperViewStyle,
|
|
369
421
|
{
|
|
370
|
-
width: totalWidth,
|
|
422
|
+
width: totalWidth + extraWidthDueToBubble,
|
|
371
423
|
height: containerHeightIncludingBelowXAxis,
|
|
372
424
|
// zIndex,
|
|
373
425
|
},
|
|
374
|
-
], children: [_jsxs(Svg, { height: svgHeight, width: totalWidth, onPress: props.onBackgroundPress, children: [
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
// textFontWeight,
|
|
379
|
-
startIndex, endIndex, false, showValuesAsBubbleLabels, 0), showRegressionLine && (_jsx(AnimatedLine, { x1: regressionLineX1, y1: regressionLineY1, x2: regressionLineConfig.isAnimated
|
|
426
|
+
], children: [_jsxs(Svg, { height: svgHeight, width: totalWidth + extraWidthDueToBubble, onPress: props.onBackgroundPress, children: [showGradient && (_jsx(Defs, { children: data === null || data === void 0 ? void 0 : data.map(function (item, index) {
|
|
427
|
+
var _a;
|
|
428
|
+
return (_jsxs(RadialGradient, { id: "radial".concat(index), cx: "50%", cy: "50%", r: "50%", children: [_jsx(Stop, { offset: "0%", stopColor: (_a = item.centerColorForGradient) !== null && _a !== void 0 ? _a : centerColorForGradient }), _jsx(Stop, { offset: "100%", stopColor: item.bubbleColor || bubblesColor })] }, index));
|
|
429
|
+
}) })), renderBubbles(hideBubbles, data, data, bubblesShape, bubblesWidth, bubblesHeight, bubblesColor, bubblesRadius, labelFontSize, startIndex, endIndex, false, showValuesAsBubbleLabels, 0), showRegressionLine && (_jsx(AnimatedLine, { x1: regressionLineX1, y1: regressionLineY1, x2: regressionLineConfig.isAnimated
|
|
380
430
|
? AnimatedRegressionLineX
|
|
381
431
|
: regressionLineX2, y2: regressionLineConfig.isAnimated
|
|
382
432
|
? AnimatedRegressionLineY
|
|
@@ -392,7 +442,7 @@ export var BubbleChart = function (props) {
|
|
|
392
442
|
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev);
|
|
393
443
|
},
|
|
394
444
|
bounces: props.bounces,
|
|
395
|
-
overScrollMode: (
|
|
445
|
+
overScrollMode: (_d = props.overScrollMode) !== null && _d !== void 0 ? _d : 'auto',
|
|
396
446
|
};
|
|
397
447
|
return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled })));
|
|
398
448
|
};
|
|
@@ -26,9 +26,9 @@ var isCloseToLeft = function (_a, endReachedOffset) {
|
|
|
26
26
|
contentSize.width - endReachedOffset);
|
|
27
27
|
};
|
|
28
28
|
var BarAndLineChartsWrapper = function (props) {
|
|
29
|
-
var _a, _b, _c, _d, _e;
|
|
30
|
-
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, stepHeight = props.stepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, scrollRef = props.scrollRef, initialSpacing = props.initialSpacing, data = props.data, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, disableScroll = props.disableScroll, showScrollIndicator = props.showScrollIndicator, scrollToEnd = props.scrollToEnd, scrollToIndex = props.scrollToIndex, scrollAnimation = props.scrollAnimation, indicatorColor = props.indicatorColor, spacing = props.spacing, renderChartContent = props.renderChartContent, remainingScrollViewProps = props.remainingScrollViewProps, endSpacing = props.endSpacing, hideAxesAndRules = props.hideAxesAndRules, showXAxisIndices = props.showXAxisIndices, xAxisIndicesHeight = props.xAxisIndicesHeight, xAxisIndicesWidth = props.xAxisIndicesWidth, xAxisIndicesColor = props.xAxisIndicesColor, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, onEndReached = props.onEndReached, onStartReached = props.onStartReached, endReachedOffset = props.endReachedOffset, onMomentumScrollEnd = props.onMomentumScrollEnd, onScrollEndDrag = props.onScrollEndDrag, nestedScrollEnabled = props.nestedScrollEnabled,
|
|
31
|
-
var
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, stepHeight = props.stepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, scrollRef = props.scrollRef, initialSpacing = props.initialSpacing, data = props.data, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, disableScroll = props.disableScroll, showScrollIndicator = props.showScrollIndicator, scrollToEnd = props.scrollToEnd, scrollToIndex = props.scrollToIndex, scrollAnimation = props.scrollAnimation, indicatorColor = props.indicatorColor, spacing = props.spacing, renderChartContent = props.renderChartContent, remainingScrollViewProps = props.remainingScrollViewProps, endSpacing = props.endSpacing, hideAxesAndRules = props.hideAxesAndRules, showXAxisIndices = props.showXAxisIndices, xAxisIndicesHeight = props.xAxisIndicesHeight, xAxisIndicesWidth = props.xAxisIndicesWidth, xAxisIndicesColor = props.xAxisIndicesColor, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, onEndReached = props.onEndReached, onStartReached = props.onStartReached, endReachedOffset = props.endReachedOffset, onMomentumScrollEnd = props.onMomentumScrollEnd, onScrollEndDrag = props.onScrollEndDrag, nestedScrollEnabled = props.nestedScrollEnabled, _g = props.extraWidthDueToDataPoint, extraWidthDueToDataPoint = _g === void 0 ? 0 : _g;
|
|
31
|
+
var _h = useBarAndLineChartsWrapper(__assign(__assign({}, props), { isRTL: I18nManager.isRTL })), containerHeightIncludingBelowXAxis = _h.containerHeightIncludingBelowXAxis, xAxisLabelsVerticalShift = _h.xAxisLabelsVerticalShift, trimYAxisAtTop = _h.trimYAxisAtTop, yAxisExtraHeight = _h.yAxisExtraHeight, overflowTop = _h.overflowTop, xAxisLabelsHeight = _h.xAxisLabelsHeight, xAxisTextNumberOfLines = _h.xAxisTextNumberOfLines, actualContainerWidth = _h.actualContainerWidth, transformForHorizontal = _h.transformForHorizontal, horizSectionProps = _h.horizSectionProps, referenceLinesOverChartContent = _h.referenceLinesOverChartContent, setCanMomentum = _h.setCanMomentum, isCloseToStart = _h.isCloseToStart, isCloseToEnd = _h.isCloseToEnd, canMomentum = _h.canMomentum, yAxisAtTop = _h.yAxisAtTop, yAxisThickness = _h.yAxisThickness, yAxisSide = _h.yAxisSide, showVerticalLines = _h.showVerticalLines, verticalLinesProps = _h.verticalLinesProps;
|
|
32
32
|
useEffect(function () {
|
|
33
33
|
if (pointerConfig && getPointerProps) {
|
|
34
34
|
getPointerProps({ pointerIndex: pointerIndex, pointerX: pointerX, pointerY: pointerY });
|
|
@@ -97,9 +97,11 @@ var BarAndLineChartsWrapper = function (props) {
|
|
|
97
97
|
position: 'absolute',
|
|
98
98
|
bottom: chartType === chartTypes.LINE_BI_COLOR ? 0 : xAxisThickness,
|
|
99
99
|
},
|
|
100
|
-
!!props.width
|
|
100
|
+
(!!props.width || chartType === chartTypes.BUBBLE) && {
|
|
101
|
+
width: ((_d = props.width) !== null && _d !== void 0 ? _d : totalWidth) + extraWidthDueToDataPoint,
|
|
102
|
+
},
|
|
101
103
|
horizontal && {
|
|
102
|
-
width: ((
|
|
104
|
+
width: ((_e = props.width) !== null && _e !== void 0 ? _e : totalWidth) + (props.width ? endSpacing : -20),
|
|
103
105
|
},
|
|
104
106
|
], contentContainerStyle: [
|
|
105
107
|
{
|
|
@@ -107,7 +109,7 @@ var BarAndLineChartsWrapper = function (props) {
|
|
|
107
109
|
yAxisExtraHeight +
|
|
108
110
|
labelsExtraHeight +
|
|
109
111
|
(50 + xAxisLabelsVerticalShift),
|
|
110
|
-
width: Math.max((
|
|
112
|
+
width: Math.max((_f = props.width) !== null && _f !== void 0 ? _f : 0, totalWidth - spacing + endSpacing) +
|
|
111
113
|
extraWidthDueToDataPoint,
|
|
112
114
|
paddingLeft: initialSpacing,
|
|
113
115
|
paddingBottom: noOfSectionsBelowXAxis * stepHeight + labelsExtraHeight,
|
|
@@ -47,7 +47,7 @@ var RenderVerticalLines = function (props) {
|
|
|
47
47
|
zIndex: verticalLinesZIndex || -1,
|
|
48
48
|
}, children: _jsx(Svg, { height: containerHeightIncludingBelowXAxis, width: totalWidth, children: verticalLinesAr.map(function (item, index) {
|
|
49
49
|
var _a, _b, _c, _d, _e, _f;
|
|
50
|
-
if (!index && chartType === chartTypes.BUBBLE)
|
|
50
|
+
if (!index && chartType === chartTypes.BUBBLE && initialSpacing === 0)
|
|
51
51
|
return null;
|
|
52
52
|
var totalSpacing = initialSpacing;
|
|
53
53
|
if (verticalLinesSpacing) {
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
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.74",
|
|
4
4
|
"description": "The most complete 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.",
|
|
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.78"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/cli": "^7.24.8",
|