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