react-native-gifted-charts 1.4.20 → 1.4.22
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 +4 -3
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +113 -0
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +264 -0
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +172 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +233 -0
- package/dist/BarChart/styles.d.ts +45 -0
- package/dist/BarChart/styles.js +46 -0
- package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
- package/dist/Components/AnimatedThreeDBar/index.js +129 -0
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +13 -0
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +128 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
- package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/cap.js +16 -0
- package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +40 -0
- package/dist/Components/common/LinearGradient.d.ts +16 -0
- package/dist/Components/common/LinearGradient.js +15 -0
- package/dist/Components/common/Pointer.d.ts +1 -0
- package/dist/Components/common/Pointer.js +16 -0
- package/dist/Components/common/StripAndLabel.d.ts +1 -0
- package/dist/Components/common/StripAndLabel.js +43 -0
- package/dist/Components/lineSvg.d.ts +14 -0
- package/dist/Components/lineSvg.js +22 -0
- package/dist/LineChart/LineChartBicolor.d.ts +2 -0
- package/dist/LineChart/LineChartBicolor.js +294 -0
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1089 -0
- package/dist/LineChart/styles.d.ts +43 -0
- package/dist/LineChart/styles.js +46 -0
- package/dist/PieChart/index.d.ts +2 -0
- package/dist/PieChart/index.js +99 -0
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +182 -0
- package/dist/PieChartPro/index.d.ts +2 -0
- package/dist/PieChartPro/index.js +124 -0
- package/dist/PopulationPyramid/index.d.ts +2 -0
- package/dist/PopulationPyramid/index.js +130 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +12 -0
- package/package.json +21 -20
- package/src/BarChart/Animated2DWithGradient.tsx +0 -197
- package/src/BarChart/RenderBars.tsx +0 -527
- package/src/BarChart/RenderStackBars.tsx +0 -359
- package/src/BarChart/index.tsx +0 -391
- package/src/BarChart/styles.tsx +0 -47
- package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
- package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
- package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
- package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
- package/src/Components/BarSpecificComponents/cap.tsx +0 -34
- package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
- package/src/Components/common/LinearGradient.tsx +0 -27
- package/src/Components/common/Pointer.tsx +0 -37
- package/src/Components/common/StripAndLabel.tsx +0 -98
- package/src/Components/lineSvg.tsx +0 -42
- package/src/LineChart/LineChartBicolor.tsx +0 -740
- package/src/LineChart/index.tsx +0 -2231
- package/src/LineChart/styles.tsx +0 -47
- package/src/PieChart/index.tsx +0 -168
- package/src/PieChart/main.tsx +0 -363
- package/src/PieChartPro/index.tsx +0 -267
- package/src/PopulationPyramid/index.tsx +0 -603
- package/src/index.tsx +0 -26
- package/src/todos.md +0 -24
- package/src/utils/index.ts +0 -16
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import Rule from '../lineSvg';
|
|
4
|
+
import { styles } from '../../LineChart/styles';
|
|
5
|
+
import { getHorizSectionVals, yAxisSides, chartTypes, } from 'gifted-charts-core';
|
|
6
|
+
export var renderHorizSections = function (props) {
|
|
7
|
+
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;
|
|
8
|
+
var _a = getHorizSectionVals(props), secondaryYAxisConfig = _a.secondaryYAxisConfig, horizSections = _a.horizSections, yAxisExtraHeightAtTop = _a.yAxisExtraHeightAtTop, secondaryHorizSections = _a.secondaryHorizSections, showReferenceLine1 = _a.showReferenceLine1, referenceLine1Config = _a.referenceLine1Config, referenceLine1Position = _a.referenceLine1Position, showReferenceLine2 = _a.showReferenceLine2, referenceLine2Config = _a.referenceLine2Config, referenceLine2Position = _a.referenceLine2Position, showReferenceLine3 = _a.showReferenceLine3, referenceLine3Config = _a.referenceLine3Config, referenceLine3Position = _a.referenceLine3Position, horizSectionsBelow = _a.horizSectionsBelow, secondaryHorizSectionsBelow = _a.secondaryHorizSectionsBelow, getLabelTexts = _a.getLabelTexts, getLabelTextsForSecondaryYAxis = _a.getLabelTextsForSecondaryYAxis;
|
|
9
|
+
var renderAxesAndRules = function (index) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
11
|
+
var invertedIndex = horizSections.length - index - 1;
|
|
12
|
+
return (_jsxs(View, { style: [
|
|
13
|
+
index === noOfSections
|
|
14
|
+
? styles.lastLeftPart
|
|
15
|
+
: !index
|
|
16
|
+
? { justifyContent: 'flex-start' }
|
|
17
|
+
: styles.leftPart,
|
|
18
|
+
{
|
|
19
|
+
borderColor: yAxisColor,
|
|
20
|
+
backgroundColor: (_a = sectionColors === null || sectionColors === void 0 ? void 0 : sectionColors[invertedIndex]) !== null && _a !== void 0 ? _a : backgroundColor,
|
|
21
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
22
|
+
},
|
|
23
|
+
!index ? { height: stepHeight / 2, marginTop: stepHeight / 2 } : null,
|
|
24
|
+
yAxisSide === yAxisSides.RIGHT
|
|
25
|
+
? { borderRightWidth: yAxisThickness }
|
|
26
|
+
: { borderLeftWidth: yAxisThickness },
|
|
27
|
+
], children: [index === noOfSections ? (_jsx(Rule, { config: {
|
|
28
|
+
thickness: xAxisThickness,
|
|
29
|
+
color: xAxisColor,
|
|
30
|
+
width: xAxisLength ||
|
|
31
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
32
|
+
dashWidth: dashWidth,
|
|
33
|
+
dashGap: dashGap,
|
|
34
|
+
type: xAxisType,
|
|
35
|
+
} })) : hideRules ? null : (_jsx(Rule, { config: {
|
|
36
|
+
thickness: (_c = (_b = rulesConfigArray[invertedIndex]) === null || _b === void 0 ? void 0 : _b.rulesThickness) !== null && _c !== void 0 ? _c : rulesThickness,
|
|
37
|
+
color: (_e = (_d = rulesConfigArray[invertedIndex]) === null || _d === void 0 ? void 0 : _d.rulesColor) !== null && _e !== void 0 ? _e : rulesColor,
|
|
38
|
+
width: (_h = (_g = (_f = rulesConfigArray[invertedIndex]) === null || _f === void 0 ? void 0 : _f.rulesLength) !== null && _g !== void 0 ? _g : rulesLength) !== null && _h !== void 0 ? _h : (props.width || totalWidth - spacing) + endSpacing,
|
|
39
|
+
dashWidth: (_k = (_j = rulesConfigArray[invertedIndex]) === null || _j === void 0 ? void 0 : _j.dashWidth) !== null && _k !== void 0 ? _k : dashWidth,
|
|
40
|
+
dashGap: (_m = (_l = rulesConfigArray[invertedIndex]) === null || _l === void 0 ? void 0 : _l.dashGap) !== null && _m !== void 0 ? _m : dashGap,
|
|
41
|
+
type: (_p = (_o = rulesConfigArray[invertedIndex]) === null || _o === void 0 ? void 0 : _o.rulesType) !== null && _p !== void 0 ? _p : rulesType,
|
|
42
|
+
} })), showYAxisIndices && index !== noOfSections ? (_jsx(View, { style: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
height: yAxisIndicesHeight,
|
|
45
|
+
width: yAxisIndicesWidth,
|
|
46
|
+
left: yAxisIndicesWidth / -2 +
|
|
47
|
+
(yAxisSide === yAxisSides.RIGHT
|
|
48
|
+
? (width !== null && width !== void 0 ? width : totalWidth) +
|
|
49
|
+
yAxisLabelWidth / 2 +
|
|
50
|
+
yAxisIndicesWidth / 4
|
|
51
|
+
: 0),
|
|
52
|
+
backgroundColor: yAxisIndicesColor,
|
|
53
|
+
} })) : null] }));
|
|
54
|
+
};
|
|
55
|
+
var renderExtraHeightOfYAxisAtTop = function () {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return (_jsxs(View, { style: [
|
|
58
|
+
styles.horizBar,
|
|
59
|
+
{
|
|
60
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
|
|
61
|
+
top: stepHeight / 2,
|
|
62
|
+
},
|
|
63
|
+
horizontal &&
|
|
64
|
+
!yAxisAtTop && {
|
|
65
|
+
transform: [{ rotateY: '180deg' }],
|
|
66
|
+
},
|
|
67
|
+
horizontalRulesStyle,
|
|
68
|
+
], children: [_jsx(View, { style: [
|
|
69
|
+
styles.leftLabel,
|
|
70
|
+
{
|
|
71
|
+
height: yAxisExtraHeightAtTop,
|
|
72
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
73
|
+
},
|
|
74
|
+
yAxisLabelContainerStyle,
|
|
75
|
+
] }), _jsx(View, { style: [
|
|
76
|
+
styles.leftPart,
|
|
77
|
+
{
|
|
78
|
+
borderLeftColor: yAxisColor,
|
|
79
|
+
borderRightColor: yAxisColor,
|
|
80
|
+
borderTopColor: (_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.color) !== null && _a !== void 0 ? _a : xAxisColor,
|
|
81
|
+
borderTopWidth: secondaryXAxis
|
|
82
|
+
? (_b = secondaryXAxis.thickness) !== null && _b !== void 0 ? _b : xAxisThickness
|
|
83
|
+
: 0,
|
|
84
|
+
backgroundColor: backgroundColor,
|
|
85
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
86
|
+
},
|
|
87
|
+
yAxisSide === yAxisSides.RIGHT
|
|
88
|
+
? { borderRightWidth: yAxisThickness }
|
|
89
|
+
: { borderLeftWidth: yAxisThickness },
|
|
90
|
+
] })] }));
|
|
91
|
+
};
|
|
92
|
+
var renderSecondaryYaxisLabels = function (horizSections, isBelow) {
|
|
93
|
+
return horizSections.map(function (sectionItems, index) {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
var label = getLabelTextsForSecondaryYAxis(sectionItems.value, index);
|
|
96
|
+
if (secondaryYAxisConfig.hideOrigin && index === 0) {
|
|
97
|
+
label = '';
|
|
98
|
+
}
|
|
99
|
+
return (_jsxs(View, { style: [
|
|
100
|
+
styles.horizBar,
|
|
101
|
+
styles.leftLabel,
|
|
102
|
+
{
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
zIndex: 1,
|
|
105
|
+
bottom: ((_a = secondaryYAxisConfig.stepHeight) !== null && _a !== void 0 ? _a : 0) *
|
|
106
|
+
((isBelow ? 0 : noOfSectionsBelowXAxis) +
|
|
107
|
+
index -
|
|
108
|
+
(noOfSectionsBelowXAxis ? 0 : 0.5)),
|
|
109
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
110
|
+
height: (_b = secondaryYAxisConfig.stepHeight) !== null && _b !== void 0 ? _b : 0,
|
|
111
|
+
},
|
|
112
|
+
yAxisLabelContainerStyle,
|
|
113
|
+
], children: [secondaryYAxisConfig.showYAxisIndices && index !== 0 ? (_jsx(View, { style: {
|
|
114
|
+
height: secondaryYAxisConfig.yAxisIndicesHeight,
|
|
115
|
+
width: secondaryYAxisConfig.yAxisIndicesWidth,
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
left: ((_c = secondaryYAxisConfig.yAxisIndicesWidth) !== null && _c !== void 0 ? _c : 0) / -2,
|
|
118
|
+
backgroundColor: secondaryYAxisConfig.yAxisIndicesColor,
|
|
119
|
+
} })) : null, _jsx(Text, { numberOfLines: secondaryYAxisConfig.yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [secondaryYAxisConfig.yAxisTextStyle], children: label })] }, index));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var referenceLines = function () {
|
|
123
|
+
return (_jsxs(_Fragment, { children: [showReferenceLine1 ? (_jsxs(View, { style: {
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
zIndex: referenceLine1Config.zIndex,
|
|
126
|
+
bottom: ((referenceLine1Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
127
|
+
containerHeight) /
|
|
128
|
+
maxValue,
|
|
129
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
130
|
+
? 0
|
|
131
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
132
|
+
}, children: [_jsx(Rule, { config: referenceLine1Config }), referenceLine1Config.labelText ? (_jsx(Text, { style: [
|
|
133
|
+
{ position: 'absolute' },
|
|
134
|
+
referenceLine1Config.labelTextStyle,
|
|
135
|
+
], children: referenceLine1Config.labelText })) : null] })) : null, showReferenceLine2 ? (_jsxs(View, { style: {
|
|
136
|
+
position: 'absolute',
|
|
137
|
+
zIndex: referenceLine2Config.zIndex,
|
|
138
|
+
bottom: ((referenceLine2Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
139
|
+
containerHeight) /
|
|
140
|
+
maxValue,
|
|
141
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
142
|
+
? 0
|
|
143
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
144
|
+
}, children: [_jsx(Rule, { config: referenceLine2Config }), referenceLine2Config.labelText ? (_jsx(Text, { style: [
|
|
145
|
+
{ position: 'absolute' },
|
|
146
|
+
referenceLine2Config.labelTextStyle,
|
|
147
|
+
], children: referenceLine2Config.labelText })) : null] })) : null, showReferenceLine3 ? (_jsxs(View, { style: {
|
|
148
|
+
position: 'absolute',
|
|
149
|
+
zIndex: referenceLine3Config.zIndex,
|
|
150
|
+
bottom: ((referenceLine3Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
151
|
+
containerHeight) /
|
|
152
|
+
maxValue,
|
|
153
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
154
|
+
? 0
|
|
155
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
156
|
+
}, children: [_jsx(Rule, { config: referenceLine3Config }), referenceLine3Config.labelText ? (_jsx(Text, { style: [
|
|
157
|
+
{ position: 'absolute' },
|
|
158
|
+
referenceLine3Config.labelTextStyle,
|
|
159
|
+
], children: referenceLine3Config.labelText })) : null] })) : null] }));
|
|
160
|
+
};
|
|
161
|
+
var leftShiftForRIghtYaxis = (width ? width + 20 : totalWidth) +
|
|
162
|
+
yAxisLabelWidth / 2 +
|
|
163
|
+
endSpacing -
|
|
164
|
+
(chartType === chartTypes.BAR ? 40 : 60);
|
|
165
|
+
return (_jsx(_Fragment, { children: onlyReferenceLines ? (_jsx(View, { style: {
|
|
166
|
+
flexDirection: 'row',
|
|
167
|
+
backgroundColor: 'green',
|
|
168
|
+
}, children: _jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: referenceLines() }) })) : (_jsxs(View, { pointerEvents: "none", style: {
|
|
169
|
+
flexDirection: 'row',
|
|
170
|
+
marginTop: stepHeight / -2,
|
|
171
|
+
}, children: [_jsxs(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: [yAxisExtraHeightAtTop ? renderExtraHeightOfYAxisAtTop() : null, horizSections.map(function (sectionItems, index) {
|
|
172
|
+
return (_jsxs(View, { style: [
|
|
173
|
+
styles.horizBar,
|
|
174
|
+
{
|
|
175
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
|
|
176
|
+
},
|
|
177
|
+
horizontal &&
|
|
178
|
+
!yAxisAtTop && {
|
|
179
|
+
transform: [{ rotateY: '180deg' }],
|
|
180
|
+
},
|
|
181
|
+
horizontalRulesStyle,
|
|
182
|
+
], children: [_jsx(View, { style: [
|
|
183
|
+
styles.leftLabel,
|
|
184
|
+
{
|
|
185
|
+
height: index === noOfSections ? stepHeight / 2 : stepHeight,
|
|
186
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
187
|
+
},
|
|
188
|
+
yAxisLabelContainerStyle,
|
|
189
|
+
] }), renderAxesAndRules(index)] }, index));
|
|
190
|
+
}),
|
|
191
|
+
/***********************************************************************************************/
|
|
192
|
+
/************************** Render the y axis labels separately **********************/
|
|
193
|
+
/***********************************************************************************************/
|
|
194
|
+
!hideYAxisText &&
|
|
195
|
+
horizSections.map(function (sectionItems, index) {
|
|
196
|
+
var label = getLabelTexts(sectionItems.value, index);
|
|
197
|
+
if (hideOrigin && index === horizSections.length - 1) {
|
|
198
|
+
label = '';
|
|
199
|
+
}
|
|
200
|
+
return (_jsx(View, { style: [
|
|
201
|
+
styles.horizBar,
|
|
202
|
+
styles.leftLabel,
|
|
203
|
+
{
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
zIndex: 1,
|
|
206
|
+
top: stepHeight * index + yAxisExtraHeightAtTop,
|
|
207
|
+
width: yAxisLabelWidth,
|
|
208
|
+
height: index === noOfSections
|
|
209
|
+
? stepHeight / 2
|
|
210
|
+
: stepHeight,
|
|
211
|
+
},
|
|
212
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
213
|
+
left: leftShiftForRIghtYaxis,
|
|
214
|
+
},
|
|
215
|
+
horizontal &&
|
|
216
|
+
!yAxisAtTop && {
|
|
217
|
+
transform: [
|
|
218
|
+
{
|
|
219
|
+
translateX: (width !== null && width !== void 0 ? width : totalWidth) - 30 + endSpacing,
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
yAxisLabelContainerStyle,
|
|
224
|
+
], children: _jsx(Text, { numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
|
|
225
|
+
yAxisTextStyle,
|
|
226
|
+
horizontal && {
|
|
227
|
+
transform: [
|
|
228
|
+
{
|
|
229
|
+
rotate: "".concat(rotateYAxisTexts !== null && rotateYAxisTexts !== void 0 ? rotateYAxisTexts : (rtl ? 90 : -90), "deg"),
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
index === noOfSections && {
|
|
234
|
+
marginBottom: stepHeight / -2,
|
|
235
|
+
},
|
|
236
|
+
], children: label }) }, index));
|
|
237
|
+
})
|
|
238
|
+
/***********************************************************************************************/
|
|
239
|
+
/***********************************************************************************************/
|
|
240
|
+
, horizSectionsBelow.map(function (sectionItems, index) {
|
|
241
|
+
return (_jsxs(View, { style: [
|
|
242
|
+
styles.horizBar,
|
|
243
|
+
{
|
|
244
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + 15,
|
|
245
|
+
},
|
|
246
|
+
index === 0 && { marginTop: negativeStepHeight / 2 },
|
|
247
|
+
], children: [_jsx(View, { style: [
|
|
248
|
+
styles.leftLabel,
|
|
249
|
+
{
|
|
250
|
+
borderRightWidth: yAxisThickness,
|
|
251
|
+
borderColor: yAxisColor,
|
|
252
|
+
marginLeft: yAxisThickness,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
height: index === 0
|
|
256
|
+
? negativeStepHeight * 1.5
|
|
257
|
+
: negativeStepHeight,
|
|
258
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
259
|
+
},
|
|
260
|
+
index === 0 && { marginTop: -negativeStepHeight / 2 },
|
|
261
|
+
] }), _jsx(View, { style: [
|
|
262
|
+
styles.leftPart,
|
|
263
|
+
{ backgroundColor: backgroundColor },
|
|
264
|
+
], children: hideRules ? null : (_jsx(Rule, { config: {
|
|
265
|
+
thickness: rulesThickness,
|
|
266
|
+
color: rulesColor,
|
|
267
|
+
width: rulesLength ||
|
|
268
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
269
|
+
dashWidth: dashWidth,
|
|
270
|
+
dashGap: dashGap,
|
|
271
|
+
type: rulesType,
|
|
272
|
+
} })) })] }, index));
|
|
273
|
+
}),
|
|
274
|
+
/***********************************************************************************************/
|
|
275
|
+
/************************* Render the y axis labels below origin *********************/
|
|
276
|
+
/***********************************************************************************************/
|
|
277
|
+
!hideYAxisText &&
|
|
278
|
+
horizSectionsBelow.map(function (sectionItems, index) {
|
|
279
|
+
var label = getLabelTexts(horizSectionsBelow[horizSectionsBelow.length - 1 - index]
|
|
280
|
+
.value, index);
|
|
281
|
+
return (_jsx(View, { style: [
|
|
282
|
+
styles.horizBar,
|
|
283
|
+
styles.leftLabel,
|
|
284
|
+
{
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
zIndex: 1,
|
|
287
|
+
bottom: negativeStepHeight * index,
|
|
288
|
+
width: yAxisLabelWidth,
|
|
289
|
+
height: index === noOfSectionsBelowXAxis
|
|
290
|
+
? negativeStepHeight / 2
|
|
291
|
+
: negativeStepHeight,
|
|
292
|
+
},
|
|
293
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
294
|
+
left: (width !== null && width !== void 0 ? width : totalWidth) + yAxisLabelWidth,
|
|
295
|
+
},
|
|
296
|
+
yAxisLabelContainerStyle,
|
|
297
|
+
], children: _jsx(Text, { numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
|
|
298
|
+
yAxisTextStyle,
|
|
299
|
+
index === noOfSectionsBelowXAxis && {
|
|
300
|
+
marginBottom: negativeStepHeight / -2,
|
|
301
|
+
},
|
|
302
|
+
], children: label }) }, index));
|
|
303
|
+
})
|
|
304
|
+
/***********************************************************************************************/
|
|
305
|
+
/***********************************************************************************************/
|
|
306
|
+
, renderReferenceLines ? referenceLines() : null] }),
|
|
307
|
+
/***********************************************************************************************/
|
|
308
|
+
/************************* Render the secondary Y Axis *********************/
|
|
309
|
+
/***********************************************************************************************/
|
|
310
|
+
secondaryYAxis ? (_jsxs(View, { style: {
|
|
311
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
312
|
+
left: width ? yAxisLabelWidth : yAxisLabelWidth - spacing,
|
|
313
|
+
borderColor: secondaryYAxisConfig.yAxisColor,
|
|
314
|
+
borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
|
|
315
|
+
height: containerHeight + yAxisExtraHeightAtTop,
|
|
316
|
+
bottom: stepHeight / -2,
|
|
317
|
+
}, children: [!secondaryYAxisConfig.hideYAxisText
|
|
318
|
+
? renderSecondaryYaxisLabels(secondaryHorizSections, false)
|
|
319
|
+
: null, noOfSectionsBelowXAxis && !secondaryYAxisConfig.hideYAxisText
|
|
320
|
+
? renderSecondaryYaxisLabels(secondaryHorizSectionsBelow, true)
|
|
321
|
+
: null] })) : null] })) }));
|
|
322
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View, Animated } from 'react-native';
|
|
3
|
+
import Svg, { Path } from 'react-native-svg';
|
|
4
|
+
import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
|
|
5
|
+
import { renderDataPoints } from './renderDataPoints';
|
|
6
|
+
import { renderSpecificDataPoints } from './renderSpecificDataPoints';
|
|
7
|
+
var RenderLineInBarChart = function (props) {
|
|
8
|
+
var _a;
|
|
9
|
+
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;
|
|
10
|
+
var firstBarWidth = (_a = data[0].barWidth) !== null && _a !== void 0 ? _a : barWidth;
|
|
11
|
+
var dataPointsProps = {
|
|
12
|
+
data: data,
|
|
13
|
+
lineConfig: lineConfig,
|
|
14
|
+
barWidth: barWidth,
|
|
15
|
+
containerHeight: containerHeight,
|
|
16
|
+
maxValue: maxValue,
|
|
17
|
+
firstBarWidth: firstBarWidth,
|
|
18
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
19
|
+
spacing: spacing,
|
|
20
|
+
selectedIndex: selectedIndex,
|
|
21
|
+
};
|
|
22
|
+
var specificVerticalLinesProps = {
|
|
23
|
+
data: data,
|
|
24
|
+
barWidth: barWidth,
|
|
25
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
26
|
+
initialSpacing: initialSpacing,
|
|
27
|
+
spacing: spacing,
|
|
28
|
+
containerHeight: containerHeight,
|
|
29
|
+
lineConfig: lineConfig,
|
|
30
|
+
maxValue: maxValue,
|
|
31
|
+
};
|
|
32
|
+
var specificDataPointsProps = {
|
|
33
|
+
data: data,
|
|
34
|
+
barWidth: barWidth,
|
|
35
|
+
firstBarWidth: firstBarWidth,
|
|
36
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
37
|
+
lineConfig: lineConfig,
|
|
38
|
+
spacing: spacing,
|
|
39
|
+
containerHeight: containerHeight,
|
|
40
|
+
maxValue: maxValue,
|
|
41
|
+
};
|
|
42
|
+
var renderAnimatedLine = function () {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
// console.log('animatedWidth is-------->', animatedWidth);
|
|
45
|
+
return (_jsx(Animated.View, { pointerEvents: "none", style: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
height: containerHeight + 10,
|
|
48
|
+
left: 6 - yAxisLabelWidth,
|
|
49
|
+
bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
50
|
+
width: animatedWidth,
|
|
51
|
+
zIndex: lineBehindBars ? -1 : 100000,
|
|
52
|
+
// backgroundColor: 'wheat',
|
|
53
|
+
}, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", stroke: lineConfig.color, strokeWidth: lineConfig.thickness }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
54
|
+
? renderDataPoints(dataPointsProps)
|
|
55
|
+
: 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 }))] }) }));
|
|
56
|
+
};
|
|
57
|
+
var renderLine = function () {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
return (_jsx(View, { pointerEvents: "none", style: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
height: containerHeight + 10 + labelsExtraHeight,
|
|
62
|
+
left: 6 - yAxisLabelWidth,
|
|
63
|
+
bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
64
|
+
width: totalWidth,
|
|
65
|
+
zIndex: lineBehindBars ? -1 : 100000,
|
|
66
|
+
// backgroundColor: 'rgba(200,150,150,0.1)'
|
|
67
|
+
}, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", stroke: lineConfig.color, strokeWidth: lineConfig.thickness }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
68
|
+
? renderDataPoints(dataPointsProps)
|
|
69
|
+
: 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 }))] }) }));
|
|
70
|
+
};
|
|
71
|
+
if (lineConfig.isAnimated) {
|
|
72
|
+
return renderAnimatedLine();
|
|
73
|
+
}
|
|
74
|
+
return renderLine();
|
|
75
|
+
};
|
|
76
|
+
export default RenderLineInBarChart;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { styles } from '../../../BarChart/styles';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
|
|
6
|
+
import { Rect, Text as CanvasText, Circle } from 'react-native-svg';
|
|
7
|
+
export var renderDataPoints = function (props) {
|
|
8
|
+
var data = props.data, lineConfig = props.lineConfig, barWidth = props.barWidth, containerHeight = props.containerHeight, maxValue = props.maxValue, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, spacing = props.spacing, selectedIndex = props.selectedIndex;
|
|
9
|
+
return data.map(function (item, index) {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
if (index < lineConfig.startIndex ||
|
|
12
|
+
index > lineConfig.endIndex ||
|
|
13
|
+
item.hideDataPoint) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
17
|
+
var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
|
|
18
|
+
var dataPointColor = lineConfig.focusEnabled &&
|
|
19
|
+
index === ((_a = lineConfig.focusedDataPointIndex) !== null && _a !== void 0 ? _a : selectedIndex)
|
|
20
|
+
? lineConfig.focusedDataPointColor
|
|
21
|
+
: lineConfig.dataPointsColor;
|
|
22
|
+
var dataPointRadius = lineConfig.focusEnabled &&
|
|
23
|
+
index === ((_b = lineConfig.focusedDataPointIndex) !== null && _b !== void 0 ? _b : selectedIndex)
|
|
24
|
+
? lineConfig.focusedDataPointRadius
|
|
25
|
+
: lineConfig.dataPointsRadius;
|
|
26
|
+
var value = (_c = item.value) !== null && _c !== void 0 ? _c : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
|
|
27
|
+
if (customDataPoint) {
|
|
28
|
+
return (_jsx(View, { style: [
|
|
29
|
+
styles.customDataPointContainer,
|
|
30
|
+
{
|
|
31
|
+
height: lineConfig.dataPointsHeight,
|
|
32
|
+
width: lineConfig.dataPointsWidth,
|
|
33
|
+
top: containerHeight -
|
|
34
|
+
(value * containerHeight) / maxValue -
|
|
35
|
+
((_e = (_d = item.shiftY) !== null && _d !== void 0 ? _d : lineConfig.shiftY) !== null && _e !== void 0 ? _e : 0),
|
|
36
|
+
left: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing),
|
|
37
|
+
},
|
|
38
|
+
], children: customDataPoint(item, index) }));
|
|
39
|
+
}
|
|
40
|
+
if (lineConfig.dataPointsShape === 'rectangular') {
|
|
41
|
+
return (_jsxs(Fragment, { children: [_jsx(Rect, { x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
42
|
+
lineConfig.dataPointsHeight / 2, width: lineConfig.dataPointsWidth, height: lineConfig.dataPointsHeight, fill: dataPointColor }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
43
|
+
lineConfig.dataPointsHeight / 2 +
|
|
44
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
45
|
+
}
|
|
46
|
+
return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), cy: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue), r: dataPointRadius, fill: dataPointColor }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
47
|
+
lineConfig.dataPointsHeight / 2 +
|
|
48
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
49
|
+
});
|
|
50
|
+
};
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderSpecificDataPoints: (props: any) => any;
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
|
|
4
|
+
import { Circle, Rect, Text as CanvasText } from 'react-native-svg';
|
|
5
|
+
export var renderSpecificDataPoints = function (props) {
|
|
6
|
+
var data = props.data, barWidth = props.barWidth, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, lineConfig = props.lineConfig, spacing = props.spacing, containerHeight = props.containerHeight, maxValue = props.maxValue;
|
|
7
|
+
return data.map(function (item, index) {
|
|
8
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
9
|
+
var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
|
|
10
|
+
var y = getYForLineInBar(item.value, lineConfig.shiftY, containerHeight, maxValue);
|
|
11
|
+
if (item.showDataPoint) {
|
|
12
|
+
if (item.dataPointShape === 'rectangular') {
|
|
13
|
+
return (_jsxs(Fragment, { children: [_jsx(Rect, { x: x, y: y - item.dataPointsHeight / 2, width: item.dataPointWidth || lineConfig.dataPointsWidth, height: item.dataPointHeight || 2, fill: item.dataPointColor || 'black' }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || 'black', fontSize: item.textFontSize || 10, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
|
|
14
|
+
(item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
|
|
15
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: x, cy: y, r: item.dataPointRadius || 3, fill: item.dataPointColor || 'black' }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || 'black', fontSize: item.textFontSize || 10, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
|
|
19
|
+
(item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
|
|
20
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderSpecificVerticalLines: (props: any) => any;
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Rect } from 'react-native-svg';
|
|
3
|
+
export var renderSpecificVerticalLines = function (props) {
|
|
4
|
+
var data = props.data, barWidth = props.barWidth, yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue;
|
|
5
|
+
return data.map(function (item, index) {
|
|
6
|
+
if (item.showVerticalLine) {
|
|
7
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
8
|
+
return (_jsx(Rect, { x: yAxisLabelWidth +
|
|
9
|
+
6 -
|
|
10
|
+
(item.verticalLineThickness || 1) / 2 -
|
|
11
|
+
1 -
|
|
12
|
+
(initialSpacing - currentBarWidth / 2) +
|
|
13
|
+
(currentBarWidth + spacing) * index, y: containerHeight -
|
|
14
|
+
lineConfig.shiftY -
|
|
15
|
+
(item.value * containerHeight) / maxValue +
|
|
16
|
+
9, width: item.verticalLineThickness || 1, height: (item.value * containerHeight) / maxValue + lineConfig.shiftY, fill: item.verticalLineColor || 'lightgray' }));
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { chartTypes } from 'gifted-charts-core';
|
|
4
|
+
import { Line, Svg } from 'react-native-svg';
|
|
5
|
+
var RenderVerticalLines = function (props) {
|
|
6
|
+
var 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;
|
|
7
|
+
var getHeightOfVerticalLine = function (index) {
|
|
8
|
+
if (verticalLinesUptoDataPoint) {
|
|
9
|
+
if (index < data.length) {
|
|
10
|
+
return ((data[index].value * containerHeight) / maxValue - xAxisThickness);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return verticalLinesHeight !== null && verticalLinesHeight !== void 0 ? verticalLinesHeight : 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return (verticalLinesHeight ||
|
|
18
|
+
containerHeightIncludingBelowXAxis - xAxisThickness);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var extendedContainerHeight = containerHeight + 10 + labelsExtraHeight;
|
|
22
|
+
var thickness = verticalLinesThickness || 2;
|
|
23
|
+
var heightAdjustmentDueToStrokeLinecap = verticalLinesStrokeLinecap === 'round' ||
|
|
24
|
+
verticalLinesStrokeLinecap === 'square'
|
|
25
|
+
? thickness / 2
|
|
26
|
+
: 0;
|
|
27
|
+
return (_jsx(View, { style: {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
height: extendedContainerHeight,
|
|
30
|
+
bottom: 60 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
31
|
+
width: totalWidth,
|
|
32
|
+
zIndex: verticalLinesZIndex || -1,
|
|
33
|
+
}, children: _jsx(Svg, { children: verticalLinesAr.map(function (item, index) {
|
|
34
|
+
var totalSpacing = initialSpacing;
|
|
35
|
+
if (verticalLinesSpacing) {
|
|
36
|
+
totalSpacing = verticalLinesSpacing * (index + 1);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (stackData) {
|
|
40
|
+
totalSpacing += (stackData[0].barWidth || barWidth || 30) / 2;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
totalSpacing += (data[0].barWidth || barWidth || 30) / 2;
|
|
44
|
+
}
|
|
45
|
+
for (var i = 0; i < index; i++) {
|
|
46
|
+
var actualSpacing = spacing;
|
|
47
|
+
if (stackData) {
|
|
48
|
+
if (i >= stackData.length - 1) {
|
|
49
|
+
actualSpacing += (barWidth || 30) / 2;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (stackData[i].spacing || stackData[i].spacing === 0) {
|
|
53
|
+
actualSpacing = stackData[i].spacing;
|
|
54
|
+
}
|
|
55
|
+
if (stackData[i + 1].barWidth) {
|
|
56
|
+
actualSpacing += stackData[i + 1].barWidth;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
actualSpacing += barWidth || 30;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (i >= data.length - 1) {
|
|
65
|
+
actualSpacing += (barWidth || 30) / 2;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (data[i].spacing || data[i].spacing === 0) {
|
|
69
|
+
actualSpacing = data[i].spacing;
|
|
70
|
+
}
|
|
71
|
+
if (data[i + 1].barWidth) {
|
|
72
|
+
actualSpacing += data[i + 1].barWidth;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
actualSpacing += barWidth || 30;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
totalSpacing += actualSpacing;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var x = verticalLinesShift +
|
|
83
|
+
1 +
|
|
84
|
+
(chartType === chartTypes.BAR
|
|
85
|
+
? totalSpacing - 1
|
|
86
|
+
: verticalLinesSpacing
|
|
87
|
+
? verticalLinesSpacing * (index + 1)
|
|
88
|
+
: index * spacing + (initialSpacing - 2));
|
|
89
|
+
return (_jsx(Line, { x1: x, y1: extendedContainerHeight -
|
|
90
|
+
getHeightOfVerticalLine(index) +
|
|
91
|
+
heightAdjustmentDueToStrokeLinecap, x2: x, y2: extendedContainerHeight - heightAdjustmentDueToStrokeLinecap, stroke: verticalLinesColor || 'lightgray', strokeWidth: verticalLinesThickness || 2, strokeDasharray: verticalLinesStrokeDashArray !== null && verticalLinesStrokeDashArray !== void 0 ? verticalLinesStrokeDashArray : '', strokeLinecap: verticalLinesStrokeLinecap }, index));
|
|
92
|
+
}) }) }));
|
|
93
|
+
};
|
|
94
|
+
export default RenderVerticalLines;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Svg, { Defs, Rect } from 'react-native-svg';
|
|
3
|
+
var BarBackgroundPattern = function (props) {
|
|
4
|
+
var barBackgroundPatternFromItem = props.barBackgroundPatternFromItem, barBackgroundPatternFromProps = props.barBackgroundPatternFromProps, patternIdFromItem = props.patternIdFromItem, patternIdFromProps = props.patternIdFromProps;
|
|
5
|
+
return (_jsxs(Svg, { children: [_jsx(Defs, { children: barBackgroundPatternFromItem
|
|
6
|
+
? barBackgroundPatternFromItem()
|
|
7
|
+
: barBackgroundPatternFromProps() }), _jsx(Rect, { stroke: "transparent", x: "1", y: "1", width: "100%", height: "100%", fill: "url(#".concat(patternIdFromItem !== null && patternIdFromItem !== void 0 ? patternIdFromItem : patternIdFromProps, ")") })] }));
|
|
8
|
+
};
|
|
9
|
+
export default BarBackgroundPattern;
|