-
Notifications
You must be signed in to change notification settings - Fork 1
/
BarChartDemo.js
120 lines (117 loc) · 2.98 KB
/
BarChartDemo.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
import React from 'react';
import {AppRegistry, StyleSheet, Text, View, processColor} from 'react-native';
import {BarChart} from 'react-native-charts-wrapper';
export default class BarChartDemo extends React.Component {
constructor() {
super();
}
render() {
const data = {
legend: {
enabled: false,
textSize: 14,
form: 'SQUARE',
formSize: 14,
xEntrySpace: 10,
yEntrySpace: 5,
formToTextSpace: 5,
wordWrapEnabled: true,
maxSizePercent: 0.5,
},
data: {
dataSets: [
{
values: [
{y: 100},
{y: 105},
{y: 102},
{y: 110},
{y: 114},
{y: 109},
{y: 105},
{y: 99},
{y: 105},
{y: 110},
{y: 115},
{y: 120},
],
label: 'Bar dataSet',
config: {
color: processColor('#F6AD5F'),
barShadowColor: processColor('#EF8413'),
highlightAlpha: 90,
highlightColor: processColor('#ff3333'),
valueTextSize: 8,
},
},
],
config: {
barWidth: 0.5,
},
},
highlights: [{x: 3}, {x: 8}, {x: 12}],
xAxis: {
valueFormatter: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
],
granularityEnabled: true,
granularity: 1,
position: 'BOTTOM',
drawGridLines: false,
},
yAxis: {
left: {
granularityEnabled: false,
granularity: 100,
},
right: {
enabled: false,
},
drawGridLines: true,
},
};
// const handleSelect = (event) => {
// let entry = event.nativeEvent
// if (entry == null) {
// this.setState({ ...this.state, selectedEntry: null })
// } else {
// this.setState({ ...this.state, selectedEntry: JSON.stringify(entry) })
// }
// console.log(event.nativeEvent)
// }
return (
<View style={{flex: 1}}>
<View style={{height: 300}}>
<BarChart
style={{flex: 1}}
data={data.data}
xAxis={data.xAxis}
yAxis={data.yAxis}
animation={{durationX: 2000}}
legend={data.legend}
//gridBackgroundColor={processColor('#ffffff')}
visibleRange={{x: {min: 0, max: 6}}}
drawBarShadow={false}
drawValueAboveBar={true}
drawHighlightArrow={true}
//onSelect={handleSelect.bind(this)}
highlights={data.highlights}
chartDescription={{text: ''}}
//onChange={(event) => console.log(event.nativeEvent)}
/>
</View>
</View>
);
}
}