RaddarChart.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div :class="className" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import * as echarts from 'echarts'
  6. require('echarts/theme/macarons') // echarts theme
  7. import resize from './mixins/resize'
  8. const animationDuration = 3000
  9. export default {
  10. mixins: [resize],
  11. props: {
  12. className: {
  13. type: String,
  14. default: 'chart'
  15. },
  16. width: {
  17. type: String,
  18. default: '100%'
  19. },
  20. height: {
  21. type: String,
  22. default: '300px'
  23. }
  24. },
  25. data() {
  26. return {
  27. chart: null
  28. }
  29. },
  30. mounted() {
  31. this.$nextTick(() => {
  32. this.initChart()
  33. })
  34. },
  35. beforeDestroy() {
  36. if (!this.chart) {
  37. return
  38. }
  39. this.chart.dispose()
  40. this.chart = null
  41. },
  42. methods: {
  43. initChart() {
  44. this.chart = echarts.init(this.$el, 'macarons')
  45. this.chart.setOption({
  46. title: {
  47. text: ''
  48. },
  49. tooltip:{trigger:'item',backgroundColor:'#f2f2f2'},
  50. legend: {
  51. data:[]
  52. },
  53. splitArea : {
  54. show : false,
  55. areaStyle : {
  56. color: 'rgba(255,0,0,0)', // 图表背景的颜色
  57. },
  58. },
  59. // 设置雷达图中间射线的颜色
  60. axisLine: {
  61. lineStyle: {
  62. color: 'rgba(131,141,158,.1)',
  63. },
  64. },
  65. splitLine : {
  66. show : true,
  67. lineStyle : {
  68. width : 1,
  69. color : 'rgba(131,141,158,.1)', // 设置网格的颜色
  70. },
  71. },
  72. radar: {
  73. // shape: 'circle',
  74. indicator: [
  75. { name: '烟雾告警', max: 65000 },
  76. { name: '越线告警', max: 66000 },
  77. { name: '徘徊告警', max: 30000 },
  78. { name: '陌生人告警', max: 38000 },
  79. { name: '火焰告警', max: 52000 },
  80. ]
  81. },
  82. series: [
  83. {
  84. name: 'Budget vs spending',
  85. type: 'radar',
  86. areaStyle: {
  87. normal: {
  88. width: 1,
  89. opacity: 0.2,
  90. },
  91. },
  92. data: [
  93. {
  94. value: [42000, 30800, 20000, 35000, 30000, ],
  95. name: 'Allocated Budget',
  96. // 设置区域边框和区域的颜色
  97. itemStyle: {
  98. normal: {
  99. color: 'rgba(255,171,43,1)',
  100. lineStyle: {
  101. color: 'rgba(255,171,43,0.17)',
  102. },
  103. },
  104. },
  105. areaStyle: {
  106. color: 'rgba(255,171,43,1)'
  107. }
  108. },
  109. ]
  110. }
  111. ]
  112. })
  113. }
  114. }
  115. }
  116. </script>