react-native-gifted-charts 1.3.1 → 1.3.4

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/README.md CHANGED
@@ -37,11 +37,11 @@ However, we are planning to add support for web which will be available soon.
37
37
 
38
38
  ---
39
39
 
40
- ## Version 1.2.x 🎉
41
- Version 1.2.0 onwards we are dependent only on `react-native-svg` and `react-native-linear-gradient`. Earlier, Pie and Donut charts were rendered using `react-native-canvas`, but now they are also rendered using <b>svg</b>. We are no longer using `react-native-canvas` neither `react-native-webview`!
40
+ ## [Version 1.3.4 🎉](release-notes/release-notes.md)
41
+ Version 1.3.4 is a mojor release. It has code refactor, many bug fixes and some new features. Have a look at the Release Notes to see what's new in `1.3.4`.<br />
42
+ **[Release notes](release-notes/release-notes.md)**
42
43
 
43
44
  ## Installation
44
-
45
45
  ```sh
46
46
  npm install react-native-gifted-charts react-native-linear-gradient react-native-svg
47
47
  ```
@@ -51,6 +51,7 @@ For iOS-
51
51
  ```sh
52
52
  cd ios && pod install
53
53
  ```
54
+ Please note that `react-native-svg` and `react-native-linear-gradient` are needed for the library to work, so make sure they are installed in your project.
54
55
 
55
56
  # Docs
56
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.3.1",
3
+ "version": "1.3.4",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -24,8 +24,6 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "dependencies": {
27
- "react-native-linear-gradient": "^2.7.3",
28
- "react-native-svg": "^13.9.0"
29
27
  },
30
28
  "devDependencies": {
31
29
  "@babel/core": "^7.22.5",
@@ -46,19 +44,22 @@
46
44
  },
47
45
  "peerDependencies": {
48
46
  "react": "*",
49
- "react-native": "*"
47
+ "react-native": "*",
48
+ "react-native-linear-gradient": "*",
49
+ "react-native-svg": "*"
50
50
  },
51
51
  "keywords": [
52
- "react-native",
53
52
  "chart",
54
53
  "charts",
55
54
  "graph",
55
+ "data visualization",
56
56
  "bar",
57
57
  "pie",
58
58
  "donut",
59
59
  "area",
60
60
  "line",
61
61
  "react",
62
- "react native"
62
+ "react native",
63
+ "react-native"
63
64
  ]
64
65
  }
@@ -8,6 +8,8 @@ import {
8
8
  } from 'react-native';
9
9
  import LinearGradient from 'react-native-linear-gradient';
10
10
  import Svg, {Defs, Rect} from 'react-native-svg';
11
+ import Cap from '../Components/BarSpecificComponents/cap';
12
+ import {itemType} from './types';
11
13
 
12
14
  if (Platform.OS === 'android') {
13
15
  UIManager.setLayoutAnimationEnabledExperimental &&
@@ -20,20 +22,24 @@ type propTypes = {
20
22
  minHeight: number;
21
23
  opacity?: number;
22
24
  animationDuration: number;
23
- roundedTop: Boolean;
24
- roundedBottom: Boolean;
25
+ roundedTop: boolean;
26
+ roundedBottom: boolean;
25
27
  barWidth: number;
26
28
  gradientColor: ColorValue;
27
29
  frontColor: ColorValue;
28
- noGradient?: Boolean;
29
- noAnimation?: Boolean;
30
- cappedBars?: Boolean;
30
+ noGradient?: boolean;
31
+ noAnimation?: boolean;
32
+ cappedBars?: boolean;
31
33
  capThickness?: number;
32
34
  capColor?: ColorValue;
33
35
  capRadius?: number;
34
- horizontal: Boolean;
35
- intactTopLabel: Boolean;
36
+ horizontal: boolean;
37
+ intactTopLabel: boolean;
36
38
  barBorderRadius?: number;
39
+ barBorderTopLeftRadius?: number;
40
+ barBorderTopRightRadius?: number;
41
+ barBorderBottomLeftRadius?: number;
42
+ barBorderBottomRightRadius?: number;
37
43
  containerHeight?: number;
38
44
  maxValue?: number;
39
45
  barBackgroundPattern?: Function;
@@ -41,29 +47,6 @@ type propTypes = {
41
47
  barMarginBottom?: number;
42
48
  barStyle?: object;
43
49
  };
44
- type itemType = {
45
- value?: number;
46
- onPress?: any;
47
- frontColor?: ColorValue;
48
- sideColor?: ColorValue;
49
- topColor?: ColorValue;
50
- showGradient?: Boolean;
51
- gradientColor?: any;
52
- label?: String;
53
- barWidth?: number;
54
- labelTextStyle?: any;
55
- topLabelComponent?: Function;
56
- topLabelContainerStyle?: any;
57
- disablePress?: any;
58
- capThickness?: number;
59
- capColor?: ColorValue;
60
- capRadius?: number;
61
- barBorderRadius?: number;
62
- barBackgroundPattern?: Function;
63
- patternId?: String;
64
- barMarginBottom?: number;
65
- barStyle?: object;
66
- };
67
50
 
68
51
  const Animated2DWithGradient = (props: propTypes) => {
69
52
  const {
@@ -79,8 +62,13 @@ const Animated2DWithGradient = (props: propTypes) => {
79
62
  containerHeight,
80
63
  maxValue,
81
64
  barMarginBottom,
65
+ barBorderRadius,
66
+ barBorderTopLeftRadius,
67
+ barBorderTopRightRadius,
68
+ barBorderBottomLeftRadius,
69
+ barBorderBottomRightRadius,
82
70
  } = props;
83
- const [height, setHeight] = useState(noAnimation ? props.height : 2);
71
+ const [height, setHeight] = useState(noAnimation ? props.height : 0.2);
84
72
  const [initialRender, setInitialRender] = useState(
85
73
  noAnimation ? false : true,
86
74
  );
@@ -154,8 +142,23 @@ const Animated2DWithGradient = (props: propTypes) => {
154
142
  height: '100%',
155
143
  backgroundColor:
156
144
  item.frontColor || props.frontColor || 'black',
157
- borderRadius:
158
- props.barBorderRadius || item.barBorderRadius || 0,
145
+ borderRadius: item.barBorderRadius || barBorderRadius || 0,
146
+ borderTopLeftRadius:
147
+ item.barBorderTopLeftRadius ||
148
+ barBorderTopLeftRadius ||
149
+ 0,
150
+ borderTopRightRadius:
151
+ item.barBorderTopRightRadius ||
152
+ barBorderTopRightRadius ||
153
+ 0,
154
+ borderBottomLeftRadius:
155
+ item.barBorderBottomLeftRadius ||
156
+ barBorderBottomLeftRadius ||
157
+ 0,
158
+ borderBottomRightRadius:
159
+ item.barBorderBottomRightRadius ||
160
+ barBorderBottomRightRadius ||
161
+ 0,
159
162
  },
160
163
  props.roundedBottom && {
161
164
  borderBottomLeftRadius:
@@ -178,28 +181,16 @@ const Animated2DWithGradient = (props: propTypes) => {
178
181
  borderTopRightRadius: (item.barWidth || barWidth || 30) / 2,
179
182
  },
180
183
  ]}>
181
- {props.cappedBars && (
182
- <View
183
- style={{
184
- position: 'absolute',
185
- width: '100%',
186
- height:
187
- item.capThickness === 0
188
- ? 0
189
- : item.capThickness || props.capThickness || 6,
190
- backgroundColor:
191
- item.capColor || props.capColor || 'black',
192
- borderTopLeftRadius:
193
- item.capRadius === 0
194
- ? 0
195
- : item.capRadius || props.capRadius || 0,
196
- borderTopRightRadius:
197
- item.capRadius === 0
198
- ? 0
199
- : item.capRadius || props.capRadius || 0,
200
- }}
184
+ {props.cappedBars && item.value ? (
185
+ <Cap
186
+ capThicknessFromItem={item.capThickness}
187
+ capThicknessFromProps={props.capThickness}
188
+ capColorFromItem={item.capColor}
189
+ capColorFromProps={props.capColor}
190
+ capRadiusFromItem={item.capRadius}
191
+ capRadiusFromProps={props.capRadius}
201
192
  />
202
- )}
193
+ ) : null}
203
194
  </View>
204
195
  ) : (
205
196
  <LinearGradient
@@ -208,8 +199,23 @@ const Animated2DWithGradient = (props: propTypes) => {
208
199
  position: 'absolute',
209
200
  width: '100%',
210
201
  height: '100%',
211
- borderRadius:
212
- props.barBorderRadius || item.barBorderRadius || 0,
202
+ borderRadius: item.barBorderRadius || barBorderRadius || 0,
203
+ borderTopLeftRadius:
204
+ item.barBorderTopLeftRadius ||
205
+ barBorderTopLeftRadius ||
206
+ 0,
207
+ borderTopRightRadius:
208
+ item.barBorderTopRightRadius ||
209
+ barBorderTopRightRadius ||
210
+ 0,
211
+ borderBottomLeftRadius:
212
+ item.barBorderBottomLeftRadius ||
213
+ barBorderBottomLeftRadius ||
214
+ 0,
215
+ borderBottomRightRadius:
216
+ item.barBorderBottomRightRadius ||
217
+ barBorderBottomRightRadius ||
218
+ 0,
213
219
  },
214
220
  props.roundedBottom && {
215
221
  borderBottomLeftRadius:
@@ -267,7 +273,7 @@ const Animated2DWithGradient = (props: propTypes) => {
267
273
  <Defs>
268
274
  {item.barBackgroundPattern
269
275
  ? item.barBackgroundPattern()
270
- : barBackgroundPattern()}
276
+ : barBackgroundPattern?.()}
271
277
  </Defs>
272
278
  <Rect
273
279
  stroke="transparent"