@harveylx/react-native-gifted-charts 1.4.70

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  4. package/dist/BarChart/Animated2DWithGradient.js +78 -0
  5. package/dist/BarChart/RenderBars.d.ts +3 -0
  6. package/dist/BarChart/RenderBars.js +222 -0
  7. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  8. package/dist/BarChart/RenderStackBars.js +214 -0
  9. package/dist/BarChart/index.d.ts +2 -0
  10. package/dist/BarChart/index.js +256 -0
  11. package/dist/BarChart/styles.d.ts +45 -0
  12. package/dist/BarChart/styles.js +46 -0
  13. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  14. package/dist/Components/AnimatedThreeDBar/index.js +103 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
  16. package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  18. package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  30. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  31. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  32. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
  33. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  34. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  35. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  36. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  37. package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
  38. package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
  39. package/dist/Components/common/LinearGradient.d.ts +16 -0
  40. package/dist/Components/common/LinearGradient.js +15 -0
  41. package/dist/Components/common/Pointer.d.ts +1 -0
  42. package/dist/Components/common/Pointer.js +18 -0
  43. package/dist/Components/common/StripAndLabel.d.ts +2 -0
  44. package/dist/Components/common/StripAndLabel.js +60 -0
  45. package/dist/Components/lineSvg.d.ts +14 -0
  46. package/dist/Components/lineSvg.js +22 -0
  47. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  48. package/dist/LineChart/LineChartBicolor.js +298 -0
  49. package/dist/LineChart/index.d.ts +2 -0
  50. package/dist/LineChart/index.js +1137 -0
  51. package/dist/LineChart/styles.d.ts +43 -0
  52. package/dist/LineChart/styles.js +46 -0
  53. package/dist/PieChart/index.d.ts +2 -0
  54. package/dist/PieChart/index.js +146 -0
  55. package/dist/PieChart/main.d.ts +2 -0
  56. package/dist/PieChart/main.js +178 -0
  57. package/dist/PieChartPro/index.d.ts +2 -0
  58. package/dist/PieChartPro/index.js +124 -0
  59. package/dist/PopulationPyramid/index.d.ts +2 -0
  60. package/dist/PopulationPyramid/index.js +132 -0
  61. package/dist/RadarChart/index.d.ts +2 -0
  62. package/dist/RadarChart/index.js +113 -0
  63. package/dist/index.d.ts +8 -0
  64. package/dist/index.js +8 -0
  65. package/dist/utils/index.d.ts +5 -0
  66. package/dist/utils/index.js +22 -0
  67. package/package.json +89 -0
@@ -0,0 +1,468 @@
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
+ };
26
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
27
+ import { Text, View } from 'react-native';
28
+ import Rule from '../lineSvg';
29
+ import { styles } from '../../LineChart/styles';
30
+ import { getHorizSectionVals, yAxisSides, chartTypes, } from '@harveylx/gifted-charts-core';
31
+ export var renderHorizSections = function (props) {
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
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, onlyLabels = props.onlyLabels, renderReferenceLines = props.renderReferenceLines, secondaryXAxis = props.secondaryXAxis, customBackground = props.customBackground, allowFontScaling = props.allowFontScaling;
34
+ var _k = getHorizSectionVals(props), secondaryYAxisConfig = _k.secondaryYAxisConfig, horizSections = _k.horizSections, yAxisExtraHeightAtTop = _k.yAxisExtraHeightAtTop, secondaryHorizSections = _k.secondaryHorizSections, showReferenceLine1 = _k.showReferenceLine1, referenceLine1Config = _k.referenceLine1Config, referenceLine1Position = _k.referenceLine1Position, showReferenceLine2 = _k.showReferenceLine2, referenceLine2Config = _k.referenceLine2Config, referenceLine2Position = _k.referenceLine2Position, showReferenceLine3 = _k.showReferenceLine3, referenceLine3Config = _k.referenceLine3Config, referenceLine3Position = _k.referenceLine3Position, horizSectionsBelow = _k.horizSectionsBelow, secondaryHorizSectionsBelow = _k.secondaryHorizSectionsBelow, getLabelTexts = _k.getLabelTexts, getLabelTextsForSecondaryYAxis = _k.getLabelTextsForSecondaryYAxis;
35
+ var secondaryYAxisExtraHeightAtBottom = 10;
36
+ var negativeSectionsCountDiffPrimaryVsSecondary = secondaryHorizSectionsBelow.length - horizSectionsBelow.length;
37
+ var isLineChart = chartType === chartTypes.LINE;
38
+ var isLineBiColor = chartType === chartTypes.LINE_BI_COLOR;
39
+ var renderAxesAndRules = function (index) {
40
+ var _a, _b, _c, _d, _e, _f, _g, _h;
41
+ var invertedIndex = horizSections.length - index - 1;
42
+ var rulesConfigArrayLocal = rulesConfigArray[invertedIndex - 1];
43
+ return (_jsxs(View, { style: [
44
+ index === noOfSections
45
+ ? styles.lastLeftPart
46
+ : !index
47
+ ? { justifyContent: 'flex-start' }
48
+ : styles.leftPart,
49
+ {
50
+ borderColor: yAxisColor,
51
+ backgroundColor: (_a = sectionColors === null || sectionColors === void 0 ? void 0 : sectionColors[invertedIndex]) !== null && _a !== void 0 ? _a : backgroundColor,
52
+ width: (props.width || totalWidth - spacing) + endSpacing,
53
+ },
54
+ !index ? { height: stepHeight / 2, marginTop: stepHeight / 2 } : null,
55
+ yAxisSide === yAxisSides.RIGHT
56
+ ? { borderRightWidth: yAxisThickness }
57
+ : { borderLeftWidth: yAxisThickness },
58
+ ], children: [index === noOfSections ? (_jsx(Rule, { config: {
59
+ thickness: xAxisThickness,
60
+ color: xAxisColor,
61
+ width: xAxisLength ||
62
+ (props.width || totalWidth - spacing) + endSpacing,
63
+ dashWidth: dashWidth,
64
+ dashGap: dashGap,
65
+ type: xAxisType,
66
+ } })) : hideRules ? null : (_jsx(Rule, { config: {
67
+ thickness: (_b = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesThickness) !== null && _b !== void 0 ? _b : rulesThickness,
68
+ color: (_c = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesColor) !== null && _c !== void 0 ? _c : rulesColor,
69
+ width: (_e = (_d = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesLength) !== null && _d !== void 0 ? _d : rulesLength) !== null && _e !== void 0 ? _e : (props.width || totalWidth - spacing) + endSpacing,
70
+ dashWidth: (_f = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.dashWidth) !== null && _f !== void 0 ? _f : dashWidth,
71
+ dashGap: (_g = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.dashGap) !== null && _g !== void 0 ? _g : dashGap,
72
+ type: (_h = rulesConfigArrayLocal === null || rulesConfigArrayLocal === void 0 ? void 0 : rulesConfigArrayLocal.rulesType) !== null && _h !== void 0 ? _h : rulesType,
73
+ } })), showYAxisIndices && index !== noOfSections ? (_jsx(View, { style: {
74
+ position: 'absolute',
75
+ height: yAxisIndicesHeight,
76
+ width: yAxisIndicesWidth,
77
+ left: yAxisIndicesWidth / -2 +
78
+ (yAxisSide === yAxisSides.RIGHT
79
+ ? (width !== null && width !== void 0 ? width : totalWidth) +
80
+ yAxisLabelWidth / 2 +
81
+ yAxisIndicesWidth / 4
82
+ : 0),
83
+ backgroundColor: yAxisIndicesColor,
84
+ } })) : null] }));
85
+ };
86
+ var renderExtraHeightOfYAxisAtTop = function () {
87
+ var _a, _b;
88
+ return (_jsxs(View, { style: [
89
+ styles.horizBar,
90
+ {
91
+ width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
92
+ top: stepHeight / 2,
93
+ },
94
+ horizontal &&
95
+ !yAxisAtTop && {
96
+ transform: [{ rotateY: '180deg' }],
97
+ },
98
+ horizontalRulesStyle,
99
+ ], children: [_jsx(View, { style: [
100
+ styles.leftLabel,
101
+ {
102
+ height: yAxisExtraHeightAtTop,
103
+ width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
104
+ },
105
+ yAxisLabelContainerStyle,
106
+ ] }), _jsx(View, { style: [
107
+ styles.leftPart,
108
+ {
109
+ borderLeftColor: yAxisColor,
110
+ borderRightColor: yAxisColor,
111
+ borderTopColor: (_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.color) !== null && _a !== void 0 ? _a : xAxisColor,
112
+ borderTopWidth: secondaryXAxis
113
+ ? ((_b = secondaryXAxis.thickness) !== null && _b !== void 0 ? _b : xAxisThickness)
114
+ : 0,
115
+ backgroundColor: backgroundColor,
116
+ width: (props.width || totalWidth - spacing) + endSpacing,
117
+ },
118
+ yAxisSide === yAxisSides.RIGHT
119
+ ? { borderRightWidth: yAxisThickness }
120
+ : { borderLeftWidth: yAxisThickness },
121
+ ] })] }));
122
+ };
123
+ var renderSecondaryYaxisLabels = function (horizSections, isBelow) {
124
+ return horizSections.map(function (sectionItems, index) {
125
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
126
+ var label = getLabelTextsForSecondaryYAxis(sectionItems.value, index);
127
+ if (secondaryYAxisConfig.hideOrigin && index === 0) {
128
+ label = '';
129
+ }
130
+ return (_jsxs(View, { style: [
131
+ styles.horizBar,
132
+ styles.leftLabel,
133
+ {
134
+ position: 'absolute',
135
+ zIndex: 1,
136
+ bottom: (index - 0.5) *
137
+ (isBelow
138
+ ? ((_b = (_a = secondaryYAxisConfig.negativeStepHeight) !== null && _a !== void 0 ? _a : secondaryYAxisConfig.stepHeight) !== null && _b !== void 0 ? _b : 0)
139
+ : ((_c = secondaryYAxisConfig.stepHeight) !== null && _c !== void 0 ? _c : 0)) +
140
+ (isBelow ? secondaryYAxisExtraHeightAtBottom : 0),
141
+ width: secondaryYAxisConfig.yAxisLabelWidth,
142
+ height: isBelow
143
+ ? ((_e = (_d = secondaryYAxisConfig.negativeStepHeight) !== null && _d !== void 0 ? _d : secondaryYAxisConfig.stepHeight) !== null && _e !== void 0 ? _e : 0)
144
+ : ((_f = secondaryYAxisConfig.stepHeight) !== null && _f !== void 0 ? _f : 0),
145
+ },
146
+ (_g = secondaryYAxisConfig.yAxisLabelContainerStyle) !== null && _g !== void 0 ? _g : yAxisLabelContainerStyle,
147
+ ], children: [secondaryYAxisConfig.showYAxisIndices && (index !== 0 || isBelow) ? (_jsx(View, { style: {
148
+ height: secondaryYAxisConfig.yAxisIndicesHeight,
149
+ width: secondaryYAxisConfig.yAxisIndicesWidth,
150
+ position: 'absolute',
151
+ left: ((_h = secondaryYAxisConfig.yAxisIndicesWidth) !== null && _h !== void 0 ? _h : 0) / -2,
152
+ backgroundColor: secondaryYAxisConfig.yAxisIndicesColor,
153
+ } })) : null, _jsx(Text, { numberOfLines: secondaryYAxisConfig.yAxisTextNumberOfLines, ellipsizeMode: 'clip', allowFontScaling: allowFontScaling, style: [
154
+ {
155
+ textAlign: 'left',
156
+ width: (_k = (_j = secondaryYAxisConfig.yAxisLabelContainerStyle) === null || _j === void 0 ? void 0 : _j.width) !== null && _k !== void 0 ? _k : secondaryYAxisConfig.yAxisLabelWidth,
157
+ marginLeft: 10,
158
+ },
159
+ secondaryYAxisConfig.yAxisTextStyle,
160
+ ], children: label })] }, index));
161
+ });
162
+ };
163
+ var referenceLines = function () {
164
+ return (_jsxs(_Fragment, { children: [showReferenceLine1 ? (_jsxs(View, { style: {
165
+ position: 'absolute',
166
+ zIndex: referenceLine1Config.zIndex,
167
+ bottom: ((referenceLine1Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
168
+ containerHeight) /
169
+ maxValue,
170
+ left: yAxisSide === yAxisSides.RIGHT
171
+ ? 0
172
+ : yAxisLabelWidth + yAxisThickness,
173
+ }, children: [_jsx(Rule, { config: referenceLine1Config }), referenceLine1Config.labelText ? (_jsx(Text, { allowFontScaling: allowFontScaling, style: [
174
+ { position: 'absolute' },
175
+ referenceLine1Config.labelTextStyle,
176
+ ], children: referenceLine1Config.labelText })) : null] })) : null, showReferenceLine2 ? (_jsxs(View, { style: {
177
+ position: 'absolute',
178
+ zIndex: referenceLine2Config.zIndex,
179
+ bottom: ((referenceLine2Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
180
+ containerHeight) /
181
+ maxValue,
182
+ left: yAxisSide === yAxisSides.RIGHT
183
+ ? 0
184
+ : yAxisLabelWidth + yAxisThickness,
185
+ }, children: [_jsx(Rule, { config: referenceLine2Config }), referenceLine2Config.labelText ? (_jsx(Text, { allowFontScaling: allowFontScaling, style: [
186
+ { position: 'absolute' },
187
+ referenceLine2Config.labelTextStyle,
188
+ ], children: referenceLine2Config.labelText })) : null] })) : null, showReferenceLine3 ? (_jsxs(View, { style: {
189
+ position: 'absolute',
190
+ zIndex: referenceLine3Config.zIndex,
191
+ bottom: ((referenceLine3Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
192
+ containerHeight) /
193
+ maxValue,
194
+ left: yAxisSide === yAxisSides.RIGHT
195
+ ? 0
196
+ : yAxisLabelWidth + yAxisThickness,
197
+ }, children: [_jsx(Rule, { config: referenceLine3Config }), referenceLine3Config.labelText ? (_jsx(Text, { allowFontScaling: allowFontScaling, style: [
198
+ { position: 'absolute' },
199
+ referenceLine3Config.labelTextStyle,
200
+ ], children: referenceLine3Config.labelText })) : null] })) : null] }));
201
+ };
202
+ var horizSectionsBelowRenderer = function (index, showBorder) {
203
+ var _a;
204
+ // negative sections height will correspond to negative Y-axis config in case there are extra negative horiz sections corresponding to the secondary Y axis
205
+ var localNegativeStepHeight = !showBorder
206
+ ? ((_a = secondaryYAxisConfig.negativeStepHeight) !== null && _a !== void 0 ? _a : negativeStepHeight)
207
+ : negativeStepHeight;
208
+ return (_jsxs(View, { style: [
209
+ styles.horizBar,
210
+ {
211
+ width: (width !== null && width !== void 0 ? width : totalWidth) + 15,
212
+ },
213
+ index === 0 && { marginTop: localNegativeStepHeight / 2 },
214
+ ], children: [_jsx(View, { style: [
215
+ styles.leftLabel,
216
+ {
217
+ marginLeft: yAxisThickness,
218
+ },
219
+ {
220
+ height: index === 0
221
+ ? localNegativeStepHeight * 1.5
222
+ : localNegativeStepHeight,
223
+ width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
224
+ },
225
+ index === 0 && { marginTop: -localNegativeStepHeight / 2 },
226
+ ] }), _jsx(View, { style: {
227
+ position: 'absolute',
228
+ top: index === 0 ? -localNegativeStepHeight / 2 : 0,
229
+ left: yAxisSide === yAxisSides.RIGHT
230
+ ? width
231
+ ? width + 19
232
+ : totalWidth -
233
+ (isLineChart ? 31 : isLineBiColor ? spacing - 19 : 1)
234
+ : yAxisLabelWidth,
235
+ borderRightWidth: yAxisThickness,
236
+ borderColor: yAxisColor,
237
+ height: index === 0
238
+ ? localNegativeStepHeight * 1.5
239
+ : localNegativeStepHeight,
240
+ } }), _jsx(View, { style: [styles.leftPart, { backgroundColor: backgroundColor }], children: hideRules ? null : (_jsx(Rule, { config: {
241
+ thickness: rulesThickness,
242
+ color: rulesColor,
243
+ width: rulesLength ||
244
+ (props.width || totalWidth - spacing) + endSpacing,
245
+ dashWidth: dashWidth,
246
+ dashGap: dashGap,
247
+ type: rulesType,
248
+ } })) })] }, index));
249
+ };
250
+ var leftShiftForRIghtYaxis = (width ? width + (isLineChart ? 50 : 20) : totalWidth) +
251
+ yAxisLabelWidth / 2 +
252
+ endSpacing -
253
+ (isLineChart ? 70 : 40);
254
+ return (_jsx(_Fragment, { children: onlyReferenceLines ? (_jsx(View, { style: {
255
+ flexDirection: 'row',
256
+ }, children: _jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: referenceLines() }) })) : (_jsxs(View, { pointerEvents: "none", style: {
257
+ flexDirection: 'row',
258
+ marginTop: stepHeight / -2,
259
+ position: onlyLabels ? 'absolute' : 'relative',
260
+ }, children: [_jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: onlyLabels ? (!hideYAxisText &&
261
+ horizSections.map(function (sectionItems, index) {
262
+ var label = getLabelTexts(sectionItems.value, index);
263
+ if (hideOrigin && index === horizSections.length - 1) {
264
+ label = '';
265
+ }
266
+ return (_jsx(View, { style: [
267
+ styles.horizBar,
268
+ styles.leftLabel,
269
+ {
270
+ position: 'absolute',
271
+ zIndex: 1,
272
+ top: stepHeight * index + yAxisExtraHeightAtTop,
273
+ width: yAxisLabelWidth,
274
+ height: index === noOfSections ? stepHeight / 2 : stepHeight,
275
+ },
276
+ yAxisSide === yAxisSides.RIGHT && {
277
+ left: leftShiftForRIghtYaxis,
278
+ },
279
+ horizontal &&
280
+ !yAxisAtTop && {
281
+ transform: [
282
+ {
283
+ translateX: (width !== null && width !== void 0 ? width : totalWidth) - 30 + endSpacing,
284
+ },
285
+ ],
286
+ },
287
+ yAxisLabelContainerStyle,
288
+ ], children: _jsx(Text, { allowFontScaling: allowFontScaling, numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
289
+ yAxisTextStyle,
290
+ horizontal && {
291
+ transform: [
292
+ {
293
+ rotate: "".concat(rotateYAxisTexts !== null && rotateYAxisTexts !== void 0 ? rotateYAxisTexts : (rtl ? 90 : -90), "deg"),
294
+ },
295
+ ],
296
+ },
297
+ index === noOfSections && {
298
+ marginBottom: stepHeight / -2,
299
+ },
300
+ ], children: label }) }, index));
301
+ })) : (_jsxs(_Fragment, { children: [customBackground ? (_jsx(View, { style: {
302
+ position: 'absolute',
303
+ backgroundColor: customBackground.color,
304
+ width: (_a = customBackground.width) !== null && _a !== void 0 ? _a : (width !== null && width !== void 0 ? width : totalWidth) +
305
+ endSpacing -
306
+ 9 +
307
+ ((_b = customBackground.widthAdjustment) !== null && _b !== void 0 ? _b : 0),
308
+ height: (_c = customBackground.height) !== null && _c !== void 0 ? _c : '100%',
309
+ left: yAxisLabelWidth +
310
+ ((_d = customBackground.horizontalShift) !== null && _d !== void 0 ? _d : 0),
311
+ top: (_e = customBackground.verticalShift) !== null && _e !== void 0 ? _e : 0,
312
+ }, children: customBackground.component
313
+ ? customBackground.component()
314
+ : null })) : null, yAxisExtraHeightAtTop ? renderExtraHeightOfYAxisAtTop() : null, horizSections.map(function (sectionItems, index) {
315
+ return (_jsxs(View, { style: [
316
+ styles.horizBar,
317
+ {
318
+ width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
319
+ },
320
+ horizontal &&
321
+ !yAxisAtTop && {
322
+ transform: [{ rotateY: '180deg' }],
323
+ },
324
+ horizontalRulesStyle,
325
+ ], children: [_jsx(View, { style: [
326
+ styles.leftLabel,
327
+ {
328
+ height: index === noOfSections
329
+ ? stepHeight / 2
330
+ : stepHeight,
331
+ width: yAxisSide === yAxisSides.RIGHT
332
+ ? 0
333
+ : yAxisLabelWidth,
334
+ },
335
+ yAxisLabelContainerStyle,
336
+ ] }), renderAxesAndRules(index)] }, index));
337
+ }),
338
+ /***********************************************************************************************/
339
+ /************************** Render the y axis labels separately **********************/
340
+ /***********************************************************************************************/
341
+ !hideYAxisText &&
342
+ horizSections.map(function (sectionItems, index) {
343
+ var label = getLabelTexts(sectionItems.value, index);
344
+ if (hideOrigin && index === horizSections.length - 1) {
345
+ label = '';
346
+ }
347
+ return (_jsx(View, { style: [
348
+ styles.horizBar,
349
+ styles.leftLabel,
350
+ {
351
+ position: 'absolute',
352
+ zIndex: 1,
353
+ top: stepHeight * index + yAxisExtraHeightAtTop,
354
+ width: yAxisLabelWidth,
355
+ height: index === noOfSections
356
+ ? stepHeight / 2
357
+ : stepHeight,
358
+ },
359
+ yAxisSide === yAxisSides.RIGHT && {
360
+ left: leftShiftForRIghtYaxis,
361
+ },
362
+ horizontal &&
363
+ !yAxisAtTop && {
364
+ transform: [
365
+ {
366
+ translateX: (width !== null && width !== void 0 ? width : totalWidth) - 30 + endSpacing,
367
+ },
368
+ ],
369
+ },
370
+ yAxisLabelContainerStyle,
371
+ ], children: _jsx(Text, { allowFontScaling: allowFontScaling, numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
372
+ yAxisTextStyle,
373
+ horizontal && {
374
+ transform: [
375
+ {
376
+ rotate: "".concat(rotateYAxisTexts !== null && rotateYAxisTexts !== void 0 ? rotateYAxisTexts : (rtl ? 90 : -90), "deg"),
377
+ },
378
+ ],
379
+ },
380
+ index === noOfSections && {
381
+ marginBottom: stepHeight / -2,
382
+ },
383
+ ], children: label }) }, index));
384
+ })
385
+ /***********************************************************************************************/
386
+ /***********************************************************************************************/
387
+ , horizSectionsBelow.map(function (_, index) {
388
+ return horizSectionsBelowRenderer(index, true);
389
+ }),
390
+ /***********************************************************************************************/
391
+ /* If more -ve sections in Secondary Y-axis, then we need to render the Rules for them */
392
+ /***********************************************************************************************/
393
+ secondaryYAxis &&
394
+ negativeSectionsCountDiffPrimaryVsSecondary > 0
395
+ ? __spreadArray([], __read(Array(negativeSectionsCountDiffPrimaryVsSecondary).keys()), false).map(function (_, index) {
396
+ return horizSectionsBelowRenderer(index, false);
397
+ })
398
+ : null,
399
+ /***********************************************************************************************/
400
+ /************************* Render the y axis labels below origin *********************/
401
+ /***********************************************************************************************/
402
+ !hideYAxisText &&
403
+ horizSectionsBelow.map(function (_, index) {
404
+ var invertedIndex = horizSectionsBelow.length - 1 - index;
405
+ var label = getLabelTexts(horizSectionsBelow[invertedIndex].value, index);
406
+ return (_jsx(View, { style: [
407
+ styles.horizBar,
408
+ styles.leftLabel,
409
+ {
410
+ position: 'absolute',
411
+ zIndex: 1,
412
+ top: containerHeight +
413
+ negativeStepHeight * (invertedIndex + 1) +
414
+ yAxisExtraHeightAtTop,
415
+ width: yAxisLabelWidth,
416
+ height: index === noOfSectionsBelowXAxis
417
+ ? negativeStepHeight / 2
418
+ : negativeStepHeight,
419
+ },
420
+ yAxisSide === yAxisSides.RIGHT && {
421
+ left: (width
422
+ ? width - 15
423
+ : totalWidth - (isLineChart ? 65 : 35)) +
424
+ yAxisLabelWidth,
425
+ },
426
+ yAxisLabelContainerStyle,
427
+ ], children: _jsx(Text, { allowFontScaling: allowFontScaling, numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
428
+ yAxisTextStyle,
429
+ index === noOfSectionsBelowXAxis && {
430
+ marginBottom: negativeStepHeight / -2,
431
+ },
432
+ ], children: label }) }, index));
433
+ })
434
+ /***********************************************************************************************/
435
+ /***********************************************************************************************/
436
+ , renderReferenceLines ? referenceLines() : null] })) }),
437
+ /***********************************************************************************************/
438
+ /************************* Render the secondary Y Axis *********************/
439
+ /***********************************************************************************************/
440
+ !onlyLabels && secondaryYAxis ? (_jsx(View, { style: {
441
+ width: secondaryYAxisConfig.yAxisLabelWidth,
442
+ left: width ? yAxisLabelWidth : yAxisLabelWidth - spacing,
443
+ borderColor: secondaryYAxisConfig.yAxisColor,
444
+ borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
445
+ height: containerHeight + yAxisExtraHeightAtTop,
446
+ bottom: stepHeight / -2,
447
+ }, children: !secondaryYAxisConfig.hideYAxisText
448
+ ? renderSecondaryYaxisLabels(secondaryHorizSections, false)
449
+ : null })) : null,
450
+ /***********************************************************************************************/
451
+ /************************* Render the secondary Y Axis below origin *********************/
452
+ /***********************************************************************************************/
453
+ !onlyLabels &&
454
+ secondaryYAxis &&
455
+ secondaryYAxisConfig.noOfSectionsBelowXAxis ? (_jsx(View, { style: {
456
+ width: (_f = secondaryYAxisConfig.yAxisLabelWidth) !== null && _f !== void 0 ? _f : yAxisLabelWidth,
457
+ left: (width ? yAxisLabelWidth : yAxisLabelWidth - spacing) -
458
+ ((_g = secondaryYAxisConfig.yAxisLabelWidth) !== null && _g !== void 0 ? _g : yAxisLabelWidth),
459
+ borderColor: secondaryYAxisConfig.yAxisColor,
460
+ borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
461
+ height: ((_j = (_h = secondaryYAxisConfig.negativeStepHeight) !== null && _h !== void 0 ? _h : secondaryYAxisConfig.stepHeight) !== null && _j !== void 0 ? _j : stepHeight) *
462
+ secondaryHorizSectionsBelow.length +
463
+ secondaryYAxisExtraHeightAtBottom,
464
+ bottom: -containerHeight - stepHeight / 2 - yAxisExtraHeightAtTop,
465
+ }, children: !secondaryYAxisConfig.hideYAxisText
466
+ ? renderSecondaryYaxisLabels(secondaryHorizSectionsBelow, true)
467
+ : null })) : null] })) }));
468
+ };
@@ -0,0 +1,3 @@
1
+ import { LineInBarChartPropsType } from '@harveylx/gifted-charts-core';
2
+ declare const RenderLineInBarChart: (props: LineInBarChartPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default RenderLineInBarChart;
@@ -0,0 +1,87 @@
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
+ import { isIos } from '../../../utils';
8
+ var RenderLineInBarChart = function (props) {
9
+ var _a, _b;
10
+ var yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, arrowPoints = props.arrowPoints, data = props.data, totalWidth = props.totalWidth, barWidth = props.barWidth, labelsExtraHeight = props.labelsExtraHeight, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, selectedIndex = props.selectedIndex, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, yAxisOffset = props.yAxisOffset, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity;
11
+ var firstBarWidth = (_a = data[0].barWidth) !== null && _a !== void 0 ? _a : barWidth;
12
+ var opacity = highlightEnabled
13
+ ? ((_b = selectedIndex.includes) === null || _b === void 0 ? void 0 : _b.call(selectedIndex, -1))
14
+ ? 1
15
+ : lowlightOpacity
16
+ : 1;
17
+ var svgHeight = containerHeightIncludingBelowXAxis + labelsExtraHeight;
18
+ var dataPointsProps = {
19
+ data: data,
20
+ lineConfig: lineConfig,
21
+ barWidth: barWidth,
22
+ containerHeight: containerHeight,
23
+ maxValue: maxValue,
24
+ firstBarWidth: firstBarWidth,
25
+ yAxisLabelWidth: yAxisLabelWidth,
26
+ spacing: spacing,
27
+ selectedIndex: selectedIndex[0],
28
+ yAxisOffset: yAxisOffset,
29
+ opacity: opacity,
30
+ svgHeight: svgHeight,
31
+ totalWidth: totalWidth,
32
+ };
33
+ var specificVerticalLinesProps = {
34
+ data: data,
35
+ barWidth: barWidth,
36
+ yAxisLabelWidth: yAxisLabelWidth,
37
+ initialSpacing: initialSpacing,
38
+ spacing: spacing,
39
+ containerHeight: containerHeight,
40
+ lineConfig: lineConfig,
41
+ maxValue: maxValue,
42
+ };
43
+ var specificDataPointsProps = {
44
+ data: data,
45
+ barWidth: barWidth,
46
+ firstBarWidth: firstBarWidth,
47
+ yAxisLabelWidth: yAxisLabelWidth,
48
+ lineConfig: lineConfig,
49
+ spacing: spacing,
50
+ containerHeight: containerHeight,
51
+ maxValue: maxValue,
52
+ yAxisOffset: yAxisOffset,
53
+ };
54
+ var renderAnimatedLine = function () {
55
+ var _a, _b, _c;
56
+ return (_jsx(Animated.View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
57
+ position: 'absolute',
58
+ height: svgHeight,
59
+ left: 6 - yAxisLabelWidth,
60
+ bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
61
+ width: animatedWidth,
62
+ zIndex: lineBehindBars ? -1 : 100000,
63
+ // backgroundColor: 'wheat',
64
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
65
+ ? renderDataPoints(dataPointsProps)
66
+ : renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
67
+ };
68
+ var renderLine = function () {
69
+ var _a, _b, _c;
70
+ return (_jsx(View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
71
+ position: 'absolute',
72
+ height: containerHeightIncludingBelowXAxis + labelsExtraHeight,
73
+ left: 6 - yAxisLabelWidth,
74
+ bottom: -10 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
75
+ width: totalWidth,
76
+ zIndex: lineBehindBars ? -1 : 100000,
77
+ // backgroundColor: 'rgba(200,150,150,0.1)'
78
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
79
+ ? renderDataPoints(dataPointsProps)
80
+ : renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
81
+ };
82
+ if (lineConfig.isAnimated) {
83
+ return renderAnimatedLine();
84
+ }
85
+ return renderLine();
86
+ };
87
+ export default RenderLineInBarChart;
@@ -0,0 +1,2 @@
1
+ import { DataPointProps } from '@harveylx/gifted-charts-core';
2
+ export declare const renderDataPoints: (props: DataPointProps) => import("react/jsx-runtime").JSX.Element;