react-native-gifted-charts 1.4.4 → 1.4.6

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.6",
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.18"
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)}
@@ -119,6 +135,8 @@ export const PieChart = (props: PieChartPropsType) => {
119
135
  props.data[selectedIndex].strokeWidth || undefined,
120
136
  gradientCenterColor:
121
137
  props.data[selectedIndex].gradientCenterColor || undefined,
138
+ shiftTextX: props.data[selectedIndex].shiftTextX || undefined,
139
+ shiftTextY: props.data[selectedIndex].shiftTextY || undefined,
122
140
  },
123
141
  {
124
142
  value: total - props.data[selectedIndex].value,
@@ -132,6 +150,9 @@ export const PieChart = (props: PieChartPropsType) => {
132
150
  innerRadius={props.innerRadius || radius / 2.5}
133
151
  isBiggerPie
134
152
  setSelectedIndex={setSelectedIndex}
153
+ paddingHorizontal={paddingHorizontal}
154
+ paddingVertical={paddingVertical}
155
+ extraRadiusForFocused={extraRadiusForFocused}
135
156
  />
136
157
  </View>
137
158
  )}
@@ -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 (
@@ -250,8 +264,12 @@ export const PieChartMain = (props: PieChartMainProps) => {
250
264
  {/* <Line x1={mx} x2={cx} y1={my} y2={cy} stroke="black" /> */}
251
265
  {showTextBackground ? (
252
266
  <Circle
253
- cx={x}
254
- cy={y - (item.textSize || textSize) / 4}
267
+ cx={x + (item.shiftTextBackgroundX ?? item.shiftTextX ?? 0)}
268
+ cy={
269
+ y +
270
+ (item.shiftTextBackgroundY ?? item.shiftTextY ?? 0) -
271
+ (item.textSize || textSize) / 4
272
+ }
255
273
  r={
256
274
  item.textBackgroundRadius ||
257
275
  props.textBackgroundRadius ||
@@ -334,7 +352,8 @@ export const PieChartMain = (props: PieChartMainProps) => {
334
352
  backgroundColor: shadowColor,
335
353
  borderRadius: radius,
336
354
  position: 'absolute',
337
- top: shadowWidth,
355
+ top: shadowWidth + paddingVertical / 2,
356
+ left: paddingHorizontal / 2,
338
357
  zIndex: -1,
339
358
  }}
340
359
  />