BIChartsItem.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import React, { Component } from 'react';
  2. import {
  3. StyleSheet,
  4. Text,
  5. View,
  6. TouchableOpacity,
  7. Image,
  8. } from 'react-native';
  9. import {NativeModules} from 'react-native';
  10. const YRRnBridge = NativeModules.YRRnBridge;
  11. import Echarts from 'native-echarts';
  12. import Dimensions from 'Dimensions';
  13. import NavigationUtil from "../../navigator/NavigationUtil";
  14. const {width} = Dimensions.get('window');
  15. export default class BIChartsItem extends Component {
  16. constructor(props) {
  17. super(props);
  18. const{typeTitle} = this.props;
  19. const typeOptions = {
  20. apple:[2, 4, 7, 2, 2, 7, 13, 16],
  21. organ: [6, 9, 9, 2, 8, 7, 17, 18],
  22. banana: [6, 9, 3, 2, 8, 7, 1, 8],
  23. }
  24. const option = {
  25. title:{
  26. text:'水果对比',
  27. top:'0',
  28. left:'10',
  29. font:10,
  30. textStyle:{
  31. fontSize: 18,
  32. color:'darkGray',
  33. }
  34. },
  35. //点击某一个点的数据的时候,显示出悬浮窗
  36. tooltip : {
  37. trigger: 'axis'
  38. },
  39. //可以手动选择现实几个图标
  40. legend: {
  41. padding:[
  42. 240,
  43. 100,
  44. 100,
  45. 100,
  46. ],
  47. data:['苹果','橘子','香蕉']
  48. },
  49. //各种表格
  50. toolbox: {
  51. //改变icon的布局朝向
  52. orient: 'horizontal',
  53. show : false,
  54. showTitle:true,
  55. feature : {
  56. //show是否显示表格,readOnly是否只读
  57. dataView : {show: true, readOnly: true},
  58. magicType : {
  59. //折线图 柱形图 总数统计 分开平铺
  60. type: ['line', 'bar','stack','tiled'],
  61. },
  62. }
  63. },
  64. xAxis : [
  65. {
  66. //就是一月份这个显示为一个线段,而不是数轴那种一个点点
  67. boundaryGap:true,
  68. type : 'category',
  69. name : '时间',
  70. data : ['1月','2月','3月','4月','5月','6月','7月','8月']
  71. }
  72. ],
  73. yAxis : [
  74. {
  75. type : 'value',
  76. name : '销量(kg)'
  77. }
  78. ],
  79. //图形的颜色组
  80. color:['rgb(249,159,94)','rgb(67,205,126)','rgb(167,205,126)'],
  81. //需要显示的图形名称,类型,以及数据设置
  82. series : [
  83. {
  84. name:'苹果',
  85. //默认显
  86. type:typeTitle,
  87. data:typeOptions.apple
  88. },
  89. {
  90. name:'橘子',
  91. type:typeTitle,
  92. data:typeOptions.organ
  93. },{
  94. name:'香蕉',
  95. type:typeTitle,
  96. data:typeOptions.banana
  97. }
  98. ]
  99. };
  100. this.state = {
  101. options:option,
  102. }
  103. }
  104. _onPressAllScreen(){
  105. NavigationUtil.goPage(this.state.options,'AllScreenChart',)
  106. }
  107. render() {
  108. return (
  109. <View style={styles.cell_content}>
  110. <View style={styles.topView}>
  111. <Text style={styles.topView_title}>
  112. 今年水果排行榜和种类
  113. </Text>
  114. <TouchableOpacity
  115. style = {styles.topView_touch}
  116. onPress={()=>this._onPressAllScreen()}
  117. >
  118. <Image style={styles.topView_image}
  119. source={{uri: 'bi_allScreen'}}
  120. >
  121. </Image>
  122. </TouchableOpacity>
  123. </View>
  124. <Echarts option={this.state.options} height={260} width={width}/>
  125. </View>
  126. );
  127. }
  128. }
  129. const styles = StyleSheet.create({
  130. cell_content:{
  131. backgroundColor:'white',
  132. padding:10,
  133. marginTop:10,
  134. marginLeft:10,
  135. marginRight:10,
  136. marginVertical:3,
  137. borderColor:'#dddddd',
  138. borderWidth:0.5,
  139. borderRadius:8,
  140. shadowColor:'gray',
  141. shadowOffset:{width: 2,height: 2},
  142. shadowOpacity:0.4,
  143. shadowRadius:1,
  144. elevation: 2,
  145. },
  146. topView:{
  147. height: 30,
  148. justifyContent:'space-between',
  149. flexDirection:'row',
  150. },
  151. topView_title:{
  152. fontSize:18,
  153. color: '#333333',
  154. height:30,
  155. marginLeft: 10,
  156. width:200,
  157. lineHeight:30,
  158. },
  159. topView_touch:{
  160. padding:1,
  161. height:30,
  162. width:30,
  163. },
  164. topView_image:{
  165. marginTop:5,
  166. height:20,
  167. width:20,
  168. },
  169. });