react-native-gifted-charts 1.4.70 → 1.4.72

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 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 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.
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,7 +18,7 @@ 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 () {
@@ -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
- spacing / 2,
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: [labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
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 () {
@@ -0,0 +1,2 @@
1
+ import { BubbleChartPropsType } from 'gifted-charts-core';
2
+ export declare const BubbleChart: (props: BubbleChartPropsType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,398 @@
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 { BubbleDefaults, 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, Line } from 'react-native-svg';
18
+ import { isWebApp, screenWidth } from '../utils';
19
+ var AnimatedCircle = Animated.createAnimatedComponent(Circle);
20
+ var AnimatedRect = Animated.createAnimatedComponent(Rect);
21
+ var AnimatedLine = Animated.createAnimatedComponent(Line);
22
+ export var BubbleChart = function (props) {
23
+ var _a, _b, _c, _d, _e, _f;
24
+ var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
25
+ var pointsOpacityValue = useMemo(function () { return new Animated.Value(0); }, []);
26
+ var secondaryXAxis = props.secondaryXAxis;
27
+ var _g = useBubbleChart(__assign(__assign({}, props), { parentWidth: (_a = props.parentWidth) !== null && _a !== void 0 ? _a : screenWidth })), barAndLineChartsWrapperProps = _g.barAndLineChartsWrapperProps, totalWidth = _g.totalWidth, animationDuration = _g.animationDuration, _h = _g.containerHeightIncludingBelowXAxis, containerHeightIncludingBelowXAxis = _h === void 0 ? 0 : _h, getY = _g.getY, getX = _g.getX, maxValue = _g.maxValue, selectedIndex = _g.selectedIndex, setSelectedIndex = _g.setSelectedIndex, showTextOnFocus = _g.showTextOnFocus, focusEnabled = _g.focusEnabled, focusTogether = _g.focusTogether, selectedLineNumber = _g.selectedLineNumber, lastLineNumber = _g.lastLineNumber, initialSpacing = _g.initialSpacing, spacing = _g.spacing, containerHeight = _g.containerHeight, handleFocus = _g.handleFocus, handleUnFocus = _g.handleUnFocus, isAnimated = _g.isAnimated, showBubbleOnFocus = _g.showBubbleOnFocus, showBubbleLabelOnFocus = _g.showBubbleLabelOnFocus, bubblesShape = _g.bubblesShape, bubblesWidth = _g.bubblesWidth, bubblesHeight = _g.bubblesHeight, bubblesColor = _g.bubblesColor, bubblesRadius = _g.bubblesRadius, labelFontSize = _g.labelFontSize, labelTextStyle = _g.labelTextStyle, startIndex = _g.startIndex, endIndex = _g.endIndex, showValuesAsBubbleLabels = _g.showValuesAsBubbleLabels, hideBubbles = _g.hideBubbles, xAxisLabelsVerticalShift = _g.xAxisLabelsVerticalShift, labelsExtraHeight = _g.labelsExtraHeight, xAxisThickness = _g.xAxisThickness, xAxisTextNumberOfLines = _g.xAxisTextNumberOfLines, rotateLabel = _g.rotateLabel, allowFontScaling = _g.allowFontScaling, borderColor = _g.borderColor, borderWidth = _g.borderWidth, opacity = _g.opacity, xAxisLabelTexts = _g.xAxisLabelTexts, showRegressionLine = _g.showRegressionLine, regressionLineX1 = _g.regressionLineX1, regressionLineY1 = _g.regressionLineY1, regressionLineX2 = _g.regressionLineX2, regressionLineY2 = _g.regressionLineY2, regressionLineConfig = _g.regressionLineConfig;
28
+ var progress = useRef(new Animated.Value(0)).current;
29
+ var AnimatedRegressionLineX = useRef(new Animated.Value(0)).current;
30
+ var AnimatedRegressionLineY = useRef(new Animated.Value(0)).current;
31
+ var scrollRef = (_b = props.scrollRef) !== null && _b !== void 0 ? _b : useRef(null);
32
+ var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
33
+ var appearingOpacity = opacityValue.interpolate({
34
+ inputRange: [0, 1],
35
+ outputRange: [0, 1],
36
+ });
37
+ // const appearRegressionLine = RegressionLine.interpolate({
38
+ // inputRange:[0,1],
39
+ // outputRange:[regressionLineX1,regressionLineX2]
40
+ // })
41
+ var growingRadii = useMemo(function () {
42
+ var _a;
43
+ return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (item) {
44
+ var _a;
45
+ return progress.interpolate({
46
+ inputRange: [0, 1],
47
+ outputRange: [0, (_a = item.r) !== null && _a !== void 0 ? _a : bubblesRadius],
48
+ });
49
+ });
50
+ }, [props.data, progress]);
51
+ var growingHeight = ((_c = props.data) !== null && _c !== void 0 ? _c : []).map(function (_, i) {
52
+ var _a, _b;
53
+ return progress.interpolate({
54
+ inputRange: [0, 1],
55
+ outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].bubbleHeight) !== null && _b !== void 0 ? _b : bubblesHeight],
56
+ });
57
+ });
58
+ var growingWidth = ((_d = props.data) !== null && _d !== void 0 ? _d : []).map(function (_, i) {
59
+ var _a, _b;
60
+ return progress.interpolate({
61
+ inputRange: [0, 1],
62
+ outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].bubbleWidth) !== null && _b !== void 0 ? _b : bubblesWidth],
63
+ });
64
+ });
65
+ var appearingDataPoints = pointsOpacityValue.interpolate({
66
+ inputRange: [0, 1],
67
+ outputRange: [0, opacity],
68
+ });
69
+ var drawRegressionLine = useCallback(function () {
70
+ if (!regressionLineConfig.isAnimated)
71
+ return;
72
+ AnimatedRegressionLineX.setValue(regressionLineX1);
73
+ AnimatedRegressionLineY.setValue(regressionLineY1);
74
+ Animated.parallel([
75
+ Animated.timing(AnimatedRegressionLineX, {
76
+ toValue: regressionLineX2,
77
+ duration: regressionLineConfig.animationDuration,
78
+ easing: Easing.linear,
79
+ useNativeDriver: false, // SVG props
80
+ }),
81
+ Animated.timing(AnimatedRegressionLineY, {
82
+ toValue: regressionLineY2,
83
+ duration: regressionLineConfig.animationDuration,
84
+ easing: Easing.linear,
85
+ useNativeDriver: false, // SVG props
86
+ }),
87
+ ]).start();
88
+ }, [regressionLineConfig]);
89
+ var decreaseWidth = useCallback(function () {
90
+ widthValue.setValue(0);
91
+ Animated.timing(widthValue, {
92
+ toValue: totalWidth,
93
+ duration: animationDuration,
94
+ easing: Easing.linear,
95
+ useNativeDriver: false,
96
+ }).start();
97
+ }, [animationDuration, widthValue]);
98
+ var labelsAppear = useCallback(function () {
99
+ opacityValue.setValue(0);
100
+ Animated.timing(opacityValue, {
101
+ toValue: 1,
102
+ duration: 500,
103
+ easing: Easing.ease,
104
+ useNativeDriver: false,
105
+ }).start();
106
+ }, [opacityValue]);
107
+ var radiiGrow = useCallback(function () {
108
+ if (bubblesShape === 'rectangular')
109
+ return;
110
+ progress.setValue(0);
111
+ Animated.timing(progress, {
112
+ toValue: 1,
113
+ duration: animationDuration,
114
+ easing: Easing.out(Easing.cubic),
115
+ useNativeDriver: false,
116
+ }).start();
117
+ }, [progress, animationDuration]);
118
+ var bubblesHeightsWidthsGrow = useCallback(function () {
119
+ if (bubblesShape !== 'rectangular')
120
+ return;
121
+ progress.setValue(0);
122
+ Animated.timing(progress, {
123
+ toValue: 1,
124
+ duration: animationDuration,
125
+ easing: Easing.out(Easing.cubic),
126
+ useNativeDriver: false,
127
+ }).start();
128
+ }, [progress, animationDuration]);
129
+ var dataPointsAppear = useCallback(function () {
130
+ pointsOpacityValue.setValue(0);
131
+ Animated.timing(pointsOpacityValue, {
132
+ toValue: 1,
133
+ duration: animationDuration,
134
+ easing: Easing.ease,
135
+ useNativeDriver: false,
136
+ }).start();
137
+ }, [pointsOpacityValue]);
138
+ useEffect(function () {
139
+ if (isAnimated) {
140
+ decreaseWidth();
141
+ labelsAppear();
142
+ dataPointsAppear();
143
+ if (bubblesShape === 'rectangular') {
144
+ bubblesHeightsWidthsGrow();
145
+ }
146
+ else {
147
+ radiiGrow();
148
+ }
149
+ }
150
+ if (regressionLineConfig.isAnimated) {
151
+ drawRegressionLine();
152
+ }
153
+ }, [isAnimated, bubblesShape]);
154
+ var svgHeight = containerHeightIncludingBelowXAxis + ((_e = props.overflowBottom) !== null && _e !== void 0 ? _e : 0);
155
+ // const onStripPress = (item: any, index: number) => {
156
+ // if (props.focusedBubbleIndex === undefined || !props.onFocus) {
157
+ // setSelectedIndex(index);
158
+ // }
159
+ // if (props.onFocus) {
160
+ // props.onFocus(item, index);
161
+ // }
162
+ // };
163
+ var renderLabel = function (top, index, label) {
164
+ var _a, _b;
165
+ return (_jsx(View, { style: [
166
+ {
167
+ position: 'absolute',
168
+ bottom: top
169
+ ? containerHeight +
170
+ 60 +
171
+ ((_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _a !== void 0 ? _a : 15)
172
+ : -xAxisTextNumberOfLines * 18 - (containerHeight - 200) / 20,
173
+ zIndex: 10,
174
+ width: spacing + labelsExtraHeight,
175
+ left: initialSpacing + spacing * index - spacing / 2,
176
+ height: (_b = props.xAxisLabelsHeight) !== null && _b !== void 0 ? _b : xAxisTextNumberOfLines * 18,
177
+ },
178
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
179
+ ], children: _jsx(Text, { style: { textAlign: 'center' }, allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label }) }));
180
+ };
181
+ var renderAnimatedLabel = function (top, index, label) {
182
+ var _a, _b;
183
+ return (_jsx(Animated.View, { style: [
184
+ {
185
+ height: rotateLabel
186
+ ? 40
187
+ : ((_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18),
188
+ position: 'absolute',
189
+ bottom: top
190
+ ? containerHeight +
191
+ 60 +
192
+ ((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
193
+ : rotateLabel
194
+ ? 10
195
+ : -xAxisTextNumberOfLines * 18,
196
+ zIndex: 10,
197
+ width: spacing,
198
+ left: initialSpacing + spacing * index - spacing / 2,
199
+ opacity: appearingOpacity,
200
+ },
201
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
202
+ ], children: _jsx(Text, { allowFontScaling: allowFontScaling, style: { textAlign: 'center' }, numberOfLines: xAxisTextNumberOfLines, children: label }) }));
203
+ };
204
+ var renderDataPoints = function (hideBubbles, dataForRender, originalDataFromProps, bubsShape, bubsWidth, bubsHeight, bubsColor, bubsRadius, labelFontSize,
205
+ // textColor: any,
206
+ // textFontSize: any,
207
+ // textFontFamily: any,
208
+ // textFontWeight: any,
209
+ startIndex, endIndex, isSecondary, showValuesAsDataPointsText, key) {
210
+ var getYOrSecondaryY = getY; //isSecondary ? getSecondaryY : getY;
211
+ return dataForRender.map(function (item, index) {
212
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
213
+ if (index < startIndex || index > endIndex)
214
+ return null;
215
+ if (item.hideBubble) {
216
+ return null;
217
+ }
218
+ var bubblesShape, bubblesWidth, bubblesHeight, dataPointsColor, bubblesRadius, text, customBubble, labelComponent;
219
+ if (index === selectedIndex &&
220
+ (focusTogether || key === selectedLineNumber)) {
221
+ bubblesShape =
222
+ item.focusedBubbleShape ||
223
+ props.focusedBubbleShape ||
224
+ item.bubbleShape ||
225
+ bubsShape;
226
+ bubblesWidth =
227
+ item.focusedBubbleWidth ||
228
+ props.focusedBubbleWidth ||
229
+ item.bubbleWidth ||
230
+ bubsWidth;
231
+ bubblesHeight =
232
+ item.focusedBubbleHeight ||
233
+ props.focusedBubbleHeight ||
234
+ item.bubbleHeight ||
235
+ bubsHeight;
236
+ dataPointsColor =
237
+ item.focusedBubbleColor ||
238
+ props.focusedBubbleColor ||
239
+ 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;
242
+ if (showTextOnFocus) {
243
+ text = item.label;
244
+ }
245
+ customBubble =
246
+ item.focusedCustomBubble ||
247
+ props.focusedCustomBubble ||
248
+ item.customBubble ||
249
+ props.customBubble;
250
+ labelComponent =
251
+ item.focusedLabelComponent ||
252
+ item.labelComponent ||
253
+ props.focusedLabelComponent ||
254
+ props.labelComponent;
255
+ }
256
+ else {
257
+ bubblesShape = item.bubbleShape || bubsShape;
258
+ bubblesWidth = item.bubbleWidth || bubsWidth;
259
+ bubblesHeight = item.bubbleHeight || bubsHeight;
260
+ dataPointsColor = item.bubbleColor || bubsColor;
261
+ bubblesRadius = (_d = item.r) !== null && _d !== void 0 ? _d : bubsRadius;
262
+ if (showTextOnFocus) {
263
+ text = '';
264
+ }
265
+ customBubble = item.customBubble || props.customBubble;
266
+ labelComponent = item.labelComponent || props.labelComponent;
267
+ }
268
+ if (showValuesAsDataPointsText) {
269
+ text = originalDataFromProps[index].y;
270
+ }
271
+ var labelWidth = item.labelWidth
272
+ ? item.labelWidth
273
+ : props.labelWidth
274
+ ? props.labelWidth
275
+ : 30;
276
+ var textLabel = !showTextOnFocus && !showValuesAsDataPointsText
277
+ ? item.label
278
+ : text.toString();
279
+ var textStyle = ((_f = (_e = item.labelTextStyle) !== null && _e !== void 0 ? _e : labelTextStyle) !== null && _f !== void 0 ? _f : {});
280
+ var fontSize = textStyle.fontSize || item.labelFontSize || labelFontSize;
281
+ var defaultFontSize = 14;
282
+ 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
+ var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
284
+ handleFocus(index);
285
+ }, onPressOut: handleUnFocus })) : null })) : null, hideBubbles ? null : (_jsxs(_Fragment, { children: [customBubble ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: getX(index), y: getYOrSecondaryY(item.y) - bubblesHeight / 2, children: customBubble(item, index) })) : (_jsx(Animated.View, { style: {
286
+ position: 'absolute',
287
+ // height: svgHeight,
288
+ // width: totalWidth,
289
+ left: getX(index) - bubblesWidth / 2,
290
+ top: getYOrSecondaryY(item.y) - bubblesHeight / 2,
291
+ opacity: isAnimated ? appearingOpacity : 1,
292
+ }, children: customBubble(item, index) }))) : null, bubblesShape === 'rectangular' ? (_jsx(Fragment, { children: customBubble ? null : (_jsx(AnimatedRect, { x: getX(index) - bubblesWidth / 2, y: getYOrSecondaryY(item.y) - bubblesHeight / 2, width: isAnimated ? growingWidth[index] : bubblesWidth, height: isAnimated ? growingHeight[index] : bubblesHeight, opacity: isAnimated ? appearingDataPoints : opacity, fill: showBubbleOnFocus
293
+ ? index === selectedIndex
294
+ ? dataPointsColor
295
+ : 'none'
296
+ : dataPointsColor, stroke: (_g = item.borderColor) !== null && _g !== void 0 ? _g : borderColor, strokeWidth: (_h = item.borderWidth) !== null && _h !== void 0 ? _h : borderWidth, strokeOpacity: (_k = (_j = item.borderOpacity) !== null && _j !== void 0 ? _j : props.borderOpacity) !== null && _k !== void 0 ? _k : (isAnimated ? appearingDataPoints : opacity), onPress: function () {
297
+ item.onPress
298
+ ? item.onPress(item, index)
299
+ : props.onPress
300
+ ? props.onPress(item, index)
301
+ : focusEnabled
302
+ ? handleFocus(index)
303
+ : null;
304
+ }, onPressOut: function () {
305
+ if (!item.onPress && !props.onPress && focusEnabled) {
306
+ handleUnFocus();
307
+ }
308
+ } })) }, index)) : (_jsx(Fragment, { children: customBubble ? null : (_jsx(AnimatedCircle, { cx: getX(index), cy: getYOrSecondaryY(item.y), r: isAnimated ? growingRadii[index] : bubblesRadius, fill: showBubbleOnFocus
309
+ ? index === selectedIndex
310
+ ? dataPointsColor
311
+ : 'none'
312
+ : dataPointsColor, opacity: isAnimated ? appearingDataPoints : opacity, stroke: (_l = item.borderColor) !== null && _l !== void 0 ? _l : borderColor, strokeWidth: (_m = item.borderWidth) !== null && _m !== void 0 ? _m : borderWidth, strokeOpacity: (_p = (_o = item.borderOpacity) !== null && _o !== void 0 ? _o : props.borderOpacity) !== null && _p !== void 0 ? _p : (isAnimated ? appearingDataPoints : opacity), onPress: function () {
313
+ item.onPress
314
+ ? item.onPress(item, index)
315
+ : props.onPress
316
+ ? props.onPress(item, index)
317
+ : focusEnabled
318
+ ? handleFocus(index)
319
+ : null;
320
+ }, onPressOut: function () {
321
+ if (!item.onPress && !props.onPress && focusEnabled) {
322
+ handleUnFocus();
323
+ }
324
+ } })) }, index)), labelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: labelWidth, x: initialSpacing +
325
+ (item.labelShiftX || props.labelShiftX || 0) -
326
+ labelWidth / 2 +
327
+ spacing * index, y: containerHeight +
328
+ (item.labelShiftY || props.labelShiftY || 0) -
329
+ (item.y * containerHeight) / maxValue, children: showBubbleLabelOnFocus
330
+ ? index === selectedIndex &&
331
+ (focusTogether || key == selectedLineNumber)
332
+ ? labelComponent(item, index) // not pushed in latest release
333
+ : null
334
+ : labelComponent(item, index) })) : (_jsx(Animated.View, { style: {
335
+ position: 'absolute',
336
+ height: svgHeight,
337
+ width: labelWidth,
338
+ left: getX(index) -
339
+ defaultFontSize / 2 +
340
+ (item.labelShiftX || props.labelShiftX || 0),
341
+ top: getYOrSecondaryY(item.y) -
342
+ defaultFontSize / 1.5 +
343
+ (item.labelShiftY || props.labelShiftY || 0),
344
+ opacity: isAnimated ? appearingDataPoints : 1,
345
+ }, children: showBubbleLabelOnFocus
346
+ ? index === selectedIndex &&
347
+ (focusTogether || key == selectedLineNumber)
348
+ ? labelComponent(item, index) // not pushed in latest release
349
+ : null
350
+ : labelComponent(item, index) }))) : null) : textLabel ? (!showTextOnFocus || index === selectedIndex ? (_jsx(Animated.Text, { style: __assign(__assign({}, textStyle), { position: 'absolute', left: getX(index) -
351
+ Math.min(bubblesRadius, (textLabel.length * fontSize) / 3) +
352
+ (item.labelShiftX || props.labelShiftX || 0), top: getYOrSecondaryY(item.y) -
353
+ fontSize / 1.5 +
354
+ (item.labelShiftY || props.labelShiftY || 0), fontSize: fontSize, opacity: isAnimated
355
+ ? appearingDataPoints
356
+ : ((_q = textStyle.opacity) !== null && _q !== void 0 ? _q : 1) }), children: textLabel })) : null) : null, index === selectedIndex ? _jsx(Text, { children: '' }) : null] }))] }, index));
357
+ });
358
+ };
359
+ var svgWrapperViewStyle = {
360
+ position: 'absolute',
361
+ top: 0, // 281 + xAxisLabelsVerticalShift + labelsExtraHeight - xAxisThickness,
362
+ left: 0,
363
+ zIndex: 1,
364
+ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
365
+ };
366
+ var renderChartContent = function () {
367
+ return (_jsxs(View, { style: [
368
+ svgWrapperViewStyle,
369
+ {
370
+ width: totalWidth,
371
+ height: containerHeightIncludingBelowXAxis,
372
+ // zIndex,
373
+ },
374
+ ], children: [_jsxs(Svg, { height: svgHeight, width: totalWidth, onPress: props.onBackgroundPress, children: [renderDataPoints(hideBubbles, props.data, props.data, bubblesShape, bubblesWidth, bubblesHeight, bubblesColor, bubblesRadius, labelFontSize,
375
+ // textColor,
376
+ // textFontSize,
377
+ // textFontFamily,
378
+ // textFontWeight,
379
+ startIndex, endIndex, false, showValuesAsBubbleLabels, 0), showRegressionLine && (_jsx(AnimatedLine, { x1: regressionLineX1, y1: regressionLineY1, x2: regressionLineConfig.isAnimated
380
+ ? AnimatedRegressionLineX
381
+ : regressionLineX2, y2: regressionLineConfig.isAnimated
382
+ ? AnimatedRegressionLineY
383
+ : regressionLineY2, stroke: regressionLineConfig.color, strokeOpacity: regressionLineConfig.opacity, strokeWidth: regressionLineConfig.thickness, strokeDasharray: regressionLineConfig.strokeDashArray }))] }), xAxisLabelTexts === null || xAxisLabelTexts === void 0 ? void 0 : xAxisLabelTexts.map(function (label, index) {
384
+ return (_jsx(View, { children: isAnimated
385
+ ? renderAnimatedLabel(false, index, label)
386
+ : renderLabel(false, index, label) }, index));
387
+ })] }));
388
+ };
389
+ var remainingScrollViewProps = {
390
+ onScroll: function (ev) {
391
+ var _a;
392
+ (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev);
393
+ },
394
+ bounces: props.bounces,
395
+ overScrollMode: (_f = props.overScrollMode) !== null && _f !== void 0 ? _f : 'auto',
396
+ };
397
+ return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled })));
398
+ };
@@ -36,6 +36,7 @@ export var renderHorizSections = function (props) {
36
36
  var negativeSectionsCountDiffPrimaryVsSecondary = secondaryHorizSectionsBelow.length - horizSectionsBelow.length;
37
37
  var isLineChart = chartType === chartTypes.LINE;
38
38
  var isLineBiColor = chartType === chartTypes.LINE_BI_COLOR;
39
+ var chartWiseTotalWidth = chartType === chartTypes.BUBBLE ? totalWidth : totalWidth - spacing;
39
40
  var renderAxesAndRules = function (index) {
40
41
  var _a, _b, _c, _d, _e, _f, _g, _h;
41
42
  var invertedIndex = horizSections.length - index - 1;
@@ -49,7 +50,7 @@ export var renderHorizSections = function (props) {
49
50
  {
50
51
  borderColor: yAxisColor,
51
52
  backgroundColor: (_a = sectionColors === null || sectionColors === void 0 ? void 0 : sectionColors[invertedIndex]) !== null && _a !== void 0 ? _a : backgroundColor,
52
- width: (props.width || totalWidth - spacing) + endSpacing,
53
+ width: (props.width || chartWiseTotalWidth) + endSpacing,
53
54
  },
54
55
  !index ? { height: stepHeight / 2, marginTop: stepHeight / 2 } : null,
55
56
  yAxisSide === yAxisSides.RIGHT
@@ -59,14 +60,14 @@ export var renderHorizSections = function (props) {
59
60
  thickness: xAxisThickness,
60
61
  color: xAxisColor,
61
62
  width: xAxisLength ||
62
- (props.width || totalWidth - spacing) + endSpacing,
63
+ (props.width || chartWiseTotalWidth) + endSpacing,
63
64
  dashWidth: dashWidth,
64
65
  dashGap: dashGap,
65
66
  type: xAxisType,
66
67
  } })) : hideRules ? null : (_jsx(Rule, { config: {
67
68
  thickness: (_b = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesThickness) !== null && _b !== void 0 ? _b : rulesThickness,
68
69
  color: (_c = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesColor) !== null && _c !== void 0 ? _c : rulesColor,
69
- width: (_e = (_d = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesLength) !== null && _d !== void 0 ? _d : rulesLength) !== null && _e !== void 0 ? _e : (props.width || totalWidth - spacing) + endSpacing,
70
+ width: (_e = (_d = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesLength) !== null && _d !== void 0 ? _d : rulesLength) !== null && _e !== void 0 ? _e : (props.width || chartWiseTotalWidth) + endSpacing,
70
71
  dashWidth: (_f = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.dashWidth) !== null && _f !== void 0 ? _f : dashWidth,
71
72
  dashGap: (_g = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.dashGap) !== null && _g !== void 0 ? _g : dashGap,
72
73
  type: (_h = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesType) !== null && _h !== void 0 ? _h : rulesType,
@@ -113,7 +114,7 @@ export var renderHorizSections = function (props) {
113
114
  ? ((_b = secondaryXAxis.thickness) !== null && _b !== void 0 ? _b : xAxisThickness)
114
115
  : 0,
115
116
  backgroundColor: backgroundColor,
116
- width: (props.width || totalWidth - spacing) + endSpacing,
117
+ width: (props.width || chartWiseTotalWidth) + endSpacing,
117
118
  },
118
119
  yAxisSide === yAxisSides.RIGHT
119
120
  ? { borderRightWidth: yAxisThickness }
@@ -241,7 +242,7 @@ export var renderHorizSections = function (props) {
241
242
  thickness: rulesThickness,
242
243
  color: rulesColor,
243
244
  width: rulesLength ||
244
- (props.width || totalWidth - spacing) + endSpacing,
245
+ (props.width || chartWiseTotalWidth) + endSpacing,
245
246
  dashWidth: dashWidth,
246
247
  dashGap: dashGap,
247
248
  type: rulesType,
@@ -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: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
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: containerHeightIncludingBelowXAxis + labelsExtraHeight,
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
  };
@@ -18,17 +18,18 @@ var RenderVerticalLines = function (props) {
18
18
  var showVerticalLines = props.showVerticalLines, // this is the value passed by user (note that it's not the effective value that is computed by traversing through the data array and finding any item for which showVerticalLines is true)
19
19
  verticalLinesAr = props.verticalLinesAr, verticalLinesSpacing = props.verticalLinesSpacing, spacing = props.spacing, initialSpacing = props.initialSpacing, verticalLinesZIndex = props.verticalLinesZIndex, verticalLinesHeight = props.verticalLinesHeight, verticalLinesThickness = props.verticalLinesThickness, verticalLinesColor = props.verticalLinesColor, verticalLinesStrokeDashArray = props.verticalLinesStrokeDashArray, verticalLinesShift = props.verticalLinesShift, verticalLinesUptoDataPoint = props.verticalLinesUptoDataPoint, verticalLinesStrokeLinecap = props.verticalLinesStrokeLinecap, xAxisThickness = props.xAxisThickness, labelsExtraHeight = props.labelsExtraHeight, containerHeight = props.containerHeight, data = props.data, stackData = props.stackData, barWidth = props.barWidth, maxValue = props.maxValue, chartType = props.chartType, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, totalWidth = props.totalWidth, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift;
20
20
  var getHeightOfVerticalLine = function (index) {
21
+ var _a, _b, _c, _d, _e;
21
22
  if (verticalLinesUptoDataPoint) {
22
23
  if (index < data.length) {
23
24
  return ((data[index].value * containerHeight) / maxValue - xAxisThickness);
24
25
  }
25
26
  else {
26
- return verticalLinesHeight !== null && verticalLinesHeight !== void 0 ? verticalLinesHeight : 0;
27
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.verticalLineHeight) !== null && _b !== void 0 ? _b : verticalLinesHeight) !== null && _c !== void 0 ? _c : 0;
27
28
  }
28
29
  }
29
30
  else {
30
- return (verticalLinesHeight ||
31
- containerHeightIncludingBelowXAxis - xAxisThickness);
31
+ return ((_e = (_d = data === null || data === void 0 ? void 0 : data[index]) === null || _d === void 0 ? void 0 : _d.verticalLineHeight) !== null && _e !== void 0 ? _e : (verticalLinesHeight ||
32
+ containerHeightIncludingBelowXAxis - xAxisThickness));
32
33
  }
33
34
  };
34
35
  var extendedContainerHeight = containerHeight + 10 + labelsExtraHeight;
@@ -46,6 +47,8 @@ var RenderVerticalLines = function (props) {
46
47
  zIndex: verticalLinesZIndex || -1,
47
48
  }, children: _jsx(Svg, { height: containerHeightIncludingBelowXAxis, width: totalWidth, children: verticalLinesAr.map(function (item, index) {
48
49
  var _a, _b, _c, _d, _e, _f;
50
+ if (!index && chartType === chartTypes.BUBBLE)
51
+ return null;
49
52
  var totalSpacing = initialSpacing;
50
53
  if (verticalLinesSpacing) {
51
54
  totalSpacing = verticalLinesSpacing * (index + 1);
@@ -101,7 +104,7 @@ var RenderVerticalLines = function (props) {
101
104
  ? ((_a = item.verticalLineShift) !== null && _a !== void 0 ? _a : verticalLinesShift)
102
105
  : verticalLinesShift;
103
106
  var x = verticalLinesShiftLocal +
104
- 1 +
107
+ 2 +
105
108
  (chartType === chartTypes.BAR // This logic exists because we have renderSpecificVerticalLines in Line Charts which I would love to deprecate at the earliest, because that functionality gets handled here elegantly
106
109
  ? totalSpacing - 1
107
110
  : verticalLinesSpacing
@@ -674,6 +674,18 @@ export var LineChart = function (props) {
674
674
  ? renderDataPoints(secondaryLineConfig.hideDataPoints, secondaryData, props.secondaryData, secondaryLineConfig.dataPointsShape, secondaryLineConfig.dataPointsWidth, secondaryLineConfig.dataPointsHeight, secondaryLineConfig.dataPointsColor, secondaryLineConfig.dataPointsRadius, secondaryLineConfig.textColor, secondaryLineConfig.textFontSize, secondaryLineConfig.startIndex, secondaryLineConfig.endIndex, true, secondaryLineConfig.showValuesAsDataPointsText, cumulativeSpacingSecondary, 6666)
675
675
  : null] }));
676
676
  };
677
+ var areaComponent = function (isNthAreaChart, startFillColor, endFillColor, startOpacity, endOpacity, uniqueId, fillPoints, startIndex, endIndex, propsData, clipRangeId, currentLineThickness, spreadAreaData, spacingArray, spreadAreaColor, spreadAreaOpacity) {
678
+ // For Area Chart
679
+ return (_jsxs(_Fragment, { children: [isNthAreaChart &&
680
+ getAreaGradientComponent(startFillColor, endFillColor, startOpacity, endOpacity, uniqueId), isNthAreaChart &&
681
+ (startIndex !== 0 || endIndex !== data.length - 1) &&
682
+ getClipRange(startIndex, endIndex, clipRangeId), isNthAreaChart ? (props.interpolateMissingValues === false &&
683
+ propsData.some(function (item) { return isNaN(item.value); }) ? null : animateOnDataChange && animatedFillPath ? (_jsx(AnimatedPath, { onPress: props.onChartAreaPress, d: animatedFillPath, fill: props.areaGradientId
684
+ ? "url(#".concat(props.areaGradientId, ")")
685
+ : "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness })) : (_jsx(Path, { onPress: props.onChartAreaPress, d: fillPoints, fill: props.areaGradientId
686
+ ? "url(#".concat(props.areaGradientId, ")")
687
+ : "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness }))) : null, spreadAreaData && (_jsx(Path, { d: getSpreadAreaPath(spreadAreaData, getX, getY, spacingArray, props.curvature, curveType), fill: spreadAreaColor || 'rgba(0,0,255,0.2)', stroke: "none", opacity: spreadAreaOpacity !== null && spreadAreaOpacity !== void 0 ? spreadAreaOpacity : 0.3 }))] }));
688
+ };
677
689
  var lineSvgComponent = function (points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, key, hideDataPoints, data, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray) {
678
690
  var _a, _b;
679
691
  if (!points)
@@ -714,7 +726,7 @@ export var LineChart = function (props) {
714
726
  }
715
727
  return (_jsxs(Svg, { height: svgHeight,
716
728
  // width={widthValue}
717
- onPress: props.onBackgroundPress, children: [lineGradient && getLineGradientComponent(), points.includes(SEGMENT_START) || points.includes(RANGE_ENTER) ? (ar.map(function (item, index) {
729
+ onPress: props.onBackgroundPress, children: [areaComponent(isNthAreaChart, startFillColor, endFillColor, startOpacity, endOpacity, uniqueId, fillPoints, startIndex, endIndex, propsData, clipRangeId, currentLineThickness, spreadAreaData, spacingArray, spreadAreaColor, spreadAreaOpacity), lineGradient && getLineGradientComponent(), points.includes(SEGMENT_START) || points.includes(RANGE_ENTER) ? (ar.map(function (item, index) {
718
730
  var lineSvgProps = {
719
731
  d: item.d,
720
732
  fill: 'none',
@@ -733,15 +745,7 @@ export var LineChart = function (props) {
733
745
  lineSvgProps.strokeDasharray = item.strokeDashArray;
734
746
  }
735
747
  return _jsx(Path, __assign({}, lineSvgProps), index);
736
- })) : animateOnDataChange && animatedPath ? (_jsx(AnimatedPath, __assign({}, lineSvgPropsOuter))) : colors ? (_jsx(Defs, { children: _jsx(Mask, { id: "pathMask", children: _jsx(Path, __assign({}, lineSvgPropsOuter, { stroke: colors ? 'white' : color })) }) })) : (_jsx(Path, __assign({}, lineSvgPropsOuter))), colors && getColorBackRects(), isNthAreaChart &&
737
- getAreaGradientComponent(startFillColor, endFillColor, startOpacity, endOpacity, uniqueId), isNthAreaChart &&
738
- (startIndex !== 0 || endIndex !== data.length - 1) &&
739
- getClipRange(startIndex, endIndex, clipRangeId), isNthAreaChart ? (props.interpolateMissingValues === false &&
740
- propsData.some(function (item) { return isNaN(item.value); }) ? null : animateOnDataChange && animatedFillPath ? (_jsx(AnimatedPath, { onPress: props.onChartAreaPress, d: animatedFillPath, fill: props.areaGradientId
741
- ? "url(#".concat(props.areaGradientId, ")")
742
- : "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness })) : (_jsx(Path, { onPress: props.onChartAreaPress, d: fillPoints, fill: props.areaGradientId
743
- ? "url(#".concat(props.areaGradientId, ")")
744
- : "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness }))) : null, spreadAreaData && (_jsx(Path, { d: getSpreadAreaPath(spreadAreaData, getX, getY, spacingArray, props.curvature, curveType), fill: spreadAreaColor || 'rgba(0,0,255,0.2)', stroke: "none", opacity: spreadAreaOpacity !== null && spreadAreaOpacity !== void 0 ? spreadAreaOpacity : 0.3 })), renderSpecificVerticalLines(data, cumulativeSpacing1), renderSpecificVerticalLines(data2, cumulativeSpacing2), renderSpecificVerticalLines(data3, cumulativeSpacing3), renderSpecificVerticalLines(data4, cumulativeSpacing4), renderSpecificVerticalLines(data5, cumulativeSpacing5), (_b = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set, index) {
748
+ })) : animateOnDataChange && animatedPath ? (_jsx(AnimatedPath, __assign({}, lineSvgPropsOuter))) : colors ? (_jsx(Defs, { children: _jsx(Mask, { id: "pathMask", children: _jsx(Path, __assign({}, lineSvgPropsOuter, { stroke: colors ? 'white' : color })) }) })) : (_jsx(Path, __assign({}, lineSvgPropsOuter))), colors && getColorBackRects(), renderSpecificVerticalLines(data, cumulativeSpacing1), renderSpecificVerticalLines(data2, cumulativeSpacing2), renderSpecificVerticalLines(data3, cumulativeSpacing3), renderSpecificVerticalLines(data4, cumulativeSpacing4), renderSpecificVerticalLines(data5, cumulativeSpacing5), (_b = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set, index) {
745
749
  return renderSpecificVerticalLines(set === null || set === void 0 ? void 0 : set.data, cumulativeSpacingForSet[index]);
746
750
  })) !== null && _b !== void 0 ? _b : null, isAnimated && !renderDataPointsAfterAnimationEnds // in this condition onPress won't work properly in case of multi-line, so it's suggested to use either renderDataPointsAfterAnimationEnds prop if you want to use onPress for data points
747
751
  ? renderDataPoints(hideDataPoints, data, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key)
@@ -749,17 +753,6 @@ export var LineChart = function (props) {
749
753
  ? renderDataPointsForEachLine()
750
754
  : null, showArrow && (_jsx(Path, { d: arrowPoints, fill: arrowFillColor, stroke: arrowStrokeColor, strokeWidth: arrowStrokeWidth }))] }));
751
755
  };
752
- // const getClosestValueFromSpacingArray = (spacingArray:number[],x:number):number => {
753
- // let dif=0,prevDif=0,i;
754
- // for(i=0;i<spacingArray.length;i++){
755
- // dif = Math.abs(spacingArray[i]-x)
756
- // if(prevDif!=0 && prevDif<dif){
757
- // break;
758
- // }
759
- // prevDif = dif;
760
- // }
761
- // return i-1;
762
- // }
763
756
  var activatePointers = function (x) {
764
757
  var _a;
765
758
  var factor = (x - initialSpacing) / ((_a = props.spacing1) !== null && _a !== void 0 ? _a : spacing); // getClosestValueFromSpacingArray(cumulativeSpacing1,x-initialSpacing)
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment, useEffect } from 'react';
3
3
  import { Animated, View } from 'react-native';
4
- import Svg, { Line, Polygon, Circle, Text as SvgText, Defs, RadialGradient, Stop, TSpan, } from 'react-native-svg';
4
+ import Svg, { Line, Polygon, Circle, Text as SvgText, Defs, RadialGradient, Stop, TSpan, G, } from 'react-native-svg';
5
5
  import { useRadarChart } from 'gifted-charts-core';
6
6
  export var RadarChart = function (props) {
7
- var _a = useRadarChart(props), data = _a.data, dataSet = _a.dataSet, center = _a.center, radius = _a.radius, chartSize = _a.chartSize, polarToCartesian = _a.polarToCartesian, labels = _a.labels, labelConfigArray = _a.labelConfigArray, labelsPositionOffset = _a.labelsPositionOffset, dataLabelsConfigArray = _a.dataLabelsConfigArray, maxValue = _a.maxValue, dataLabels = _a.dataLabels, dataLabelsArray = _a.dataLabelsArray, gridSections = _a.gridSections, gridFill = _a.gridFill, fontSize = _a.fontSize, stroke = _a.stroke, textAnchor = _a.textAnchor, alignmentBaseline = _a.alignmentBaseline, fontWeight = _a.fontWeight, fontFamily = _a.fontFamily, dataLabelsPositionOffset = _a.dataLabelsPositionOffset, polygonStroke = _a.polygonStroke, polygonStrokeWidth = _a.polygonStrokeWidth, polygonStrokeDashArray = _a.polygonStrokeDashArray, polygonFill = _a.polygonFill, polygonGradientColor = _a.polygonGradientColor, polygonShowGradient = _a.polygonShowGradient, polygonOpacity = _a.polygonOpacity, polygonGradientOpacity = _a.polygonGradientOpacity, polygonIsAnimated = _a.polygonIsAnimated, polygonAnimationDuration = _a.polygonAnimationDuration, asterLinesStroke = _a.asterLinesStroke, asterLinesStrokeWidth = _a.asterLinesStrokeWidth, asterLinesStrokeDashArray = _a.asterLinesStrokeDashArray, polygonPoints = _a.polygonPoints, initialPolygonPoints = _a.initialPolygonPoints, polygonPointsArray = _a.polygonPointsArray, initialPolygonPointsArray = _a.initialPolygonPointsArray, polygonConfigArray = _a.polygonConfigArray, angleStep = _a.angleStep, circular = _a.circular, hideGrid = _a.hideGrid, hideLabels = _a.hideLabels, hideAsterLines = _a.hideAsterLines, getGridLevelProps = _a.getGridLevelProps, animateTogether = _a.animateTogether, startAngle = _a.startAngle;
7
+ var _a = useRadarChart(props), data = _a.data, dataSet = _a.dataSet, center = _a.center, radius = _a.radius, chartSize = _a.chartSize, chartContainerProps = _a.chartContainerProps, polarToCartesian = _a.polarToCartesian, labels = _a.labels, labelConfigArray = _a.labelConfigArray, labelsPositionOffset = _a.labelsPositionOffset, dataLabelsConfigArray = _a.dataLabelsConfigArray, maxValue = _a.maxValue, dataLabels = _a.dataLabels, dataLabelsArray = _a.dataLabelsArray, gridSections = _a.gridSections, gridFill = _a.gridFill, fontSize = _a.fontSize, stroke = _a.stroke, textAnchor = _a.textAnchor, alignmentBaseline = _a.alignmentBaseline, fontWeight = _a.fontWeight, fontFamily = _a.fontFamily, dataLabelsPositionOffset = _a.dataLabelsPositionOffset, polygonStroke = _a.polygonStroke, polygonStrokeWidth = _a.polygonStrokeWidth, polygonStrokeDashArray = _a.polygonStrokeDashArray, polygonFill = _a.polygonFill, polygonGradientColor = _a.polygonGradientColor, polygonShowGradient = _a.polygonShowGradient, polygonOpacity = _a.polygonOpacity, polygonGradientOpacity = _a.polygonGradientOpacity, polygonIsAnimated = _a.polygonIsAnimated, polygonAnimationDuration = _a.polygonAnimationDuration, asterLinesStroke = _a.asterLinesStroke, asterLinesStrokeWidth = _a.asterLinesStrokeWidth, asterLinesStrokeDashArray = _a.asterLinesStrokeDashArray, polygonPoints = _a.polygonPoints, initialPolygonPoints = _a.initialPolygonPoints, polygonPointsArray = _a.polygonPointsArray, initialPolygonPointsArray = _a.initialPolygonPointsArray, polygonConfigArray = _a.polygonConfigArray, angleStep = _a.angleStep, circular = _a.circular, hideGrid = _a.hideGrid, hideLabels = _a.hideLabels, hideAsterLines = _a.hideAsterLines, getGridLevelProps = _a.getGridLevelProps, animateTogether = _a.animateTogether, startAngle = _a.startAngle;
8
8
  var initialPolygonPointsAr = initialPolygonPoints.split(' ');
9
9
  var finalPolygonPointsAr = polygonPoints.split(' ');
10
10
  var AnimatedPolygon = Animated.createAnimatedComponent(Polygon);
@@ -64,50 +64,54 @@ export var RadarChart = function (props) {
64
64
  });
65
65
  /******************************************************************************************/
66
66
  /******************************************************************************************/
67
- return (_jsx(View, { style: { justifyContent: 'center', alignItems: 'center' }, children: _jsxs(Svg, { height: chartSize, width: chartSize, children: [(polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.length) ? (polygonConfigArray.map(function (polygonConfigItem, index) {
68
- var fill = polygonConfigItem.fill, gradientColor = polygonConfigItem.gradientColor, opacity = polygonConfigItem.opacity, gradientOpacity = polygonConfigItem.gradientOpacity;
69
- return (_jsx(Defs, { children: _jsxs(RadialGradient, { id: "polygon-".concat(index), cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: gradientColor, stopOpacity: gradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: fill, stopOpacity: opacity })] }, "polygon-".concat(index)) }, "defs-".concat(index)));
70
- })) : polygonShowGradient ? (_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'polygon', cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: polygonGradientColor, stopOpacity: polygonGradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: polygonFill, stopOpacity: polygonOpacity })] }, 'polygon') })) : null, hideGrid
71
- ? null
72
- : gridSections.map(function (l, ind) {
73
- var _a = getGridLevelProps(l, ind), level = _a.level, gridGradientColorLocal = _a.gridGradientColorLocal, gridFillColorLocal = _a.gridFillColorLocal, gridOpacityLocal = _a.gridOpacityLocal, gridGradientOpacityLocal = _a.gridGradientOpacityLocal, gridStrokeLocal = _a.gridStrokeLocal, gridStrokeWidthLocal = _a.gridStrokeWidthLocal, gridShowGradientLocal = _a.gridShowGradientLocal, gridStrokeDashArrayLocal = _a.gridStrokeDashArrayLocal, levelPolygonPoints = _a.levelPolygonPoints, r = _a.r;
74
- return (_jsxs(Fragment, { children: [_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'grad' + level, cx: center, cy: center, rx: r, ry: r, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "".concat(100 - 100 / level, "%"), stopColor: gridGradientColorLocal, stopOpacity: gridGradientOpacityLocal }), _jsx(Stop, { offset: "100%", stopColor: gridFillColorLocal, stopOpacity: gridOpacityLocal })] }, level + '') }), circular ? (_jsx(Circle, { cx: center, cy: center, r: r, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal ? "url(#grad".concat(level, ")") : gridFill }, "grid-".concat(level))) : (_jsx(Polygon, { points: levelPolygonPoints, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal ? "url(#grad".concat(level, ")") : gridFill }, "grid-".concat(level)))] }, "fragment-".concat(level)));
75
- }), dataSet ? (polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.map(function (item, index) {
76
- var polygonPoints = polygonPointsArray[index];
77
- var animatedPolygonPoints = animatedPathsForSet[index];
78
- var stroke = item.stroke, strokeWidth = item.strokeWidth, strokeDashArray = item.strokeDashArray, fill = item.fill, showGradient = item.showGradient, opacity = item.opacity, _a = item.isAnimated, isAnimated = _a === void 0 ? polygonIsAnimated : _a;
79
- return (_jsx(AnimatedPolygon, { points: isAnimated ? animatedPolygonPoints : polygonPoints, fill: showGradient ? 'url(#polygon)' : fill, stroke: stroke, strokeWidth: strokeWidth, strokeDasharray: strokeDashArray, opacity: opacity }, "polygon-".concat(index)));
80
- })) : (_jsx(AnimatedPolygon, { points: polygonIsAnimated ? animatedPaths : polygonPoints, fill: polygonShowGradient ? 'url(#polygon)' : polygonFill, stroke: polygonStroke, strokeWidth: polygonStrokeWidth, strokeDasharray: polygonStrokeDashArray, opacity: polygonOpacity })), (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) && (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.length) ? (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.map(function (labels, index) {
81
- var dataItem = dataSet[index];
82
- return labels === null || labels === void 0 ? void 0 : labels.map(function (label, labelIndex) {
83
- var _a, _b, _c;
84
- var _d = polarToCartesian(labelIndex * angleStep, dataItem[labelIndex] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
85
- var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[labelIndex]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
86
- return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index, "-").concat(labelIndex)));
87
- });
88
- })) : (dataLabels === null || dataLabels === void 0 ? void 0 : dataLabels.length) ? (_jsx(SvgText, { children: dataLabels.map(function (label, index) {
89
- var _a, _b, _c;
90
- var _d = polarToCartesian(index * angleStep, data[index] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
91
- var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[index]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
92
- return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index)));
93
- }) })) : null, hideAsterLines
94
- ? null
95
- : labels.map(function (_, index) {
96
- var angle = index * angleStep + startAngle;
97
- var _a = polarToCartesian(angle, maxValue), x = _a.x, y = _a.y;
98
- return (_jsx(Line, { x1: center, y1: center, x2: x, y2: y, stroke: asterLinesStroke, strokeWidth: asterLinesStrokeWidth, strokeDasharray: asterLinesStrokeDashArray }, "axis-".concat(index)));
99
- }), hideLabels
100
- ? null
101
- : labels.map(function (category, index) {
102
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
103
- var angle = index * angleStep + startAngle;
104
- var _q = polarToCartesian(angle, maxValue + labelsPositionOffset), x = _q.x, y = _q.y; // Offset for label position
105
- var fontSizeLocal = (_b = (_a = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _a === void 0 ? void 0 : _a.fontSize) !== null && _b !== void 0 ? _b : fontSize;
106
- var fontWeightLocal = (_d = (_c = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _c === void 0 ? void 0 : _c.fontWeight) !== null && _d !== void 0 ? _d : fontWeight;
107
- var fontFamilyLocal = (_f = (_e = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _e === void 0 ? void 0 : _e.fontFamily) !== null && _f !== void 0 ? _f : fontFamily;
108
- var colorLocal = (_h = (_g = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _g === void 0 ? void 0 : _g.stroke) !== null && _h !== void 0 ? _h : stroke;
109
- var textAnchorLocal = (_k = (_j = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _j === void 0 ? void 0 : _j.textAnchor) !== null && _k !== void 0 ? _k : textAnchor;
110
- var alignmentBaselineLocal = (_m = (_l = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _l === void 0 ? void 0 : _l.alignmentBaseline) !== null && _m !== void 0 ? _m : alignmentBaseline;
111
- return (_jsx(SvgText, { x: x, y: y, fontSize: fontSizeLocal, fontWeight: fontWeightLocal, fontFamily: fontFamilyLocal, fill: colorLocal, textAnchor: (_o = textAnchorLocal) !== null && _o !== void 0 ? _o : 'middle', alignmentBaseline: (_p = alignmentBaselineLocal) !== null && _p !== void 0 ? _p : 'middle', children: category.split('\n').map(function (line, idx) { return (_jsx(TSpan, { x: x, dy: idx === 0 ? 0 : fontSizeLocal, children: line }, idx)); }) }, "label-".concat(index)));
112
- })] }) }));
67
+ return (_jsx(View, { style: { justifyContent: 'center', alignItems: 'center' }, children: _jsx(Svg, { height: chartContainerProps.height, width: chartContainerProps.width, style: { backgroundColor: chartContainerProps.backgroundColor }, children: _jsxs(G, { translateX: chartContainerProps.shiftX, translateY: chartContainerProps.shiftY, children: [(polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.length) ? (polygonConfigArray.map(function (polygonConfigItem, index) {
68
+ var fill = polygonConfigItem.fill, gradientColor = polygonConfigItem.gradientColor, opacity = polygonConfigItem.opacity, gradientOpacity = polygonConfigItem.gradientOpacity;
69
+ return (_jsx(Defs, { children: _jsxs(RadialGradient, { id: "polygon-".concat(index), cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: gradientColor, stopOpacity: gradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: fill, stopOpacity: opacity })] }, "polygon-".concat(index)) }, "defs-".concat(index)));
70
+ })) : polygonShowGradient ? (_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'polygon', cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: polygonGradientColor, stopOpacity: polygonGradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: polygonFill, stopOpacity: polygonOpacity })] }, 'polygon') })) : null, hideGrid
71
+ ? null
72
+ : gridSections.map(function (l, ind) {
73
+ var _a = getGridLevelProps(l, ind), level = _a.level, gridGradientColorLocal = _a.gridGradientColorLocal, gridFillColorLocal = _a.gridFillColorLocal, gridOpacityLocal = _a.gridOpacityLocal, gridGradientOpacityLocal = _a.gridGradientOpacityLocal, gridStrokeLocal = _a.gridStrokeLocal, gridStrokeWidthLocal = _a.gridStrokeWidthLocal, gridShowGradientLocal = _a.gridShowGradientLocal, gridStrokeDashArrayLocal = _a.gridStrokeDashArrayLocal, levelPolygonPoints = _a.levelPolygonPoints, r = _a.r;
74
+ return (_jsxs(Fragment, { children: [_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'grad' + level, cx: center, cy: center, rx: r, ry: r, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "".concat(100 - 100 / level, "%"), stopColor: gridGradientColorLocal, stopOpacity: gridGradientOpacityLocal }), _jsx(Stop, { offset: "100%", stopColor: gridFillColorLocal, stopOpacity: gridOpacityLocal })] }, level + '') }), circular ? (_jsx(Circle, { cx: center, cy: center, r: r, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal
75
+ ? "url(#grad".concat(level, ")")
76
+ : gridFill }, "grid-".concat(level))) : (_jsx(Polygon, { points: levelPolygonPoints, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal
77
+ ? "url(#grad".concat(level, ")")
78
+ : gridFill }, "grid-".concat(level)))] }, "fragment-".concat(level)));
79
+ }), dataSet ? (polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.map(function (item, index) {
80
+ var polygonPoints = polygonPointsArray[index];
81
+ var animatedPolygonPoints = animatedPathsForSet[index];
82
+ var stroke = item.stroke, strokeWidth = item.strokeWidth, strokeDashArray = item.strokeDashArray, fill = item.fill, showGradient = item.showGradient, opacity = item.opacity, _a = item.isAnimated, isAnimated = _a === void 0 ? polygonIsAnimated : _a;
83
+ return (_jsx(AnimatedPolygon, { points: isAnimated ? animatedPolygonPoints : polygonPoints, fill: showGradient ? 'url(#polygon)' : fill, stroke: stroke, strokeWidth: strokeWidth, strokeDasharray: strokeDashArray, opacity: opacity }, "polygon-".concat(index)));
84
+ })) : (_jsx(AnimatedPolygon, { points: polygonIsAnimated ? animatedPaths : polygonPoints, fill: polygonShowGradient ? 'url(#polygon)' : polygonFill, stroke: polygonStroke, strokeWidth: polygonStrokeWidth, strokeDasharray: polygonStrokeDashArray, opacity: polygonOpacity })), (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) && (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.length) ? (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.map(function (labels, index) {
85
+ var dataItem = dataSet[index];
86
+ return labels === null || labels === void 0 ? void 0 : labels.map(function (label, labelIndex) {
87
+ var _a, _b, _c;
88
+ var _d = polarToCartesian(labelIndex * angleStep, dataItem[labelIndex] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
89
+ var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[labelIndex]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
90
+ return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index, "-").concat(labelIndex)));
91
+ });
92
+ })) : (dataLabels === null || dataLabels === void 0 ? void 0 : dataLabels.length) ? (_jsx(SvgText, { children: dataLabels.map(function (label, index) {
93
+ var _a, _b, _c;
94
+ var _d = polarToCartesian(index * angleStep, data[index] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
95
+ var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[index]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
96
+ return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index)));
97
+ }) })) : null, hideAsterLines
98
+ ? null
99
+ : labels.map(function (_, index) {
100
+ var angle = index * angleStep + startAngle;
101
+ var _a = polarToCartesian(angle, maxValue), x = _a.x, y = _a.y;
102
+ return (_jsx(Line, { x1: center, y1: center, x2: x, y2: y, stroke: asterLinesStroke, strokeWidth: asterLinesStrokeWidth, strokeDasharray: asterLinesStrokeDashArray }, "axis-".concat(index)));
103
+ }), hideLabels
104
+ ? null
105
+ : labels.map(function (category, index) {
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
107
+ var angle = index * angleStep + startAngle;
108
+ var _q = polarToCartesian(angle, maxValue + labelsPositionOffset), x = _q.x, y = _q.y; // Offset for label position
109
+ var fontSizeLocal = (_b = (_a = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _a === void 0 ? void 0 : _a.fontSize) !== null && _b !== void 0 ? _b : fontSize;
110
+ var fontWeightLocal = (_d = (_c = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _c === void 0 ? void 0 : _c.fontWeight) !== null && _d !== void 0 ? _d : fontWeight;
111
+ var fontFamilyLocal = (_f = (_e = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _e === void 0 ? void 0 : _e.fontFamily) !== null && _f !== void 0 ? _f : fontFamily;
112
+ var colorLocal = (_h = (_g = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _g === void 0 ? void 0 : _g.stroke) !== null && _h !== void 0 ? _h : stroke;
113
+ var textAnchorLocal = (_k = (_j = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _j === void 0 ? void 0 : _j.textAnchor) !== null && _k !== void 0 ? _k : textAnchor;
114
+ var alignmentBaselineLocal = (_m = (_l = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _l === void 0 ? void 0 : _l.alignmentBaseline) !== null && _m !== void 0 ? _m : alignmentBaseline;
115
+ return (_jsx(SvgText, { x: x, y: y, fontSize: fontSizeLocal, fontWeight: fontWeightLocal, fontFamily: fontFamilyLocal, fill: colorLocal, textAnchor: (_o = textAnchorLocal) !== null && _o !== void 0 ? _o : 'middle', alignmentBaseline: (_p = alignmentBaselineLocal) !== null && _p !== void 0 ? _p : 'middle', children: category.split('\n').map(function (line, idx) { return (_jsx(TSpan, { x: x, dy: idx === 0 ? 0 : fontSizeLocal, children: line }, idx)); }) }, "label-".concat(index)));
116
+ })] }) }) }));
113
117
  };
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export { LineChart } from './LineChart';
5
5
  export { LineChartBicolor } from './LineChart/LineChartBicolor';
6
6
  export { PopulationPyramid } from './PopulationPyramid';
7
7
  export { RadarChart } from './RadarChart';
8
- export { type barDataItem, type barDataItemNullSafe, type stackDataItem, type BarChartPropsType, type StackedBarChartPropsType, type pieDataItem, type PieChartPropsType, type lineDataItem, type lineDataItemNullSafe, type bicolorLineDataItem, type LineChartPropsType, type LineChartBicolorPropsType, type popnPyramidDataItem, type PopulationPyramidPropsType, chartTypes, ruleTypes, CurveType, yAxisSides, EdgePosition, type DataSet, type DataSetNullSafe, type Linecap, type RulesConfig, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type Pointer, type HighlightedRange, type LineSegment, type LineProperties, Framework, type XAxisConfig, type DataPointProps, type IntersectionAreaConfig, type LabelLineConfig, type TooltipProps, type RadarChartProps, type PolygonConfig, type GridConfig, type GridSectionConfig, type AsterLinesConfig, } from 'gifted-charts-core';
8
+ export { BubbleChart } from './BubbleChart';
9
+ export { type barDataItem, type barDataItemNullSafe, type stackDataItem, type BarChartPropsType, type StackedBarChartPropsType, type pieDataItem, type PieChartPropsType, type lineDataItem, type lineDataItemNullSafe, type bicolorLineDataItem, type LineChartPropsType, type LineChartBicolorPropsType, type popnPyramidDataItem, type PopulationPyramidPropsType, chartTypes, ruleTypes, CurveType, yAxisSides, EdgePosition, type DataSet, type DataSetNullSafe, type Linecap, type RulesConfig, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type Pointer, type HighlightedRange, type LineSegment, type LineProperties, Framework, type XAxisConfig, type DataPointProps, type IntersectionAreaConfig, type LabelLineConfig, type TooltipProps, type RadarChartProps, type BubbleChartPropsType, type PolygonConfig, type GridConfig, type GridSectionConfig, type AsterLinesConfig, } from 'gifted-charts-core';
package/dist/index.js CHANGED
@@ -5,4 +5,5 @@ export { LineChart } from './LineChart';
5
5
  export { LineChartBicolor } from './LineChart/LineChartBicolor';
6
6
  export { PopulationPyramid } from './PopulationPyramid';
7
7
  export { RadarChart } from './RadarChart';
8
+ export { BubbleChart } from './BubbleChart';
8
9
  export { chartTypes, ruleTypes, CurveType, yAxisSides, EdgePosition, Framework, } from 'gifted-charts-core';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.4.70",
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.",
3
+ "version": "1.4.72",
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": [
7
7
  "dist"
@@ -26,7 +26,7 @@
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "dependencies": {
29
- "gifted-charts-core": "0.1.72"
29
+ "gifted-charts-core": "0.1.75"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/cli": "^7.24.8",
@@ -79,6 +79,7 @@
79
79
  "star",
80
80
  "population",
81
81
  "pyramid",
82
+ "bubble",
82
83
  "react",
83
84
  "react native",
84
85
  "react-native"