react-native-gifted-charts 1.4.33 → 1.4.35

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.
@@ -20,10 +20,15 @@ import { getPropsForAnimated2DWithGradient, AxesAndRulesDefaults, } from 'gifted
20
20
  import Tooltip from '../Components/BarSpecificComponents/tooltip';
21
21
  var RenderBars = function (props) {
22
22
  var _a, _b, _c, _d, _e;
23
- var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, propSpacing = props.propSpacing, side = props.side, data = props.data, barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, isThreeD = props.isThreeD, isAnimated = props.isAnimated, rotateLabel = props.rotateLabel, appearingOpacity = props.appearingOpacity, animationDuration = props.animationDuration, autoShiftLabels = props.autoShiftLabels, label = props.label, secondaryLabel = props.secondaryLabel, labelTextStyle = props.labelTextStyle, secondaryLabelTextStyle = props.secondaryLabelTextStyle, xAxisTextNumberOfLines = props.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, renderTooltip = props.renderTooltip, leftShiftForTooltip = props.leftShiftForTooltip, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, initialSpacing = props.initialSpacing, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, _f = props.xAxisThickness, xAxisThickness = _f === void 0 ? AxesAndRulesDefaults.xAxisThickness : _f, horizontal = props.horizontal, rtl = props.rtl, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, yAxisOffset = props.yAxisOffset, barWidth = props.barWidth, _g = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _g === void 0 ? 0 : _g, stepHeight = props.stepHeight, stepValue = props.stepValue, negativeStepHeight = props.negativeStepHeight, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip, secondaryXAxis = props.secondaryXAxis;
24
- var heightFactor = item.value < 0
25
- ? negativeStepHeight / negativeStepValue
26
- : stepHeight / stepValue;
23
+ var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, propSpacing = props.propSpacing, side = props.side, data = props.data, barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, isThreeD = props.isThreeD, isAnimated = props.isAnimated, rotateLabel = props.rotateLabel, appearingOpacity = props.appearingOpacity, animationDuration = props.animationDuration, autoShiftLabels = props.autoShiftLabels, label = props.label, secondaryLabel = props.secondaryLabel, labelTextStyle = props.labelTextStyle, secondaryLabelTextStyle = props.secondaryLabelTextStyle, xAxisTextNumberOfLines = props.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, renderTooltip = props.renderTooltip, leftShiftForTooltip = props.leftShiftForTooltip, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, initialSpacing = props.initialSpacing, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, _f = props.xAxisThickness, xAxisThickness = _f === void 0 ? AxesAndRulesDefaults.xAxisThickness : _f, horizontal = props.horizontal, rtl = props.rtl, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, yAxisOffset = props.yAxisOffset, barWidth = props.barWidth, _g = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _g === void 0 ? 0 : _g, stepHeight = props.stepHeight, stepValue = props.stepValue, negativeStepHeight = props.negativeStepHeight, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip, secondaryXAxis = props.secondaryXAxis, secondaryStepHeight = props.secondaryStepHeight, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight, secondaryNegativeStepValue = props.secondaryNegativeStepValue, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis;
24
+ var heightFactor = item.isSecondary
25
+ ? item.value < 0
26
+ ? (secondaryNegativeStepHeight !== null && secondaryNegativeStepHeight !== void 0 ? secondaryNegativeStepHeight : secondaryStepHeight) /
27
+ (secondaryNegativeStepValue !== null && secondaryNegativeStepValue !== void 0 ? secondaryNegativeStepValue : secondaryStepValue)
28
+ : secondaryStepHeight / secondaryStepValue
29
+ : item.value < 0
30
+ ? negativeStepHeight / negativeStepValue
31
+ : stepHeight / stepValue;
27
32
  var barHeight = Math.max(minHeight, Math.abs(item.value) * heightFactor - xAxisThickness);
28
33
  var _h = getPropsForAnimated2DWithGradient(__assign(__assign({}, props), { barHeight: barHeight })), commonStyleForBar = _h.commonStyleForBar, barStyleWithBackground = _h.barStyleWithBackground, commonPropsFor2dAnd3dBars = _h.commonPropsFor2dAnd3dBars, isFocused = _h.isFocused, focusedBarConfig = _h.focusedBarConfig, localFrontColor = _h.localFrontColor;
29
34
  var itemOrPropsBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
@@ -176,34 +181,23 @@ var RenderBars = function (props) {
176
181
  width: commonPropsFor2dAnd3dBars.barWidth,
177
182
  height: barHeight,
178
183
  marginRight: spacing,
184
+ transform: [
185
+ {
186
+ translateY: (containerHeight || 200) -
187
+ (barHeight - 10 + xAxisLabelsVerticalShift) +
188
+ (item.value < 0 ? Math.abs(item.value) * heightFactor : 0),
189
+ },
190
+ { rotateZ: item.value < 0 ? '180deg' : '0deg' },
191
+ ],
179
192
  },
180
- pointerConfig
181
- ? {
182
- transform: [
183
- {
184
- translateY: (containerHeight || 200) -
185
- (barHeight - 10 + xAxisLabelsVerticalShift) +
186
- (item.value < 0 ? Math.abs(item.value) * heightFactor : 0),
187
- },
188
- ],
189
- }
190
- : item.value < 0
191
- ? {
192
- transform: [
193
- {
194
- translateY: Math.abs(item.value) * heightFactor,
195
- },
196
- { rotateZ: '180deg' },
197
- ],
198
- }
199
- : null,
200
193
  side !== 'right' && { zIndex: data.length - index },
201
194
  ];
202
195
  var pressDisabled = item.disablePress ||
203
196
  props.disablePress ||
204
197
  (pointerConfig && pointerConfig.barTouchable !== true);
205
198
  var barContent = function () {
206
- var isBarBelowXaxisAndInvisible = item.value < 0 && !noOfSectionsBelowXAxis;
199
+ var isBarBelowXaxisAndInvisible = item.value < 0 &&
200
+ !(noOfSectionsBelowXAxis || secondaryNoOfSectionsBelowXAxis);
207
201
  var animated2DWithGradient = function (noGradient, noAnimation) { return (_jsx(Animated2DWithGradient, __assign({}, commonPropsFor2dAnd3dBars, { animationDuration: animationDuration || 800, roundedBottom: props.roundedBottom || false, roundedTop: props.roundedTop || false, noGradient: noGradient, noAnimation: noAnimation, containerHeight: containerHeight, maxValue: maxValue, minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : 0, barMarginBottom: barMarginBottom, cappedBars: props.cappedBars, capThickness: props.capThickness, capColor: props.capColor, capRadius: props.capRadius, horizontal: horizontal, barBorderWidth: barBorderWidth, barBorderColor: barBorderColor, commonStyleForBar: commonStyleForBar, barStyleWithBackground: barStyleWithBackground }))); };
208
202
  return (_jsxs(_Fragment, { children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
209
203
  zIndex: 2,
@@ -22,8 +22,8 @@ if (Platform.OS === 'android') {
22
22
  }
23
23
  var RenderStackBars = function (props) {
24
24
  var _a;
25
- var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, 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;
26
- var _e = useRenderStackBars(props), 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;
25
+ var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, 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;
26
+ 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;
27
27
  var renderLabel = function (label, labelTextStyle) {
28
28
  return (_jsx(View, { style: [
29
29
  {
@@ -116,7 +116,7 @@ var RenderStackBars = function (props) {
116
116
  ] })) : null, stackItem.innerBarComponent && stackItem.innerBarComponent()] }, index));
117
117
  }), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
118
118
  ? item.barBackgroundPattern()
119
- : barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "1", y: "1", width: "100%", height: "100%", fill: "url(#".concat(item.patternId || patternId, ")") })] }))] }), localBarInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: localBarInnerComponent(item, index) })) : null, (item.topLabelComponent || showValuesAsTopLabel) && (_jsx(View, { style: [
119
+ : barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "1", y: "1", width: "100%", height: totalHeight, fill: "url(#".concat(item.patternId || patternId, ")") })] }))] }), localBarInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: localBarInnerComponent(item, index) })) : null, (item.topLabelComponent || showValuesAsTopLabel) && (_jsx(View, { style: [
120
120
  {
121
121
  position: 'absolute',
122
122
  top: containsNegativeValue
@@ -152,17 +152,13 @@ var RenderStackBars = function (props) {
152
152
  width: item.stacks[0].barWidth || props.barWidth || 30,
153
153
  height: totalHeight,
154
154
  marginRight: spacing,
155
+ transform: [
156
+ {
157
+ translateY: (containerHeight || 200) -
158
+ (totalHeight - 10 + xAxisLabelsVerticalShift),
159
+ },
160
+ ],
155
161
  },
156
- props.pointerConfig
157
- ? {
158
- transform: [
159
- {
160
- translateY: (containerHeight || 200) -
161
- (totalHeight - 10 + xAxisLabelsVerticalShift),
162
- },
163
- ],
164
- }
165
- : null,
166
162
  ], children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
167
163
  zIndex: 2,
168
164
  position: 'absolute',
@@ -109,6 +109,14 @@ export var BarChart = function (props) {
109
109
  containsNegative: false,
110
110
  });
111
111
  };
112
+ var contentContainerStyle = {
113
+ position: 'absolute',
114
+ height: containerHeightIncludingBelowXAxis,
115
+ bottom: 60,
116
+ paddingLeft: initialSpacing,
117
+ width: totalWidth,
118
+ flexDirection: 'row',
119
+ };
112
120
  var renderChartContent = function () {
113
121
  if (pointerConfig) {
114
122
  return (_jsxs(View, { onStartShouldSetResponder: function () { return !!pointerConfig; }, onMoveShouldSetResponder: function () { return !!pointerConfig; }, onResponderGrant: function (evt) {
@@ -190,14 +198,7 @@ export var BarChart = function (props) {
190
198
  setResponderActive(false);
191
199
  if (!persistPointer)
192
200
  setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
193
- }, onResponderTerminationRequest: function (evt) { return false; }, style: {
194
- position: 'absolute',
195
- height: containerHeightIncludingBelowXAxis,
196
- bottom: 60,
197
- paddingLeft: initialSpacing,
198
- width: totalWidth,
199
- flexDirection: 'row',
200
- }, children: [pointerX > 0 && stripBehindBars ? (_jsx(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: {
201
+ }, onResponderTerminationRequest: function (evt) { return false; }, style: contentContainerStyle, children: [pointerX > 0 && stripBehindBars ? (_jsx(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: {
201
202
  position: 'absolute',
202
203
  height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
203
204
  bottom: xAxisLabelsVerticalShift + labelsExtraHeight,
@@ -217,7 +218,7 @@ export var BarChart = function (props) {
217
218
  ] })) : null] }));
218
219
  }
219
220
  else {
220
- return renderChart();
221
+ return _jsx(View, { style: contentContainerStyle, children: renderChart() });
221
222
  }
222
223
  };
223
224
  var renderChart = function () {
@@ -1,3 +1,28 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
1
26
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
27
  import { Text, View } from 'react-native';
3
28
  import Rule from '../lineSvg';
@@ -8,6 +33,7 @@ export var renderHorizSections = function (props) {
8
33
  var chartType = props.chartType, width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, xAxisThickness = props.xAxisThickness, xAxisColor = props.xAxisColor, xAxisLength = props.xAxisLength, xAxisType = props.xAxisType, dashWidth = props.dashWidth, dashGap = props.dashGap, backgroundColor = props.backgroundColor, hideRules = props.hideRules, rulesLength = props.rulesLength, rulesType = props.rulesType, rulesThickness = props.rulesThickness, rulesColor = props.rulesColor, rulesConfigArray = props.rulesConfigArray, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisTextStyle = props.yAxisTextStyle, rotateYAxisTexts = props.rotateYAxisTexts, rtl = props.rtl, containerHeight = props.containerHeight, maxValue = props.maxValue, yAxisOffset = props.yAxisOffset, horizontal = props.horizontal, yAxisAtTop = props.yAxisAtTop, secondaryYAxis = props.secondaryYAxis, onlyReferenceLines = props.onlyReferenceLines, renderReferenceLines = props.renderReferenceLines, secondaryXAxis = props.secondaryXAxis;
9
34
  var _e = getHorizSectionVals(props), secondaryYAxisConfig = _e.secondaryYAxisConfig, horizSections = _e.horizSections, yAxisExtraHeightAtTop = _e.yAxisExtraHeightAtTop, secondaryHorizSections = _e.secondaryHorizSections, showReferenceLine1 = _e.showReferenceLine1, referenceLine1Config = _e.referenceLine1Config, referenceLine1Position = _e.referenceLine1Position, showReferenceLine2 = _e.showReferenceLine2, referenceLine2Config = _e.referenceLine2Config, referenceLine2Position = _e.referenceLine2Position, showReferenceLine3 = _e.showReferenceLine3, referenceLine3Config = _e.referenceLine3Config, referenceLine3Position = _e.referenceLine3Position, horizSectionsBelow = _e.horizSectionsBelow, secondaryHorizSectionsBelow = _e.secondaryHorizSectionsBelow, getLabelTexts = _e.getLabelTexts, getLabelTextsForSecondaryYAxis = _e.getLabelTextsForSecondaryYAxis;
10
35
  var secondaryYAxisExtraHeightAtBottom = 10;
36
+ var negativeSectionsCountDiffPrimaryVsSecondary = secondaryHorizSectionsBelow.length - horizSectionsBelow.length;
11
37
  var renderAxesAndRules = function (index) {
12
38
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
13
39
  var invertedIndex = horizSections.length - index - 1;
@@ -170,13 +196,50 @@ export var renderHorizSections = function (props) {
170
196
  referenceLine3Config.labelTextStyle,
171
197
  ], children: referenceLine3Config.labelText })) : null] })) : null] }));
172
198
  };
199
+ var horizSectionsBelowRenderer = function (index, showBorder) {
200
+ var _a;
201
+ // negative sections height will correspond to negative Y-axis config in case there are extra negative horiz sections corresponding to the secondary Y axis
202
+ var localNegativeStepHeight = !showBorder
203
+ ? ((_a = secondaryYAxisConfig.negativeStepHeight) !== null && _a !== void 0 ? _a : negativeStepHeight)
204
+ : negativeStepHeight;
205
+ return (_jsxs(View, { style: [
206
+ styles.horizBar,
207
+ {
208
+ width: (width !== null && width !== void 0 ? width : totalWidth) + 15,
209
+ },
210
+ index === 0 && { marginTop: localNegativeStepHeight / 2 },
211
+ ], children: [_jsx(View, { style: [
212
+ styles.leftLabel,
213
+ {
214
+ marginLeft: yAxisThickness,
215
+ },
216
+ showBorder && {
217
+ borderRightWidth: yAxisThickness,
218
+ borderColor: yAxisColor,
219
+ },
220
+ {
221
+ height: index === 0
222
+ ? localNegativeStepHeight * 1.5
223
+ : localNegativeStepHeight,
224
+ width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
225
+ },
226
+ index === 0 && { marginTop: -localNegativeStepHeight / 2 },
227
+ ] }), _jsx(View, { style: [styles.leftPart, { backgroundColor: backgroundColor }], children: hideRules ? null : (_jsx(Rule, { config: {
228
+ thickness: rulesThickness,
229
+ color: rulesColor,
230
+ width: rulesLength ||
231
+ (props.width || totalWidth - spacing) + endSpacing,
232
+ dashWidth: dashWidth,
233
+ dashGap: dashGap,
234
+ type: rulesType,
235
+ } })) })] }, index));
236
+ };
173
237
  var leftShiftForRIghtYaxis = (width ? width + 20 : totalWidth) +
174
238
  yAxisLabelWidth / 2 +
175
239
  endSpacing -
176
240
  (chartType === chartTypes.BAR ? 40 : 60);
177
241
  return (_jsx(_Fragment, { children: onlyReferenceLines ? (_jsx(View, { style: {
178
242
  flexDirection: 'row',
179
- backgroundColor: 'green',
180
243
  }, children: _jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: referenceLines() }) })) : (_jsxs(View, { pointerEvents: "none", style: {
181
244
  flexDirection: 'row',
182
245
  marginTop: stepHeight / -2,
@@ -249,54 +312,31 @@ export var renderHorizSections = function (props) {
249
312
  })
250
313
  /***********************************************************************************************/
251
314
  /***********************************************************************************************/
252
- , horizSectionsBelow.map(function (sectionItems, index) {
253
- return (_jsxs(View, { style: [
254
- styles.horizBar,
255
- {
256
- width: (width !== null && width !== void 0 ? width : totalWidth) + 15,
257
- },
258
- index === 0 && { marginTop: negativeStepHeight / 2 },
259
- ], children: [_jsx(View, { style: [
260
- styles.leftLabel,
261
- {
262
- borderRightWidth: yAxisThickness,
263
- borderColor: yAxisColor,
264
- marginLeft: yAxisThickness,
265
- },
266
- {
267
- height: index === 0
268
- ? negativeStepHeight * 1.5
269
- : negativeStepHeight,
270
- width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
271
- },
272
- index === 0 && { marginTop: -negativeStepHeight / 2 },
273
- ] }), _jsx(View, { style: [
274
- styles.leftPart,
275
- { backgroundColor: backgroundColor },
276
- ], children: hideRules ? null : (_jsx(Rule, { config: {
277
- thickness: rulesThickness,
278
- color: rulesColor,
279
- width: rulesLength ||
280
- (props.width || totalWidth - spacing) + endSpacing,
281
- dashWidth: dashWidth,
282
- dashGap: dashGap,
283
- type: rulesType,
284
- } })) })] }, index));
315
+ , horizSectionsBelow.map(function (_, index) {
316
+ return horizSectionsBelowRenderer(index, true);
285
317
  }),
286
318
  /***********************************************************************************************/
319
+ /* If more -ve sections in Secondary Y-axis, then we need to render the Rules for them */
320
+ /***********************************************************************************************/
321
+ secondaryYAxis && negativeSectionsCountDiffPrimaryVsSecondary > 0
322
+ ? __spreadArray([], __read(Array(negativeSectionsCountDiffPrimaryVsSecondary).keys()), false).map(function (_, index) { return horizSectionsBelowRenderer(index, false); })
323
+ : null,
324
+ /***********************************************************************************************/
287
325
  /************************* Render the y axis labels below origin *********************/
288
326
  /***********************************************************************************************/
289
327
  !hideYAxisText &&
290
- horizSectionsBelow.map(function (sectionItems, index) {
291
- var label = getLabelTexts(horizSectionsBelow[horizSectionsBelow.length - 1 - index]
292
- .value, index);
328
+ horizSectionsBelow.map(function (_, index) {
329
+ var invertedIndex = horizSectionsBelow.length - 1 - index;
330
+ var label = getLabelTexts(horizSectionsBelow[invertedIndex].value, index);
293
331
  return (_jsx(View, { style: [
294
332
  styles.horizBar,
295
333
  styles.leftLabel,
296
334
  {
297
335
  position: 'absolute',
298
336
  zIndex: 1,
299
- bottom: negativeStepHeight * index,
337
+ top: containerHeight +
338
+ negativeStepHeight * (invertedIndex + 1) +
339
+ yAxisExtraHeightAtTop,
300
340
  width: yAxisLabelWidth,
301
341
  height: index === noOfSectionsBelowXAxis
302
342
  ? negativeStepHeight / 2
@@ -332,7 +372,7 @@ export var renderHorizSections = function (props) {
332
372
  /***********************************************************************************************/
333
373
  /************************* Render the secondary Y Axis below origin *********************/
334
374
  /***********************************************************************************************/
335
- secondaryYAxisConfig.noOfSectionsBelowXAxis ? (_jsx(View, { style: {
375
+ secondaryYAxis && secondaryYAxisConfig.noOfSectionsBelowXAxis ? (_jsx(View, { style: {
336
376
  width: (_a = secondaryYAxisConfig.yAxisLabelWidth) !== null && _a !== void 0 ? _a : yAxisLabelWidth,
337
377
  left: (width ? yAxisLabelWidth : yAxisLabelWidth - spacing) -
338
378
  ((_b = secondaryYAxisConfig.yAxisLabelWidth) !== null && _b !== void 0 ? _b : yAxisLabelWidth),
@@ -24,7 +24,7 @@ export var StripAndLabel = function (props) {
24
24
  : -pointerYLocal + 8,
25
25
  width: pointerStripWidth,
26
26
  height: pointerStripUptoDataPoint
27
- ? containerHeight - pointerYLocal + 10 - xAxisThickness
27
+ ? containerHeight - pointerYLocal + 4 - xAxisThickness
28
28
  : pointerStripHeight + (containsNegative ? 10 : 0),
29
29
  marginTop: pointerStripUptoDataPoint
30
30
  ? 0
@@ -34,7 +34,7 @@ export var StripAndLabel = function (props) {
34
34
  }, children: _jsx(Svg, { children: _jsx(Line, { stroke: pointerStripColor, strokeWidth: pointerStripWidth, strokeDasharray: (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.strokeDashArray)
35
35
  ? pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.strokeDashArray
36
36
  : '', x1: 0, y1: 0, x2: 0, y2: pointerStripUptoDataPoint
37
- ? containerHeight - pointerYLocal + 10 - xAxisThickness
37
+ ? containerHeight - pointerYLocal + 4 - xAxisThickness
38
38
  : pointerStripHeight + 10 }) }) })) : null, pointerLabelComponent ? (_jsx(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: [
39
39
  {
40
40
  position: 'absolute',
@@ -248,7 +248,7 @@ export var LineChartBicolor = function (props) {
248
248
  ? fillPointsArray.map(function (item, index) {
249
249
  return (_jsx(Path, { d: item.points, fill: item.color === 'green'
250
250
  ? 'url(#Gradient)'
251
- : 'url(#GradientNegative)', stroke: 'transparent', strokeWidth: currentLineThickness || thickness }, index));
251
+ : 'url(#GradientNegative)', stroke: 'none', strokeWidth: currentLineThickness || thickness }, index));
252
252
  })
253
253
  : null, renderSpecificVerticalLines(data), !hideDataPoints1
254
254
  ? renderDataPoints(data, dataPointsShape1, dataPointsWidth1, dataPointsHeight1, dataPointsColor1, dataPointsRadius1, textColor1, textFontSize1, startIndex1, endIndex1)
@@ -196,7 +196,7 @@ export var LineChart = function (props) {
196
196
  ]);
197
197
  var svgWrapperViewStyle = {
198
198
  position: 'absolute',
199
- bottom: 62 +
199
+ bottom: 63 +
200
200
  xAxisLabelsVerticalShift +
201
201
  labelsExtraHeight -
202
202
  xAxisThickness -
@@ -262,7 +262,7 @@ export var LineChart = function (props) {
262
262
  var getYOrSecondaryY = isSecondary ? getSecondaryY : getY;
263
263
  return dataForRender.map(function (item, index) {
264
264
  var _a;
265
- var _b, _c, _d, _e, _f;
265
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
266
266
  if (index < startIndex || index > endIndex)
267
267
  return null;
268
268
  if (item.hideDataPoint) {
@@ -290,10 +290,7 @@ export var LineChart = function (props) {
290
290
  props.focusedDataPointColor ||
291
291
  LineDefaults.focusedDataPointColor;
292
292
  dataPointsRadius =
293
- item.focusedDataPointRadius ||
294
- props.focusedDataPointRadius ||
295
- item.dataPointRadius ||
296
- dataPtsRadius;
293
+ (_d = (_c = (_b = item.focusedDataPointRadius) !== null && _b !== void 0 ? _b : props.focusedDataPointRadius) !== null && _c !== void 0 ? _c : item.dataPointRadius) !== null && _d !== void 0 ? _d : dataPtsRadius;
297
294
  if (showTextOnFocus) {
298
295
  text = item.dataPointText;
299
296
  }
@@ -310,7 +307,7 @@ export var LineChart = function (props) {
310
307
  dataPointsWidth = item.dataPointWidth || dataPtsWidth;
311
308
  dataPointsHeight = item.dataPointHeight || dataPtsHeight;
312
309
  dataPointsColor = item.dataPointColor || dataPtsColor;
313
- dataPointsRadius = item.dataPointRadius || dataPtsRadius;
310
+ dataPointsRadius = (_e = item.dataPointRadius) !== null && _e !== void 0 ? _e : dataPtsRadius;
314
311
  if (showTextOnFocus) {
315
312
  text = '';
316
313
  }
@@ -320,10 +317,10 @@ export var LineChart = function (props) {
320
317
  if (showValuesAsDataPointsText) {
321
318
  text = originalDataFromProps[index].value;
322
319
  }
323
- var currentStripHeight = (_b = item.stripHeight) !== null && _b !== void 0 ? _b : stripHeight;
324
- var currentStripWidth = (_c = item.stripWidth) !== null && _c !== void 0 ? _c : stripWidth;
325
- var currentStripOpacity = (_d = item.stripOpacity) !== null && _d !== void 0 ? _d : stripOpacity;
326
- var currentStripStrokeDashArray = (_f = (_e = item.stripStrokeDashArray) !== null && _e !== void 0 ? _e : stripStrokeDashArray) !== null && _f !== void 0 ? _f : '';
320
+ var currentStripHeight = (_f = item.stripHeight) !== null && _f !== void 0 ? _f : stripHeight;
321
+ var currentStripWidth = (_g = item.stripWidth) !== null && _g !== void 0 ? _g : stripWidth;
322
+ var currentStripOpacity = (_h = item.stripOpacity) !== null && _h !== void 0 ? _h : stripOpacity;
323
+ var currentStripStrokeDashArray = (_k = (_j = item.stripStrokeDashArray) !== null && _j !== void 0 ? _j : stripStrokeDashArray) !== null && _k !== void 0 ? _k : '';
327
324
  var currentStripColor = item.stripColor || stripColor;
328
325
  var position = I18nManager.isRTL ? 'right' : 'left';
329
326
  var y1 = currentStripHeight
@@ -765,7 +762,7 @@ export var LineChart = function (props) {
765
762
  onResponderEnd: function (evt) {
766
763
  // console.log('evt...end.......',evt);
767
764
  setResponderStartTime(0);
768
- setPointerIndex(-1);
765
+ // setPointerIndex(-1);
769
766
  setResponderActive(false);
770
767
  if (!persistPointer)
771
768
  setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
@@ -818,7 +815,7 @@ export var LineChart = function (props) {
818
815
  onResponderEnd: function (evt) {
819
816
  // console.log('evt...end.......',evt);
820
817
  setResponderStartTime(0);
821
- setPointerIndex(-1);
818
+ // setPointerIndex(-1);
822
819
  setResponderActive(false);
823
820
  if (!persistPointer)
824
821
  setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { View } from 'react-native';
13
+ import { Platform, View } from 'react-native';
14
14
  import { PieChartMain } from './main';
15
15
  import { pieColors, usePieChart } from 'gifted-charts-core';
16
16
  export var PieChart = function (props) {
@@ -77,7 +77,7 @@ export var PieChart = function (props) {
77
77
  position: 'absolute',
78
78
  top: -extraRadius,
79
79
  left: -extraRadius,
80
- zIndex: -1, // was not getting displayed in web (using Expo)
80
+ zIndex: Platform.OS === 'web' ? -1 : 0, // was not getting displayed in web (using Expo)
81
81
  }, children: _jsx(PieChartMain, __assign({}, props, { data: [
82
82
  {
83
83
  value: props.data[selectedIndex].value,
@@ -57,7 +57,7 @@ export var PieChartMain = function (props) {
57
57
  : item.strokeWidth === 0
58
58
  ? 0
59
59
  : item.strokeWidth || strokeWidth, fill: props.selectedIndex === index || item.peripheral
60
- ? 'transparent'
60
+ ? 'none'
61
61
  : showGradient
62
62
  ? "url(#grad".concat(index, ")")
63
63
  : item.color || pieColors[index % 9], onPressIn: function () {
@@ -71,10 +71,10 @@ export var PieChartPro = function (props) {
71
71
  }) }), data.map(function (item, index) {
72
72
  var _a, _b, _c, _d;
73
73
  var borderWidth = (_a = item.strokeWidth) !== null && _a !== void 0 ? _a : strokeWidth;
74
- var borderColor = (_c = (_b = item.strokeColor) !== null && _b !== void 0 ? _b : props.strokeColor) !== null && _c !== void 0 ? _c : (borderWidth ? 'black' : 'transparent');
74
+ var borderColor = (_c = (_b = item.strokeColor) !== null && _b !== void 0 ? _b : props.strokeColor) !== null && _c !== void 0 ? _c : (borderWidth ? 'black' : 'none');
75
75
  var strokeDashArrayLocal = (_d = item.strokeDashArray) !== null && _d !== void 0 ? _d : strokeDashArray;
76
76
  return (_jsx(AnimatedPath, { id: "renderPath", d: isAnimated ? animatedPaths[index] : dFinal[index], fill: ring
77
- ? 'transparent'
77
+ ? 'none'
78
78
  : showGradient
79
79
  ? "url(#grad".concat(index, ")")
80
80
  : data[index].color || pieColors[index % 9], strokeWidth: borderWidth, strokeDasharray: strokeDashArrayLocal, stroke: borderColor }, "path".concat(index)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.4.33",
3
+ "version": "1.4.35",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  },
27
27
  "dependencies": {
28
- "gifted-charts-core": "^0.1.34"
28
+ "gifted-charts-core": "^0.1.36"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/cli": "^7.24.8",