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