react-native-gifted-charts 1.0.21 → 1.2.2

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
@@ -29,18 +29,15 @@ The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts
29
29
 
30
30
  ---
31
31
 
32
+ ## Version 1.2.x 🎉
33
+ 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`!
34
+
32
35
  ## Installation
33
36
 
34
37
  ```sh
35
38
  npm install react-native-gifted-charts react-native-linear-gradient react-native-svg
36
39
  ```
37
40
 
38
- For Pie chart and Donut chart, these additional packages should be installed-
39
-
40
- ```sh
41
- npm i react-native-canvas react-native-webview
42
- ```
43
-
44
41
  For iOS-
45
42
 
46
43
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.0.21",
3
+ "version": "1.2.2",
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": [
@@ -29,10 +29,8 @@
29
29
  "@types/react": "^17.0.5",
30
30
  "@types/react-dom": "^17.0.3",
31
31
  "@types/react-native": "^0.64.5",
32
- "react-native-canvas": "^0.1.37",
33
32
  "react-native-linear-gradient": "^2.5.6",
34
33
  "react-native-svg": "^12.1.0",
35
- "react-native-webview": "^11.4.4",
36
34
  "typescript": "^4.2.4"
37
35
  },
38
36
  "devDependencies": {
@@ -42,7 +40,6 @@
42
40
  "babel-jest": "^27.0.6",
43
41
  "eslint": "^7.31.0",
44
42
  "jest": "^27.0.6",
45
- "@types/react-native-canvas": "^0.1.7",
46
43
  "metro-react-native-babel-preset": "^0.66.2",
47
44
  "react-test-renderer": "17.0.1"
48
45
  },
@@ -64,4 +61,4 @@
64
61
  "jest": {
65
62
  "preset": "react-native"
66
63
  }
67
- }
64
+ }
@@ -653,7 +653,7 @@ export const BarChart = (props: PropTypes) => {
653
653
  styles.horizBar,
654
654
  {
655
655
  width: horizontal
656
- ? props.width || totalWidth
656
+ ? props.width || Math.min(300, totalWidth)
657
657
  : props.width || totalWidth + 11,
658
658
  },
659
659
  yAxisSide === 'right' && {transform: [{rotateY: '180deg'}]},
@@ -668,7 +668,13 @@ export const BarChart = (props: PropTypes) => {
668
668
  },
669
669
  horizontal &&
670
670
  !yAxisAtTop && {
671
- transform: [{translateX: totalWidth + yAxisThickness}],
671
+ transform: [
672
+ {
673
+ translateX:
674
+ (props.width || Math.min(300, totalWidth)) +
675
+ yAxisThickness,
676
+ },
677
+ ],
672
678
  },
673
679
  {
674
680
  height:
@@ -676,7 +682,8 @@ export const BarChart = (props: PropTypes) => {
676
682
  width: yAxisLabelWidth,
677
683
  },
678
684
  yAxisLabelContainerStyle,
679
- ]}/>
685
+ ]}
686
+ />
680
687
  <View
681
688
  style={[
682
689
  index === noOfSections
@@ -697,7 +704,7 @@ export const BarChart = (props: PropTypes) => {
697
704
  thickness: rulesThickness,
698
705
  color: rulesColor,
699
706
  width: horizontal
700
- ? props.width || totalWidth
707
+ ? props.width || Math.min(300, totalWidth)
701
708
  : (props.width || totalWidth) + 11,
702
709
  dashWidth: dashWidth,
703
710
  dashGap: dashGap,
@@ -744,6 +751,17 @@ export const BarChart = (props: PropTypes) => {
744
751
  {rotateY: '180deg'},
745
752
  ],
746
753
  },
754
+ horizontal &&
755
+ !yAxisAtTop && {
756
+ transform: [
757
+ {
758
+ translateX:
759
+ (props.width || Math.min(300, totalWidth)) +
760
+ yAxisThickness +
761
+ yAxisLabelWidth,
762
+ },
763
+ ],
764
+ },
747
765
  yAxisLabelContainerStyle,
748
766
  ]}>
749
767
  <Text
@@ -796,7 +814,8 @@ export const BarChart = (props: PropTypes) => {
796
814
  width: yAxisLabelWidth,
797
815
  },
798
816
  index === 0 && {marginTop: -stepHeight / 2},
799
- ]}/>
817
+ ]}
818
+ />
800
819
  <View
801
820
  style={[styles.leftPart, {backgroundColor: backgroundColor}]}>
802
821
  {hideRules ? null : (
@@ -1291,8 +1310,8 @@ export const BarChart = (props: PropTypes) => {
1291
1310
  labelsExtraHeight,
1292
1311
  },
1293
1312
  yAxisSide === 'right' && {marginLeft: yAxisLabelWidth + yAxisThickness},
1294
- props.width && {width: props.width},
1295
- horizontal && {transform: [{rotate: '90deg'}, {translateY: -15}]},
1313
+ props.width && !horizontal && {width: props.width},
1314
+ horizontal && {transform: [{rotate: '90deg'}, {translateY: 15}]},
1296
1315
  ]}>
1297
1316
  {props.hideAxesAndRules !== true && renderHorizSections()}
1298
1317
  <ScrollView
@@ -1310,7 +1329,7 @@ export const BarChart = (props: PropTypes) => {
1310
1329
  bottom: stepHeight * -0.5 - 60 + xAxisThickness,
1311
1330
  },
1312
1331
  props.width && {width: props.width - 11},
1313
- horizontal && {width: totalWidth},
1332
+ horizontal && {width: props.width || Math.min(300, totalWidth)},
1314
1333
  ]}
1315
1334
  scrollEnabled={!disableScroll}
1316
1335
  contentContainerStyle={[