AllScreenChart.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import React,{ Component} from 'react';
  2. import {
  3. StyleSheet,
  4. Text,
  5. View,
  6. TouchableOpacity,
  7. Image,
  8. DeviceEventEmitter
  9. } from 'react-native';
  10. import {NativeModules} from 'react-native';
  11. const YRRnBridge = NativeModules.YRRnBridge;
  12. import Orientation from 'react-native-orientation';
  13. import Echarts from 'native-echarts';
  14. import Dimensions from 'Dimensions';
  15. const {width,height} = Dimensions.get('window');
  16. export default class AllScreenChart extends Component {
  17. constructor(props) {
  18. super(props);
  19. const {params} = this.props.navigation.state;
  20. params.legend.padding = [10,10,10,10];
  21. console.log(params);
  22. console.log(this.props.navigation.state.params);
  23. this.state = {
  24. options:params,
  25. width:width,
  26. height:height,
  27. }
  28. }
  29. componentDidMount() {
  30. Orientation.lockToLandscapeRight();
  31. const initial = Orientation.getInitialOrientation();
  32. if (initial === 'PORTRAIT') {
  33. this.setState({
  34. width:width,
  35. height:height,
  36. })
  37. } else {
  38. this.setState({
  39. width:height,
  40. height:width,
  41. })
  42. }
  43. }
  44. _onPressAllScreen(){
  45. Orientation.lockToPortrait();
  46. this.props.navigation.goBack();
  47. }
  48. render() {
  49. return (
  50. <View style={styles.container}>
  51. <View style={styles.topView}>
  52. <Text style={styles.topView_title}>
  53. 今年水果排行榜和种类
  54. </Text>
  55. <TouchableOpacity
  56. style = {styles.topView_touch}
  57. onPress={()=>this._onPressAllScreen()}
  58. >
  59. <Image style={styles.topView_image}
  60. source={{uri: 'bi_allScreen'}}
  61. >
  62. </Image>
  63. </TouchableOpacity>
  64. </View>
  65. <Echarts option={this.state.options} height={this.state.width-50} width={this.state.height}/>
  66. </View>
  67. );
  68. }
  69. }
  70. const styles = StyleSheet.create({
  71. container:{
  72. backgroundColor:'white',
  73. flex:1,
  74. },
  75. topView:{
  76. marginTop:20,
  77. marginBottom:6,
  78. height: 30,
  79. justifyContent:'space-between',
  80. flexDirection:'row',
  81. },
  82. topView_title:{
  83. fontSize:18,
  84. color: '#333333',
  85. height:30,
  86. marginLeft: 10,
  87. width:200,
  88. lineHeight:30,
  89. },
  90. topView_touch:{
  91. padding:1,
  92. marginRight:20,
  93. paddingRight:20,
  94. height:30,
  95. width:30,
  96. },
  97. topView_image:{
  98. marginTop:5,
  99. marginRight:18,
  100. height:20,
  101. width:20,
  102. },
  103. });