securityAlarmManageOnlineTrend.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <script>
  2. import apiSecurityAlarmMgr from "@/api/security/apiSecurityAlarmMgr";
  3. export default {
  4. data() {
  5. return {
  6. option: {
  7. legend: {
  8. data: [
  9. '摄像头',
  10. '水浸设备',
  11. ]
  12. },
  13. grid: {
  14. left: '0%', //默认10%
  15. right: '1%', //默认10%
  16. bottom: '18%', //默认60
  17. top: '15%',
  18. containLabel: true
  19. //grid区域是否包含坐标轴的刻度标签
  20. },
  21. xAxis: {
  22. data: []
  23. },
  24. yAxis: [
  25. {
  26. type: 'value',
  27. min: 0,
  28. max: 100,
  29. nameTextStyle: {
  30. padding: [10, 0, 10, -12]
  31. },
  32. axisLabel: {
  33. show: true,
  34. formatter: '{value}%'
  35. }
  36. },
  37. ],
  38. dataZoom: [
  39. {
  40. type: 'slider',
  41. start: 0,
  42. end: 100,
  43. height: 12,
  44. },
  45. {
  46. type: 'inside',
  47. start: 0,
  48. end: 100,
  49. }
  50. ],
  51. tooltip: {
  52. trigger: 'axis',
  53. axisPointer: {
  54. type: 'shadow'
  55. },
  56. textStyle: {
  57. color: '#fff',
  58. align: 'left',
  59. fontSize: 14
  60. },
  61. axisLine: {//x坐标轴轴线
  62. show: true,
  63. lineStyle: {//x坐标轴轴线样式
  64. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  65. }
  66. },
  67. backgroundColor: 'rgba(0,0,0,0.8)',
  68. },
  69. series: [
  70. {
  71. name: '摄像头',
  72. data: [],
  73. type: 'line',
  74. smooth: true,
  75. //areaStyle: {
  76. // color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  77. // offset: 0,
  78. // color: '#A6C9FF' // 0% 处的颜色
  79. // }, {
  80. // offset: 0.8,
  81. // color: '#ffffff' // 100% 处的颜色
  82. // }], false),
  83. //},
  84. lineStyle: {
  85. color: "#5A9BFE",
  86. width: 1,
  87. },
  88. emphasis: {
  89. scale:1.5
  90. }
  91. },
  92. {
  93. name: '水浸设备',
  94. data: [],
  95. type: 'line',
  96. smooth: true,
  97. //areaStyle: {
  98. // color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  99. // offset: 0,
  100. // color: '#B0E5CB' // 0% 处的颜色
  101. // }, {
  102. // offset: 0.8,
  103. // color: '#ffffff' // 100% 处的颜色
  104. // }], false),
  105. //},
  106. lineStyle: {
  107. color: "#62CC97",
  108. width: 1,
  109. },
  110. emphasis: {
  111. scale:1.5
  112. },
  113. }
  114. ]
  115. },
  116. }
  117. },
  118. props: {
  119. height: Number,
  120. queryData: Object
  121. },
  122. mounted() {
  123. this.$nextTick(()=>{
  124. this.init()
  125. })
  126. },
  127. methods: {
  128. init() {
  129. let chart = this.$echarts.init(this.$refs.myChart)
  130. this.chart = chart;
  131. this.$util.chartsResize(this.chart);
  132. chart.setOption(this.option)
  133. this.getData()
  134. },
  135. getData() {
  136. return apiSecurityAlarmMgr.getEquipmentOnline(this.queryData).then(res=>{
  137. let data = this.$util.dataUtil.covertDataToEcharts(res, ['camera','waterImmersion'])
  138. this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <template>
  145. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  146. </template>
  147. <style lang="less" scoped>
  148. </style>