SensorStatus.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="item">
  3. <div class="title">
  4. <span class="name">传感器在线状况</span>
  5. <span class="number">24</span>
  6. </div>
  7. <div class="container">
  8. <div id="sensor-status-chart" v-if="status"></div>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import * as echarts from 'echarts';
  14. export default {
  15. name:"SensorStatus",
  16. data(){
  17. return{
  18. myChart:null,
  19. status:true,
  20. option :{
  21. tooltip: {
  22. trigger: 'axis',
  23. axisPointer: {
  24. type: 'shadow'
  25. }
  26. },
  27. legend: {
  28. textStyle:{
  29. color:'#fff'
  30. }
  31. },
  32. grid: {
  33. top:'20%',
  34. left: '3%',
  35. right: '4%',
  36. bottom: '3%',
  37. containLabel: true
  38. },
  39. xAxis: {
  40. type: 'value',
  41. boundaryGap: [0, 0.01],
  42. axisLabel:{
  43. color:'#fff'
  44. },
  45. axisLine:{
  46. show:false
  47. },
  48. splitLine: {
  49. show: false,
  50. },
  51. },
  52. yAxis: {
  53. type: 'category',
  54. data: ['在线', '离线'],
  55. axisLabel:{
  56. color:'#fff'
  57. },
  58. splitLine: {
  59. show: false,
  60. },
  61. },
  62. series: [
  63. {
  64. name: '压力',
  65. type: 'bar',
  66. data: [63,19, 23, 31, 12, 13]
  67. },
  68. {
  69. name: '位移',
  70. type: 'bar',
  71. data: [19, 23, 31, 12, 13, 68]
  72. },
  73. {
  74. name: '有害气体',
  75. type: 'bar',
  76. data: [19, 23, 31, 12, 13, 68]
  77. }
  78. ]
  79. }
  80. }
  81. },
  82. created(){
  83. // this.$nextTick(()=>{
  84. // this.init()
  85. // })
  86. },
  87. methods:{
  88. init(){
  89. var chartDom = document.getElementById('sensor-status-chart');
  90. var myChart = echarts.init(chartDom);
  91. this.option && myChart.setOption(this.option);
  92. myChart.on('click', function(params) {
  93. console.log("SensorStatus",params)
  94. });
  95. this.myChart=myChart
  96. }
  97. },
  98. destroyed() {
  99. this.status=false
  100. },
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .container{
  105. height: 13.2vh !important;
  106. // min-height: 164px;
  107. #sensor-status-chart{
  108. width: 95%;
  109. height: 100%;
  110. }
  111. }
  112. </style>