securityAlarmManageCategory.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="myChart" ref="myChart" :style="{height: height+'px'}"></div>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. }
  9. },
  10. props: {
  11. height: Number
  12. },
  13. mounted() {
  14. this.init()
  15. },
  16. methods: {
  17. init() {
  18. let chart = this.$echarts.init(this.$refs.myChart);
  19. let options = {
  20. color: ['#80B2FF','#FFDF80'],
  21. legend: {
  22. data: [
  23. '告警次数',
  24. ]
  25. },
  26. grid: {
  27. left: '2%', //默认10%
  28. right: '2%', //默认10%
  29. bottom: '10%', //默认60
  30. top: '15%',
  31. containLabel: true
  32. //grid区域是否包含坐标轴的刻度标签
  33. },
  34. xAxis: {
  35. type: 'category',
  36. data: ['火焰告警', '烟雾告警', '水浸异常', '设备故障', '违规闯入', '行为异常']
  37. },
  38. yAxis: [
  39. {
  40. //name: '告警次数',
  41. type: 'value',
  42. nameTextStyle: {
  43. padding: [10, 0, 10, 15]
  44. },
  45. },
  46. ],
  47. tooltip: {
  48. trigger: 'axis',
  49. axisPointer: {
  50. type: 'shadow'
  51. },
  52. textStyle: {
  53. color: '#fff',
  54. align: 'left',
  55. fontSize: 14
  56. },
  57. axisLine: {//x坐标轴轴线
  58. show: true,
  59. lineStyle: {//x坐标轴轴线样式
  60. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  61. }
  62. },
  63. backgroundColor: 'rgba(0,0,0,0.8)',
  64. },
  65. series: [
  66. {
  67. name: '告警次数',
  68. data: [120, 125, 133, 145, 170, 175],
  69. type: 'bar',
  70. backgroundStyle: {
  71. color: 'rgba(180, 180, 180, 0.2)'
  72. }
  73. },
  74. ]
  75. };
  76. chart.setOption(options);
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="less" scoped>
  82. </style>