This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
PieChartScreen.js
87 lines (77 loc) · 1.9 KB
/
PieChartScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {PieChart} from 'react-native-mp-android-chart';
class PieChartScreen extends React.Component {
constructor() {
super();
this.state = {
legend: {
enabled: true,
textSize: 14,
form: 'CIRCLE',
position: 'RIGHT_OF_CHART',
fontFamily: 'monospace',
wordWrapEnabled: true
},
data: {
datasets: [{
yValues: [40, 21, 15, 9, 15],
label: 'Pie dataset',
config: {
colors: ['#C0FF8C', '#FFF78C', '#FFD08C', '#8CEAFF', '#FF8C9D'],
sliceSpace: 5,
selectionShift: 13
}
}],
xValues: ['Sandwiches', 'Salads', 'Soup', 'Beverages', 'Desserts']
},
description: {
text: 'This is Pie chart description',
textSize: 15,
textColor: 'darkgray',
fontFamily: 'monospace',
fontStyle: 2
}
};
}
render() {
return (
<View style={styles.container}>
<PieChart
style={styles.chart}
logEnabled={true}
backgroundColor={'#f0f0f0'}
description={this.state.description}
data={this.state.data}
legend={this.state.legend}
drawSliceText={true}
usePercentValues={false}
centerText={'Pie center text!'}
centerTextRadiusPercent={100}
holeRadius={40}
holeColor={'#f0f0f0'}
transparentCircleRadius={45}
transparentCircleColor={'#f0f0f0'}
transparentCircleAlpha={50}
maxAngle={350}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF'
},
chart: {
flex: 1
}
});
AppRegistry.registerComponent('PieChartScreen', () => PieChartScreen);
export default PieChartScreen;