react-native-gifted-charts 1.4.34 → 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.
|
|
25
|
-
?
|
|
26
|
-
|
|
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 &&
|
|
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
|
{
|
|
@@ -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',
|
package/dist/BarChart/index.js
CHANGED
|
@@ -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 (
|
|
253
|
-
return (
|
|
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 (
|
|
291
|
-
var
|
|
292
|
-
|
|
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
|
-
|
|
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),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.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.
|
|
28
|
+
"gifted-charts-core": "^0.1.36"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/cli": "^7.24.8",
|