react-native-gifted-charts 1.4.4 → 1.4.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "dependencies": {
27
- "gifted-charts-core": "^0.0.14"
27
+ "gifted-charts-core": "^0.0.15"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.22.5",
@@ -14,6 +14,7 @@ export const BarChart = (props: BarChartPropsType) => {
14
14
 
15
15
  const scrollRef = props.scrollRef ?? useRef(null);
16
16
  const remainingScrollViewProps = {
17
+ onScroll: (ev: any) => props.onScroll?.(ev),
17
18
  onTouchStart: evt => {
18
19
  if (props.renderTooltip) {
19
20
  setSelectedIndex(-1);
@@ -732,6 +732,7 @@ export const LineChartBicolor = (props: LineChartBicolorPropsType) => {
732
732
  scrollRef={scrollRef}
733
733
  animatedWidth={animatedWidth}
734
734
  renderChartContent={renderChartContent}
735
+ remainingScrollViewProps={{onScroll: (ev: any) => props.onScroll?.(ev)}}
735
736
  />
736
737
  );
737
738
  };
@@ -1790,6 +1790,7 @@ export const LineChart = (props: LineChartPropsType) => {
1790
1790
 
1791
1791
  const remainingScrollViewProps = {
1792
1792
  onScroll: (ev: any) => {
1793
+ props.onScroll?.(ev);
1793
1794
  if (
1794
1795
  pointerConfig &&
1795
1796
  pointerConfig.activatePointersOnLongPress &&
@@ -25,6 +25,8 @@ export const PieChart = (props: PieChartPropsType) => {
25
25
  shiftInnerCenterY,
26
26
  tiltAngle,
27
27
  isDataShifted,
28
+ paddingHorizontal,
29
+ paddingVertical,
28
30
  } = usePieChart(props);
29
31
 
30
32
  const renderInnerCircle = (innerRadius, innerCircleBorderWidth) => {
@@ -40,8 +42,18 @@ export const PieChart = (props: PieChartPropsType) => {
40
42
  // zIndex: 100,
41
43
  alignSelf: 'center',
42
44
  backgroundColor: innerCircleColor,
43
- left: canvasWidth / 2 - innerRadius + shiftInnerCenterX,
44
- top: canvasHeight / 2 - innerRadius + shiftInnerCenterY,
45
+ left:
46
+ canvasWidth / 2 -
47
+ innerRadius +
48
+ shiftInnerCenterX +
49
+ extraRadiusForFocused +
50
+ paddingHorizontal / 2,
51
+ top:
52
+ canvasHeight / 2 -
53
+ innerRadius +
54
+ shiftInnerCenterY +
55
+ extraRadiusForFocused +
56
+ paddingVertical / 2,
45
57
  borderWidth: innerCircleBorderWidth,
46
58
  borderColor: innerCircleBorderColor,
47
59
  justifyContent: 'center',
@@ -80,16 +92,20 @@ export const PieChart = (props: PieChartPropsType) => {
80
92
  return (
81
93
  <View
82
94
  style={{
83
- height: (radius + extraRadiusForFocused) * (props.semiCircle ? 1 : 2),
84
- width: (radius + extraRadiusForFocused) * 2,
85
- marginLeft: extraRadiusForFocused * 2,
86
- marginTop: extraRadiusForFocused * 2,
95
+ height:
96
+ (radius + extraRadiusForFocused + paddingVertical / 2) *
97
+ (props.semiCircle ? 1 : 2),
98
+ width: (radius + extraRadiusForFocused + paddingHorizontal / 2) * 2,
99
+ overflow: 'hidden',
87
100
  }}>
88
101
  <View style={{position: 'absolute'}}>
89
102
  <PieChartMain
90
103
  {...props}
91
104
  selectedIndex={selectedIndex}
92
105
  setSelectedIndex={setSelectedIndex}
106
+ paddingHorizontal={paddingHorizontal}
107
+ paddingVertical={paddingVertical}
108
+ extraRadiusForFocused={extraRadiusForFocused}
93
109
  />
94
110
  </View>
95
111
  {renderInnerCircle(innerRadius, innerCircleBorderWidth)}
@@ -132,6 +148,9 @@ export const PieChart = (props: PieChartPropsType) => {
132
148
  innerRadius={props.innerRadius || radius / 2.5}
133
149
  isBiggerPie
134
150
  setSelectedIndex={setSelectedIndex}
151
+ paddingHorizontal={paddingHorizontal}
152
+ paddingVertical={paddingVertical}
153
+ extraRadiusForFocused={extraRadiusForFocused}
135
154
  />
136
155
  </View>
137
156
  )}
@@ -56,6 +56,9 @@ export const PieChartMain = (props: PieChartMainProps) => {
56
56
  cy,
57
57
  pData,
58
58
  mData,
59
+ paddingHorizontal,
60
+ paddingVertical,
61
+ extraRadiusForFocused,
59
62
  } = getPieChartMainProps(props);
60
63
 
61
64
  return (
@@ -64,27 +67,38 @@ export const PieChartMain = (props: PieChartMainProps) => {
64
67
  style={[
65
68
  {
66
69
  backgroundColor: backgroundColor,
67
- height: semiCircle ? canvasHeight / 2 : canvasHeight,
68
- width: canvasWidth,
70
+ height: semiCircle
71
+ ? (canvasHeight + paddingVertical) / 2 + extraRadiusForFocused
72
+ : canvasHeight + paddingVertical + extraRadiusForFocused * 2,
73
+ width: canvasWidth + paddingHorizontal + extraRadiusForFocused * 2,
69
74
  overflow: 'hidden',
70
75
  },
71
76
  isThreeD && {transform: [{rotateX: tiltAngle}]},
72
77
  ]}>
73
78
  <Svg
74
79
  pointerEvents={rnVersion >= 720000 ? 'box-none' : 'auto'} // use 'box-none' react-native version 0.72 onwards
75
- viewBox={`${strokeWidth / -2 + minShiftX} ${
76
- strokeWidth / -2 + minShiftY
80
+ viewBox={`${strokeWidth / -2 + minShiftX - extraRadiusForFocused - paddingHorizontal / 2} ${
81
+ strokeWidth / -2 +
82
+ minShiftY -
83
+ extraRadiusForFocused -
84
+ paddingVertical / 2
77
85
  } ${
78
- (radius + strokeWidth) * 2 +
86
+ (radius + extraRadiusForFocused + strokeWidth) * 2 +
87
+ paddingHorizontal +
79
88
  horizAdjustment +
80
89
  (horizAdjustment ? strokeWidth : 0)
81
90
  } ${
82
- (radius + strokeWidth) * 2 +
83
- +vertAdjustment +
91
+ (radius + extraRadiusForFocused + strokeWidth) * 2 +
92
+ paddingVertical +
93
+ vertAdjustment +
84
94
  (vertAdjustment ? strokeWidth : 0)
85
95
  }`}
86
- height={radius * 2 + strokeWidth}
87
- width={radius * 2 + strokeWidth}>
96
+ height={
97
+ (radius + extraRadiusForFocused) * 2 + strokeWidth + paddingVertical
98
+ }
99
+ width={
100
+ (radius + extraRadiusForFocused) * 2 + strokeWidth + paddingHorizontal
101
+ }>
88
102
  <Defs>
89
103
  {data.map((item, index) => {
90
104
  return (
@@ -334,7 +348,8 @@ export const PieChartMain = (props: PieChartMainProps) => {
334
348
  backgroundColor: shadowColor,
335
349
  borderRadius: radius,
336
350
  position: 'absolute',
337
- top: shadowWidth,
351
+ top: shadowWidth + paddingVertical / 2,
352
+ left: paddingHorizontal / 2,
338
353
  zIndex: -1,
339
354
  }}
340
355
  />