react-native-gifted-charts 1.4.19 → 1.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +6 -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 -147
  43. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -158
  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 -2228
  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,147 +0,0 @@
1
- import React from 'react';
2
- import {View, Animated} from 'react-native';
3
- import Svg, {Path} from 'react-native-svg';
4
- import {renderSpecificVerticalLines} from './renderSpecificVerticalLines';
5
- import {renderDataPoints} from './renderDataPoints';
6
- import {renderSpecificDataPoints} from './renderSpecificDataPoints';
7
-
8
- const RenderLineInBarChart = (props: any) => {
9
- const {
10
- yAxisLabelWidth,
11
- initialSpacing,
12
- spacing,
13
- containerHeight,
14
- lineConfig,
15
- maxValue,
16
- animatedWidth,
17
- lineBehindBars,
18
- points,
19
- arrowPoints,
20
- data,
21
- totalWidth,
22
- barWidth,
23
- labelsExtraHeight,
24
- xAxisLabelsVerticalShift,
25
- } = props;
26
-
27
- const firstBarWidth = data[0].barWidth ?? barWidth;
28
-
29
- const dataPointsProps = {
30
- data,
31
- lineConfig,
32
- barWidth,
33
- containerHeight,
34
- maxValue,
35
- firstBarWidth,
36
- yAxisLabelWidth,
37
- spacing,
38
- };
39
-
40
- const specificVerticalLinesProps = {
41
- data,
42
- barWidth,
43
- yAxisLabelWidth,
44
- initialSpacing,
45
- spacing,
46
- containerHeight,
47
- lineConfig,
48
- maxValue,
49
- };
50
-
51
- const specificDataPointsProps = {
52
- data,
53
- barWidth,
54
- firstBarWidth,
55
- yAxisLabelWidth,
56
- lineConfig,
57
- spacing,
58
- containerHeight,
59
- maxValue,
60
- };
61
-
62
- const renderAnimatedLine = () => {
63
- // console.log('animatedWidth is-------->', animatedWidth);
64
- return (
65
- <Animated.View
66
- pointerEvents="none"
67
- style={{
68
- position: 'absolute',
69
- height: containerHeight + 10,
70
- left: 6 - yAxisLabelWidth,
71
- bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
72
- width: animatedWidth,
73
- zIndex: lineBehindBars ? -1 : 100000,
74
- // backgroundColor: 'wheat',
75
- }}>
76
- <Svg>
77
- <Path
78
- d={points}
79
- fill="none"
80
- stroke={lineConfig.color}
81
- strokeWidth={lineConfig.thickness}
82
- />
83
-
84
- {renderSpecificVerticalLines(specificVerticalLinesProps)}
85
-
86
- {!lineConfig.hideDataPoints
87
- ? renderDataPoints(dataPointsProps)
88
- : renderSpecificDataPoints(specificDataPointsProps)}
89
- {lineConfig.showArrow && (
90
- <Path
91
- d={arrowPoints}
92
- fill={lineConfig.arrowConfig.fillColor}
93
- stroke={lineConfig.arrowConfig.strokeColor}
94
- strokeWidth={lineConfig.arrowConfig.strokeWidth}
95
- />
96
- )}
97
- </Svg>
98
- </Animated.View>
99
- );
100
- };
101
-
102
- const renderLine = () => {
103
- return (
104
- <View
105
- pointerEvents="none"
106
- style={{
107
- position: 'absolute',
108
- height: containerHeight + 10 + labelsExtraHeight,
109
- left: 6 - yAxisLabelWidth,
110
- bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
111
- width: totalWidth,
112
- zIndex: lineBehindBars ? -1 : 100000,
113
- // backgroundColor: 'rgba(200,150,150,0.1)'
114
- }}>
115
- <Svg>
116
- <Path
117
- d={points}
118
- fill="none"
119
- stroke={lineConfig.color}
120
- strokeWidth={lineConfig.thickness}
121
- />
122
- {renderSpecificVerticalLines(specificVerticalLinesProps)}
123
-
124
- {!lineConfig.hideDataPoints
125
- ? renderDataPoints(dataPointsProps)
126
- : renderSpecificDataPoints(specificDataPointsProps)}
127
- {lineConfig.showArrow && (
128
- <Path
129
- d={arrowPoints}
130
- fill={lineConfig.arrowConfig.fillColor}
131
- stroke={lineConfig.arrowConfig.strokeColor}
132
- strokeWidth={lineConfig.arrowConfig.strokeWidth}
133
- />
134
- )}
135
- </Svg>
136
- </View>
137
- );
138
- };
139
-
140
- if (lineConfig.isAnimated) {
141
- return renderAnimatedLine();
142
- }
143
-
144
- return renderLine();
145
- };
146
-
147
- export default RenderLineInBarChart;
@@ -1,158 +0,0 @@
1
- import React, {Fragment} from 'react';
2
- import {styles} from '../../../BarChart/styles';
3
- import {View} from 'react-native';
4
- import {getXForLineInBar, getYForLineInBar} from 'gifted-charts-core';
5
- import {Rect, Text as CanvasText, Circle} from 'react-native-svg';
6
-
7
- export const renderDataPoints = (props: any) => {
8
- const {
9
- data,
10
- lineConfig,
11
- barWidth,
12
- containerHeight,
13
- maxValue,
14
- firstBarWidth,
15
- yAxisLabelWidth,
16
- spacing,
17
- } = props;
18
- return data.map((item: any, index: number) => {
19
- if (index < lineConfig.startIndex || index > lineConfig.endIndex || item.hideDataPoint) {
20
- return null;
21
- }
22
- const currentBarWidth = item.barWidth || barWidth || 30;
23
- const customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
24
- const value =
25
- item.value ??
26
- item.stacks.reduce((total: number, item: any) => total + item.value, 0);
27
- if (customDataPoint) {
28
- return (
29
- <View
30
- style={[
31
- styles.customDataPointContainer,
32
- {
33
- height: lineConfig.dataPointsHeight,
34
- width: lineConfig.dataPointsWidth,
35
- top:
36
- containerHeight -
37
- (value * containerHeight) / maxValue -
38
- (item.shiftY ?? lineConfig.shiftY ?? 0),
39
- left: getXForLineInBar(
40
- index,
41
- firstBarWidth,
42
- currentBarWidth,
43
- yAxisLabelWidth,
44
- lineConfig,
45
- spacing,
46
- ),
47
- },
48
- ]}>
49
- {customDataPoint(item, index)}
50
- </View>
51
- );
52
- }
53
- if (lineConfig.dataPointsShape === 'rectangular') {
54
- return (
55
- <Fragment key={index}>
56
- <Rect
57
- x={getXForLineInBar(
58
- index,
59
- firstBarWidth,
60
- currentBarWidth,
61
- yAxisLabelWidth,
62
- lineConfig,
63
- spacing,
64
- )}
65
- y={
66
- getYForLineInBar(
67
- value,
68
- lineConfig.shiftY,
69
- containerHeight,
70
- maxValue,
71
- ) -
72
- lineConfig.dataPointsHeight / 2
73
- }
74
- width={lineConfig.dataPointsWidth}
75
- height={lineConfig.dataPointsHeight}
76
- fill={lineConfig.dataPointsColor}
77
- />
78
- {item.dataPointText && (
79
- <CanvasText
80
- fill={item.textColor || lineConfig.textColor}
81
- fontSize={item.textFontSize || lineConfig.textFontSize}
82
- x={
83
- getXForLineInBar(
84
- index,
85
- firstBarWidth,
86
- currentBarWidth,
87
- yAxisLabelWidth,
88
- lineConfig,
89
- spacing,
90
- ) + (item.textShiftX || lineConfig.textShiftX || 0)
91
- }
92
- y={
93
- getYForLineInBar(
94
- value,
95
- lineConfig.shiftY,
96
- containerHeight,
97
- maxValue,
98
- ) -
99
- lineConfig.dataPointsHeight / 2 +
100
- (item.textShiftY || lineConfig.textShiftY || 0)
101
- }>
102
- {item.dataPointText}
103
- </CanvasText>
104
- )}
105
- </Fragment>
106
- );
107
- }
108
- return (
109
- <Fragment key={index}>
110
- <Circle
111
- cx={getXForLineInBar(
112
- index,
113
- firstBarWidth,
114
- currentBarWidth,
115
- yAxisLabelWidth,
116
- lineConfig,
117
- spacing,
118
- )}
119
- cy={getYForLineInBar(
120
- value,
121
- lineConfig.shiftY,
122
- containerHeight,
123
- maxValue,
124
- )}
125
- r={lineConfig.dataPointsRadius}
126
- fill={lineConfig.dataPointsColor}
127
- />
128
- {item.dataPointText && (
129
- <CanvasText
130
- fill={item.textColor || lineConfig.textColor}
131
- fontSize={item.textFontSize || lineConfig.textFontSize}
132
- x={
133
- getXForLineInBar(
134
- index,
135
- firstBarWidth,
136
- currentBarWidth,
137
- yAxisLabelWidth,
138
- lineConfig,
139
- spacing,
140
- ) + (item.textShiftX || lineConfig.textShiftX || 0)
141
- }
142
- y={
143
- getYForLineInBar(
144
- value,
145
- lineConfig.shiftY,
146
- containerHeight,
147
- maxValue,
148
- ) -
149
- lineConfig.dataPointsHeight / 2 +
150
- (item.textShiftY || lineConfig.textShiftY || 0)
151
- }>
152
- {item.dataPointText}
153
- </CanvasText>
154
- )}
155
- </Fragment>
156
- );
157
- });
158
- };
@@ -1,86 +0,0 @@
1
- import React, {Fragment} from 'react';
2
- import {getXForLineInBar, getYForLineInBar} from 'gifted-charts-core';
3
- import {Circle, Rect, Text as CanvasText} from 'react-native-svg';
4
-
5
- export const renderSpecificDataPoints = (props: any) => {
6
- const {
7
- data,
8
- barWidth,
9
- firstBarWidth,
10
- yAxisLabelWidth,
11
- lineConfig,
12
- spacing,
13
- containerHeight,
14
- maxValue,
15
- } = props;
16
- return data.map((item: any, index: number) => {
17
- const currentBarWidth = item.barWidth || barWidth || 30;
18
- const x = getXForLineInBar(
19
- index,
20
- firstBarWidth,
21
- currentBarWidth,
22
- yAxisLabelWidth,
23
- lineConfig,
24
- spacing,
25
- );
26
- const y = getYForLineInBar(
27
- item.value,
28
- lineConfig.shiftY,
29
- containerHeight,
30
- maxValue,
31
- );
32
- if (item.showDataPoint) {
33
- if (item.dataPointShape === 'rectangular') {
34
- return (
35
- <Fragment key={index}>
36
- <Rect
37
- x={x}
38
- y={y - item.dataPointsHeight / 2}
39
- width={item.dataPointWidth || lineConfig.dataPointsWidth}
40
- height={item.dataPointHeight || 2}
41
- fill={item.dataPointColor || 'black'}
42
- />
43
- {item.dataPointText && (
44
- <CanvasText
45
- fill={item.textColor || 'black'}
46
- fontSize={item.textFontSize || 10}
47
- x={x + (item.textShiftX || lineConfig.textShiftX || 0)}
48
- y={
49
- y -
50
- (item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
51
- (item.textShiftY || lineConfig.textShiftY || 0)
52
- }>
53
- {item.dataPointText}
54
- </CanvasText>
55
- )}
56
- </Fragment>
57
- );
58
- } else {
59
- return (
60
- <Fragment key={index}>
61
- <Circle
62
- cx={x}
63
- cy={y}
64
- r={item.dataPointRadius || 3}
65
- fill={item.dataPointColor || 'black'}
66
- />
67
- {item.dataPointText && (
68
- <CanvasText
69
- fill={item.textColor || 'black'}
70
- fontSize={item.textFontSize || 10}
71
- x={x + (item.textShiftX || lineConfig.textShiftX || 0)}
72
- y={
73
- y -
74
- (item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
75
- (item.textShiftY || lineConfig.textShiftY || 0)
76
- }>
77
- {item.dataPointText}
78
- </CanvasText>
79
- )}
80
- </Fragment>
81
- );
82
- }
83
- }
84
- return null;
85
- });
86
- };
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import {Rect} from 'react-native-svg';
3
-
4
- export const renderSpecificVerticalLines = (props: any) => {
5
- const {
6
- data,
7
- barWidth,
8
- yAxisLabelWidth,
9
- initialSpacing,
10
- spacing,
11
- containerHeight,
12
- lineConfig,
13
- maxValue,
14
- } = props;
15
- return data.map((item: any, index: number) => {
16
- if (item.showVerticalLine) {
17
- const currentBarWidth = item.barWidth || barWidth || 30;
18
- return (
19
- <Rect
20
- x={
21
- yAxisLabelWidth +
22
- 6 -
23
- (item.verticalLineThickness || 1) / 2 -
24
- 1 -
25
- (initialSpacing - currentBarWidth / 2) +
26
- (currentBarWidth + spacing) * index
27
- }
28
- y={
29
- containerHeight -
30
- lineConfig.shiftY -
31
- (item.value * containerHeight) / maxValue +
32
- 9
33
- }
34
- width={item.verticalLineThickness || 1}
35
- height={(item.value * containerHeight) / maxValue + lineConfig.shiftY}
36
- fill={item.verticalLineColor || 'lightgray'}
37
- />
38
- );
39
- }
40
- return null;
41
- });
42
- };
@@ -1,131 +0,0 @@
1
- import React from 'react';
2
- import {View} from 'react-native';
3
- import {chartTypes} from 'gifted-charts-core';
4
- import {Line, Svg} from 'react-native-svg';
5
-
6
- const RenderVerticalLines = (props: any) => {
7
- const {
8
- verticalLinesAr,
9
- verticalLinesSpacing,
10
- spacing,
11
- initialSpacing,
12
- verticalLinesZIndex,
13
- verticalLinesHeight,
14
- verticalLinesThickness,
15
- verticalLinesColor,
16
- verticalLinesStrokeDashArray,
17
- verticalLinesShift,
18
- verticalLinesUptoDataPoint,
19
- xAxisThickness,
20
- labelsExtraHeight,
21
- containerHeight,
22
- data,
23
- stackData,
24
- barWidth,
25
- maxValue,
26
- chartType,
27
- containerHeightIncludingBelowXAxis,
28
- totalWidth,
29
- xAxisLabelsVerticalShift,
30
- } = props;
31
-
32
- const getHeightOfVerticalLine = (index: number) => {
33
- if (verticalLinesUptoDataPoint) {
34
- if (index < data.length) {
35
- return (
36
- (data[index].value * containerHeight) / maxValue - xAxisThickness
37
- );
38
- } else {
39
- return verticalLinesHeight ?? 0;
40
- }
41
- } else {
42
- return (
43
- verticalLinesHeight ||
44
- containerHeightIncludingBelowXAxis - xAxisThickness
45
- );
46
- }
47
- };
48
-
49
- const extendedContainerHeight = containerHeight + 10 + labelsExtraHeight;
50
-
51
- return (
52
- <View
53
- style={{
54
- position: 'absolute',
55
- height: extendedContainerHeight,
56
- bottom: 60 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
57
- width: totalWidth,
58
- zIndex: verticalLinesZIndex || -1,
59
- }}>
60
- <Svg>
61
- {verticalLinesAr.map((item: any, index: number) => {
62
- let totalSpacing = initialSpacing;
63
- if (verticalLinesSpacing) {
64
- totalSpacing = verticalLinesSpacing * (index + 1);
65
- } else {
66
- if (stackData) {
67
- totalSpacing += (stackData[0].barWidth || barWidth || 30) / 2;
68
- } else {
69
- totalSpacing += (data[0].barWidth || barWidth || 30) / 2;
70
- }
71
- for (let i = 0; i < index; i++) {
72
- let actualSpacing = spacing;
73
- if (stackData) {
74
- if (i >= stackData.length - 1) {
75
- actualSpacing += (barWidth || 30) / 2;
76
- } else {
77
- if (stackData[i].spacing || stackData[i].spacing === 0) {
78
- actualSpacing = stackData[i].spacing;
79
- }
80
- if (stackData[i + 1].barWidth) {
81
- actualSpacing += stackData[i + 1].barWidth;
82
- } else {
83
- actualSpacing += barWidth || 30;
84
- }
85
- }
86
- } else {
87
- if (i >= data.length - 1) {
88
- actualSpacing += (barWidth || 30) / 2;
89
- } else {
90
- if (data[i].spacing || data[i].spacing === 0) {
91
- actualSpacing = data[i].spacing;
92
- }
93
- if (data[i + 1].barWidth) {
94
- actualSpacing += data[i + 1].barWidth;
95
- } else {
96
- actualSpacing += barWidth || 30;
97
- }
98
- }
99
- }
100
- totalSpacing += actualSpacing;
101
- }
102
- }
103
-
104
- const x =
105
- verticalLinesShift +
106
- 1 +
107
- (chartType === chartTypes.BAR
108
- ? totalSpacing - 1
109
- : verticalLinesSpacing
110
- ? verticalLinesSpacing * (index + 1)
111
- : index * spacing + (initialSpacing - 2));
112
-
113
- return (
114
- <Line
115
- key={index}
116
- x1={x}
117
- y1={extendedContainerHeight - getHeightOfVerticalLine(index)}
118
- x2={x}
119
- y2={extendedContainerHeight}
120
- stroke={verticalLinesColor || 'lightgray'}
121
- strokeWidth={verticalLinesThickness || 2}
122
- strokeDasharray={verticalLinesStrokeDashArray ?? ''}
123
- />
124
- );
125
- })}
126
- </Svg>
127
- </View>
128
- );
129
- };
130
-
131
- export default RenderVerticalLines;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import Svg, {Defs, Rect} from 'react-native-svg';
3
-
4
- const BarBackgroundPattern = (props: any) => {
5
- const {
6
- barBackgroundPatternFromItem,
7
- barBackgroundPatternFromProps,
8
- patternIdFromItem,
9
- patternIdFromProps,
10
- } = props;
11
- return (
12
- <Svg>
13
- <Defs>
14
- {barBackgroundPatternFromItem
15
- ? barBackgroundPatternFromItem()
16
- : barBackgroundPatternFromProps()}
17
- </Defs>
18
- <Rect
19
- stroke="transparent"
20
- x="1"
21
- y="1"
22
- width="100%"
23
- height="100%"
24
- fill={`url(#${patternIdFromItem ?? patternIdFromProps})`}
25
- />
26
- </Svg>
27
- );
28
- };
29
-
30
- export default BarBackgroundPattern;
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import {View} from 'react-native';
3
- import {BarDefaults} from 'gifted-charts-core';
4
-
5
- const Cap = (props: any) => {
6
- const {
7
- capThicknessFromItem,
8
- capThicknessFromProps,
9
- capColorFromItem,
10
- capColorFromProps,
11
- capRadiusFromItem,
12
- capRadiusFromProps,
13
- } = props;
14
- return (
15
- <View
16
- style={{
17
- position: 'absolute',
18
- width: '100%',
19
- height:
20
- capThicknessFromItem ??
21
- capThicknessFromProps ??
22
- BarDefaults.capThickness,
23
- backgroundColor:
24
- capColorFromItem ?? capColorFromProps ?? BarDefaults.capColor,
25
- borderTopLeftRadius:
26
- capRadiusFromItem ?? capRadiusFromProps ?? BarDefaults.capRadius,
27
- borderTopRightRadius:
28
- capRadiusFromItem ?? capRadiusFromProps ?? BarDefaults.capRadius,
29
- }}
30
- />
31
- );
32
- };
33
-
34
- export default Cap;
@@ -1,59 +0,0 @@
1
- import React, {useState} from 'react';
2
- import {View} from 'react-native';
3
-
4
- interface TooltipProps {
5
- barHeight: number;
6
- barWidth: number;
7
- item: any;
8
- index: number;
9
- isLast: boolean;
10
- leftSpacing: number;
11
- leftShiftForLastIndexTooltip: number;
12
- leftShiftForTooltip: number;
13
- renderTooltip?: Function;
14
- autoCenterTooltip?: boolean;
15
- horizontal?: boolean;
16
- }
17
-
18
- const Tooltip = (props: TooltipProps) => {
19
- const {
20
- barHeight,
21
- barWidth,
22
- item,
23
- index,
24
- isLast,
25
- leftSpacing,
26
- leftShiftForLastIndexTooltip,
27
- leftShiftForTooltip,
28
- renderTooltip,
29
- autoCenterTooltip,
30
- horizontal,
31
- } = props;
32
-
33
- const [leftShiftTooltipForCentering, setLeftShiftTooltipForCentering] =
34
- useState(0);
35
-
36
- return (
37
- <View
38
- style={{
39
- position: 'absolute',
40
- bottom: barHeight + 60,
41
- left:
42
- leftSpacing -
43
- (isLast ? leftShiftForLastIndexTooltip : leftShiftForTooltip) -
44
- leftShiftTooltipForCentering,
45
- zIndex: 1000,
46
- transform: [{rotate: horizontal ? '-90deg' : '0deg'}],
47
- }}
48
- onLayout={event => {
49
- if (!autoCenterTooltip) return;
50
- const {width} = event.nativeEvent.layout;
51
- const shift = (width - barWidth) / 2;
52
- if (shift > 0) setLeftShiftTooltipForCentering(shift);
53
- }}>
54
- {renderTooltip?.(item, index)}
55
- </View>
56
- );
57
- };
58
-
59
- export default Tooltip;