react-native-gifted-charts 1.4.11 → 1.4.12

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