-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathApp.js
171 lines (169 loc) · 4.87 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import React from 'react'
import { ScrollView, StatusBar, Dimensions, Text } from 'react-native'
import ScrollableTabView from 'react-native-scrollable-tab-view'
import {
LineChart,
BarChart,
PieChart,
ProgressChart,
ContributionGraph
} from 'react-native-chart-kit'
import { data, contributionData, pieChartData, progressChartData } from './data'
import 'babel-polyfill'
// in Expo - swipe left to see the following styling, or create your own
const chartConfigs = [
{
backgroundColor: '#000000',
backgroundGradientFrom: '#1E2923',
backgroundGradientTo: '#08130D',
color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,
style: {
borderRadius: 16
}
},
{
backgroundColor: '#022173',
backgroundGradientFrom: '#022173',
backgroundGradientTo: '#1b3fa0',
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
},
{
backgroundColor: '#ffffff',
backgroundGradientFrom: '#ffffff',
backgroundGradientTo: '#ffffff',
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`
},
{
backgroundColor: '#26872a',
backgroundGradientFrom: '#43a047',
backgroundGradientTo: '#66bb6a',
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
},
{
backgroundColor: '#000000',
backgroundGradientFrom: '#000000',
backgroundGradientTo: '#000000',
color: (opacity = 1) => `rgba(${255}, ${255}, ${255}, ${opacity})`
}, {
backgroundColor: '#0091EA',
backgroundGradientFrom: '#0091EA',
backgroundGradientTo: '#0091EA',
color: (opacity = 1) => `rgba(${255}, ${255}, ${255}, ${opacity})`
},
{
backgroundColor: '#e26a00',
backgroundGradientFrom: '#fb8c00',
backgroundGradientTo: '#ffa726',
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
},
{
backgroundColor: '#b90602',
backgroundGradientFrom: '#e53935',
backgroundGradientTo: '#ef5350',
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
},
{
backgroundColor: '#ff3e03',
backgroundGradientFrom: '#ff3e03',
backgroundGradientTo: '#ff3e03',
color: (opacity = 1) => `rgba(${0}, ${0}, ${0}, ${opacity})`
}
]
export default class App extends React.Component {
renderTabBar() {
return <StatusBar hidden/>
}
render() {
const width = Dimensions.get('window').width
const height = 220
return (
<ScrollableTabView renderTabBar={this.renderTabBar}>
{chartConfigs.map(chartConfig => {
const labelStyle = {
color: chartConfig.color(),
marginVertical: 10,
textAlign: 'center',
fontSize: 16
}
const graphStyle = {
marginVertical: 8,
...chartConfig.style
}
return (
<ScrollView
key={Math.random()}
style={{
backgroundColor: chartConfig.backgroundColor
}}
>
<Text style={labelStyle}>Bezier Line Chart</Text>
<LineChart
data={data}
width={width}
height={height}
chartConfig={chartConfig}
bezier
style={graphStyle}
/>
<Text style={labelStyle}>Progress Chart</Text>
<ProgressChart
data={progressChartData}
width={width}
height={height}
chartConfig={chartConfig}
style={graphStyle}
/>
<Text style={labelStyle}>Bar Graph</Text>
<BarChart
width={width}
height={height}
data={data}
chartConfig={chartConfig}
style={graphStyle}
/>
<Text style={labelStyle}>Pie Chart</Text>
<PieChart
data={pieChartData}
height={height}
width={width}
chartConfig={chartConfig}
accessor="population"
style={graphStyle}
/>
<Text style={labelStyle}>Line Chart</Text>
<LineChart
data={data}
width={width}
height={height}
chartConfig={chartConfig}
style={graphStyle}
/>
<Text style={labelStyle}>Contribution Graph</Text>
<ContributionGraph
values={contributionData}
width={width}
height={height}
endDate={new Date('2016-05-01')}
numDays={105}
chartConfig={chartConfig}
style={graphStyle}
/>
</ScrollView>
)
})}
</ScrollableTabView>
)
}
}