react-native-gifted-charts 1.4.19 → 1.4.21
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 +6 -3
- package/dist/BarChart/Animated2DWithGradient.js +1 -0
- package/dist/BarChart/RenderBars.js +1 -0
- package/dist/BarChart/RenderStackBars.js +1 -0
- package/dist/BarChart/index.js +1 -0
- package/dist/BarChart/styles.js +1 -0
- package/dist/Components/AnimatedThreeDBar/index.js +1 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +1 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +1 -0
- package/dist/Components/BarSpecificComponents/cap.js +1 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +1 -0
- package/dist/Components/common/LinearGradient.js +1 -0
- package/dist/Components/common/Pointer.js +1 -0
- package/dist/Components/common/StripAndLabel.js +1 -0
- package/dist/Components/lineSvg.js +1 -0
- package/dist/LineChart/LineChartBicolor.js +1 -0
- package/dist/LineChart/index.js +1 -0
- package/dist/LineChart/styles.js +1 -0
- package/dist/PieChart/index.js +1 -0
- package/dist/PieChart/main.js +1 -0
- package/dist/PieChartPro/index.js +1 -0
- package/dist/PopulationPyramid/index.js +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/index.js +1 -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 -147
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -158
- 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 -2228
- 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
package/src/LineChart/index.tsx
DELETED
|
@@ -1,2228 +0,0 @@
|
|
|
1
|
-
import React, {Fragment, useCallback, useEffect, useMemo, useRef} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Animated,
|
|
5
|
-
Easing,
|
|
6
|
-
Text,
|
|
7
|
-
Dimensions,
|
|
8
|
-
Platform,
|
|
9
|
-
ColorValue,
|
|
10
|
-
I18nManager,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
import {styles} from './styles';
|
|
13
|
-
import {screenWidth} from '../utils';
|
|
14
|
-
import Svg, {
|
|
15
|
-
Path,
|
|
16
|
-
LinearGradient,
|
|
17
|
-
Stop,
|
|
18
|
-
Circle,
|
|
19
|
-
Rect,
|
|
20
|
-
Text as CanvasText,
|
|
21
|
-
Line,
|
|
22
|
-
} from 'react-native-svg';
|
|
23
|
-
import {
|
|
24
|
-
getSegmentedPathObjects,
|
|
25
|
-
getRegionPathObjects,
|
|
26
|
-
RANGE_ENTER,
|
|
27
|
-
RANGE_EXIT,
|
|
28
|
-
SEGMENT_END,
|
|
29
|
-
SEGMENT_START,
|
|
30
|
-
STOP,
|
|
31
|
-
LineChartPropsType,
|
|
32
|
-
lineDataItem,
|
|
33
|
-
LineSvgProps,
|
|
34
|
-
useLineChart,
|
|
35
|
-
adjustToOffset,
|
|
36
|
-
LineProperties,
|
|
37
|
-
} from 'gifted-charts-core';
|
|
38
|
-
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
39
|
-
import {StripAndLabel} from '../Components/common/StripAndLabel';
|
|
40
|
-
import {Pointer} from '../Components/common/Pointer';
|
|
41
|
-
|
|
42
|
-
let initialData: Array<lineDataItem> | null = null;
|
|
43
|
-
let animations: Array<Animated.Value> = [];
|
|
44
|
-
|
|
45
|
-
export const LineChart = (props: LineChartPropsType) => {
|
|
46
|
-
const scrollRef = props.scrollRef ?? useRef(null);
|
|
47
|
-
const opacValue = useMemo(() => new Animated.Value(0), []);
|
|
48
|
-
const heightValue = useMemo(() => new Animated.Value(0), []);
|
|
49
|
-
const widthValue = useMemo(() => new Animated.Value(0), []);
|
|
50
|
-
const widthValue2 = useMemo(() => new Animated.Value(0), []);
|
|
51
|
-
const widthValue3 = useMemo(() => new Animated.Value(0), []);
|
|
52
|
-
const widthValue4 = useMemo(() => new Animated.Value(0), []);
|
|
53
|
-
const widthValue5 = useMemo(() => new Animated.Value(0), []);
|
|
54
|
-
|
|
55
|
-
if (!initialData) {
|
|
56
|
-
initialData = props.dataSet?.[0]?.data ?? props.data ?? [];
|
|
57
|
-
animations = initialData.map(item => new Animated.Value(item.value));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const {
|
|
61
|
-
scrollX,
|
|
62
|
-
setScrollX,
|
|
63
|
-
arrow1Points,
|
|
64
|
-
arrow2Points,
|
|
65
|
-
arrow3Points,
|
|
66
|
-
arrow4Points,
|
|
67
|
-
arrow5Points,
|
|
68
|
-
secondaryArrowPoints,
|
|
69
|
-
pointerIndex,
|
|
70
|
-
setPointerIndex,
|
|
71
|
-
pointerX,
|
|
72
|
-
setPointerX,
|
|
73
|
-
pointerY,
|
|
74
|
-
setPointerY,
|
|
75
|
-
pointerItem,
|
|
76
|
-
setPointerItem,
|
|
77
|
-
pointerY2,
|
|
78
|
-
setPointerY2,
|
|
79
|
-
pointerItem2,
|
|
80
|
-
setPointerItem2,
|
|
81
|
-
pointerY3,
|
|
82
|
-
setPointerY3,
|
|
83
|
-
pointerItem3,
|
|
84
|
-
setPointerItem3,
|
|
85
|
-
pointerY4,
|
|
86
|
-
setPointerY4,
|
|
87
|
-
pointerItem4,
|
|
88
|
-
setPointerItem4,
|
|
89
|
-
pointerY5,
|
|
90
|
-
setPointerY5,
|
|
91
|
-
pointerYsForDataSet,
|
|
92
|
-
setPointerYsForDataSet,
|
|
93
|
-
pointerItem5,
|
|
94
|
-
setPointerItem5,
|
|
95
|
-
secondaryPointerY,
|
|
96
|
-
setSecondaryPointerY,
|
|
97
|
-
secondaryPointerItem,
|
|
98
|
-
setSecondaryPointerItem,
|
|
99
|
-
responderStartTime,
|
|
100
|
-
setResponderStartTime,
|
|
101
|
-
setResponderActive,
|
|
102
|
-
points,
|
|
103
|
-
points2,
|
|
104
|
-
points3,
|
|
105
|
-
points4,
|
|
106
|
-
points5,
|
|
107
|
-
secondaryPoints,
|
|
108
|
-
fillPoints,
|
|
109
|
-
fillPoints2,
|
|
110
|
-
fillPoints3,
|
|
111
|
-
fillPoints4,
|
|
112
|
-
fillPoints5,
|
|
113
|
-
secondaryFillPoints,
|
|
114
|
-
pointsFromSet,
|
|
115
|
-
fillPointsFromSet,
|
|
116
|
-
arrowPointsFromSet,
|
|
117
|
-
selectedIndex,
|
|
118
|
-
setSelectedIndex,
|
|
119
|
-
containerHeight,
|
|
120
|
-
data,
|
|
121
|
-
data2,
|
|
122
|
-
data3,
|
|
123
|
-
data4,
|
|
124
|
-
data5,
|
|
125
|
-
secondaryData,
|
|
126
|
-
dataSet,
|
|
127
|
-
data0,
|
|
128
|
-
labelsExtraHeight,
|
|
129
|
-
animationDuration,
|
|
130
|
-
onDataChangeAnimationDuration,
|
|
131
|
-
animateTogether,
|
|
132
|
-
animateOnDataChange,
|
|
133
|
-
startIndex1,
|
|
134
|
-
startIndex2,
|
|
135
|
-
endIndex1,
|
|
136
|
-
endIndex2,
|
|
137
|
-
startIndex3,
|
|
138
|
-
endIndex3,
|
|
139
|
-
startIndex4,
|
|
140
|
-
endIndex4,
|
|
141
|
-
startIndex5,
|
|
142
|
-
endIndex5,
|
|
143
|
-
initialSpacing,
|
|
144
|
-
thickness,
|
|
145
|
-
yAxisLabelWidth,
|
|
146
|
-
spacing,
|
|
147
|
-
xAxisThickness,
|
|
148
|
-
dataPointsHeight1,
|
|
149
|
-
dataPointsWidth1,
|
|
150
|
-
dataPointsRadius1,
|
|
151
|
-
dataPointsColor1,
|
|
152
|
-
dataPointsShape1,
|
|
153
|
-
dataPointsHeight2,
|
|
154
|
-
dataPointsWidth2,
|
|
155
|
-
dataPointsRadius2,
|
|
156
|
-
dataPointsColor2,
|
|
157
|
-
dataPointsShape2,
|
|
158
|
-
dataPointsHeight3,
|
|
159
|
-
dataPointsWidth3,
|
|
160
|
-
dataPointsRadius3,
|
|
161
|
-
dataPointsColor3,
|
|
162
|
-
dataPointsShape3,
|
|
163
|
-
dataPointsHeight4,
|
|
164
|
-
dataPointsWidth4,
|
|
165
|
-
dataPointsRadius4,
|
|
166
|
-
dataPointsColor4,
|
|
167
|
-
dataPointsShape4,
|
|
168
|
-
dataPointsHeight5,
|
|
169
|
-
dataPointsWidth5,
|
|
170
|
-
dataPointsRadius5,
|
|
171
|
-
dataPointsColor5,
|
|
172
|
-
dataPointsShape5,
|
|
173
|
-
getIsNthAreaChart,
|
|
174
|
-
textFontSize1,
|
|
175
|
-
textFontSize2,
|
|
176
|
-
textFontSize3,
|
|
177
|
-
textFontSize4,
|
|
178
|
-
textFontSize5,
|
|
179
|
-
textColor1,
|
|
180
|
-
textColor2,
|
|
181
|
-
textColor3,
|
|
182
|
-
textColor4,
|
|
183
|
-
textColor5,
|
|
184
|
-
totalWidth,
|
|
185
|
-
maxValue,
|
|
186
|
-
overflowTop,
|
|
187
|
-
extendedContainerHeight,
|
|
188
|
-
getX,
|
|
189
|
-
getY,
|
|
190
|
-
getSecondaryY,
|
|
191
|
-
secondaryMaxValue,
|
|
192
|
-
showValuesAsDataPointsText,
|
|
193
|
-
thickness1,
|
|
194
|
-
thickness2,
|
|
195
|
-
thickness3,
|
|
196
|
-
thickness4,
|
|
197
|
-
thickness5,
|
|
198
|
-
zIndex1,
|
|
199
|
-
zIndex2,
|
|
200
|
-
zIndex3,
|
|
201
|
-
zIndex4,
|
|
202
|
-
zIndex5,
|
|
203
|
-
strokeDashArray1,
|
|
204
|
-
strokeDashArray2,
|
|
205
|
-
strokeDashArray3,
|
|
206
|
-
strokeDashArray4,
|
|
207
|
-
strokeDashArray5,
|
|
208
|
-
rotateLabel,
|
|
209
|
-
isAnimated,
|
|
210
|
-
hideDataPoints1,
|
|
211
|
-
hideDataPoints2,
|
|
212
|
-
hideDataPoints3,
|
|
213
|
-
hideDataPoints4,
|
|
214
|
-
hideDataPoints5,
|
|
215
|
-
color1,
|
|
216
|
-
color2,
|
|
217
|
-
color3,
|
|
218
|
-
color4,
|
|
219
|
-
color5,
|
|
220
|
-
startFillColor1,
|
|
221
|
-
endFillColor1,
|
|
222
|
-
startOpacity1,
|
|
223
|
-
endOpacity1,
|
|
224
|
-
startFillColor2,
|
|
225
|
-
endFillColor2,
|
|
226
|
-
startOpacity2,
|
|
227
|
-
endOpacity2,
|
|
228
|
-
startFillColor3,
|
|
229
|
-
endFillColor3,
|
|
230
|
-
startOpacity3,
|
|
231
|
-
endOpacity3,
|
|
232
|
-
startFillColor4,
|
|
233
|
-
endFillColor4,
|
|
234
|
-
startOpacity4,
|
|
235
|
-
endOpacity4,
|
|
236
|
-
startFillColor5,
|
|
237
|
-
endFillColor5,
|
|
238
|
-
startOpacity5,
|
|
239
|
-
endOpacity5,
|
|
240
|
-
arrowStrokeWidth1,
|
|
241
|
-
arrowStrokeColor1,
|
|
242
|
-
arrowFillColor1,
|
|
243
|
-
arrowStrokeWidth2,
|
|
244
|
-
arrowStrokeColor2,
|
|
245
|
-
arrowFillColor2,
|
|
246
|
-
arrowStrokeWidth3,
|
|
247
|
-
arrowStrokeColor3,
|
|
248
|
-
arrowFillColor3,
|
|
249
|
-
arrowStrokeWidth4,
|
|
250
|
-
arrowStrokeColor4,
|
|
251
|
-
arrowFillColor4,
|
|
252
|
-
arrowStrokeWidth5,
|
|
253
|
-
arrowStrokeColor5,
|
|
254
|
-
arrowFillColor5,
|
|
255
|
-
arrowStrokeWidthsFromSet,
|
|
256
|
-
arrowStrokeColorsFromSet,
|
|
257
|
-
arrowFillColorsFromSet,
|
|
258
|
-
secondaryLineConfig,
|
|
259
|
-
gradientDirection,
|
|
260
|
-
stepHeight,
|
|
261
|
-
noOfSectionsBelowXAxis,
|
|
262
|
-
xAxisTextNumberOfLines,
|
|
263
|
-
xAxisLabelsVerticalShift,
|
|
264
|
-
pointerConfig,
|
|
265
|
-
pointerHeight,
|
|
266
|
-
pointerWidth,
|
|
267
|
-
pointerRadius,
|
|
268
|
-
pointerColor,
|
|
269
|
-
pointerComponent,
|
|
270
|
-
showPointerStrip,
|
|
271
|
-
pointerStripHeight,
|
|
272
|
-
pointerStripWidth,
|
|
273
|
-
pointerStripColor,
|
|
274
|
-
pointerStripUptoDataPoint,
|
|
275
|
-
pointerLabelComponent,
|
|
276
|
-
stripOverPointer,
|
|
277
|
-
shiftPointerLabelX,
|
|
278
|
-
shiftPointerLabelY,
|
|
279
|
-
pointerLabelWidth,
|
|
280
|
-
pointerLabelHeight,
|
|
281
|
-
autoAdjustPointerLabelPosition,
|
|
282
|
-
pointerVanishDelay,
|
|
283
|
-
activatePointersOnLongPress,
|
|
284
|
-
activatePointersDelay,
|
|
285
|
-
persistPointer,
|
|
286
|
-
hidePointer1,
|
|
287
|
-
hidePointer2,
|
|
288
|
-
hidePointer3,
|
|
289
|
-
hidePointer4,
|
|
290
|
-
hidePointer5,
|
|
291
|
-
hideSecondaryPointer,
|
|
292
|
-
pointerEvents,
|
|
293
|
-
focusEnabled,
|
|
294
|
-
showDataPointOnFocus,
|
|
295
|
-
showStripOnFocus,
|
|
296
|
-
showTextOnFocus,
|
|
297
|
-
showDataPointLabelOnFocus,
|
|
298
|
-
stripHeight,
|
|
299
|
-
stripWidth,
|
|
300
|
-
stripColor,
|
|
301
|
-
stripOpacity,
|
|
302
|
-
stripStrokeDashArray,
|
|
303
|
-
unFocusOnPressOut,
|
|
304
|
-
delayBeforeUnFocus,
|
|
305
|
-
containerHeightIncludingBelowXAxis,
|
|
306
|
-
lineGradient,
|
|
307
|
-
lineGradientDirection,
|
|
308
|
-
lineGradientStartColor,
|
|
309
|
-
lineGradientEndColor,
|
|
310
|
-
barAndLineChartsWrapperProps,
|
|
311
|
-
} = useLineChart({
|
|
312
|
-
...props,
|
|
313
|
-
animations,
|
|
314
|
-
parentWidth: props.parentWidth ?? screenWidth,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
const {secondaryXAxis} = props;
|
|
318
|
-
|
|
319
|
-
const widthValuesFromSet = useMemo(
|
|
320
|
-
() => dataSet?.map(set => new Animated.Value(0)),
|
|
321
|
-
[],
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
useEffect(() => {
|
|
325
|
-
if (animateOnDataChange) {
|
|
326
|
-
Animated.parallel(
|
|
327
|
-
animations.map((anItem, index) =>
|
|
328
|
-
Animated.timing(anItem, {
|
|
329
|
-
toValue: data[index]?.value ?? 0,
|
|
330
|
-
useNativeDriver: Platform.OS === 'ios', // if useNativeDriver is set to true, animateOnDataChange feature fails for Android, so setting it true only for iOS
|
|
331
|
-
duration: onDataChangeAnimationDuration,
|
|
332
|
-
}),
|
|
333
|
-
),
|
|
334
|
-
).start();
|
|
335
|
-
}
|
|
336
|
-
}, [animateOnDataChange, data, onDataChangeAnimationDuration]);
|
|
337
|
-
|
|
338
|
-
const labelsAppear = useCallback(() => {
|
|
339
|
-
opacValue.setValue(0);
|
|
340
|
-
Animated.timing(opacValue, {
|
|
341
|
-
toValue: 1,
|
|
342
|
-
duration: 500,
|
|
343
|
-
easing: Easing.ease,
|
|
344
|
-
useNativeDriver: false,
|
|
345
|
-
}).start();
|
|
346
|
-
}, [opacValue]);
|
|
347
|
-
|
|
348
|
-
const appearingOpacity = opacValue.interpolate({
|
|
349
|
-
inputRange: [0, 1],
|
|
350
|
-
outputRange: [0, 1],
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
const decreaseWidth = useCallback(() => {
|
|
354
|
-
widthValue.setValue(0);
|
|
355
|
-
Animated.timing(widthValue, {
|
|
356
|
-
toValue: 1,
|
|
357
|
-
duration: animationDuration,
|
|
358
|
-
easing: Easing.linear,
|
|
359
|
-
useNativeDriver: false,
|
|
360
|
-
}).start();
|
|
361
|
-
}, [animationDuration, widthValue]);
|
|
362
|
-
|
|
363
|
-
const decreaseWidth2 = useCallback(() => {
|
|
364
|
-
widthValue2.setValue(0);
|
|
365
|
-
Animated.timing(widthValue2, {
|
|
366
|
-
toValue: 1,
|
|
367
|
-
duration: animationDuration,
|
|
368
|
-
easing: Easing.linear,
|
|
369
|
-
useNativeDriver: false,
|
|
370
|
-
}).start();
|
|
371
|
-
}, [animationDuration, widthValue2]);
|
|
372
|
-
|
|
373
|
-
const decreaseWidth3 = useCallback(() => {
|
|
374
|
-
widthValue3.setValue(0);
|
|
375
|
-
Animated.timing(widthValue3, {
|
|
376
|
-
toValue: 1,
|
|
377
|
-
duration: animationDuration,
|
|
378
|
-
easing: Easing.linear,
|
|
379
|
-
useNativeDriver: false,
|
|
380
|
-
}).start();
|
|
381
|
-
}, [animationDuration, widthValue3]);
|
|
382
|
-
|
|
383
|
-
const decreaseWidth4 = useCallback(() => {
|
|
384
|
-
widthValue4.setValue(0);
|
|
385
|
-
Animated.timing(widthValue4, {
|
|
386
|
-
toValue: 1,
|
|
387
|
-
duration: animationDuration,
|
|
388
|
-
easing: Easing.linear,
|
|
389
|
-
useNativeDriver: false,
|
|
390
|
-
}).start();
|
|
391
|
-
}, [animationDuration, widthValue4]);
|
|
392
|
-
|
|
393
|
-
const decreaseWidth5 = useCallback(() => {
|
|
394
|
-
widthValue5.setValue(0);
|
|
395
|
-
Animated.timing(widthValue5, {
|
|
396
|
-
toValue: 1,
|
|
397
|
-
duration: animationDuration,
|
|
398
|
-
easing: Easing.linear,
|
|
399
|
-
useNativeDriver: false,
|
|
400
|
-
}).start();
|
|
401
|
-
}, [animationDuration, widthValue5]);
|
|
402
|
-
|
|
403
|
-
const decreaseWidthsFromSet = useCallback(() => {
|
|
404
|
-
dataSet?.map((set, index) => {
|
|
405
|
-
widthValuesFromSet?.[index]?.setValue(0);
|
|
406
|
-
if (widthValuesFromSet?.[index]) {
|
|
407
|
-
Animated.timing(widthValuesFromSet?.[index], {
|
|
408
|
-
toValue: 1,
|
|
409
|
-
duration: animationDuration,
|
|
410
|
-
easing: Easing.linear,
|
|
411
|
-
useNativeDriver: false,
|
|
412
|
-
}).start();
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}, [animationDuration, widthValuesFromSet]);
|
|
416
|
-
|
|
417
|
-
useEffect(() => {
|
|
418
|
-
decreaseWidth();
|
|
419
|
-
labelsAppear();
|
|
420
|
-
widthValuesFromSet?.forEach((item: any, index: number) => {
|
|
421
|
-
setTimeout(
|
|
422
|
-
() => {
|
|
423
|
-
decreaseWidthsFromSet();
|
|
424
|
-
},
|
|
425
|
-
animateTogether ? 0 : animationDuration * index,
|
|
426
|
-
);
|
|
427
|
-
});
|
|
428
|
-
setTimeout(
|
|
429
|
-
() => {
|
|
430
|
-
decreaseWidth2();
|
|
431
|
-
},
|
|
432
|
-
animateTogether ? 0 : animationDuration,
|
|
433
|
-
);
|
|
434
|
-
setTimeout(
|
|
435
|
-
() => {
|
|
436
|
-
decreaseWidth3();
|
|
437
|
-
},
|
|
438
|
-
animateTogether ? 0 : animationDuration * 2,
|
|
439
|
-
);
|
|
440
|
-
setTimeout(
|
|
441
|
-
() => {
|
|
442
|
-
decreaseWidth4();
|
|
443
|
-
},
|
|
444
|
-
animateTogether ? 0 : animationDuration * 3,
|
|
445
|
-
);
|
|
446
|
-
setTimeout(
|
|
447
|
-
() => {
|
|
448
|
-
decreaseWidth5();
|
|
449
|
-
},
|
|
450
|
-
animateTogether ? 0 : animationDuration * 4,
|
|
451
|
-
);
|
|
452
|
-
}, [
|
|
453
|
-
animateTogether,
|
|
454
|
-
animationDuration,
|
|
455
|
-
decreaseWidth,
|
|
456
|
-
decreaseWidth2,
|
|
457
|
-
decreaseWidth3,
|
|
458
|
-
decreaseWidth4,
|
|
459
|
-
decreaseWidth5,
|
|
460
|
-
labelsAppear,
|
|
461
|
-
]);
|
|
462
|
-
|
|
463
|
-
const renderLabel = (
|
|
464
|
-
top: boolean,
|
|
465
|
-
index: number,
|
|
466
|
-
label: String,
|
|
467
|
-
labelTextStyle: any,
|
|
468
|
-
labelComponent: Function | undefined,
|
|
469
|
-
) => {
|
|
470
|
-
return (
|
|
471
|
-
<View
|
|
472
|
-
style={[
|
|
473
|
-
{
|
|
474
|
-
position: 'absolute',
|
|
475
|
-
bottom: top
|
|
476
|
-
? containerHeight +
|
|
477
|
-
60 +
|
|
478
|
-
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
479
|
-
: 54 - xAxisTextNumberOfLines * 18,
|
|
480
|
-
zIndex: 10,
|
|
481
|
-
width: spacing + labelsExtraHeight,
|
|
482
|
-
left:
|
|
483
|
-
index === 0 && initialSpacing < 10
|
|
484
|
-
? initialSpacing / 2 + spacing * index - spacing / 2 + 4
|
|
485
|
-
: initialSpacing / 2 + spacing * index - spacing / 2 - 10,
|
|
486
|
-
height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
|
|
487
|
-
},
|
|
488
|
-
rotateLabel && {transform: [{rotate: '60deg'}]},
|
|
489
|
-
]}>
|
|
490
|
-
{labelComponent ? (
|
|
491
|
-
labelComponent()
|
|
492
|
-
) : (
|
|
493
|
-
<Text
|
|
494
|
-
style={[{textAlign: 'center'}, labelTextStyle]}
|
|
495
|
-
numberOfLines={xAxisTextNumberOfLines}>
|
|
496
|
-
{label}
|
|
497
|
-
</Text>
|
|
498
|
-
)}
|
|
499
|
-
</View>
|
|
500
|
-
);
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
const renderAnimatedLabel = (
|
|
504
|
-
top: boolean,
|
|
505
|
-
index: number,
|
|
506
|
-
label: String,
|
|
507
|
-
labelTextStyle: any,
|
|
508
|
-
labelComponent: Function | undefined,
|
|
509
|
-
) => {
|
|
510
|
-
return (
|
|
511
|
-
<Animated.View
|
|
512
|
-
style={[
|
|
513
|
-
{
|
|
514
|
-
height: rotateLabel
|
|
515
|
-
? 40
|
|
516
|
-
: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
|
|
517
|
-
position: 'absolute',
|
|
518
|
-
bottom: top
|
|
519
|
-
? containerHeight +
|
|
520
|
-
60 +
|
|
521
|
-
(secondaryXAxis?.labelsDistanceFromXaxis ?? 15)
|
|
522
|
-
: rotateLabel
|
|
523
|
-
? 10
|
|
524
|
-
: 54 - xAxisTextNumberOfLines * 18,
|
|
525
|
-
zIndex: 10,
|
|
526
|
-
width: spacing,
|
|
527
|
-
left:
|
|
528
|
-
index === 0 && initialSpacing < 10
|
|
529
|
-
? initialSpacing / 2 + spacing * index - spacing / 2 + 4
|
|
530
|
-
: initialSpacing / 2 + spacing * index - spacing / 2 - 10,
|
|
531
|
-
opacity: appearingOpacity,
|
|
532
|
-
},
|
|
533
|
-
rotateLabel && {transform: [{rotate: '60deg'}]},
|
|
534
|
-
]}>
|
|
535
|
-
{labelComponent ? (
|
|
536
|
-
labelComponent()
|
|
537
|
-
) : (
|
|
538
|
-
<Text
|
|
539
|
-
style={[{textAlign: 'center'}, labelTextStyle]}
|
|
540
|
-
numberOfLines={xAxisTextNumberOfLines}>
|
|
541
|
-
{label}
|
|
542
|
-
</Text>
|
|
543
|
-
)}
|
|
544
|
-
</Animated.View>
|
|
545
|
-
);
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
const animatedWidth = widthValue.interpolate({
|
|
549
|
-
inputRange: [0, 1],
|
|
550
|
-
outputRange: [0, totalWidth],
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
const animatedWidth2 = widthValue2.interpolate({
|
|
554
|
-
inputRange: [0, 1],
|
|
555
|
-
outputRange: [0, totalWidth],
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
const animatedWidth3 = widthValue3.interpolate({
|
|
559
|
-
inputRange: [0, 1],
|
|
560
|
-
outputRange: [0, totalWidth],
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
const animatedWidth4 = widthValue4.interpolate({
|
|
564
|
-
inputRange: [0, 1],
|
|
565
|
-
outputRange: [0, totalWidth],
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
const animatedWidth5 = widthValue5.interpolate({
|
|
569
|
-
inputRange: [0, 1],
|
|
570
|
-
outputRange: [0, totalWidth],
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
const onStripPress = (item: any, index: number) => {
|
|
574
|
-
if (props.focusedDataPointIndex === undefined || !props.onFocus) {
|
|
575
|
-
setSelectedIndex(index);
|
|
576
|
-
}
|
|
577
|
-
if (props.onFocus) {
|
|
578
|
-
props.onFocus(item, index);
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
const renderDataPoints = (
|
|
583
|
-
hideDataPoints: any,
|
|
584
|
-
dataForRender: any,
|
|
585
|
-
originalDataFromProps: any,
|
|
586
|
-
dataPtsShape: any,
|
|
587
|
-
dataPtsWidth: any,
|
|
588
|
-
dataPtsHeight: any,
|
|
589
|
-
dataPtsColor: any,
|
|
590
|
-
dataPtsRadius: any,
|
|
591
|
-
textColor: any,
|
|
592
|
-
textFontSize: any,
|
|
593
|
-
startIndex: any,
|
|
594
|
-
endIndex: any,
|
|
595
|
-
isSecondary: any,
|
|
596
|
-
showValuesAsDataPointsText: any,
|
|
597
|
-
) => {
|
|
598
|
-
const getYOrSecondaryY = isSecondary ? getSecondaryY : getY;
|
|
599
|
-
return dataForRender.map((item: lineDataItem, index: number) => {
|
|
600
|
-
if (index < startIndex || index > endIndex) return null;
|
|
601
|
-
if (item.hideDataPoint) {
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
let dataPointsShape,
|
|
605
|
-
dataPointsWidth,
|
|
606
|
-
dataPointsHeight,
|
|
607
|
-
dataPointsColor,
|
|
608
|
-
dataPointsRadius,
|
|
609
|
-
text,
|
|
610
|
-
customDataPoint,
|
|
611
|
-
dataPointLabelComponent;
|
|
612
|
-
if (index === selectedIndex) {
|
|
613
|
-
dataPointsShape =
|
|
614
|
-
item.focusedDataPointShape ||
|
|
615
|
-
props.focusedDataPointShape ||
|
|
616
|
-
item.dataPointShape ||
|
|
617
|
-
dataPtsShape;
|
|
618
|
-
dataPointsWidth =
|
|
619
|
-
item.focusedDataPointWidth ||
|
|
620
|
-
props.focusedDataPointWidth ||
|
|
621
|
-
item.dataPointWidth ||
|
|
622
|
-
dataPtsWidth;
|
|
623
|
-
dataPointsHeight =
|
|
624
|
-
item.focusedDataPointHeight ||
|
|
625
|
-
props.focusedDataPointHeight ||
|
|
626
|
-
item.dataPointHeight ||
|
|
627
|
-
dataPtsHeight;
|
|
628
|
-
dataPointsColor =
|
|
629
|
-
item.focusedDataPointColor || props.focusedDataPointColor || 'orange';
|
|
630
|
-
dataPointsRadius =
|
|
631
|
-
item.focusedDataPointRadius ||
|
|
632
|
-
props.focusedDataPointRadius ||
|
|
633
|
-
item.dataPointRadius ||
|
|
634
|
-
dataPtsRadius;
|
|
635
|
-
if (showTextOnFocus) {
|
|
636
|
-
text = item.dataPointText;
|
|
637
|
-
}
|
|
638
|
-
customDataPoint =
|
|
639
|
-
item.focusedCustomDataPoint ||
|
|
640
|
-
props.focusedCustomDataPoint ||
|
|
641
|
-
item.customDataPoint ||
|
|
642
|
-
props.customDataPoint;
|
|
643
|
-
dataPointLabelComponent =
|
|
644
|
-
item.focusedDataPointLabelComponent || item.dataPointLabelComponent;
|
|
645
|
-
} else {
|
|
646
|
-
dataPointsShape = item.dataPointShape || dataPtsShape;
|
|
647
|
-
dataPointsWidth = item.dataPointWidth || dataPtsWidth;
|
|
648
|
-
dataPointsHeight = item.dataPointHeight || dataPtsHeight;
|
|
649
|
-
dataPointsColor = item.dataPointColor || dataPtsColor;
|
|
650
|
-
dataPointsRadius = item.dataPointRadius || dataPtsRadius;
|
|
651
|
-
if (showTextOnFocus) {
|
|
652
|
-
text = '';
|
|
653
|
-
}
|
|
654
|
-
customDataPoint = item.customDataPoint || props.customDataPoint;
|
|
655
|
-
dataPointLabelComponent = item.dataPointLabelComponent;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
if (showValuesAsDataPointsText) {
|
|
659
|
-
text = originalDataFromProps[index].value;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
const currentStripHeight = item.stripHeight ?? stripHeight;
|
|
663
|
-
const currentStripWidth = item.stripWidth ?? stripWidth;
|
|
664
|
-
const currentStripOpacity = item.stripOpacity ?? stripOpacity;
|
|
665
|
-
const currentStripStrokeDashArray =
|
|
666
|
-
item.stripStrokeDashArray ?? stripStrokeDashArray ?? '';
|
|
667
|
-
const currentStripColor = item.stripColor || stripColor;
|
|
668
|
-
const position = I18nManager.isRTL ? 'right' : 'left';
|
|
669
|
-
|
|
670
|
-
const y1 = currentStripHeight
|
|
671
|
-
? containerHeight - currentStripHeight + 8
|
|
672
|
-
: containerHeight -
|
|
673
|
-
dataPointsHeight / 2 +
|
|
674
|
-
14 -
|
|
675
|
-
(item.value * containerHeight) / maxValue;
|
|
676
|
-
|
|
677
|
-
const actualStripHeight =
|
|
678
|
-
currentStripHeight ||
|
|
679
|
-
(item.value * containerHeight) / maxValue - 2 + overflowTop;
|
|
680
|
-
|
|
681
|
-
return (
|
|
682
|
-
<Fragment key={index}>
|
|
683
|
-
{focusEnabled ? (
|
|
684
|
-
<>
|
|
685
|
-
{unFocusOnPressOut ? ( // remove strip on onFocus
|
|
686
|
-
<Rect
|
|
687
|
-
onPressIn={() => onStripPress(item, index)}
|
|
688
|
-
onPressOut={() =>
|
|
689
|
-
setTimeout(() => setSelectedIndex(-1), delayBeforeUnFocus)
|
|
690
|
-
}
|
|
691
|
-
x={initialSpacing + (spacing * index - spacing / 2)}
|
|
692
|
-
y={8}
|
|
693
|
-
width={spacing}
|
|
694
|
-
height={containerHeight - 0}
|
|
695
|
-
fill={'none'}
|
|
696
|
-
/>
|
|
697
|
-
) : (
|
|
698
|
-
<Rect
|
|
699
|
-
onPress={() => onStripPress(item, index)}
|
|
700
|
-
x={initialSpacing + (spacing * index - spacing / 2)}
|
|
701
|
-
y={8}
|
|
702
|
-
width={spacing}
|
|
703
|
-
height={containerHeight}
|
|
704
|
-
fill={'none'}
|
|
705
|
-
/>
|
|
706
|
-
)}
|
|
707
|
-
</>
|
|
708
|
-
) : null}
|
|
709
|
-
{item.showStrip ||
|
|
710
|
-
(focusEnabled && index === selectedIndex && showStripOnFocus) ? (
|
|
711
|
-
<Line
|
|
712
|
-
x1={initialSpacing + spacing * index - currentStripWidth / 2 - 1}
|
|
713
|
-
y1={y1}
|
|
714
|
-
x2={initialSpacing + spacing * index - currentStripWidth / 2 - 1}
|
|
715
|
-
y2={y1 + actualStripHeight}
|
|
716
|
-
strokeWidth={currentStripWidth}
|
|
717
|
-
stroke={currentStripColor}
|
|
718
|
-
strokeDasharray={currentStripStrokeDashArray}
|
|
719
|
-
opacity={currentStripOpacity}
|
|
720
|
-
/>
|
|
721
|
-
) : null}
|
|
722
|
-
{hideDataPoints ? null : (
|
|
723
|
-
<>
|
|
724
|
-
{customDataPoint ? (
|
|
725
|
-
<View
|
|
726
|
-
style={[
|
|
727
|
-
styles.customDataPointContainer,
|
|
728
|
-
{
|
|
729
|
-
height: dataPointsHeight,
|
|
730
|
-
width: dataPointsWidth,
|
|
731
|
-
top: getYOrSecondaryY(item.value),
|
|
732
|
-
[position]:
|
|
733
|
-
initialSpacing - dataPointsWidth + spacing * index,
|
|
734
|
-
transform: [{scaleX: I18nManager.isRTL ? -1 : 1}],
|
|
735
|
-
},
|
|
736
|
-
]}>
|
|
737
|
-
{customDataPoint(item, index)}
|
|
738
|
-
</View>
|
|
739
|
-
) : null}
|
|
740
|
-
{dataPointsShape === 'rectangular' ? (
|
|
741
|
-
<Fragment key={index}>
|
|
742
|
-
{customDataPoint ? null : (
|
|
743
|
-
<Rect
|
|
744
|
-
x={getX(index) - dataPointsWidth / 2}
|
|
745
|
-
y={getYOrSecondaryY(item.value) - dataPointsHeight / 2}
|
|
746
|
-
width={dataPointsWidth}
|
|
747
|
-
height={dataPointsHeight}
|
|
748
|
-
fill={
|
|
749
|
-
showDataPointOnFocus
|
|
750
|
-
? index === selectedIndex
|
|
751
|
-
? dataPointsColor
|
|
752
|
-
: 'none'
|
|
753
|
-
: dataPointsColor
|
|
754
|
-
}
|
|
755
|
-
onPress={() => {
|
|
756
|
-
item.onPress
|
|
757
|
-
? item.onPress(item, index)
|
|
758
|
-
: props.onPress
|
|
759
|
-
? props.onPress(item, index)
|
|
760
|
-
: null;
|
|
761
|
-
}}
|
|
762
|
-
/>
|
|
763
|
-
)}
|
|
764
|
-
</Fragment>
|
|
765
|
-
) : (
|
|
766
|
-
<Fragment key={index}>
|
|
767
|
-
{customDataPoint ? null : (
|
|
768
|
-
<Circle
|
|
769
|
-
cx={getX(index)}
|
|
770
|
-
cy={getYOrSecondaryY(item.value)}
|
|
771
|
-
r={dataPointsRadius}
|
|
772
|
-
fill={
|
|
773
|
-
showDataPointOnFocus
|
|
774
|
-
? index === selectedIndex
|
|
775
|
-
? dataPointsColor
|
|
776
|
-
: 'none'
|
|
777
|
-
: dataPointsColor
|
|
778
|
-
}
|
|
779
|
-
onPress={() => {
|
|
780
|
-
item.onPress
|
|
781
|
-
? item.onPress(item, index)
|
|
782
|
-
: props.onPress
|
|
783
|
-
? props.onPress(item, index)
|
|
784
|
-
: null;
|
|
785
|
-
}}
|
|
786
|
-
/>
|
|
787
|
-
)}
|
|
788
|
-
</Fragment>
|
|
789
|
-
)}
|
|
790
|
-
{dataPointLabelComponent ? (
|
|
791
|
-
!showTextOnFocus || index === selectedIndex ? (
|
|
792
|
-
<View
|
|
793
|
-
style={[
|
|
794
|
-
styles.customDataPointContainer,
|
|
795
|
-
{
|
|
796
|
-
zIndex: index === selectedIndex ? 1000 : 0,
|
|
797
|
-
top:
|
|
798
|
-
containerHeight +
|
|
799
|
-
(item.dataPointLabelShiftY ||
|
|
800
|
-
props.dataPointLabelShiftY ||
|
|
801
|
-
0) -
|
|
802
|
-
(item.value * containerHeight) / maxValue,
|
|
803
|
-
left:
|
|
804
|
-
initialSpacing +
|
|
805
|
-
(item.dataPointLabelShiftX ||
|
|
806
|
-
props.dataPointLabelShiftX ||
|
|
807
|
-
0) -
|
|
808
|
-
(item.dataPointLabelWidth
|
|
809
|
-
? item.dataPointLabelWidth + 20
|
|
810
|
-
: props.dataPointLabelWidth
|
|
811
|
-
? props.dataPointLabelWidth + 20
|
|
812
|
-
: 50) /
|
|
813
|
-
2 +
|
|
814
|
-
spacing * index,
|
|
815
|
-
},
|
|
816
|
-
]}>
|
|
817
|
-
{showDataPointLabelOnFocus
|
|
818
|
-
? index === selectedIndex
|
|
819
|
-
? dataPointLabelComponent()
|
|
820
|
-
: null
|
|
821
|
-
: dataPointLabelComponent()}
|
|
822
|
-
</View>
|
|
823
|
-
) : null
|
|
824
|
-
) : text || item.dataPointText ? (
|
|
825
|
-
!showTextOnFocus || index === selectedIndex ? (
|
|
826
|
-
<CanvasText
|
|
827
|
-
fill={item.textColor || textColor}
|
|
828
|
-
fontSize={item.textFontSize || textFontSize}
|
|
829
|
-
x={
|
|
830
|
-
getX(index) -
|
|
831
|
-
dataPointsWidth +
|
|
832
|
-
(item.textShiftX || props.textShiftX || 0)
|
|
833
|
-
}
|
|
834
|
-
y={
|
|
835
|
-
getYOrSecondaryY(item.value) -
|
|
836
|
-
dataPointsHeight / 2 +
|
|
837
|
-
(item.textShiftY || props.textShiftY || 0)
|
|
838
|
-
}>
|
|
839
|
-
{!showTextOnFocus && !showValuesAsDataPointsText
|
|
840
|
-
? item.dataPointText
|
|
841
|
-
: text}
|
|
842
|
-
</CanvasText>
|
|
843
|
-
) : null
|
|
844
|
-
) : null}
|
|
845
|
-
</>
|
|
846
|
-
)}
|
|
847
|
-
</Fragment>
|
|
848
|
-
);
|
|
849
|
-
});
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
const renderSpecificVerticalLines = (dataForRender: any) => {
|
|
853
|
-
return dataForRender.map((item: lineDataItem, index: number) => {
|
|
854
|
-
if (item.showVerticalLine) {
|
|
855
|
-
const x = getX(index);
|
|
856
|
-
return (
|
|
857
|
-
<Line
|
|
858
|
-
key={index}
|
|
859
|
-
x1={x}
|
|
860
|
-
y1={extendedContainerHeight}
|
|
861
|
-
x2={x}
|
|
862
|
-
y2={
|
|
863
|
-
item.verticalLineUptoDataPoint ?? props.verticalLinesUptoDataPoint
|
|
864
|
-
? getY(item.value)
|
|
865
|
-
: -xAxisThickness
|
|
866
|
-
}
|
|
867
|
-
stroke={
|
|
868
|
-
item.verticalLineColor || props.verticalLinesColor || 'lightgray'
|
|
869
|
-
}
|
|
870
|
-
strokeWidth={
|
|
871
|
-
item.verticalLineThickness || props.verticalLinesThickness || 2
|
|
872
|
-
}
|
|
873
|
-
strokeDasharray={
|
|
874
|
-
item.verticalLineStrokeDashArray ??
|
|
875
|
-
props.verticalLinesStrokeDashArray ??
|
|
876
|
-
''
|
|
877
|
-
}
|
|
878
|
-
/>
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
return null;
|
|
882
|
-
});
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
const renderPointer = (lineNumber: number, isDataSet?: boolean) => {
|
|
886
|
-
if (isDataSet) {
|
|
887
|
-
let pointerItemLocal, pointerYLocal, pointerColorLocal;
|
|
888
|
-
return dataSet?.map((set, index) => {
|
|
889
|
-
const pIndex = barAndLineChartsWrapperProps.pointerIndex;
|
|
890
|
-
pointerItemLocal = set[pIndex];
|
|
891
|
-
pointerYLocal = pointerYsForDataSet[index];
|
|
892
|
-
pointerColorLocal =
|
|
893
|
-
pointerConfig?.pointerColorsForDataSet?.[index] ?? pointerColor;
|
|
894
|
-
return (
|
|
895
|
-
<Fragment key={'dSetPts' + index}>
|
|
896
|
-
{Pointer({
|
|
897
|
-
pointerX,
|
|
898
|
-
pointerYLocal: pointerYLocal + xAxisThickness,
|
|
899
|
-
pointerComponent,
|
|
900
|
-
pointerHeight,
|
|
901
|
-
pointerRadius,
|
|
902
|
-
pointerWidth,
|
|
903
|
-
pointerItemLocal,
|
|
904
|
-
pointerColorLocal,
|
|
905
|
-
})}
|
|
906
|
-
</Fragment>
|
|
907
|
-
);
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
if (lineNumber === 1 && hidePointer1) return;
|
|
911
|
-
if (lineNumber === 2 && hidePointer2) return;
|
|
912
|
-
if (lineNumber === 3 && hidePointer3) return;
|
|
913
|
-
if (lineNumber === 4 && hidePointer4) return;
|
|
914
|
-
if (lineNumber === 5 && hidePointer5) return;
|
|
915
|
-
// 6 is for secondaryData
|
|
916
|
-
if (lineNumber === 6 && hideSecondaryPointer) return;
|
|
917
|
-
|
|
918
|
-
let pointerItemLocal, pointerYLocal, pointerColorLocal;
|
|
919
|
-
switch (lineNumber) {
|
|
920
|
-
case 1:
|
|
921
|
-
pointerItemLocal = pointerItem;
|
|
922
|
-
pointerYLocal = pointerY;
|
|
923
|
-
pointerColorLocal = pointerConfig?.pointer1Color || pointerColor;
|
|
924
|
-
break;
|
|
925
|
-
case 2:
|
|
926
|
-
pointerItemLocal = pointerItem2;
|
|
927
|
-
pointerYLocal = pointerY2;
|
|
928
|
-
pointerColorLocal = pointerConfig?.pointer2Color || pointerColor;
|
|
929
|
-
break;
|
|
930
|
-
case 3:
|
|
931
|
-
pointerItemLocal = pointerItem3;
|
|
932
|
-
pointerYLocal = pointerY3;
|
|
933
|
-
pointerColorLocal = pointerConfig?.pointer3Color || pointerColor;
|
|
934
|
-
break;
|
|
935
|
-
case 4:
|
|
936
|
-
pointerItemLocal = pointerItem4;
|
|
937
|
-
pointerYLocal = pointerY4;
|
|
938
|
-
pointerColorLocal = pointerConfig?.pointer4Color || pointerColor;
|
|
939
|
-
break;
|
|
940
|
-
case 5:
|
|
941
|
-
pointerItemLocal = pointerItem5;
|
|
942
|
-
pointerYLocal = pointerY5;
|
|
943
|
-
pointerColorLocal = pointerConfig?.pointer5Color || pointerColor;
|
|
944
|
-
break;
|
|
945
|
-
case 6:
|
|
946
|
-
pointerItemLocal = secondaryPointerItem;
|
|
947
|
-
pointerYLocal = secondaryPointerY;
|
|
948
|
-
pointerColorLocal =
|
|
949
|
-
pointerConfig?.secondaryPointerColor || pointerColor;
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
if (!pointerYLocal) return;
|
|
953
|
-
|
|
954
|
-
return Pointer({
|
|
955
|
-
pointerX,
|
|
956
|
-
pointerYLocal: pointerYLocal + xAxisThickness,
|
|
957
|
-
pointerComponent,
|
|
958
|
-
pointerHeight,
|
|
959
|
-
pointerRadius,
|
|
960
|
-
pointerWidth,
|
|
961
|
-
pointerItemLocal,
|
|
962
|
-
pointerColorLocal,
|
|
963
|
-
});
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
const renderStripAndLabel = () => {
|
|
967
|
-
let pointerItemLocal, pointerYLocal;
|
|
968
|
-
|
|
969
|
-
pointerItemLocal = [
|
|
970
|
-
{...pointerItem, value: props.data?.[pointerIndex]?.value},
|
|
971
|
-
];
|
|
972
|
-
let arr = [pointerY];
|
|
973
|
-
if (pointerY2 !== 0) {
|
|
974
|
-
arr.push(pointerY2);
|
|
975
|
-
pointerItemLocal.push({
|
|
976
|
-
...pointerItem,
|
|
977
|
-
value: props.data2?.[pointerIndex]?.value,
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
if (pointerY3 !== 0) {
|
|
981
|
-
arr.push(pointerY3);
|
|
982
|
-
pointerItemLocal.push({
|
|
983
|
-
...pointerItem,
|
|
984
|
-
value: props.data3?.[pointerIndex]?.value,
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
if (pointerY4 !== 0) {
|
|
988
|
-
arr.push(pointerY4);
|
|
989
|
-
pointerItemLocal.push({
|
|
990
|
-
...pointerItem,
|
|
991
|
-
value: props.data4?.[pointerIndex]?.value,
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
if (pointerY5 !== 0) {
|
|
995
|
-
arr.push(pointerY5);
|
|
996
|
-
pointerItemLocal.push({
|
|
997
|
-
...pointerItem,
|
|
998
|
-
value: props.data5?.[pointerIndex]?.value,
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
if (secondaryPointerY !== 0) {
|
|
1002
|
-
pointerItemLocal.push({
|
|
1003
|
-
...pointerItem,
|
|
1004
|
-
value: props.secondaryData?.[pointerIndex]?.value,
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
pointerYLocal = Math.min(...arr);
|
|
1008
|
-
|
|
1009
|
-
return StripAndLabel({
|
|
1010
|
-
autoAdjustPointerLabelPosition,
|
|
1011
|
-
pointerX,
|
|
1012
|
-
pointerLabelWidth,
|
|
1013
|
-
activatePointersOnLongPress,
|
|
1014
|
-
yAxisLabelWidth,
|
|
1015
|
-
pointerRadius,
|
|
1016
|
-
pointerWidth,
|
|
1017
|
-
shiftPointerLabelX,
|
|
1018
|
-
pointerLabelHeight,
|
|
1019
|
-
pointerYLocal,
|
|
1020
|
-
pointerStripUptoDataPoint,
|
|
1021
|
-
pointerStripHeight,
|
|
1022
|
-
shiftPointerLabelY,
|
|
1023
|
-
pointerItemLocal,
|
|
1024
|
-
showPointerStrip,
|
|
1025
|
-
pointerStripWidth,
|
|
1026
|
-
containerHeight,
|
|
1027
|
-
xAxisThickness,
|
|
1028
|
-
pointerStripColor,
|
|
1029
|
-
pointerConfig,
|
|
1030
|
-
pointerLabelComponent,
|
|
1031
|
-
secondaryPointerItem,
|
|
1032
|
-
scrollX,
|
|
1033
|
-
pointerEvents,
|
|
1034
|
-
});
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
|
-
const getLineGradientComponent = () => {
|
|
1038
|
-
return props.lineGradientComponent ? (
|
|
1039
|
-
props.lineGradientComponent()
|
|
1040
|
-
) : (
|
|
1041
|
-
<LinearGradient
|
|
1042
|
-
id="lineGradient"
|
|
1043
|
-
x1="0"
|
|
1044
|
-
y1="0"
|
|
1045
|
-
x2={lineGradientDirection === 'horizontal' ? '1' : '0'}
|
|
1046
|
-
y2={lineGradientDirection === 'vertical' ? '1' : '0'}>
|
|
1047
|
-
<Stop offset="0" stopColor={lineGradientStartColor} />
|
|
1048
|
-
<Stop offset="1" stopColor={lineGradientEndColor} />
|
|
1049
|
-
</LinearGradient>
|
|
1050
|
-
);
|
|
1051
|
-
};
|
|
1052
|
-
|
|
1053
|
-
const getAreaGradientComponent = (
|
|
1054
|
-
startFillColor: string,
|
|
1055
|
-
endFillColor: string,
|
|
1056
|
-
startOpacity: number,
|
|
1057
|
-
endOpacity: number,
|
|
1058
|
-
) => {
|
|
1059
|
-
return props.areaGradientComponent ? (
|
|
1060
|
-
props.areaGradientComponent()
|
|
1061
|
-
) : (
|
|
1062
|
-
<LinearGradient
|
|
1063
|
-
id="Gradient"
|
|
1064
|
-
x1="0"
|
|
1065
|
-
y1="0"
|
|
1066
|
-
x2={gradientDirection === 'horizontal' ? '1' : '0'}
|
|
1067
|
-
y2={gradientDirection === 'vertical' ? '1' : '0'}>
|
|
1068
|
-
<Stop
|
|
1069
|
-
offset="0"
|
|
1070
|
-
stopColor={startFillColor}
|
|
1071
|
-
stopOpacity={startOpacity.toString()}
|
|
1072
|
-
/>
|
|
1073
|
-
<Stop
|
|
1074
|
-
offset="1"
|
|
1075
|
-
stopColor={endFillColor}
|
|
1076
|
-
stopOpacity={endOpacity.toString()}
|
|
1077
|
-
/>
|
|
1078
|
-
</LinearGradient>
|
|
1079
|
-
);
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
const lineSvgComponent = (
|
|
1083
|
-
points: any,
|
|
1084
|
-
currentLineThickness: number | undefined,
|
|
1085
|
-
color: ColorValue,
|
|
1086
|
-
fillPoints: any,
|
|
1087
|
-
startFillColor: string,
|
|
1088
|
-
endFillColor: string,
|
|
1089
|
-
startOpacity: number,
|
|
1090
|
-
endOpacity: number,
|
|
1091
|
-
strokeDashArray: Array<number> | undefined | null,
|
|
1092
|
-
showArrow: boolean,
|
|
1093
|
-
arrowPoints: any,
|
|
1094
|
-
arrowStrokeWidth: any,
|
|
1095
|
-
arrowStrokeColor: any,
|
|
1096
|
-
arrowFillColor: any,
|
|
1097
|
-
key: any,
|
|
1098
|
-
) => {
|
|
1099
|
-
if (!points) return null;
|
|
1100
|
-
const isCurved = points.includes('C');
|
|
1101
|
-
const isNthAreaChart = getIsNthAreaChart(key ?? 0);
|
|
1102
|
-
let ar: LineProperties[] = [{d: '', color: '', strokeWidth: 0}];
|
|
1103
|
-
if (points.includes(RANGE_ENTER)) {
|
|
1104
|
-
ar = getRegionPathObjects(
|
|
1105
|
-
points,
|
|
1106
|
-
color,
|
|
1107
|
-
currentLineThickness ?? 0,
|
|
1108
|
-
thickness,
|
|
1109
|
-
strokeDashArray ?? [],
|
|
1110
|
-
isCurved,
|
|
1111
|
-
RANGE_ENTER,
|
|
1112
|
-
STOP,
|
|
1113
|
-
RANGE_EXIT,
|
|
1114
|
-
);
|
|
1115
|
-
} else if (points.includes(SEGMENT_START)) {
|
|
1116
|
-
ar = getSegmentedPathObjects(
|
|
1117
|
-
points,
|
|
1118
|
-
color,
|
|
1119
|
-
currentLineThickness ?? 0,
|
|
1120
|
-
thickness,
|
|
1121
|
-
strokeDashArray ?? [],
|
|
1122
|
-
isCurved,
|
|
1123
|
-
SEGMENT_START,
|
|
1124
|
-
SEGMENT_END,
|
|
1125
|
-
);
|
|
1126
|
-
}
|
|
1127
|
-
const lineSvgPropsOuter: LineSvgProps = {
|
|
1128
|
-
d: points,
|
|
1129
|
-
fill: 'none',
|
|
1130
|
-
stroke: lineGradient
|
|
1131
|
-
? props.lineGradientId
|
|
1132
|
-
? `url(#${props.lineGradientId})`
|
|
1133
|
-
: `url(#lineGradient)`
|
|
1134
|
-
: color,
|
|
1135
|
-
strokeWidth: currentLineThickness || thickness,
|
|
1136
|
-
};
|
|
1137
|
-
if (
|
|
1138
|
-
strokeDashArray &&
|
|
1139
|
-
strokeDashArray.length === 2 &&
|
|
1140
|
-
typeof strokeDashArray[0] === 'number' &&
|
|
1141
|
-
typeof strokeDashArray[1] === 'number'
|
|
1142
|
-
) {
|
|
1143
|
-
lineSvgPropsOuter.strokeDasharray = strokeDashArray;
|
|
1144
|
-
}
|
|
1145
|
-
return (
|
|
1146
|
-
<Svg onPress={props.onBackgroundPress}>
|
|
1147
|
-
{lineGradient && getLineGradientComponent()}
|
|
1148
|
-
{points.includes(SEGMENT_START) || points.includes(RANGE_ENTER) ? (
|
|
1149
|
-
ar.map((item, index) => {
|
|
1150
|
-
const lineSvgProps: LineSvgProps = {
|
|
1151
|
-
d: item.d,
|
|
1152
|
-
fill: 'none',
|
|
1153
|
-
stroke: lineGradient
|
|
1154
|
-
? props.lineGradientId
|
|
1155
|
-
? `url(#${props.lineGradientId})`
|
|
1156
|
-
: `url(#lineGradient)`
|
|
1157
|
-
: item.color,
|
|
1158
|
-
strokeWidth: item.strokeWidth,
|
|
1159
|
-
};
|
|
1160
|
-
if (
|
|
1161
|
-
item.strokeDashArray &&
|
|
1162
|
-
item.strokeDashArray.length === 2 &&
|
|
1163
|
-
typeof item.strokeDashArray[0] === 'number' &&
|
|
1164
|
-
typeof item.strokeDashArray[1] === 'number'
|
|
1165
|
-
) {
|
|
1166
|
-
lineSvgProps.strokeDasharray = item.strokeDashArray;
|
|
1167
|
-
}
|
|
1168
|
-
return <Path key={index} {...lineSvgProps} />;
|
|
1169
|
-
})
|
|
1170
|
-
) : (
|
|
1171
|
-
<Path {...lineSvgPropsOuter} />
|
|
1172
|
-
)}
|
|
1173
|
-
|
|
1174
|
-
{/*********************** For Area Chart ************/}
|
|
1175
|
-
|
|
1176
|
-
{isNthAreaChart &&
|
|
1177
|
-
getAreaGradientComponent(
|
|
1178
|
-
startFillColor,
|
|
1179
|
-
endFillColor,
|
|
1180
|
-
startOpacity,
|
|
1181
|
-
endOpacity,
|
|
1182
|
-
)}
|
|
1183
|
-
{isNthAreaChart && (
|
|
1184
|
-
<Path
|
|
1185
|
-
onPress={props.onChartAreaPress}
|
|
1186
|
-
d={fillPoints}
|
|
1187
|
-
fill={
|
|
1188
|
-
props.areaGradientId
|
|
1189
|
-
? `url(#${props.areaGradientId})`
|
|
1190
|
-
: `url(#Gradient)`
|
|
1191
|
-
}
|
|
1192
|
-
stroke={'transparent'}
|
|
1193
|
-
strokeWidth={currentLineThickness || thickness}
|
|
1194
|
-
/>
|
|
1195
|
-
)}
|
|
1196
|
-
|
|
1197
|
-
{/******************************************************************/}
|
|
1198
|
-
|
|
1199
|
-
{renderSpecificVerticalLines(data)}
|
|
1200
|
-
{renderSpecificVerticalLines(data2)}
|
|
1201
|
-
{renderSpecificVerticalLines(data3)}
|
|
1202
|
-
{renderSpecificVerticalLines(data4)}
|
|
1203
|
-
{renderSpecificVerticalLines(data5)}
|
|
1204
|
-
|
|
1205
|
-
{dataSet?.map(set => renderSpecificVerticalLines(set?.data)) ?? null}
|
|
1206
|
-
{dataSet?.map(set => {
|
|
1207
|
-
return renderDataPoints(
|
|
1208
|
-
set.hideDataPoints ?? hideDataPoints1,
|
|
1209
|
-
set.data,
|
|
1210
|
-
adjustToOffset(set.data, -(props.yAxisOffset ?? 0)), // need the actual values passed by user
|
|
1211
|
-
set.dataPointsShape ?? dataPointsShape1,
|
|
1212
|
-
set.dataPointsWidth ?? dataPointsWidth1,
|
|
1213
|
-
set.dataPointsHeight ?? dataPointsHeight1,
|
|
1214
|
-
set.dataPointsColor ?? dataPointsColor1,
|
|
1215
|
-
set.dataPointsRadius ?? dataPointsRadius1,
|
|
1216
|
-
set.textColor ?? textColor1,
|
|
1217
|
-
set.textFontSize ?? textFontSize1,
|
|
1218
|
-
set.startIndex ?? 0,
|
|
1219
|
-
set.endIndex ?? set.data.length - 1,
|
|
1220
|
-
false,
|
|
1221
|
-
showValuesAsDataPointsText,
|
|
1222
|
-
);
|
|
1223
|
-
}) ?? null}
|
|
1224
|
-
|
|
1225
|
-
{/*** !!! Here it's done 5 times intentionally, trying to make it to only 1 breaks things !!! ***/}
|
|
1226
|
-
{renderDataPoints(
|
|
1227
|
-
hideDataPoints1,
|
|
1228
|
-
data,
|
|
1229
|
-
props.data,
|
|
1230
|
-
dataPointsShape1,
|
|
1231
|
-
dataPointsWidth1,
|
|
1232
|
-
dataPointsHeight1,
|
|
1233
|
-
dataPointsColor1,
|
|
1234
|
-
dataPointsRadius1,
|
|
1235
|
-
textColor1,
|
|
1236
|
-
textFontSize1,
|
|
1237
|
-
startIndex1,
|
|
1238
|
-
endIndex1,
|
|
1239
|
-
false,
|
|
1240
|
-
showValuesAsDataPointsText,
|
|
1241
|
-
)}
|
|
1242
|
-
{renderDataPoints(
|
|
1243
|
-
hideDataPoints2,
|
|
1244
|
-
data2,
|
|
1245
|
-
props.data2,
|
|
1246
|
-
dataPointsShape2,
|
|
1247
|
-
dataPointsWidth2,
|
|
1248
|
-
dataPointsHeight2,
|
|
1249
|
-
dataPointsColor2,
|
|
1250
|
-
dataPointsRadius2,
|
|
1251
|
-
textColor2,
|
|
1252
|
-
textFontSize2,
|
|
1253
|
-
startIndex2,
|
|
1254
|
-
endIndex2,
|
|
1255
|
-
false,
|
|
1256
|
-
showValuesAsDataPointsText,
|
|
1257
|
-
)}
|
|
1258
|
-
{renderDataPoints(
|
|
1259
|
-
hideDataPoints3,
|
|
1260
|
-
data3,
|
|
1261
|
-
props.data3,
|
|
1262
|
-
dataPointsShape3,
|
|
1263
|
-
dataPointsWidth3,
|
|
1264
|
-
dataPointsHeight3,
|
|
1265
|
-
dataPointsColor3,
|
|
1266
|
-
dataPointsRadius3,
|
|
1267
|
-
textColor3,
|
|
1268
|
-
textFontSize3,
|
|
1269
|
-
startIndex3,
|
|
1270
|
-
endIndex3,
|
|
1271
|
-
false,
|
|
1272
|
-
showValuesAsDataPointsText,
|
|
1273
|
-
)}
|
|
1274
|
-
{renderDataPoints(
|
|
1275
|
-
hideDataPoints4,
|
|
1276
|
-
data4,
|
|
1277
|
-
props.data4,
|
|
1278
|
-
dataPointsShape4,
|
|
1279
|
-
dataPointsWidth4,
|
|
1280
|
-
dataPointsHeight4,
|
|
1281
|
-
dataPointsColor4,
|
|
1282
|
-
dataPointsRadius4,
|
|
1283
|
-
textColor4,
|
|
1284
|
-
textFontSize4,
|
|
1285
|
-
startIndex4,
|
|
1286
|
-
endIndex4,
|
|
1287
|
-
false,
|
|
1288
|
-
showValuesAsDataPointsText,
|
|
1289
|
-
)}
|
|
1290
|
-
{renderDataPoints(
|
|
1291
|
-
hideDataPoints5,
|
|
1292
|
-
data5,
|
|
1293
|
-
props.data5,
|
|
1294
|
-
dataPointsShape5,
|
|
1295
|
-
dataPointsWidth5,
|
|
1296
|
-
dataPointsHeight5,
|
|
1297
|
-
dataPointsColor5,
|
|
1298
|
-
dataPointsRadius5,
|
|
1299
|
-
textColor5,
|
|
1300
|
-
textFontSize5,
|
|
1301
|
-
startIndex5,
|
|
1302
|
-
endIndex5,
|
|
1303
|
-
false,
|
|
1304
|
-
showValuesAsDataPointsText,
|
|
1305
|
-
)}
|
|
1306
|
-
{secondaryData?.length
|
|
1307
|
-
? renderDataPoints(
|
|
1308
|
-
secondaryLineConfig.hideDataPoints,
|
|
1309
|
-
secondaryData,
|
|
1310
|
-
props.secondaryData,
|
|
1311
|
-
secondaryLineConfig.dataPointsShape,
|
|
1312
|
-
secondaryLineConfig.dataPointsWidth,
|
|
1313
|
-
secondaryLineConfig.dataPointsHeight,
|
|
1314
|
-
secondaryLineConfig.dataPointsColor,
|
|
1315
|
-
secondaryLineConfig.dataPointsRadius,
|
|
1316
|
-
secondaryLineConfig.textColor,
|
|
1317
|
-
secondaryLineConfig.textFontSize,
|
|
1318
|
-
secondaryLineConfig.startIndex,
|
|
1319
|
-
secondaryLineConfig.endIndex,
|
|
1320
|
-
true,
|
|
1321
|
-
secondaryLineConfig.showValuesAsDataPointsText,
|
|
1322
|
-
)
|
|
1323
|
-
: null}
|
|
1324
|
-
{showArrow && (
|
|
1325
|
-
<Path
|
|
1326
|
-
d={arrowPoints}
|
|
1327
|
-
fill={arrowFillColor}
|
|
1328
|
-
stroke={arrowStrokeColor}
|
|
1329
|
-
strokeWidth={arrowStrokeWidth}
|
|
1330
|
-
/>
|
|
1331
|
-
)}
|
|
1332
|
-
</Svg>
|
|
1333
|
-
);
|
|
1334
|
-
};
|
|
1335
|
-
|
|
1336
|
-
const activatePointers = (x: number) => {
|
|
1337
|
-
let factor = (x - initialSpacing) / spacing;
|
|
1338
|
-
factor = Math.round(factor);
|
|
1339
|
-
factor = Math.min(factor, (data0 ?? data).length - 1);
|
|
1340
|
-
factor = Math.max(factor, 0);
|
|
1341
|
-
let z =
|
|
1342
|
-
initialSpacing +
|
|
1343
|
-
spacing * factor -
|
|
1344
|
-
(pointerRadius || pointerWidth / 2) -
|
|
1345
|
-
1;
|
|
1346
|
-
setPointerX(z);
|
|
1347
|
-
setPointerIndex(factor);
|
|
1348
|
-
let item, y;
|
|
1349
|
-
item = (data0 ?? data)[factor];
|
|
1350
|
-
y =
|
|
1351
|
-
containerHeight -
|
|
1352
|
-
(item.value * containerHeight) / maxValue -
|
|
1353
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1354
|
-
10;
|
|
1355
|
-
setPointerY(y);
|
|
1356
|
-
setPointerItem(item);
|
|
1357
|
-
if (data2 && data2.length) {
|
|
1358
|
-
item = data2[factor];
|
|
1359
|
-
if (item) {
|
|
1360
|
-
y =
|
|
1361
|
-
containerHeight -
|
|
1362
|
-
(item.value * containerHeight) / maxValue -
|
|
1363
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1364
|
-
10;
|
|
1365
|
-
setPointerY2(y);
|
|
1366
|
-
setPointerItem2(item);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
if (data3 && data3.length) {
|
|
1370
|
-
item = data3[factor];
|
|
1371
|
-
if (item) {
|
|
1372
|
-
y =
|
|
1373
|
-
containerHeight -
|
|
1374
|
-
(item.value * containerHeight) / maxValue -
|
|
1375
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1376
|
-
10;
|
|
1377
|
-
setPointerY3(y);
|
|
1378
|
-
setPointerItem3(item);
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
if (data4 && data4.length) {
|
|
1382
|
-
item = data4[factor];
|
|
1383
|
-
if (item) {
|
|
1384
|
-
y =
|
|
1385
|
-
containerHeight -
|
|
1386
|
-
(item.value * containerHeight) / maxValue -
|
|
1387
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1388
|
-
10;
|
|
1389
|
-
setPointerY4(y);
|
|
1390
|
-
setPointerItem4(item);
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
if (data5 && data5.length) {
|
|
1394
|
-
item = data5[factor];
|
|
1395
|
-
if (item) {
|
|
1396
|
-
y =
|
|
1397
|
-
containerHeight -
|
|
1398
|
-
(item.value * containerHeight) / maxValue -
|
|
1399
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1400
|
-
10;
|
|
1401
|
-
setPointerY5(y);
|
|
1402
|
-
setPointerItem5(item);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
if (secondaryData?.length) {
|
|
1406
|
-
item = secondaryData[factor];
|
|
1407
|
-
if (item) {
|
|
1408
|
-
y =
|
|
1409
|
-
containerHeight -
|
|
1410
|
-
(item.value * containerHeight) / secondaryMaxValue -
|
|
1411
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1412
|
-
10;
|
|
1413
|
-
setSecondaryPointerY(y);
|
|
1414
|
-
// @ts-ignore
|
|
1415
|
-
setSecondaryPointerItem(item);
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
if (dataSet?.length) {
|
|
1419
|
-
if (dataSet[0].data[factor]) {
|
|
1420
|
-
const ysForDataSet = dataSet.map(set => {
|
|
1421
|
-
const item = set.data[factor];
|
|
1422
|
-
const y = item
|
|
1423
|
-
? containerHeight -
|
|
1424
|
-
(item.value * containerHeight) / maxValue -
|
|
1425
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1426
|
-
10
|
|
1427
|
-
: 0;
|
|
1428
|
-
return y;
|
|
1429
|
-
});
|
|
1430
|
-
setPointerYsForDataSet(ysForDataSet);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
};
|
|
1434
|
-
|
|
1435
|
-
const renderLine = (
|
|
1436
|
-
zIndex: number,
|
|
1437
|
-
points: any,
|
|
1438
|
-
currentLineThickness: number | undefined,
|
|
1439
|
-
color: ColorValue,
|
|
1440
|
-
fillPoints: any,
|
|
1441
|
-
startFillColor: string,
|
|
1442
|
-
endFillColor: string,
|
|
1443
|
-
startOpacity: number,
|
|
1444
|
-
endOpacity: number,
|
|
1445
|
-
strokeDashArray: Array<number> | undefined | null,
|
|
1446
|
-
showArrow: any,
|
|
1447
|
-
arrowPoints: any,
|
|
1448
|
-
arrowStrokeWidth: any,
|
|
1449
|
-
arrowStrokeColor: any,
|
|
1450
|
-
arrowFillColor: any,
|
|
1451
|
-
key?: number,
|
|
1452
|
-
) => {
|
|
1453
|
-
return (
|
|
1454
|
-
<View
|
|
1455
|
-
key={key ?? 0}
|
|
1456
|
-
onMoveShouldSetResponder={evt => (pointerConfig ? true : false)}
|
|
1457
|
-
onResponderGrant={evt => {
|
|
1458
|
-
if (!pointerConfig) return;
|
|
1459
|
-
setResponderStartTime(evt.timeStamp);
|
|
1460
|
-
if (activatePointersOnLongPress) {
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
let x = evt.nativeEvent.locationX;
|
|
1464
|
-
activatePointers(x);
|
|
1465
|
-
}}
|
|
1466
|
-
onResponderMove={evt => {
|
|
1467
|
-
if (!pointerConfig) return;
|
|
1468
|
-
if (
|
|
1469
|
-
activatePointersOnLongPress &&
|
|
1470
|
-
evt.timeStamp - responderStartTime < activatePointersDelay
|
|
1471
|
-
) {
|
|
1472
|
-
return;
|
|
1473
|
-
} else {
|
|
1474
|
-
setResponderActive(true);
|
|
1475
|
-
}
|
|
1476
|
-
let x = evt.nativeEvent.locationX;
|
|
1477
|
-
if (
|
|
1478
|
-
!activatePointersOnLongPress &&
|
|
1479
|
-
x > (props.width || Dimensions.get('window').width)
|
|
1480
|
-
)
|
|
1481
|
-
return;
|
|
1482
|
-
let factor = (x - initialSpacing) / spacing;
|
|
1483
|
-
factor = Math.round(factor);
|
|
1484
|
-
factor = Math.min(factor, (data0 ?? data).length - 1);
|
|
1485
|
-
factor = Math.max(factor, 0);
|
|
1486
|
-
let z =
|
|
1487
|
-
initialSpacing +
|
|
1488
|
-
spacing * factor -
|
|
1489
|
-
(pointerRadius || pointerWidth / 2) -
|
|
1490
|
-
1;
|
|
1491
|
-
let item, y;
|
|
1492
|
-
setPointerX(z);
|
|
1493
|
-
setPointerIndex(factor);
|
|
1494
|
-
item = (data0 ?? data)[factor];
|
|
1495
|
-
y =
|
|
1496
|
-
containerHeight -
|
|
1497
|
-
(item.value * containerHeight) / maxValue -
|
|
1498
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1499
|
-
10;
|
|
1500
|
-
setPointerY(y);
|
|
1501
|
-
setPointerItem(item);
|
|
1502
|
-
if (data2 && data2.length) {
|
|
1503
|
-
item = data2[factor];
|
|
1504
|
-
if (item) {
|
|
1505
|
-
y =
|
|
1506
|
-
containerHeight -
|
|
1507
|
-
(item.value * containerHeight) / maxValue -
|
|
1508
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1509
|
-
10;
|
|
1510
|
-
setPointerY2(y);
|
|
1511
|
-
setPointerItem2(item);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
if (data3 && data3.length) {
|
|
1515
|
-
item = data3[factor];
|
|
1516
|
-
if (item) {
|
|
1517
|
-
y =
|
|
1518
|
-
containerHeight -
|
|
1519
|
-
(item.value * containerHeight) / maxValue -
|
|
1520
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1521
|
-
10;
|
|
1522
|
-
setPointerY3(y);
|
|
1523
|
-
setPointerItem3(item);
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
if (data4 && data4.length) {
|
|
1527
|
-
item = data4[factor];
|
|
1528
|
-
if (item) {
|
|
1529
|
-
y =
|
|
1530
|
-
containerHeight -
|
|
1531
|
-
(item.value * containerHeight) / maxValue -
|
|
1532
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1533
|
-
10;
|
|
1534
|
-
setPointerY4(y);
|
|
1535
|
-
setPointerItem4(item);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
if (data5 && data5.length) {
|
|
1539
|
-
item = data5[factor];
|
|
1540
|
-
if (item) {
|
|
1541
|
-
y =
|
|
1542
|
-
containerHeight -
|
|
1543
|
-
(item.value * containerHeight) / maxValue -
|
|
1544
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1545
|
-
10;
|
|
1546
|
-
setPointerY5(y);
|
|
1547
|
-
setPointerItem5(item);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
if (secondaryData?.length) {
|
|
1551
|
-
item = secondaryData[factor];
|
|
1552
|
-
if (item) {
|
|
1553
|
-
y =
|
|
1554
|
-
containerHeight -
|
|
1555
|
-
(item.value * containerHeight) / secondaryMaxValue -
|
|
1556
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1557
|
-
10;
|
|
1558
|
-
setSecondaryPointerY(y);
|
|
1559
|
-
// @ts-ignore
|
|
1560
|
-
setSecondaryPointerItem(item);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
if (dataSet?.length) {
|
|
1564
|
-
const ysForDataSet = dataSet.map(set => {
|
|
1565
|
-
const item = set.data[factor];
|
|
1566
|
-
const y = item
|
|
1567
|
-
? containerHeight -
|
|
1568
|
-
(item.value * containerHeight) / maxValue -
|
|
1569
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1570
|
-
10
|
|
1571
|
-
: 0;
|
|
1572
|
-
return y;
|
|
1573
|
-
});
|
|
1574
|
-
setPointerYsForDataSet(ysForDataSet);
|
|
1575
|
-
}
|
|
1576
|
-
}}
|
|
1577
|
-
// onResponderReject={evt => {
|
|
1578
|
-
// console.log('evt...reject.......',evt);
|
|
1579
|
-
// }}
|
|
1580
|
-
onResponderEnd={evt => {
|
|
1581
|
-
// console.log('evt...end.......',evt);
|
|
1582
|
-
setResponderStartTime(0);
|
|
1583
|
-
setPointerIndex(-1);
|
|
1584
|
-
setResponderActive(false);
|
|
1585
|
-
if (!persistPointer)
|
|
1586
|
-
setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
1587
|
-
}}
|
|
1588
|
-
onResponderTerminationRequest={evt => false}
|
|
1589
|
-
// onResponderTerminate={evt => {
|
|
1590
|
-
// console.log('evt...terminate.......',evt);
|
|
1591
|
-
// }}
|
|
1592
|
-
// onResponderRelease={evt => {
|
|
1593
|
-
// setResponderStartTime(0);
|
|
1594
|
-
// setResponderActive(false);
|
|
1595
|
-
// setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
1596
|
-
// }}
|
|
1597
|
-
style={{
|
|
1598
|
-
position: 'absolute',
|
|
1599
|
-
height:
|
|
1600
|
-
containerHeightIncludingBelowXAxis +
|
|
1601
|
-
(props.overflowBottom ?? dataPointsRadius1),
|
|
1602
|
-
bottom:
|
|
1603
|
-
60 +
|
|
1604
|
-
xAxisLabelsVerticalShift +
|
|
1605
|
-
labelsExtraHeight -
|
|
1606
|
-
xAxisThickness -
|
|
1607
|
-
(props.overflowBottom ?? dataPointsRadius1),
|
|
1608
|
-
zIndex: zIndex,
|
|
1609
|
-
transform: [{scaleX: I18nManager.isRTL ? -1 : 1}],
|
|
1610
|
-
width: totalWidth,
|
|
1611
|
-
}}>
|
|
1612
|
-
{lineSvgComponent(
|
|
1613
|
-
points,
|
|
1614
|
-
currentLineThickness,
|
|
1615
|
-
color,
|
|
1616
|
-
fillPoints,
|
|
1617
|
-
startFillColor,
|
|
1618
|
-
endFillColor,
|
|
1619
|
-
startOpacity,
|
|
1620
|
-
endOpacity,
|
|
1621
|
-
strokeDashArray,
|
|
1622
|
-
showArrow,
|
|
1623
|
-
arrowPoints,
|
|
1624
|
-
arrowStrokeWidth,
|
|
1625
|
-
arrowStrokeColor,
|
|
1626
|
-
arrowFillColor,
|
|
1627
|
-
key,
|
|
1628
|
-
)}
|
|
1629
|
-
</View>
|
|
1630
|
-
);
|
|
1631
|
-
};
|
|
1632
|
-
|
|
1633
|
-
const renderAnimatedLine = (
|
|
1634
|
-
zIndex: number,
|
|
1635
|
-
points: any,
|
|
1636
|
-
animatedWidth: any,
|
|
1637
|
-
currentLineThickness: number | undefined,
|
|
1638
|
-
color: ColorValue,
|
|
1639
|
-
fillPoints: any,
|
|
1640
|
-
startFillColor: string,
|
|
1641
|
-
endFillColor: string,
|
|
1642
|
-
startOpacity: number,
|
|
1643
|
-
endOpacity: number,
|
|
1644
|
-
strokeDashArray: Array<number> | undefined | null,
|
|
1645
|
-
showArrow: any,
|
|
1646
|
-
arrowPoints: any,
|
|
1647
|
-
arrowStrokeWidth: any,
|
|
1648
|
-
arrowStrokeColor: any,
|
|
1649
|
-
arrowFillColor: any,
|
|
1650
|
-
key?: number,
|
|
1651
|
-
) => {
|
|
1652
|
-
return (
|
|
1653
|
-
<Animated.View
|
|
1654
|
-
key={key ?? 0}
|
|
1655
|
-
onStartShouldSetResponder={evt => (pointerConfig ? true : false)}
|
|
1656
|
-
onMoveShouldSetResponder={evt => (pointerConfig ? true : false)}
|
|
1657
|
-
onResponderGrant={evt => {
|
|
1658
|
-
if (!pointerConfig) return;
|
|
1659
|
-
setResponderStartTime(evt.timeStamp);
|
|
1660
|
-
if (activatePointersOnLongPress) {
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
let x = evt.nativeEvent.locationX;
|
|
1664
|
-
activatePointers(x);
|
|
1665
|
-
}}
|
|
1666
|
-
onResponderMove={evt => {
|
|
1667
|
-
if (!pointerConfig) return;
|
|
1668
|
-
if (
|
|
1669
|
-
activatePointersOnLongPress &&
|
|
1670
|
-
evt.timeStamp - responderStartTime < activatePointersDelay
|
|
1671
|
-
) {
|
|
1672
|
-
return;
|
|
1673
|
-
} else {
|
|
1674
|
-
setResponderActive(true);
|
|
1675
|
-
}
|
|
1676
|
-
let x = evt.nativeEvent.locationX;
|
|
1677
|
-
if (
|
|
1678
|
-
!activatePointersOnLongPress &&
|
|
1679
|
-
x > (props.width || Dimensions.get('window').width)
|
|
1680
|
-
)
|
|
1681
|
-
return;
|
|
1682
|
-
let factor = (x - initialSpacing) / spacing;
|
|
1683
|
-
factor = Math.round(factor);
|
|
1684
|
-
factor = Math.min(factor, (data0 ?? data).length - 1);
|
|
1685
|
-
factor = Math.max(factor, 0);
|
|
1686
|
-
let z =
|
|
1687
|
-
initialSpacing +
|
|
1688
|
-
spacing * factor -
|
|
1689
|
-
(pointerRadius || pointerWidth / 2) -
|
|
1690
|
-
1;
|
|
1691
|
-
let item, y;
|
|
1692
|
-
setPointerX(z);
|
|
1693
|
-
setPointerIndex(factor);
|
|
1694
|
-
item = (data0 ?? data)[factor];
|
|
1695
|
-
y =
|
|
1696
|
-
containerHeight -
|
|
1697
|
-
(item.value * containerHeight) / maxValue -
|
|
1698
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1699
|
-
10;
|
|
1700
|
-
setPointerY(y);
|
|
1701
|
-
setPointerItem(item);
|
|
1702
|
-
if (data2 && data2.length) {
|
|
1703
|
-
item = data2[factor];
|
|
1704
|
-
if (item) {
|
|
1705
|
-
y =
|
|
1706
|
-
containerHeight -
|
|
1707
|
-
(item.value * containerHeight) / maxValue -
|
|
1708
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1709
|
-
10;
|
|
1710
|
-
setPointerY2(y);
|
|
1711
|
-
setPointerItem2(item);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
if (data3 && data3.length) {
|
|
1715
|
-
item = data3[factor];
|
|
1716
|
-
if (item) {
|
|
1717
|
-
y =
|
|
1718
|
-
containerHeight -
|
|
1719
|
-
(item.value * containerHeight) / maxValue -
|
|
1720
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1721
|
-
10;
|
|
1722
|
-
setPointerY3(y);
|
|
1723
|
-
setPointerItem3(item);
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
if (data4 && data4.length) {
|
|
1727
|
-
item = data4[factor];
|
|
1728
|
-
if (item) {
|
|
1729
|
-
y =
|
|
1730
|
-
containerHeight -
|
|
1731
|
-
(item.value * containerHeight) / maxValue -
|
|
1732
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1733
|
-
10;
|
|
1734
|
-
setPointerY4(y);
|
|
1735
|
-
setPointerItem4(item);
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
if (data5 && data5.length) {
|
|
1739
|
-
item = data5[factor];
|
|
1740
|
-
if (item) {
|
|
1741
|
-
y =
|
|
1742
|
-
containerHeight -
|
|
1743
|
-
(item.value * containerHeight) / maxValue -
|
|
1744
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1745
|
-
10;
|
|
1746
|
-
setPointerY5(y);
|
|
1747
|
-
setPointerItem5(item);
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
if (secondaryData?.length) {
|
|
1751
|
-
item = secondaryData[factor];
|
|
1752
|
-
if (item) {
|
|
1753
|
-
y =
|
|
1754
|
-
containerHeight -
|
|
1755
|
-
(item.value * containerHeight) / secondaryMaxValue -
|
|
1756
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1757
|
-
10;
|
|
1758
|
-
|
|
1759
|
-
setSecondaryPointerY(y);
|
|
1760
|
-
// @ts-ignore
|
|
1761
|
-
setSecondaryPointerItem(item);
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
if (dataSet?.length) {
|
|
1765
|
-
if (dataSet[0].data[factor]) {
|
|
1766
|
-
const ysForDataSet = dataSet.map(set => {
|
|
1767
|
-
const item = set.data[factor];
|
|
1768
|
-
const y = item
|
|
1769
|
-
? containerHeight -
|
|
1770
|
-
(item.value * containerHeight) / maxValue -
|
|
1771
|
-
(pointerRadius || pointerHeight / 2) +
|
|
1772
|
-
10
|
|
1773
|
-
: 0;
|
|
1774
|
-
return y;
|
|
1775
|
-
});
|
|
1776
|
-
setPointerYsForDataSet(ysForDataSet);
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
}}
|
|
1780
|
-
// onResponderReject={evt => {
|
|
1781
|
-
// console.log('evt...reject.......',evt);
|
|
1782
|
-
// }}
|
|
1783
|
-
onResponderEnd={evt => {
|
|
1784
|
-
// console.log('evt...end.......',evt);
|
|
1785
|
-
setResponderStartTime(0);
|
|
1786
|
-
setPointerIndex(-1);
|
|
1787
|
-
setResponderActive(false);
|
|
1788
|
-
if (!persistPointer)
|
|
1789
|
-
setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
1790
|
-
}}
|
|
1791
|
-
onResponderTerminationRequest={evt => false}
|
|
1792
|
-
// onResponderTerminate={evt => {
|
|
1793
|
-
// console.log('evt...terminate.......',evt);
|
|
1794
|
-
// }}
|
|
1795
|
-
// onResponderRelease={evt => {
|
|
1796
|
-
// setResponderStartTime(0);
|
|
1797
|
-
// setResponderActive(false);
|
|
1798
|
-
// setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
1799
|
-
// }}
|
|
1800
|
-
style={{
|
|
1801
|
-
position: 'absolute',
|
|
1802
|
-
height:
|
|
1803
|
-
containerHeightIncludingBelowXAxis +
|
|
1804
|
-
(props.overflowBottom ?? dataPointsRadius1),
|
|
1805
|
-
bottom:
|
|
1806
|
-
60 +
|
|
1807
|
-
xAxisLabelsVerticalShift +
|
|
1808
|
-
labelsExtraHeight -
|
|
1809
|
-
xAxisThickness -
|
|
1810
|
-
(props.overflowBottom ?? dataPointsRadius1),
|
|
1811
|
-
zIndex: zIndex,
|
|
1812
|
-
transform: [{scaleX: I18nManager.isRTL ? -1 : 1}],
|
|
1813
|
-
width: animatedWidth,
|
|
1814
|
-
}}>
|
|
1815
|
-
{lineSvgComponent(
|
|
1816
|
-
points,
|
|
1817
|
-
currentLineThickness,
|
|
1818
|
-
color,
|
|
1819
|
-
fillPoints,
|
|
1820
|
-
startFillColor,
|
|
1821
|
-
endFillColor,
|
|
1822
|
-
startOpacity,
|
|
1823
|
-
endOpacity,
|
|
1824
|
-
strokeDashArray,
|
|
1825
|
-
showArrow,
|
|
1826
|
-
arrowPoints,
|
|
1827
|
-
arrowStrokeWidth,
|
|
1828
|
-
arrowStrokeColor,
|
|
1829
|
-
arrowFillColor,
|
|
1830
|
-
key,
|
|
1831
|
-
)}
|
|
1832
|
-
</Animated.View>
|
|
1833
|
-
);
|
|
1834
|
-
};
|
|
1835
|
-
|
|
1836
|
-
const remainingScrollViewProps = {
|
|
1837
|
-
onScroll: (ev: any) => {
|
|
1838
|
-
props.onScroll?.(ev);
|
|
1839
|
-
if (
|
|
1840
|
-
pointerConfig &&
|
|
1841
|
-
pointerConfig.activatePointersOnLongPress &&
|
|
1842
|
-
pointerConfig.autoAdjustPointerLabelPosition
|
|
1843
|
-
) {
|
|
1844
|
-
setScrollX(ev.nativeEvent.contentOffset.x);
|
|
1845
|
-
}
|
|
1846
|
-
},
|
|
1847
|
-
};
|
|
1848
|
-
|
|
1849
|
-
const renderChartContent = () => {
|
|
1850
|
-
return (
|
|
1851
|
-
<>
|
|
1852
|
-
{dataSet
|
|
1853
|
-
? pointsFromSet.length
|
|
1854
|
-
? dataSet.map((set, index) => {
|
|
1855
|
-
if (isAnimated) {
|
|
1856
|
-
return renderAnimatedLine(
|
|
1857
|
-
set.zIndex ?? zIndex1,
|
|
1858
|
-
pointsFromSet[index],
|
|
1859
|
-
animatedWidth,
|
|
1860
|
-
set.thickness ?? thickness1,
|
|
1861
|
-
set.color ?? color1,
|
|
1862
|
-
fillPointsFromSet[index],
|
|
1863
|
-
set.startFillColor ?? startFillColor1,
|
|
1864
|
-
set.endFillColor ?? endFillColor1,
|
|
1865
|
-
set.startOpacity ?? startOpacity1,
|
|
1866
|
-
set.endOpacity ?? endOpacity1,
|
|
1867
|
-
set.strokeDashArray ?? strokeDashArray1,
|
|
1868
|
-
set.showArrow || props.showArrows,
|
|
1869
|
-
arrowPointsFromSet[index],
|
|
1870
|
-
arrowStrokeWidthsFromSet?.[index],
|
|
1871
|
-
arrowStrokeColorsFromSet?.[index],
|
|
1872
|
-
arrowFillColorsFromSet?.[index],
|
|
1873
|
-
index,
|
|
1874
|
-
);
|
|
1875
|
-
} else {
|
|
1876
|
-
return renderLine(
|
|
1877
|
-
set.zIndex ?? zIndex1,
|
|
1878
|
-
pointsFromSet[index],
|
|
1879
|
-
set.thickness ?? thickness1,
|
|
1880
|
-
set.color ?? color1,
|
|
1881
|
-
fillPointsFromSet[index],
|
|
1882
|
-
set.startFillColor ?? startFillColor1,
|
|
1883
|
-
set.endFillColor ?? endFillColor1,
|
|
1884
|
-
set.startOpacity ?? startOpacity1,
|
|
1885
|
-
set.endOpacity ?? endOpacity1,
|
|
1886
|
-
set.strokeDashArray ?? strokeDashArray1,
|
|
1887
|
-
set.showArrow || props.showArrows,
|
|
1888
|
-
arrowPointsFromSet[index],
|
|
1889
|
-
arrowStrokeWidthsFromSet?.[index],
|
|
1890
|
-
arrowStrokeColorsFromSet?.[index],
|
|
1891
|
-
arrowFillColorsFromSet?.[index],
|
|
1892
|
-
index,
|
|
1893
|
-
);
|
|
1894
|
-
}
|
|
1895
|
-
})
|
|
1896
|
-
: null
|
|
1897
|
-
: isAnimated
|
|
1898
|
-
? renderAnimatedLine(
|
|
1899
|
-
zIndex1,
|
|
1900
|
-
points,
|
|
1901
|
-
animatedWidth,
|
|
1902
|
-
thickness1,
|
|
1903
|
-
color1,
|
|
1904
|
-
fillPoints,
|
|
1905
|
-
startFillColor1,
|
|
1906
|
-
endFillColor1,
|
|
1907
|
-
startOpacity1,
|
|
1908
|
-
endOpacity1,
|
|
1909
|
-
strokeDashArray1,
|
|
1910
|
-
props.showArrow1 || props.showArrows,
|
|
1911
|
-
arrow1Points,
|
|
1912
|
-
arrowStrokeWidth1,
|
|
1913
|
-
arrowStrokeColor1,
|
|
1914
|
-
arrowFillColor1,
|
|
1915
|
-
0,
|
|
1916
|
-
)
|
|
1917
|
-
: renderLine(
|
|
1918
|
-
zIndex1,
|
|
1919
|
-
points,
|
|
1920
|
-
thickness1,
|
|
1921
|
-
color1,
|
|
1922
|
-
fillPoints,
|
|
1923
|
-
startFillColor1,
|
|
1924
|
-
endFillColor1,
|
|
1925
|
-
startOpacity1,
|
|
1926
|
-
endOpacity1,
|
|
1927
|
-
strokeDashArray1,
|
|
1928
|
-
props.showArrow1 || props.showArrows,
|
|
1929
|
-
arrow1Points,
|
|
1930
|
-
arrowStrokeWidth1,
|
|
1931
|
-
arrowStrokeColor1,
|
|
1932
|
-
arrowFillColor1,
|
|
1933
|
-
0,
|
|
1934
|
-
)}
|
|
1935
|
-
{secondaryPoints
|
|
1936
|
-
? isAnimated
|
|
1937
|
-
? renderAnimatedLine(
|
|
1938
|
-
secondaryLineConfig.zIndex,
|
|
1939
|
-
secondaryPoints,
|
|
1940
|
-
animatedWidth,
|
|
1941
|
-
secondaryLineConfig.thickness,
|
|
1942
|
-
secondaryLineConfig.color,
|
|
1943
|
-
secondaryFillPoints,
|
|
1944
|
-
secondaryLineConfig.startFillColor,
|
|
1945
|
-
secondaryLineConfig.endFillColor,
|
|
1946
|
-
secondaryLineConfig.startOpacity,
|
|
1947
|
-
secondaryLineConfig.endOpacity,
|
|
1948
|
-
secondaryLineConfig.strokeDashArray,
|
|
1949
|
-
secondaryLineConfig.showArrow,
|
|
1950
|
-
secondaryArrowPoints,
|
|
1951
|
-
secondaryLineConfig.arrowConfig?.strokeWidth,
|
|
1952
|
-
secondaryLineConfig.arrowConfig?.strokeColor,
|
|
1953
|
-
secondaryLineConfig.arrowConfig?.fillColor,
|
|
1954
|
-
6,
|
|
1955
|
-
)
|
|
1956
|
-
: renderLine(
|
|
1957
|
-
secondaryLineConfig.zIndex,
|
|
1958
|
-
secondaryPoints,
|
|
1959
|
-
secondaryLineConfig.thickness,
|
|
1960
|
-
secondaryLineConfig.color,
|
|
1961
|
-
secondaryFillPoints,
|
|
1962
|
-
secondaryLineConfig.startFillColor,
|
|
1963
|
-
secondaryLineConfig.endFillColor,
|
|
1964
|
-
secondaryLineConfig.startOpacity,
|
|
1965
|
-
secondaryLineConfig.endOpacity,
|
|
1966
|
-
secondaryLineConfig.strokeDashArray,
|
|
1967
|
-
secondaryLineConfig.showArrow,
|
|
1968
|
-
secondaryArrowPoints,
|
|
1969
|
-
secondaryLineConfig.arrowConfig?.strokeWidth,
|
|
1970
|
-
secondaryLineConfig.arrowConfig?.strokeColor,
|
|
1971
|
-
secondaryLineConfig.arrowConfig?.fillColor,
|
|
1972
|
-
6,
|
|
1973
|
-
)
|
|
1974
|
-
: null}
|
|
1975
|
-
{points2
|
|
1976
|
-
? isAnimated
|
|
1977
|
-
? renderAnimatedLine(
|
|
1978
|
-
zIndex2,
|
|
1979
|
-
points2,
|
|
1980
|
-
animatedWidth2,
|
|
1981
|
-
thickness2,
|
|
1982
|
-
color2,
|
|
1983
|
-
fillPoints2,
|
|
1984
|
-
startFillColor2,
|
|
1985
|
-
endFillColor2,
|
|
1986
|
-
startOpacity2,
|
|
1987
|
-
endOpacity2,
|
|
1988
|
-
strokeDashArray2,
|
|
1989
|
-
props.showArrow2 || props.showArrows,
|
|
1990
|
-
arrow2Points,
|
|
1991
|
-
arrowStrokeWidth2,
|
|
1992
|
-
arrowStrokeColor2,
|
|
1993
|
-
arrowFillColor2,
|
|
1994
|
-
1,
|
|
1995
|
-
)
|
|
1996
|
-
: renderLine(
|
|
1997
|
-
zIndex2,
|
|
1998
|
-
points2,
|
|
1999
|
-
thickness2,
|
|
2000
|
-
color2,
|
|
2001
|
-
fillPoints2,
|
|
2002
|
-
startFillColor2,
|
|
2003
|
-
endFillColor2,
|
|
2004
|
-
startOpacity2,
|
|
2005
|
-
endOpacity2,
|
|
2006
|
-
strokeDashArray2,
|
|
2007
|
-
props.showArrow2 || props.showArrows,
|
|
2008
|
-
arrow2Points,
|
|
2009
|
-
arrowStrokeWidth2,
|
|
2010
|
-
arrowStrokeColor2,
|
|
2011
|
-
arrowFillColor2,
|
|
2012
|
-
1,
|
|
2013
|
-
)
|
|
2014
|
-
: null}
|
|
2015
|
-
{points3
|
|
2016
|
-
? isAnimated
|
|
2017
|
-
? renderAnimatedLine(
|
|
2018
|
-
zIndex3,
|
|
2019
|
-
points3,
|
|
2020
|
-
animatedWidth3,
|
|
2021
|
-
thickness3,
|
|
2022
|
-
color3,
|
|
2023
|
-
fillPoints3,
|
|
2024
|
-
startFillColor3,
|
|
2025
|
-
endFillColor3,
|
|
2026
|
-
startOpacity3,
|
|
2027
|
-
endOpacity3,
|
|
2028
|
-
strokeDashArray3,
|
|
2029
|
-
props.showArrow3 || props.showArrows,
|
|
2030
|
-
arrow3Points,
|
|
2031
|
-
arrowStrokeWidth3,
|
|
2032
|
-
arrowStrokeColor3,
|
|
2033
|
-
arrowFillColor3,
|
|
2034
|
-
2,
|
|
2035
|
-
)
|
|
2036
|
-
: renderLine(
|
|
2037
|
-
zIndex3,
|
|
2038
|
-
points3,
|
|
2039
|
-
thickness3,
|
|
2040
|
-
color3,
|
|
2041
|
-
fillPoints3,
|
|
2042
|
-
startFillColor3,
|
|
2043
|
-
endFillColor3,
|
|
2044
|
-
startOpacity3,
|
|
2045
|
-
endOpacity3,
|
|
2046
|
-
strokeDashArray3,
|
|
2047
|
-
props.showArrow3 || props.showArrows,
|
|
2048
|
-
arrow3Points,
|
|
2049
|
-
arrowStrokeWidth3,
|
|
2050
|
-
arrowStrokeColor3,
|
|
2051
|
-
arrowFillColor3,
|
|
2052
|
-
2,
|
|
2053
|
-
)
|
|
2054
|
-
: null}
|
|
2055
|
-
{points4
|
|
2056
|
-
? isAnimated
|
|
2057
|
-
? renderAnimatedLine(
|
|
2058
|
-
zIndex4,
|
|
2059
|
-
points4,
|
|
2060
|
-
animatedWidth4,
|
|
2061
|
-
thickness4,
|
|
2062
|
-
color4,
|
|
2063
|
-
fillPoints4,
|
|
2064
|
-
startFillColor4,
|
|
2065
|
-
endFillColor4,
|
|
2066
|
-
startOpacity4,
|
|
2067
|
-
endOpacity4,
|
|
2068
|
-
strokeDashArray4,
|
|
2069
|
-
props.showArrow4 || props.showArrows,
|
|
2070
|
-
arrow4Points,
|
|
2071
|
-
arrowStrokeWidth4,
|
|
2072
|
-
arrowStrokeColor4,
|
|
2073
|
-
arrowFillColor4,
|
|
2074
|
-
3,
|
|
2075
|
-
)
|
|
2076
|
-
: renderLine(
|
|
2077
|
-
zIndex4,
|
|
2078
|
-
points4,
|
|
2079
|
-
thickness4,
|
|
2080
|
-
color4,
|
|
2081
|
-
fillPoints4,
|
|
2082
|
-
startFillColor4,
|
|
2083
|
-
endFillColor4,
|
|
2084
|
-
startOpacity4,
|
|
2085
|
-
endOpacity4,
|
|
2086
|
-
strokeDashArray4,
|
|
2087
|
-
props.showArrow4 || props.showArrows,
|
|
2088
|
-
arrow4Points,
|
|
2089
|
-
arrowStrokeWidth4,
|
|
2090
|
-
arrowStrokeColor4,
|
|
2091
|
-
arrowFillColor4,
|
|
2092
|
-
3,
|
|
2093
|
-
)
|
|
2094
|
-
: null}
|
|
2095
|
-
{points5
|
|
2096
|
-
? isAnimated
|
|
2097
|
-
? renderAnimatedLine(
|
|
2098
|
-
zIndex5,
|
|
2099
|
-
points5,
|
|
2100
|
-
animatedWidth5,
|
|
2101
|
-
thickness5,
|
|
2102
|
-
color5,
|
|
2103
|
-
fillPoints5,
|
|
2104
|
-
startFillColor5,
|
|
2105
|
-
endFillColor5,
|
|
2106
|
-
startOpacity5,
|
|
2107
|
-
endOpacity5,
|
|
2108
|
-
strokeDashArray5,
|
|
2109
|
-
props.showArrow5 || props.showArrows,
|
|
2110
|
-
arrow5Points,
|
|
2111
|
-
arrowStrokeWidth5,
|
|
2112
|
-
arrowStrokeColor5,
|
|
2113
|
-
arrowFillColor5,
|
|
2114
|
-
4,
|
|
2115
|
-
)
|
|
2116
|
-
: renderLine(
|
|
2117
|
-
zIndex5,
|
|
2118
|
-
points5,
|
|
2119
|
-
thickness5,
|
|
2120
|
-
color5,
|
|
2121
|
-
fillPoints5,
|
|
2122
|
-
startFillColor5,
|
|
2123
|
-
endFillColor5,
|
|
2124
|
-
startOpacity5,
|
|
2125
|
-
endOpacity5,
|
|
2126
|
-
strokeDashArray5,
|
|
2127
|
-
props.showArrow5 || props.showArrows,
|
|
2128
|
-
arrow5Points,
|
|
2129
|
-
arrowStrokeWidth5,
|
|
2130
|
-
arrowStrokeColor5,
|
|
2131
|
-
arrowFillColor5,
|
|
2132
|
-
4,
|
|
2133
|
-
)
|
|
2134
|
-
: null}
|
|
2135
|
-
{pointerX > 0 ? (
|
|
2136
|
-
<View
|
|
2137
|
-
pointerEvents={pointerEvents ?? 'none'}
|
|
2138
|
-
style={{
|
|
2139
|
-
position: 'absolute',
|
|
2140
|
-
height:
|
|
2141
|
-
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
|
|
2142
|
-
bottom:
|
|
2143
|
-
58 + labelsExtraHeight + xAxisLabelsVerticalShift - overflowTop,
|
|
2144
|
-
// width: totalWidth,
|
|
2145
|
-
zIndex: 20,
|
|
2146
|
-
}}>
|
|
2147
|
-
{!stripOverPointer && renderStripAndLabel()}
|
|
2148
|
-
{dataSet ? (
|
|
2149
|
-
renderPointer(0, true)
|
|
2150
|
-
) : (
|
|
2151
|
-
// dataSet.map((set, index) => renderPointer(index))
|
|
2152
|
-
<>
|
|
2153
|
-
{renderPointer(1)}
|
|
2154
|
-
{points2 ? renderPointer(2) : null}
|
|
2155
|
-
{points3 ? renderPointer(3) : null}
|
|
2156
|
-
{points4 ? renderPointer(4) : null}
|
|
2157
|
-
{points5 ? renderPointer(5) : null}
|
|
2158
|
-
{secondaryPoints ? renderPointer(6) : null}
|
|
2159
|
-
{stripOverPointer && renderStripAndLabel()}
|
|
2160
|
-
</>
|
|
2161
|
-
)}
|
|
2162
|
-
</View>
|
|
2163
|
-
) : null}
|
|
2164
|
-
{(data0 ?? data).map((item: lineDataItem, index: number) => {
|
|
2165
|
-
const secondaryLabel =
|
|
2166
|
-
item.secondaryLabel ?? secondaryXAxis?.labelTexts?.[index] ?? '';
|
|
2167
|
-
const secondaryLabelTextStyle =
|
|
2168
|
-
item.secondaryLabelTextStyle ??
|
|
2169
|
-
secondaryXAxis?.labelsTextStyle ??
|
|
2170
|
-
item.labelTextStyle ??
|
|
2171
|
-
props.xAxisLabelTextStyle;
|
|
2172
|
-
return (
|
|
2173
|
-
<View key={index}>
|
|
2174
|
-
{isAnimated
|
|
2175
|
-
? renderAnimatedLabel(
|
|
2176
|
-
false,
|
|
2177
|
-
index,
|
|
2178
|
-
item.label ||
|
|
2179
|
-
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
2180
|
-
? props.xAxisLabelTexts[index]
|
|
2181
|
-
: ''),
|
|
2182
|
-
item.labelTextStyle || props.xAxisLabelTextStyle,
|
|
2183
|
-
item.labelComponent,
|
|
2184
|
-
)
|
|
2185
|
-
: renderLabel(
|
|
2186
|
-
false,
|
|
2187
|
-
index,
|
|
2188
|
-
item.label ||
|
|
2189
|
-
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
2190
|
-
? props.xAxisLabelTexts[index]
|
|
2191
|
-
: ''),
|
|
2192
|
-
item.labelTextStyle || props.xAxisLabelTextStyle,
|
|
2193
|
-
item.labelComponent,
|
|
2194
|
-
)}
|
|
2195
|
-
{secondaryXAxis
|
|
2196
|
-
? isAnimated
|
|
2197
|
-
? renderAnimatedLabel(
|
|
2198
|
-
true,
|
|
2199
|
-
index,
|
|
2200
|
-
secondaryLabel,
|
|
2201
|
-
secondaryLabelTextStyle,
|
|
2202
|
-
item.secondaryLabelComponent,
|
|
2203
|
-
)
|
|
2204
|
-
: renderLabel(
|
|
2205
|
-
true,
|
|
2206
|
-
index,
|
|
2207
|
-
secondaryLabel,
|
|
2208
|
-
secondaryLabelTextStyle,
|
|
2209
|
-
item.secondaryLabelComponent,
|
|
2210
|
-
)
|
|
2211
|
-
: null}
|
|
2212
|
-
</View>
|
|
2213
|
-
);
|
|
2214
|
-
})}
|
|
2215
|
-
</>
|
|
2216
|
-
);
|
|
2217
|
-
};
|
|
2218
|
-
|
|
2219
|
-
return (
|
|
2220
|
-
<BarAndLineChartsWrapper
|
|
2221
|
-
{...barAndLineChartsWrapperProps}
|
|
2222
|
-
scrollRef={scrollRef}
|
|
2223
|
-
animatedWidth={animatedWidth}
|
|
2224
|
-
renderChartContent={renderChartContent}
|
|
2225
|
-
remainingScrollViewProps={remainingScrollViewProps}
|
|
2226
|
-
/>
|
|
2227
|
-
);
|
|
2228
|
-
};
|