react-native-gifted-charts 1.4.12 → 1.4.13
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/package.json +5 -9
- package/src/BarChart/Animated2DWithGradient.tsx +197 -0
- package/src/BarChart/RenderBars.tsx +454 -0
- package/src/BarChart/RenderStackBars.tsx +383 -0
- package/src/BarChart/index.tsx +373 -0
- package/src/BarChart/styles.tsx +47 -0
- package/src/Components/AnimatedThreeDBar/index.tsx +258 -0
- package/src/Components/AnimatedThreeDBar/styles.tsx +14 -0
- package/src/Components/BarAndLineChartsWrapper/index.tsx +244 -0
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +590 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +147 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +157 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +86 -0
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +42 -0
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +131 -0
- package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +30 -0
- package/src/Components/BarSpecificComponents/cap.tsx +34 -0
- package/src/Components/common/LinearGradient.tsx +27 -0
- package/src/Components/common/Pointer.tsx +37 -0
- package/src/Components/common/StripAndLabel.tsx +98 -0
- package/src/Components/lineSvg.tsx +42 -0
- package/src/LineChart/LineChartBicolor.tsx +740 -0
- package/src/LineChart/index.tsx +2158 -0
- package/src/LineChart/styles.tsx +47 -0
- package/src/PieChart/index.tsx +165 -0
- package/src/PieChart/main.tsx +363 -0
- package/src/PieChartPro/index.tsx +267 -0
- package/src/PopulationPyramid/index.tsx +603 -0
- package/src/index.tsx +25 -0
- package/src/todos.md +23 -0
- package/src/utils/index.ts +16 -0
- package/dist/BarChart/Animated2DWithGradient.js +0 -1
- package/dist/BarChart/RenderBars.js +0 -1
- package/dist/BarChart/RenderStackBars.js +0 -1
- package/dist/BarChart/index.js +0 -1
- package/dist/BarChart/styles.js +0 -1
- package/dist/Components/AnimatedThreeDBar/index.js +0 -1
- package/dist/Components/AnimatedThreeDBar/styles.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/index.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +0 -1
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +0 -1
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +0 -1
- package/dist/Components/BarSpecificComponents/cap.js +0 -1
- package/dist/Components/common/LinearGradient.js +0 -1
- package/dist/Components/common/Pointer.js +0 -1
- package/dist/Components/common/StripAndLabel.js +0 -1
- package/dist/Components/lineSvg.js +0 -1
- package/dist/LineChart/LineChartBicolor.js +0 -1
- package/dist/LineChart/index.js +0 -1
- package/dist/LineChart/styles.js +0 -1
- package/dist/PieChart/index.js +0 -1
- package/dist/PieChart/main.js +0 -1
- package/dist/PieChartPro/index.js +0 -1
- package/dist/PopulationPyramid/index.js +0 -1
- package/dist/index.js +0 -1
- package/dist/utils/index.js +0 -1
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Text, View} from 'react-native';
|
|
3
|
+
import Rule from '../lineSvg';
|
|
4
|
+
import {styles} from '../../LineChart/styles';
|
|
5
|
+
import {
|
|
6
|
+
getHorizSectionVals,
|
|
7
|
+
yAxisSides,
|
|
8
|
+
HorizSectionsType,
|
|
9
|
+
horizSectionPropTypes,
|
|
10
|
+
} from 'gifted-charts-core';
|
|
11
|
+
|
|
12
|
+
export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
13
|
+
const {
|
|
14
|
+
width,
|
|
15
|
+
noOfSectionsBelowXAxis,
|
|
16
|
+
totalWidth,
|
|
17
|
+
endSpacing,
|
|
18
|
+
yAxisSide,
|
|
19
|
+
horizontalRulesStyle,
|
|
20
|
+
noOfSections,
|
|
21
|
+
stepHeight,
|
|
22
|
+
yAxisLabelWidth,
|
|
23
|
+
yAxisLabelContainerStyle,
|
|
24
|
+
yAxisThickness,
|
|
25
|
+
yAxisColor,
|
|
26
|
+
xAxisThickness,
|
|
27
|
+
xAxisColor,
|
|
28
|
+
xAxisLength,
|
|
29
|
+
xAxisType,
|
|
30
|
+
dashWidth,
|
|
31
|
+
dashGap,
|
|
32
|
+
backgroundColor,
|
|
33
|
+
hideRules,
|
|
34
|
+
rulesLength,
|
|
35
|
+
rulesType,
|
|
36
|
+
rulesThickness,
|
|
37
|
+
rulesColor,
|
|
38
|
+
rulesConfigArray,
|
|
39
|
+
spacing,
|
|
40
|
+
showYAxisIndices,
|
|
41
|
+
yAxisIndicesHeight,
|
|
42
|
+
yAxisIndicesWidth,
|
|
43
|
+
yAxisIndicesColor,
|
|
44
|
+
|
|
45
|
+
hideOrigin,
|
|
46
|
+
hideYAxisText,
|
|
47
|
+
yAxisTextNumberOfLines,
|
|
48
|
+
yAxisTextStyle,
|
|
49
|
+
rotateYAxisTexts,
|
|
50
|
+
rtl,
|
|
51
|
+
|
|
52
|
+
containerHeight,
|
|
53
|
+
maxValue,
|
|
54
|
+
yAxisOffset,
|
|
55
|
+
|
|
56
|
+
horizontal,
|
|
57
|
+
yAxisAtTop,
|
|
58
|
+
secondaryYAxis,
|
|
59
|
+
onlyReferenceLines,
|
|
60
|
+
renderReferenceLines,
|
|
61
|
+
} = props;
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
secondaryYAxisConfig,
|
|
65
|
+
horizSections,
|
|
66
|
+
yAxisExtraHeightAtTop,
|
|
67
|
+
secondaryHorizSections,
|
|
68
|
+
showReferenceLine1,
|
|
69
|
+
referenceLine1Config,
|
|
70
|
+
referenceLine1Position,
|
|
71
|
+
showReferenceLine2,
|
|
72
|
+
referenceLine2Config,
|
|
73
|
+
referenceLine2Position,
|
|
74
|
+
showReferenceLine3,
|
|
75
|
+
referenceLine3Config,
|
|
76
|
+
referenceLine3Position,
|
|
77
|
+
horizSectionsBelow,
|
|
78
|
+
secondaryHorizSectionsBelow,
|
|
79
|
+
getLabelTexts,
|
|
80
|
+
getLabelTextsForSecondaryYAxis,
|
|
81
|
+
} = getHorizSectionVals(props);
|
|
82
|
+
|
|
83
|
+
const renderAxesAndRules = (index: number) => {
|
|
84
|
+
const invertedIndex = horizSections.length - index - 1;
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
style={[
|
|
88
|
+
index === noOfSections
|
|
89
|
+
? styles.lastLeftPart
|
|
90
|
+
: !index
|
|
91
|
+
? {justifyContent: 'flex-start'}
|
|
92
|
+
: styles.leftPart,
|
|
93
|
+
{
|
|
94
|
+
borderColor: yAxisColor,
|
|
95
|
+
backgroundColor: backgroundColor,
|
|
96
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
97
|
+
},
|
|
98
|
+
!index ? {height: stepHeight / 2, marginTop: stepHeight / 2} : null,
|
|
99
|
+
yAxisSide === yAxisSides.RIGHT
|
|
100
|
+
? {borderRightWidth: yAxisThickness}
|
|
101
|
+
: {borderLeftWidth: yAxisThickness},
|
|
102
|
+
]}>
|
|
103
|
+
{index === noOfSections ? (
|
|
104
|
+
<Rule
|
|
105
|
+
config={{
|
|
106
|
+
thickness: xAxisThickness,
|
|
107
|
+
color: xAxisColor,
|
|
108
|
+
width:
|
|
109
|
+
xAxisLength ||
|
|
110
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
111
|
+
dashWidth: dashWidth,
|
|
112
|
+
dashGap: dashGap,
|
|
113
|
+
type: xAxisType,
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
) : hideRules ? null : (
|
|
117
|
+
<Rule
|
|
118
|
+
config={{
|
|
119
|
+
thickness:
|
|
120
|
+
rulesConfigArray[invertedIndex]?.rulesThickness ??
|
|
121
|
+
rulesThickness,
|
|
122
|
+
color: rulesConfigArray[invertedIndex]?.rulesColor ?? rulesColor,
|
|
123
|
+
width:
|
|
124
|
+
rulesConfigArray[invertedIndex]?.rulesLength ??
|
|
125
|
+
rulesLength ??
|
|
126
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
127
|
+
dashWidth:
|
|
128
|
+
rulesConfigArray[invertedIndex]?.dashWidth ?? dashWidth,
|
|
129
|
+
dashGap: rulesConfigArray[invertedIndex]?.dashGap ?? dashGap,
|
|
130
|
+
type: rulesConfigArray[invertedIndex]?.rulesType ?? rulesType,
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
{showYAxisIndices && index !== noOfSections ? (
|
|
135
|
+
<View
|
|
136
|
+
style={{
|
|
137
|
+
height: yAxisIndicesHeight,
|
|
138
|
+
width: yAxisIndicesWidth,
|
|
139
|
+
left:
|
|
140
|
+
yAxisIndicesWidth / -2 +
|
|
141
|
+
(yAxisSide === yAxisSides.RIGHT
|
|
142
|
+
? (width ?? totalWidth) +
|
|
143
|
+
yAxisLabelWidth / 2 +
|
|
144
|
+
yAxisIndicesWidth / 4
|
|
145
|
+
: 0),
|
|
146
|
+
backgroundColor: yAxisIndicesColor,
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
) : null}
|
|
150
|
+
</View>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const renderExtraHeightOfYAxisAtTop = () => (
|
|
155
|
+
<View
|
|
156
|
+
style={[
|
|
157
|
+
styles.horizBar,
|
|
158
|
+
{
|
|
159
|
+
width: (width ?? totalWidth) + endSpacing,
|
|
160
|
+
top: stepHeight / 2,
|
|
161
|
+
},
|
|
162
|
+
horizontal &&
|
|
163
|
+
!yAxisAtTop && {
|
|
164
|
+
transform: [{rotateY: '180deg'}],
|
|
165
|
+
},
|
|
166
|
+
horizontalRulesStyle,
|
|
167
|
+
]}>
|
|
168
|
+
<View
|
|
169
|
+
style={[
|
|
170
|
+
styles.leftLabel,
|
|
171
|
+
{
|
|
172
|
+
height: yAxisExtraHeightAtTop,
|
|
173
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
174
|
+
},
|
|
175
|
+
yAxisLabelContainerStyle,
|
|
176
|
+
]}
|
|
177
|
+
/>
|
|
178
|
+
<View
|
|
179
|
+
style={[
|
|
180
|
+
styles.leftPart,
|
|
181
|
+
{
|
|
182
|
+
borderColor: yAxisColor,
|
|
183
|
+
backgroundColor: backgroundColor,
|
|
184
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
185
|
+
},
|
|
186
|
+
yAxisSide === yAxisSides.RIGHT
|
|
187
|
+
? {borderRightWidth: yAxisThickness}
|
|
188
|
+
: {borderLeftWidth: yAxisThickness},
|
|
189
|
+
]}
|
|
190
|
+
/>
|
|
191
|
+
</View>
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const renderSecondaryYaxisLabels = (
|
|
195
|
+
horizSections: HorizSectionsType,
|
|
196
|
+
isBelow: boolean,
|
|
197
|
+
) =>
|
|
198
|
+
horizSections.map((sectionItems, index) => {
|
|
199
|
+
let label = getLabelTextsForSecondaryYAxis(sectionItems.value, index);
|
|
200
|
+
if (
|
|
201
|
+
secondaryYAxisConfig.hideOrigin &&
|
|
202
|
+
index === secondaryHorizSections.length - 1
|
|
203
|
+
) {
|
|
204
|
+
label = '';
|
|
205
|
+
}
|
|
206
|
+
return (
|
|
207
|
+
<View
|
|
208
|
+
key={index}
|
|
209
|
+
style={[
|
|
210
|
+
styles.horizBar,
|
|
211
|
+
styles.leftLabel,
|
|
212
|
+
{
|
|
213
|
+
position: 'absolute',
|
|
214
|
+
zIndex: 1,
|
|
215
|
+
bottom:
|
|
216
|
+
(secondaryYAxisConfig.stepHeight ?? 0) *
|
|
217
|
+
((isBelow ? 0 : noOfSectionsBelowXAxis) +
|
|
218
|
+
index -
|
|
219
|
+
(noOfSectionsBelowXAxis ? 0 : 0.5)),
|
|
220
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
221
|
+
height: secondaryYAxisConfig.stepHeight ?? 0,
|
|
222
|
+
},
|
|
223
|
+
yAxisLabelContainerStyle,
|
|
224
|
+
]}>
|
|
225
|
+
{secondaryYAxisConfig.showYAxisIndices && index !== 0 ? (
|
|
226
|
+
<View
|
|
227
|
+
style={{
|
|
228
|
+
height: secondaryYAxisConfig.yAxisIndicesHeight,
|
|
229
|
+
width: secondaryYAxisConfig.yAxisIndicesWidth,
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
left: (secondaryYAxisConfig.yAxisIndicesWidth ?? 0) / -2,
|
|
232
|
+
backgroundColor: secondaryYAxisConfig.yAxisIndicesColor,
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
) : null}
|
|
236
|
+
<Text
|
|
237
|
+
numberOfLines={secondaryYAxisConfig.yAxisTextNumberOfLines}
|
|
238
|
+
ellipsizeMode={'clip'}
|
|
239
|
+
style={[secondaryYAxisConfig.yAxisTextStyle]}>
|
|
240
|
+
{label}
|
|
241
|
+
</Text>
|
|
242
|
+
</View>
|
|
243
|
+
);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const referenceLines = () => {
|
|
247
|
+
return (
|
|
248
|
+
<>
|
|
249
|
+
{showReferenceLine1 ? (
|
|
250
|
+
<View
|
|
251
|
+
style={{
|
|
252
|
+
position: 'absolute',
|
|
253
|
+
zIndex: referenceLine1Config.zIndex,
|
|
254
|
+
bottom:
|
|
255
|
+
((referenceLine1Position - (yAxisOffset ?? 0)) *
|
|
256
|
+
containerHeight) /
|
|
257
|
+
maxValue,
|
|
258
|
+
left:
|
|
259
|
+
yAxisSide === yAxisSides.RIGHT
|
|
260
|
+
? 0
|
|
261
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
262
|
+
}}>
|
|
263
|
+
<Rule config={referenceLine1Config} />
|
|
264
|
+
{referenceLine1Config.labelText ? (
|
|
265
|
+
<Text
|
|
266
|
+
style={[
|
|
267
|
+
{position: 'absolute'},
|
|
268
|
+
referenceLine1Config.labelTextStyle,
|
|
269
|
+
]}>
|
|
270
|
+
{referenceLine1Config.labelText}
|
|
271
|
+
</Text>
|
|
272
|
+
) : null}
|
|
273
|
+
</View>
|
|
274
|
+
) : null}
|
|
275
|
+
{showReferenceLine2 ? (
|
|
276
|
+
<View
|
|
277
|
+
style={{
|
|
278
|
+
position: 'absolute',
|
|
279
|
+
zIndex: referenceLine2Config.zIndex,
|
|
280
|
+
bottom:
|
|
281
|
+
((referenceLine2Position - (yAxisOffset ?? 0)) *
|
|
282
|
+
containerHeight) /
|
|
283
|
+
maxValue,
|
|
284
|
+
left:
|
|
285
|
+
yAxisSide === yAxisSides.RIGHT
|
|
286
|
+
? 0
|
|
287
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
288
|
+
}}>
|
|
289
|
+
<Rule config={referenceLine2Config} />
|
|
290
|
+
{referenceLine2Config.labelText ? (
|
|
291
|
+
<Text
|
|
292
|
+
style={[
|
|
293
|
+
{position: 'absolute'},
|
|
294
|
+
referenceLine2Config.labelTextStyle,
|
|
295
|
+
]}>
|
|
296
|
+
{referenceLine2Config.labelText}
|
|
297
|
+
</Text>
|
|
298
|
+
) : null}
|
|
299
|
+
</View>
|
|
300
|
+
) : null}
|
|
301
|
+
{showReferenceLine3 ? (
|
|
302
|
+
<View
|
|
303
|
+
style={{
|
|
304
|
+
position: 'absolute',
|
|
305
|
+
zIndex: referenceLine3Config.zIndex,
|
|
306
|
+
bottom:
|
|
307
|
+
((referenceLine3Position - (yAxisOffset ?? 0)) *
|
|
308
|
+
containerHeight) /
|
|
309
|
+
maxValue,
|
|
310
|
+
left:
|
|
311
|
+
yAxisSide === yAxisSides.RIGHT
|
|
312
|
+
? 0
|
|
313
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
314
|
+
}}>
|
|
315
|
+
<Rule config={referenceLine3Config} />
|
|
316
|
+
{referenceLine3Config.labelText ? (
|
|
317
|
+
<Text
|
|
318
|
+
style={[
|
|
319
|
+
{position: 'absolute'},
|
|
320
|
+
referenceLine3Config.labelTextStyle,
|
|
321
|
+
]}>
|
|
322
|
+
{referenceLine3Config.labelText}
|
|
323
|
+
</Text>
|
|
324
|
+
) : null}
|
|
325
|
+
</View>
|
|
326
|
+
) : null}
|
|
327
|
+
</>
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return (
|
|
332
|
+
<>
|
|
333
|
+
{onlyReferenceLines ? (
|
|
334
|
+
<View
|
|
335
|
+
style={{
|
|
336
|
+
flexDirection: 'row',
|
|
337
|
+
backgroundColor: 'green',
|
|
338
|
+
}}>
|
|
339
|
+
<View style={{width: (width ?? totalWidth) + endSpacing}}>
|
|
340
|
+
{referenceLines()}
|
|
341
|
+
</View>
|
|
342
|
+
</View>
|
|
343
|
+
) : (
|
|
344
|
+
<View
|
|
345
|
+
pointerEvents="none"
|
|
346
|
+
style={{
|
|
347
|
+
flexDirection: 'row',
|
|
348
|
+
marginTop: stepHeight / -2,
|
|
349
|
+
}}>
|
|
350
|
+
<View style={{width: (width ?? totalWidth) + endSpacing}}>
|
|
351
|
+
{yAxisExtraHeightAtTop ? renderExtraHeightOfYAxisAtTop() : null}
|
|
352
|
+
{horizSections.map((sectionItems, index) => {
|
|
353
|
+
return (
|
|
354
|
+
<View
|
|
355
|
+
key={index}
|
|
356
|
+
style={[
|
|
357
|
+
styles.horizBar,
|
|
358
|
+
{
|
|
359
|
+
width: (width ?? totalWidth) + endSpacing,
|
|
360
|
+
},
|
|
361
|
+
horizontal &&
|
|
362
|
+
!yAxisAtTop && {
|
|
363
|
+
transform: [{rotateY: '180deg'}],
|
|
364
|
+
},
|
|
365
|
+
horizontalRulesStyle,
|
|
366
|
+
]}>
|
|
367
|
+
<View
|
|
368
|
+
style={[
|
|
369
|
+
styles.leftLabel,
|
|
370
|
+
{
|
|
371
|
+
height:
|
|
372
|
+
index === noOfSections ? stepHeight / 2 : stepHeight,
|
|
373
|
+
width:
|
|
374
|
+
yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
375
|
+
},
|
|
376
|
+
yAxisLabelContainerStyle,
|
|
377
|
+
]}
|
|
378
|
+
/>
|
|
379
|
+
{renderAxesAndRules(index)}
|
|
380
|
+
</View>
|
|
381
|
+
);
|
|
382
|
+
})}
|
|
383
|
+
|
|
384
|
+
{
|
|
385
|
+
/***********************************************************************************************/
|
|
386
|
+
/************************** Render the y axis labels separately **********************/
|
|
387
|
+
/***********************************************************************************************/
|
|
388
|
+
|
|
389
|
+
!hideYAxisText &&
|
|
390
|
+
horizSections.map((sectionItems, index) => {
|
|
391
|
+
let label = getLabelTexts(sectionItems.value, index);
|
|
392
|
+
if (hideOrigin && index === horizSections.length - 1) {
|
|
393
|
+
label = '';
|
|
394
|
+
}
|
|
395
|
+
return (
|
|
396
|
+
<View
|
|
397
|
+
key={index}
|
|
398
|
+
style={[
|
|
399
|
+
styles.horizBar,
|
|
400
|
+
styles.leftLabel,
|
|
401
|
+
{
|
|
402
|
+
position: 'absolute',
|
|
403
|
+
zIndex: 1,
|
|
404
|
+
top: stepHeight * index + yAxisExtraHeightAtTop,
|
|
405
|
+
width: yAxisLabelWidth,
|
|
406
|
+
height:
|
|
407
|
+
index === noOfSections
|
|
408
|
+
? stepHeight / 2
|
|
409
|
+
: stepHeight,
|
|
410
|
+
},
|
|
411
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
412
|
+
left: (width ?? totalWidth) + yAxisLabelWidth / 2,
|
|
413
|
+
},
|
|
414
|
+
horizontal &&
|
|
415
|
+
!yAxisAtTop && {
|
|
416
|
+
transform: [
|
|
417
|
+
{
|
|
418
|
+
translateX:
|
|
419
|
+
(width ?? totalWidth) - 30 + endSpacing,
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
},
|
|
423
|
+
yAxisLabelContainerStyle,
|
|
424
|
+
]}>
|
|
425
|
+
<Text
|
|
426
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
427
|
+
ellipsizeMode={'clip'}
|
|
428
|
+
style={[
|
|
429
|
+
yAxisTextStyle,
|
|
430
|
+
horizontal && {
|
|
431
|
+
transform: [
|
|
432
|
+
{
|
|
433
|
+
rotate: `${
|
|
434
|
+
rotateYAxisTexts ?? (rtl ? 90 : -90)
|
|
435
|
+
}deg`,
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
},
|
|
439
|
+
index === noOfSections && {
|
|
440
|
+
marginBottom: stepHeight / -2,
|
|
441
|
+
},
|
|
442
|
+
]}>
|
|
443
|
+
{label}
|
|
444
|
+
</Text>
|
|
445
|
+
</View>
|
|
446
|
+
);
|
|
447
|
+
})
|
|
448
|
+
/***********************************************************************************************/
|
|
449
|
+
/***********************************************************************************************/
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
{horizSectionsBelow.map((sectionItems, index) => {
|
|
453
|
+
return (
|
|
454
|
+
<View
|
|
455
|
+
key={index}
|
|
456
|
+
style={[
|
|
457
|
+
styles.horizBar,
|
|
458
|
+
{
|
|
459
|
+
width: (width ?? totalWidth) + 15,
|
|
460
|
+
},
|
|
461
|
+
index === 0 && {marginTop: stepHeight / 2},
|
|
462
|
+
]}>
|
|
463
|
+
<View
|
|
464
|
+
style={[
|
|
465
|
+
styles.leftLabel,
|
|
466
|
+
{
|
|
467
|
+
borderRightWidth: yAxisThickness,
|
|
468
|
+
borderColor: yAxisColor,
|
|
469
|
+
marginLeft: yAxisThickness,
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
height: index === 0 ? stepHeight * 1.5 : stepHeight,
|
|
473
|
+
width:
|
|
474
|
+
yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
475
|
+
},
|
|
476
|
+
index === 0 && {marginTop: -stepHeight / 2},
|
|
477
|
+
]}
|
|
478
|
+
/>
|
|
479
|
+
<View
|
|
480
|
+
style={[
|
|
481
|
+
styles.leftPart,
|
|
482
|
+
{backgroundColor: backgroundColor},
|
|
483
|
+
]}>
|
|
484
|
+
{hideRules ? null : (
|
|
485
|
+
<Rule
|
|
486
|
+
config={{
|
|
487
|
+
thickness: rulesThickness,
|
|
488
|
+
color: rulesColor,
|
|
489
|
+
width:
|
|
490
|
+
rulesLength ||
|
|
491
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
492
|
+
dashWidth: dashWidth,
|
|
493
|
+
dashGap: dashGap,
|
|
494
|
+
type: rulesType,
|
|
495
|
+
}}
|
|
496
|
+
/>
|
|
497
|
+
)}
|
|
498
|
+
</View>
|
|
499
|
+
</View>
|
|
500
|
+
);
|
|
501
|
+
})}
|
|
502
|
+
|
|
503
|
+
{
|
|
504
|
+
/***********************************************************************************************/
|
|
505
|
+
/************************* Render the y axis labels below origin *********************/
|
|
506
|
+
/***********************************************************************************************/
|
|
507
|
+
|
|
508
|
+
!hideYAxisText &&
|
|
509
|
+
horizSectionsBelow.map((sectionItems, index) => {
|
|
510
|
+
let label = getLabelTexts(
|
|
511
|
+
horizSectionsBelow[horizSectionsBelow.length - 1 - index]
|
|
512
|
+
.value,
|
|
513
|
+
index,
|
|
514
|
+
);
|
|
515
|
+
return (
|
|
516
|
+
<View
|
|
517
|
+
key={index}
|
|
518
|
+
style={[
|
|
519
|
+
styles.horizBar,
|
|
520
|
+
styles.leftLabel,
|
|
521
|
+
{
|
|
522
|
+
position: 'absolute',
|
|
523
|
+
zIndex: 1,
|
|
524
|
+
bottom: stepHeight * index,
|
|
525
|
+
width: yAxisLabelWidth,
|
|
526
|
+
height:
|
|
527
|
+
index === noOfSections
|
|
528
|
+
? stepHeight / 2
|
|
529
|
+
: stepHeight,
|
|
530
|
+
},
|
|
531
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
532
|
+
left: (width ?? totalWidth) + yAxisLabelWidth,
|
|
533
|
+
},
|
|
534
|
+
yAxisLabelContainerStyle,
|
|
535
|
+
]}>
|
|
536
|
+
<Text
|
|
537
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
538
|
+
ellipsizeMode={'clip'}
|
|
539
|
+
style={[
|
|
540
|
+
yAxisTextStyle,
|
|
541
|
+
index === noOfSections && {
|
|
542
|
+
marginBottom: stepHeight / -2,
|
|
543
|
+
},
|
|
544
|
+
]}>
|
|
545
|
+
{label}
|
|
546
|
+
</Text>
|
|
547
|
+
</View>
|
|
548
|
+
);
|
|
549
|
+
})
|
|
550
|
+
/***********************************************************************************************/
|
|
551
|
+
/***********************************************************************************************/
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
{/***********************************************************************************************/
|
|
555
|
+
/************************* Render the reference lines separately *********************/
|
|
556
|
+
/***********************************************************************************************/}
|
|
557
|
+
|
|
558
|
+
{renderReferenceLines ? referenceLines() : null}
|
|
559
|
+
</View>
|
|
560
|
+
{
|
|
561
|
+
/***********************************************************************************************/
|
|
562
|
+
/************************* Render the secondary Y Axis *********************/
|
|
563
|
+
/***********************************************************************************************/
|
|
564
|
+
secondaryYAxis ? (
|
|
565
|
+
<View
|
|
566
|
+
style={{
|
|
567
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
568
|
+
left: width ? yAxisLabelWidth : yAxisLabelWidth - spacing,
|
|
569
|
+
borderColor: secondaryYAxisConfig.yAxisColor,
|
|
570
|
+
borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
|
|
571
|
+
height: containerHeight + yAxisExtraHeightAtTop,
|
|
572
|
+
bottom: stepHeight / -2,
|
|
573
|
+
}}>
|
|
574
|
+
{!secondaryYAxisConfig.hideYAxisText
|
|
575
|
+
? renderSecondaryYaxisLabels(secondaryHorizSections, false)
|
|
576
|
+
: null}
|
|
577
|
+
{noOfSectionsBelowXAxis && !secondaryYAxisConfig.hideYAxisText
|
|
578
|
+
? renderSecondaryYaxisLabels(
|
|
579
|
+
secondaryHorizSectionsBelow,
|
|
580
|
+
true,
|
|
581
|
+
)
|
|
582
|
+
: null}
|
|
583
|
+
</View>
|
|
584
|
+
) : null
|
|
585
|
+
}
|
|
586
|
+
</View>
|
|
587
|
+
)}
|
|
588
|
+
</>
|
|
589
|
+
);
|
|
590
|
+
};
|