securityAlarmManageTrend.vue 3.3 KB

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