forked from hongyin163/react-native-chart-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarChart.js
More file actions
102 lines (97 loc) · 1.84 KB
/
Copy pathBarChart.js
File metadata and controls
102 lines (97 loc) · 1.84 KB
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
/* @flow */
'use strict';
var React = require('react-native');
var TitleBar=require('./TitleBar');
var {
BarChart,
CombinedChart
}=require('../index.android');
var {
StyleSheet,
View,
Text
} = React;
var Component = React.createClass({
getBarData:function (argument) {
var data={
xValues:['1','2','3'],
yValues:[
{
data:[4.0,5.0,6.0],
label:'test1',
config:{
color:'blue'
}
},
{
data:[4.0,5.0,6.0],
label:'test2',
config:{
color:'red'
}
},
{
data:[4.0,5.0,6.0],
label:'test2',
config:{
color:'yellow'
}
}
]
};
return data;
},
getRandomData:function (argument) {
var data={};
data['xValues']=[];
data['yValues']=[
{
data:[],
label:'test1',
config:{
color:'blue'
}
}
];
for (var i = 0; i < 500; i++) {
data.xValues.push(i+'');
data.yValues[0].data.push(Math.random()*100);
};
return data;
},
render: function() {
return (
<View style={styles.container}>
<TitleBar/>
<View style={styles.chartContainer}>
<BarChart style={{flex:1}} data={this.getBarData()}/>
<BarChart
style={{flex:1}}
data={this.getRandomData()}
visibleXRange={[0,30]}
maxVisibleValueCount={50}
xAxis={{drawGridLines:false,gridLineWidth:1,position:"BOTTOM"}}
yAxisRight={{enable:false}}
yAxis={{startAtZero:false,drawGridLines:false,position:"INSIDE_CHART"}}
drawGridBackground={false}
backgroundColor={"WHITE"}
description={"测试"}
legend={{enable:true,position:'ABOVE_CHART_LEFT',direction:"LEFT_TO_RIGHT"}}
/>
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container:{
flex:1
},
chartContainer:{
flex:1
},
chart:{
flex:1
}
});
module.exports = Component;