react-native-gifted-charts 1.0.19 → 1.0.20

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.0.19",
3
+ "version": "1.0.20",
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": [
@@ -743,6 +743,9 @@ export const BarChart = (props: PropTypes) => {
743
743
  <Text
744
744
  style={[
745
745
  {position: 'absolute'},
746
+ yAxisSide === 'right' && {
747
+ transform: [{rotateY: '180deg'}],
748
+ },
746
749
  referenceLine1Config.labelTextStyle,
747
750
  ]}>
748
751
  {referenceLine1Config.labelText}
@@ -762,6 +765,9 @@ export const BarChart = (props: PropTypes) => {
762
765
  <Text
763
766
  style={[
764
767
  {position: 'absolute'},
768
+ yAxisSide === 'right' && {
769
+ transform: [{rotateY: '180deg'}],
770
+ },
765
771
  referenceLine2Config.labelTextStyle,
766
772
  ]}>
767
773
  {referenceLine2Config.labelText}
@@ -781,6 +787,9 @@ export const BarChart = (props: PropTypes) => {
781
787
  <Text
782
788
  style={[
783
789
  {position: 'absolute'},
790
+ yAxisSide === 'right' && {
791
+ transform: [{rotateY: '180deg'}],
792
+ },
784
793
  referenceLine3Config.labelTextStyle,
785
794
  ]}>
786
795
  {referenceLine3Config.labelText}
@@ -1214,7 +1223,10 @@ export const BarChart = (props: PropTypes) => {
1214
1223
  {
1215
1224
  // backgroundColor: 'yellow',
1216
1225
  height:
1217
- containerHeight + 130 + horizSectionsBelow.length * stepHeight + labelsExtraHeight,
1226
+ containerHeight +
1227
+ 130 +
1228
+ horizSectionsBelow.length * stepHeight +
1229
+ labelsExtraHeight,
1218
1230
  paddingLeft: initialSpacing,
1219
1231
  paddingBottom:
1220
1232
  horizSectionsBelow.length * stepHeight + labelsExtraHeight,
@@ -1681,6 +1681,9 @@ export const LineChart = (props: propTypes) => {
1681
1681
  <Text
1682
1682
  style={[
1683
1683
  {position: 'absolute'},
1684
+ yAxisSide === 'right' && {
1685
+ transform: [{rotateY: '180deg'}],
1686
+ },
1684
1687
  referenceLine1Config.labelTextStyle,
1685
1688
  ]}>
1686
1689
  {referenceLine1Config.labelText}
@@ -1700,6 +1703,9 @@ export const LineChart = (props: propTypes) => {
1700
1703
  <Text
1701
1704
  style={[
1702
1705
  {position: 'absolute'},
1706
+ yAxisSide === 'right' && {
1707
+ transform: [{rotateY: '180deg'}],
1708
+ },
1703
1709
  referenceLine2Config.labelTextStyle,
1704
1710
  ]}>
1705
1711
  {referenceLine2Config.labelText}
@@ -1719,6 +1725,9 @@ export const LineChart = (props: propTypes) => {
1719
1725
  <Text
1720
1726
  style={[
1721
1727
  {position: 'absolute'},
1728
+ yAxisSide === 'right' && {
1729
+ transform: [{rotateY: '180deg'}],
1730
+ },
1722
1731
  referenceLine3Config.labelTextStyle,
1723
1732
  ]}>
1724
1733
  {referenceLine3Config.labelText}
@@ -0,0 +1,136 @@
1
+ import React from 'react';
2
+ import {ColorValue, View, Text} from 'react-native';
3
+ import Svg, {
4
+ Path,
5
+ LinearGradient,
6
+ Stop,
7
+ Circle,
8
+ Rect,
9
+ Text as CanvasText,
10
+ } from 'react-native-svg';
11
+ import {svgPath, bezierCommand} from '../utils';
12
+
13
+ type propTypes = {
14
+ radius?: number;
15
+ isThreeD?: Boolean;
16
+ donut?: Boolean;
17
+ innerRadius?: number;
18
+ shadow?: Boolean;
19
+ innerCircleColor?: ColorValue;
20
+ innerCircleBorderWidth?: number;
21
+ innerCircleBorderColor?: ColorValue;
22
+ shiftInnerCenterX?: number;
23
+ shiftInnerCenterY?: number;
24
+ shadowColor?: string;
25
+ shadowWidth?: number;
26
+ strokeWidth?: number;
27
+ strokeColor?: string;
28
+ backgroundColor?: string;
29
+ data: Array<itemType>;
30
+ semiCircle?: Boolean;
31
+
32
+ showText?: Boolean;
33
+ textColor?: string;
34
+ textSize?: number;
35
+ fontStyle?: string;
36
+ fontWeight?: string;
37
+ font?: string;
38
+ showTextBackground?: Boolean;
39
+ textBackgroundColor?: string;
40
+ textBackgroundRadius?: number;
41
+ showValuesAsLabels?: Boolean;
42
+
43
+ centerLabelComponent?: Function;
44
+ tilt?: number;
45
+ initialAngle?: number;
46
+ };
47
+ type itemType = {
48
+ value: number;
49
+ shiftX?: number;
50
+ shiftY?: number;
51
+ color?: string;
52
+ text?: string;
53
+ textColor?: string;
54
+ textSize?: number;
55
+ fontStyle?: string;
56
+ fontWeight?: string;
57
+ font?: string;
58
+ textBackgroundColor?: string;
59
+ textBackgroundRadius?: number;
60
+ shiftTextX?: number;
61
+ shiftTextY?: number;
62
+ };
63
+
64
+ export const SvgPie = (props: propTypes) => {
65
+ let radius = 40;
66
+ let cx = radius,
67
+ cy = radius;
68
+ let ix = cx,
69
+ iy = 0;
70
+
71
+ let data = [30, 40, 20, 30];
72
+ let total = data.reduce((v, a) => v + a);
73
+ let acc = 0;
74
+ let pData = data.map(item => {
75
+ acc += item / total;
76
+ return acc;
77
+ });
78
+ pData = [0, ...pData];
79
+
80
+ const getCoordinatesForPercent = percent => {
81
+ const x = Math.cos(2 * Math.PI * percent);
82
+ const y = Math.sin(2 * Math.PI * percent);
83
+
84
+ return [x, y];
85
+ };
86
+
87
+ return (
88
+ <Svg height="100%" width="100%" viewBox="-5 0 110 110">
89
+ <Circle
90
+ cx={cx}
91
+ cy={cy}
92
+ r={radius}
93
+ stroke="blue"
94
+ strokeWidth="1.5"
95
+ fill="green"
96
+ />
97
+ {pData.map((item, index) => {
98
+ // if(index>1) return null;
99
+ console.log('index', index);
100
+ // let sx = ix,
101
+ // sy = iy;
102
+ let nextItem;
103
+ if (index === pData.length - 1) nextItem = pData[0];
104
+ else nextItem = pData[index + 1];
105
+ let sx = cx * (1 + Math.sin(2 * Math.PI * item));
106
+ let sy = cy * (1 - Math.cos(2 * Math.PI * item));
107
+ let ax = cx * (1 + Math.sin(2 * Math.PI * nextItem));
108
+ let ay = cy * (1 - Math.cos(2 * Math.PI * nextItem));
109
+
110
+ console.log('sx', sx);
111
+ console.log('sy', sy);
112
+ console.log('ax', ax);
113
+ console.log('ay', ay);
114
+ // let [ax, ay] = getCoordinatesForPercent(item*100);
115
+ // console.log('ax...', ax);
116
+ // console.log('ay...', ay);
117
+ return (
118
+ <Path
119
+ d={`M ${cx} ${cy} L ${sx} ${sy} A ${radius} ${radius} 0 0 1 ${ax} ${ay} L ${cx} ${cy}`}
120
+ stroke="red"
121
+ strokeWidth="1.5"
122
+ fill={'yellow'}
123
+ />
124
+ );
125
+ })}
126
+ <Circle
127
+ cx={cx}
128
+ cy={cy}
129
+ r={radius / 2.5}
130
+ stroke="red"
131
+ strokeWidth="1.5"
132
+ fill="white"
133
+ />
134
+ </Svg>
135
+ );
136
+ };
package/src/ss.html ADDED
@@ -0,0 +1,8 @@
1
+ <svg height="20" width="20" viewBox="0 0 20 20">
2
+ <circle r="10" cx="10" cy="10" fill="green" />
3
+ <circle r="5" cx="10" cy="10" fill="transparent"
4
+ stroke="tomato"
5
+ stroke-width="10"
6
+ stroke-dasharray="calc(35 * 31.4 / 100) 31.4"
7
+ transform="rotate(-90) translate(-20)" />
8
+ </svg>