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
/
BarChartScreen.js
76 lines (67 loc) · 1.56 KB
/
BarChartScreen.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
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {BarChart} from 'react-native-mp-android-chart';
class BarChartScreen extends React.Component {
constructor() {
super();
this.state = {
legend: {
enabled: true,
textSize: 14,
form: 'SQUARE',
formSize: 14,
xEntrySpace: 10,
yEntrySpace: 5,
formToTextSpace: 5,
wordWrapEnabled: true,
maxSizePercent: 0.5
},
data: {
datasets: [{
yValues: [100, 105, 102, 110, 114, 109, 105, 99, 95],
label: 'Bar dataset',
config: {
color: 'teal',
barSpacePercent: 40,
barShadowColor: 'lightgrey',
highlightAlpha: 90,
highlightColor: 'red'
}
}],
xValues: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep']
}
};
}
render() {
return (
<View style={styles.container}>
<BarChart
style={styles.chart}
data={this.state.data}
animation={{durationX: 2000}}
legend={this.state.legend}
gridBackgroundColor={'#ffffff'}
drawBarShadow={false}
drawValueAboveBar={true}
drawHighlightArrow={true}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF'
},
chart: {
flex: 1
}
});
AppRegistry.registerComponent('BarChartScreen', () => BarChartScreen);
export default BarChartScreen;