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,151 +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
- import {LineInBarChartPropsType} from 'gifted-charts-core';
8
- import {DataPointProps} from 'gifted-charts-core';
9
-
10
- const RenderLineInBarChart = (props: LineInBarChartPropsType) => {
11
- const {
12
- yAxisLabelWidth,
13
- initialSpacing,
14
- spacing,
15
- containerHeight,
16
- lineConfig,
17
- maxValue,
18
- animatedWidth,
19
- lineBehindBars,
20
- points,
21
- arrowPoints,
22
- data,
23
- totalWidth,
24
- barWidth,
25
- labelsExtraHeight,
26
- xAxisLabelsVerticalShift,
27
- selectedIndex,
28
- } = props;
29
-
30
- const firstBarWidth = data[0].barWidth ?? barWidth;
31
-
32
- const dataPointsProps: DataPointProps = {
33
- data,
34
- lineConfig,
35
- barWidth,
36
- containerHeight,
37
- maxValue,
38
- firstBarWidth,
39
- yAxisLabelWidth,
40
- spacing,
41
- selectedIndex,
42
- };
43
-
44
- const specificVerticalLinesProps = {
45
- data,
46
- barWidth,
47
- yAxisLabelWidth,
48
- initialSpacing,
49
- spacing,
50
- containerHeight,
51
- lineConfig,
52
- maxValue,
53
- };
54
-
55
- const specificDataPointsProps = {
56
- data,
57
- barWidth,
58
- firstBarWidth,
59
- yAxisLabelWidth,
60
- lineConfig,
61
- spacing,
62
- containerHeight,
63
- maxValue,
64
- };
65
-
66
- const renderAnimatedLine = () => {
67
- // console.log('animatedWidth is-------->', animatedWidth);
68
- return (
69
- <Animated.View
70
- pointerEvents="none"
71
- style={{
72
- position: 'absolute',
73
- height: containerHeight + 10,
74
- left: 6 - yAxisLabelWidth,
75
- bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
76
- width: animatedWidth,
77
- zIndex: lineBehindBars ? -1 : 100000,
78
- // backgroundColor: 'wheat',
79
- }}>
80
- <Svg>
81
- <Path
82
- d={points}
83
- fill="none"
84
- stroke={lineConfig.color}
85
- strokeWidth={lineConfig.thickness}
86
- />
87
-
88
- {renderSpecificVerticalLines(specificVerticalLinesProps)}
89
-
90
- {!lineConfig.hideDataPoints
91
- ? renderDataPoints(dataPointsProps)
92
- : renderSpecificDataPoints(specificDataPointsProps)}
93
- {lineConfig.showArrow && (
94
- <Path
95
- d={arrowPoints}
96
- fill={lineConfig.arrowConfig?.fillColor}
97
- stroke={lineConfig.arrowConfig?.strokeColor}
98
- strokeWidth={lineConfig.arrowConfig?.strokeWidth}
99
- />
100
- )}
101
- </Svg>
102
- </Animated.View>
103
- );
104
- };
105
-
106
- const renderLine = () => {
107
- return (
108
- <View
109
- pointerEvents="none"
110
- style={{
111
- position: 'absolute',
112
- height: containerHeight + 10 + labelsExtraHeight,
113
- left: 6 - yAxisLabelWidth,
114
- bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
115
- width: totalWidth,
116
- zIndex: lineBehindBars ? -1 : 100000,
117
- // backgroundColor: 'rgba(200,150,150,0.1)'
118
- }}>
119
- <Svg>
120
- <Path
121
- d={points}
122
- fill="none"
123
- stroke={lineConfig.color}
124
- strokeWidth={lineConfig.thickness}
125
- />
126
- {renderSpecificVerticalLines(specificVerticalLinesProps)}
127
-
128
- {!lineConfig.hideDataPoints
129
- ? renderDataPoints(dataPointsProps)
130
- : renderSpecificDataPoints(specificDataPointsProps)}
131
- {lineConfig.showArrow && (
132
- <Path
133
- d={arrowPoints}
134
- fill={lineConfig.arrowConfig?.fillColor}
135
- stroke={lineConfig.arrowConfig?.strokeColor}
136
- strokeWidth={lineConfig.arrowConfig?.strokeWidth}
137
- />
138
- )}
139
- </Svg>
140
- </View>
141
- );
142
- };
143
-
144
- if (lineConfig.isAnimated) {
145
- return renderAnimatedLine();
146
- }
147
-
148
- return renderLine();
149
- };
150
-
151
- export default RenderLineInBarChart;
@@ -1,175 +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
- import {DataPointProps} from 'gifted-charts-core';
7
-
8
- export const renderDataPoints = (props: DataPointProps) => {
9
- const {
10
- data,
11
- lineConfig,
12
- barWidth,
13
- containerHeight,
14
- maxValue,
15
- firstBarWidth,
16
- yAxisLabelWidth,
17
- spacing,
18
- selectedIndex,
19
- } = props;
20
- return data.map((item: any, index: number) => {
21
- if (
22
- index < lineConfig.startIndex ||
23
- index > lineConfig.endIndex ||
24
- item.hideDataPoint
25
- ) {
26
- return null;
27
- }
28
- const currentBarWidth = item.barWidth || barWidth || 30;
29
- const customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
30
- const dataPointColor =
31
- lineConfig.focusEnabled &&
32
- index === (lineConfig.focusedDataPointIndex ?? selectedIndex)
33
- ? lineConfig.focusedDataPointColor
34
- : lineConfig.dataPointsColor;
35
-
36
- const dataPointRadius =
37
- lineConfig.focusEnabled &&
38
- index === (lineConfig.focusedDataPointIndex ?? selectedIndex)
39
- ? lineConfig.focusedDataPointRadius
40
- : lineConfig.dataPointsRadius;
41
- const value =
42
- item.value ??
43
- item.stacks.reduce((total: number, item: any) => total + item.value, 0);
44
- if (customDataPoint) {
45
- return (
46
- <View
47
- style={[
48
- styles.customDataPointContainer,
49
- {
50
- height: lineConfig.dataPointsHeight,
51
- width: lineConfig.dataPointsWidth,
52
- top:
53
- containerHeight -
54
- (value * containerHeight) / maxValue -
55
- (item.shiftY ?? lineConfig.shiftY ?? 0),
56
- left: getXForLineInBar(
57
- index,
58
- firstBarWidth,
59
- currentBarWidth,
60
- yAxisLabelWidth,
61
- lineConfig,
62
- spacing,
63
- ),
64
- },
65
- ]}>
66
- {customDataPoint(item, index)}
67
- </View>
68
- );
69
- }
70
- if (lineConfig.dataPointsShape === 'rectangular') {
71
- return (
72
- <Fragment key={index}>
73
- <Rect
74
- x={getXForLineInBar(
75
- index,
76
- firstBarWidth,
77
- currentBarWidth,
78
- yAxisLabelWidth,
79
- lineConfig,
80
- spacing,
81
- )}
82
- y={
83
- getYForLineInBar(
84
- value,
85
- lineConfig.shiftY,
86
- containerHeight,
87
- maxValue,
88
- ) -
89
- lineConfig.dataPointsHeight / 2
90
- }
91
- width={lineConfig.dataPointsWidth}
92
- height={lineConfig.dataPointsHeight}
93
- fill={dataPointColor}
94
- />
95
- {item.dataPointText && (
96
- <CanvasText
97
- fill={item.textColor || lineConfig.textColor}
98
- fontSize={item.textFontSize || lineConfig.textFontSize}
99
- x={
100
- getXForLineInBar(
101
- index,
102
- firstBarWidth,
103
- currentBarWidth,
104
- yAxisLabelWidth,
105
- lineConfig,
106
- spacing,
107
- ) + (item.textShiftX || lineConfig.textShiftX || 0)
108
- }
109
- y={
110
- getYForLineInBar(
111
- value,
112
- lineConfig.shiftY,
113
- containerHeight,
114
- maxValue,
115
- ) -
116
- lineConfig.dataPointsHeight / 2 +
117
- (item.textShiftY || lineConfig.textShiftY || 0)
118
- }>
119
- {item.dataPointText}
120
- </CanvasText>
121
- )}
122
- </Fragment>
123
- );
124
- }
125
- return (
126
- <Fragment key={index}>
127
- <Circle
128
- cx={getXForLineInBar(
129
- index,
130
- firstBarWidth,
131
- currentBarWidth,
132
- yAxisLabelWidth,
133
- lineConfig,
134
- spacing,
135
- )}
136
- cy={getYForLineInBar(
137
- value,
138
- lineConfig.shiftY,
139
- containerHeight,
140
- maxValue,
141
- )}
142
- r={dataPointRadius}
143
- fill={dataPointColor}
144
- />
145
- {item.dataPointText && (
146
- <CanvasText
147
- fill={item.textColor || lineConfig.textColor}
148
- fontSize={item.textFontSize || lineConfig.textFontSize}
149
- x={
150
- getXForLineInBar(
151
- index,
152
- firstBarWidth,
153
- currentBarWidth,
154
- yAxisLabelWidth,
155
- lineConfig,
156
- spacing,
157
- ) + (item.textShiftX || lineConfig.textShiftX || 0)
158
- }
159
- y={
160
- getYForLineInBar(
161
- value,
162
- lineConfig.shiftY,
163
- containerHeight,
164
- maxValue,
165
- ) -
166
- lineConfig.dataPointsHeight / 2 +
167
- (item.textShiftY || lineConfig.textShiftY || 0)
168
- }>
169
- {item.dataPointText}
170
- </CanvasText>
171
- )}
172
- </Fragment>
173
- );
174
- });
175
- };
@@ -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;