react-native-gifted-charts 1.4.70 → 1.4.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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,385 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { LineDefaults, useBubbleChart, } from 'gifted-charts-core';
14
+ import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
15
+ import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
16
+ import { Animated, Easing, I18nManager, Text, View, } from 'react-native';
17
+ import { Circle, ForeignObject, Rect, Svg, Text as CanvasText, } from 'react-native-svg';
18
+ import { isWebApp, screenWidth } from '../utils';
19
+ var AnimatedCircle = Animated.createAnimatedComponent(Circle);
20
+ var AnimatedRect = Animated.createAnimatedComponent(Rect);
21
+ export var BubbleChart = function (props) {
22
+ var _a, _b, _c, _d;
23
+ var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
24
+ var pointsOpacityValue = useMemo(function () { return new Animated.Value(0); }, []);
25
+ var secondaryXAxis = props.secondaryXAxis;
26
+ var _e = useBubbleChart(__assign(__assign({}, props), { parentWidth: (_a = props.parentWidth) !== null && _a !== void 0 ? _a : screenWidth })), barAndLineChartsWrapperProps = _e.barAndLineChartsWrapperProps, totalWidth = _e.totalWidth, animationDuration = _e.animationDuration, _f = _e.containerHeightIncludingBelowXAxis, containerHeightIncludingBelowXAxis = _f === void 0 ? 0 : _f, getY = _e.getY, getX = _e.getX, maxValue = _e.maxValue, selectedIndex = _e.selectedIndex, setSelectedIndex = _e.setSelectedIndex, showTextOnFocus = _e.showTextOnFocus, focusEnabled = _e.focusEnabled, focusTogether = _e.focusTogether, selectedLineNumber = _e.selectedLineNumber, lastLineNumber = _e.lastLineNumber, initialSpacing = _e.initialSpacing, spacing = _e.spacing, containerHeight = _e.containerHeight, handleFocus = _e.handleFocus, handleUnFocus = _e.handleUnFocus, isAnimated = _e.isAnimated, showDataPointOnFocus = _e.showDataPointOnFocus, showDataPointLabelOnFocus = _e.showDataPointLabelOnFocus, dataPointsShape = _e.dataPointsShape, dataPointsWidth = _e.dataPointsWidth, dataPointsHeight = _e.dataPointsHeight, dataPointsColor = _e.dataPointsColor, dataPointsRadius = _e.dataPointsRadius, textColor = _e.textColor, textFontSize = _e.textFontSize, startIndex = _e.startIndex, endIndex = _e.endIndex, showValuesAsDataPointsText = _e.showValuesAsDataPointsText, cumulativeSpacing = _e.cumulativeSpacing, hideDataPoints = _e.hideDataPoints, xAxisLabelsVerticalShift = _e.xAxisLabelsVerticalShift, labelsExtraHeight = _e.labelsExtraHeight, xAxisThickness = _e.xAxisThickness, xAxisTextNumberOfLines = _e.xAxisTextNumberOfLines, rotateLabel = _e.rotateLabel, allowFontScaling = _e.allowFontScaling, borderColor = _e.borderColor, borderWidth = _e.borderWidth, opacity = _e.opacity;
27
+ var radiiValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
28
+ var pointsHeightValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
29
+ var pointsWidthValues = useMemo(function () { var _a; return ((_a = props.data) !== null && _a !== void 0 ? _a : []).map(function (_) { return new Animated.Value(0); }); }, []);
30
+ var scrollRef = (_b = props.scrollRef) !== null && _b !== void 0 ? _b : useRef(null);
31
+ var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
32
+ var appearingOpacity = opacityValue.interpolate({
33
+ inputRange: [0, 1],
34
+ outputRange: [0, 1],
35
+ });
36
+ var growingRadii = radiiValues.map(function (r, i) {
37
+ var _a, _b;
38
+ return r.interpolate({
39
+ inputRange: [0, 1],
40
+ outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].r) !== null && _b !== void 0 ? _b : dataPointsRadius],
41
+ });
42
+ });
43
+ var growingHeight = pointsHeightValues.map(function (h, i) {
44
+ var _a, _b;
45
+ return h.interpolate({
46
+ inputRange: [0, 1],
47
+ outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].dataPointHeight) !== null && _b !== void 0 ? _b : dataPointsHeight],
48
+ });
49
+ });
50
+ var growingWidth = pointsHeightValues.map(function (w, i) {
51
+ var _a, _b;
52
+ return w.interpolate({
53
+ inputRange: [0, 1],
54
+ outputRange: [0, (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[i].dataPointWidth) !== null && _b !== void 0 ? _b : dataPointsWidth],
55
+ });
56
+ });
57
+ var appearingDataPoints = pointsOpacityValue.interpolate({
58
+ inputRange: [0, 1],
59
+ outputRange: [0, opacity],
60
+ });
61
+ var decreaseWidth = useCallback(function () {
62
+ widthValue.setValue(0);
63
+ Animated.timing(widthValue, {
64
+ toValue: totalWidth,
65
+ duration: animationDuration,
66
+ easing: Easing.linear,
67
+ useNativeDriver: false,
68
+ }).start();
69
+ }, [animationDuration, widthValue]);
70
+ var labelsAppear = useCallback(function () {
71
+ opacityValue.setValue(0);
72
+ Animated.timing(opacityValue, {
73
+ toValue: 1,
74
+ duration: 500,
75
+ easing: Easing.ease,
76
+ useNativeDriver: false,
77
+ }).start();
78
+ }, [opacityValue]);
79
+ var radiiGrow = useCallback(function () {
80
+ radiiValues.forEach(function (radiusValue) {
81
+ radiusValue.setValue(0);
82
+ Animated.timing(radiusValue, {
83
+ toValue: 1,
84
+ duration: animationDuration,
85
+ easing: Easing.ease,
86
+ useNativeDriver: false,
87
+ }).start();
88
+ });
89
+ }, [radiiValues]);
90
+ var dataPointsHeightsGrow = useCallback(function () {
91
+ pointsHeightValues.forEach(function (h) {
92
+ h.setValue(0);
93
+ Animated.timing(h, {
94
+ toValue: 1,
95
+ duration: animationDuration,
96
+ easing: Easing.ease,
97
+ useNativeDriver: false,
98
+ }).start();
99
+ });
100
+ }, [pointsHeightValues]);
101
+ var dataPointsWidthsGrow = useCallback(function () {
102
+ pointsWidthValues.forEach(function (w) {
103
+ w.setValue(0);
104
+ Animated.timing(w, {
105
+ toValue: 1,
106
+ duration: animationDuration,
107
+ easing: Easing.ease,
108
+ useNativeDriver: false,
109
+ }).start();
110
+ });
111
+ }, [pointsWidthValues]);
112
+ // const dataPointsHeightGrow
113
+ var dataPointsAppear = useCallback(function () {
114
+ pointsOpacityValue.setValue(0);
115
+ Animated.timing(pointsOpacityValue, {
116
+ toValue: 1,
117
+ duration: animationDuration,
118
+ easing: Easing.ease,
119
+ useNativeDriver: false,
120
+ }).start();
121
+ }, [pointsOpacityValue]);
122
+ useEffect(function () {
123
+ if (isAnimated) {
124
+ decreaseWidth();
125
+ labelsAppear();
126
+ radiiGrow();
127
+ dataPointsAppear();
128
+ if (dataPointsShape === 'rectangular') {
129
+ dataPointsHeightsGrow();
130
+ dataPointsWidthsGrow();
131
+ }
132
+ }
133
+ }, [isAnimated, dataPointsShape]);
134
+ var svgHeight = containerHeightIncludingBelowXAxis + ((_c = props.overflowBottom) !== null && _c !== void 0 ? _c : 0);
135
+ var onStripPress = function (item, index) {
136
+ if (props.focusedDataPointIndex === undefined || !props.onFocus) {
137
+ setSelectedIndex(index);
138
+ }
139
+ if (props.onFocus) {
140
+ props.onFocus(item, index);
141
+ }
142
+ };
143
+ var renderLabel = function (top, index, label, labelTextStyle, labelComponent) {
144
+ var _a, _b;
145
+ return (_jsx(View, { style: [
146
+ {
147
+ position: 'absolute',
148
+ bottom: top
149
+ ? containerHeight +
150
+ 60 +
151
+ ((_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _a !== void 0 ? _a : 15)
152
+ : -xAxisTextNumberOfLines * 18,
153
+ zIndex: 10,
154
+ width: spacing + labelsExtraHeight,
155
+ left: initialSpacing + spacing * index - spacing / 2,
156
+ height: (_b = props.xAxisLabelsHeight) !== null && _b !== void 0 ? _b : xAxisTextNumberOfLines * 18,
157
+ },
158
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
159
+ ], children: labelComponent ? (labelComponent()) : (_jsx(Text, { style: [{ textAlign: 'center' }, labelTextStyle], allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label })) }));
160
+ };
161
+ var renderAnimatedLabel = function (top, index, label, labelTextStyle, labelComponent) {
162
+ var _a, _b;
163
+ return (_jsx(Animated.View, { style: [
164
+ {
165
+ height: rotateLabel
166
+ ? 40
167
+ : ((_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18),
168
+ position: 'absolute',
169
+ bottom: top
170
+ ? containerHeight +
171
+ 60 +
172
+ ((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
173
+ : rotateLabel
174
+ ? 10
175
+ : -xAxisTextNumberOfLines * 18,
176
+ zIndex: 10,
177
+ width: spacing,
178
+ left: initialSpacing + spacing * index - spacing / 2,
179
+ opacity: appearingOpacity,
180
+ },
181
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
182
+ ], children: labelComponent ? (labelComponent()) : (_jsx(Text, { allowFontScaling: allowFontScaling, style: [{ textAlign: 'center' }, labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
183
+ };
184
+ var renderDataPoints = function (hideDataPoints, dataForRender, originalDataFromProps, dataPtsShape, dataPtsWidth, dataPtsHeight, dataPtsColor, dataPtsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
185
+ var getYOrSecondaryY = getY; //isSecondary ? getSecondaryY : getY;
186
+ return dataForRender.map(function (item, index) {
187
+ var _a, _b, _c, _d, _e, _f, _g, _h;
188
+ if (index < startIndex || index > endIndex)
189
+ return null;
190
+ if (item.hideDataPoint) {
191
+ return null;
192
+ }
193
+ var dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, text, customDataPoint, dataPointLabelComponent;
194
+ if (index === selectedIndex &&
195
+ (focusTogether || key === selectedLineNumber)) {
196
+ dataPointsShape =
197
+ item.focusedDataPointShape ||
198
+ props.focusedDataPointShape ||
199
+ item.dataPointShape ||
200
+ dataPtsShape;
201
+ dataPointsWidth =
202
+ item.focusedDataPointWidth ||
203
+ props.focusedDataPointWidth ||
204
+ item.dataPointWidth ||
205
+ dataPtsWidth;
206
+ dataPointsHeight =
207
+ item.focusedDataPointHeight ||
208
+ props.focusedDataPointHeight ||
209
+ item.dataPointHeight ||
210
+ dataPtsHeight;
211
+ dataPointsColor =
212
+ item.focusedDataPointColor ||
213
+ props.focusedDataPointColor ||
214
+ LineDefaults.focusedDataPointColor;
215
+ dataPointsRadius =
216
+ (_c = (_b = (_a = item.focusedDataPointRadius) !== null && _a !== void 0 ? _a : props.focusedDataPointRadius) !== null && _b !== void 0 ? _b : item.r) !== null && _c !== void 0 ? _c : dataPtsRadius;
217
+ if (showTextOnFocus) {
218
+ text = item.dataPointText;
219
+ }
220
+ customDataPoint =
221
+ item.focusedCustomDataPoint ||
222
+ props.focusedCustomDataPoint ||
223
+ item.customDataPoint ||
224
+ props.customDataPoint;
225
+ dataPointLabelComponent =
226
+ item.focusedDataPointLabelComponent ||
227
+ item.dataPointLabelComponent ||
228
+ props.focusedDataPointLabelComponent ||
229
+ props.dataPointLabelComponent;
230
+ }
231
+ else {
232
+ dataPointsShape = item.dataPointShape || dataPtsShape;
233
+ dataPointsWidth = item.dataPointWidth || dataPtsWidth;
234
+ dataPointsHeight = item.dataPointHeight || dataPtsHeight;
235
+ dataPointsColor = item.dataPointColor || dataPtsColor;
236
+ dataPointsRadius = (_d = item.r) !== null && _d !== void 0 ? _d : dataPtsRadius;
237
+ if (showTextOnFocus) {
238
+ text = '';
239
+ }
240
+ customDataPoint = item.customDataPoint || props.customDataPoint;
241
+ dataPointLabelComponent =
242
+ item.dataPointLabelComponent || props.dataPointLabelComponent;
243
+ }
244
+ if (showValuesAsDataPointsText) {
245
+ text = originalDataFromProps[index].y;
246
+ }
247
+ var dataPointLabelWidth = item.dataPointLabelWidth
248
+ ? item.dataPointLabelWidth
249
+ : props.dataPointLabelWidth
250
+ ? props.dataPointLabelWidth
251
+ : 30;
252
+ return (_jsxs(Fragment, { children: [focusEnabled ? (_jsx(_Fragment, { children: key === lastLineNumber - 1 ? (_jsx(Rect, { x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight - 0, fill: 'none', onPressIn: function (evt) {
253
+ var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
254
+ handleFocus(index);
255
+ }, onPressOut: handleUnFocus })) : null })) : null, hideDataPoints ? null : (_jsxs(_Fragment, { children: [customDataPoint ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: initialSpacing -
256
+ dataPointsWidth / 2 +
257
+ ((_e = spacingArray[index - 1]) !== null && _e !== void 0 ? _e : 0), y: getYOrSecondaryY(item.y) - dataPointsHeight / 2, children: customDataPoint(item, index) })) : (_jsx(Animated.View, { style: {
258
+ position: 'absolute',
259
+ // height: svgHeight,
260
+ // width: totalWidth,
261
+ left: initialSpacing -
262
+ dataPointsWidth / 2 +
263
+ ((_f = spacingArray[index - 1]) !== null && _f !== void 0 ? _f : 0),
264
+ top: getYOrSecondaryY(item.y) - dataPointsHeight / 2,
265
+ opacity: isAnimated ? appearingOpacity : 1,
266
+ }, children: customDataPoint(item, index) }))) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(AnimatedRect, { x: getX(spacingArray, index) - dataPointsWidth / 2, y: getYOrSecondaryY(item.y) - dataPointsHeight / 2, width: isAnimated ? growingWidth[index] : dataPointsWidth, height: isAnimated ? growingHeight[index] : dataPointsHeight, opacity: isAnimated ? appearingDataPoints : opacity, fill: showDataPointOnFocus
267
+ ? index === selectedIndex
268
+ ? dataPointsColor
269
+ : 'none'
270
+ : dataPointsColor, onPress: function () {
271
+ item.onPress
272
+ ? item.onPress(item, index)
273
+ : props.onPress
274
+ ? props.onPress(item, index)
275
+ : focusEnabled
276
+ ? handleFocus(index)
277
+ : null;
278
+ }, onPressOut: function () {
279
+ if (!item.onPress && !props.onPress && focusEnabled) {
280
+ handleUnFocus();
281
+ }
282
+ } })) }, index)) : (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(AnimatedCircle, { cx: getX(spacingArray, index), cy: getYOrSecondaryY(item.y), r: isAnimated ? growingRadii[index] : dataPointsRadius, fill: showDataPointOnFocus
283
+ ? index === selectedIndex
284
+ ? dataPointsColor
285
+ : 'none'
286
+ : dataPointsColor, opacity: isAnimated ? appearingDataPoints : opacity, stroke: (_g = item.borderColor) !== null && _g !== void 0 ? _g : borderColor, strokeWidth: (_h = item.borderWidth) !== null && _h !== void 0 ? _h : borderWidth, onPress: function () {
287
+ item.onPress
288
+ ? item.onPress(item, index)
289
+ : props.onPress
290
+ ? props.onPress(item, index)
291
+ : focusEnabled
292
+ ? handleFocus(index)
293
+ : null;
294
+ }, onPressOut: function () {
295
+ if (!item.onPress && !props.onPress && focusEnabled) {
296
+ handleUnFocus();
297
+ }
298
+ } })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: dataPointLabelWidth, x: initialSpacing +
299
+ (item.dataPointLabelShiftX ||
300
+ props.dataPointLabelShiftX ||
301
+ 0) -
302
+ dataPointLabelWidth / 2 +
303
+ spacing * index, y: containerHeight +
304
+ (item.dataPointLabelShiftY ||
305
+ props.dataPointLabelShiftY ||
306
+ 0) -
307
+ (item.y * containerHeight) / maxValue, children: showDataPointLabelOnFocus
308
+ ? index === selectedIndex &&
309
+ (focusTogether || key == selectedLineNumber)
310
+ ? dataPointLabelComponent(item, index) // not pushed in latest release
311
+ : null
312
+ : dataPointLabelComponent(item, index) })) : (_jsx(View, { style: {
313
+ position: 'absolute',
314
+ height: svgHeight,
315
+ width: dataPointLabelWidth,
316
+ left: initialSpacing +
317
+ (item.dataPointLabelShiftX ||
318
+ props.dataPointLabelShiftX ||
319
+ 0) -
320
+ dataPointLabelWidth / 2 +
321
+ spacing * index,
322
+ top: containerHeight +
323
+ (item.dataPointLabelShiftY ||
324
+ props.dataPointLabelShiftY ||
325
+ 0) -
326
+ (item.y * containerHeight) / maxValue,
327
+ }, children: showDataPointLabelOnFocus
328
+ ? index === selectedIndex &&
329
+ (focusTogether || key == selectedLineNumber)
330
+ ? dataPointLabelComponent(item, index) // not pushed in latest release
331
+ : null
332
+ : dataPointLabelComponent(item, index) }))) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: getX(spacingArray, index) -
333
+ dataPointsWidth +
334
+ (item.textShiftX || props.textShiftX || 0), y: getYOrSecondaryY(item.y) -
335
+ dataPointsHeight / 2 +
336
+ (item.textShiftY || props.textShiftY || 0), children: !showTextOnFocus && !showValuesAsDataPointsText
337
+ ? item.dataPointText
338
+ : text })) : null) : null, index === selectedIndex ? _jsx(Text, { children: '' }) : null] }))] }, index));
339
+ });
340
+ };
341
+ var svgWrapperViewStyle = {
342
+ position: 'absolute',
343
+ top: 0, // 281 + xAxisLabelsVerticalShift + labelsExtraHeight - xAxisThickness,
344
+ left: 0,
345
+ zIndex: 1,
346
+ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
347
+ };
348
+ var renderChartContent = function () {
349
+ var _a;
350
+ return (_jsxs(View, { style: [
351
+ svgWrapperViewStyle,
352
+ {
353
+ width: totalWidth,
354
+ height: containerHeightIncludingBelowXAxis,
355
+ // zIndex,
356
+ },
357
+ ], children: [_jsx(Svg, { height: svgHeight, width: totalWidth, onPress: props.onBackgroundPress, children: renderDataPoints(hideDataPoints, props.data, props.data, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, false, showValuesAsDataPointsText, cumulativeSpacing, 0) }), (_a = props.data) === null || _a === void 0 ? void 0 : _a.map(function (item, index) {
358
+ var _a, _b, _c, _d, _e, _f;
359
+ var secondaryLabel = (_c = (_a = item.secondaryLabel) !== null && _a !== void 0 ? _a : (_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelTexts) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : '';
360
+ var secondaryLabelTextStyle = (_f = (_e = (_d = item.secondaryLabelTextStyle) !== null && _d !== void 0 ? _d : secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsTextStyle) !== null && _e !== void 0 ? _e : item.labelTextStyle) !== null && _f !== void 0 ? _f : props.xAxisLabelTextStyle;
361
+ return (_jsxs(View, { children: [isAnimated
362
+ ? renderAnimatedLabel(false, index, item.label ||
363
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
364
+ ? props.xAxisLabelTexts[index]
365
+ : ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent)
366
+ : renderLabel(false, index, item.label ||
367
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
368
+ ? props.xAxisLabelTexts[index]
369
+ : ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent), secondaryXAxis
370
+ ? isAnimated
371
+ ? renderAnimatedLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
372
+ : renderLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
373
+ : null] }, index));
374
+ })] }));
375
+ };
376
+ var remainingScrollViewProps = {
377
+ onScroll: function (ev) {
378
+ var _a;
379
+ (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev);
380
+ },
381
+ bounces: props.bounces,
382
+ overScrollMode: (_d = props.overScrollMode) !== null && _d !== void 0 ? _d : 'auto',
383
+ };
384
+ return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled })));
385
+ };
@@ -4,7 +4,7 @@ import Svg, { Path } from 'react-native-svg';
4
4
  import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
5
5
  import { renderDataPoints } from './renderDataPoints';
6
6
  import { renderSpecificDataPoints } from './renderSpecificDataPoints';
7
- import { isIos } from '../../../utils';
7
+ import { isIos, isWebApp } from '../../../utils';
8
8
  var RenderLineInBarChart = function (props) {
9
9
  var _a, _b;
10
10
  var yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, arrowPoints = props.arrowPoints, data = props.data, totalWidth = props.totalWidth, barWidth = props.barWidth, labelsExtraHeight = props.labelsExtraHeight, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, selectedIndex = props.selectedIndex, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, yAxisOffset = props.yAxisOffset, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity;
@@ -15,6 +15,7 @@ var RenderLineInBarChart = function (props) {
15
15
  : lowlightOpacity
16
16
  : 1;
17
17
  var svgHeight = containerHeightIncludingBelowXAxis + labelsExtraHeight;
18
+ var svgHeightProp = isWebApp ? svgHeight : undefined;
18
19
  var dataPointsProps = {
19
20
  data: data,
20
21
  lineConfig: lineConfig,
@@ -57,11 +58,11 @@ var RenderLineInBarChart = function (props) {
57
58
  position: 'absolute',
58
59
  height: svgHeight,
59
60
  left: 6 - yAxisLabelWidth,
60
- bottom: 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;
@@ -101,7 +102,7 @@ var RenderVerticalLines = function (props) {
101
102
  ? ((_a = item.verticalLineShift) !== null && _a !== void 0 ? _a : verticalLinesShift)
102
103
  : verticalLinesShift;
103
104
  var x = verticalLinesShiftLocal +
104
- 1 +
105
+ 2 +
105
106
  (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
107
  ? totalSpacing - 1
107
108
  : 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.71",
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.74"
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"