-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
79 lines (76 loc) · 2.24 KB
/
App.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
import React from 'react';
import {
View,
Text,
Dimensions
} from 'react-native';
import { PieChart } from "react-native-chart-kit";
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
data1: 10,
data2: 20,
data3: 30,
data4: 40
};
}
render() {
const screenWidth = Dimensions.get("window").width;
const pieData = [
{
name: "Data 1",
value: this.state.data1,
color: "skyblue",
legendFontColor: "#181818",
legendFontSize: 15
},
{
name: "Data 2",
value: this.state.data2,
color: "blue",
legendFontColor: "#181818",
legendFontSize: 15
},
{
name: "Data 3",
value: this.state.data3,
color: "red",
legendFontColor: "#181818",
legendFontSize: 15
},
{
name: "Data 4",
value: this.state.data4,
color: "green",
legendFontColor: "#181818",
legendFontSize: 15
}
];
const chartConfig = {
backgroundGradientFrom: "#1E2923",
backgroundGradientFromOpacity: 0,
backgroundGradientTo: "#08130D",
backgroundGradientToOpacity: 0.5,
color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,
strokeWidth: 2, // optional, default 3
barPercentage: 0.5
};
return (
<View style={{ flex:1, justifyContent: 'space-evenly', alignItems: 'center' }}>
<Text style={{ fontSize: 30 }}>Pie Chart Data</Text>
<PieChart
data={pieData}
width={screenWidth}
height={220}
chartConfig={chartConfig}
accessor="value"
backgroundColor="transparent"
paddingLeft="20"
absolute
/>
</View>
);
}
}
export default App;