radarChart.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div shadow="never" class="homeBoxCard" v-loading="loading">
  3. <div class="height260" id="radarChart" ref="radarChart" />
  4. </div>
  5. </template>
  6. <script>
  7. import { computed, defineComponent, onMounted, ref } from 'vue'
  8. import { useStore } from 'vuex'
  9. import * as echarts from 'echarts'
  10. export default defineComponent({
  11. name: 'RadarChart',
  12. setup() {
  13. const store = useStore()
  14. // 总数
  15. const total = computed(() => store.state.Home.worksChartData.total)
  16. // num
  17. const num = computed(() => store.state.Home.worksChartData.num)
  18. // 读取数据 func
  19. const loading = ref(true)
  20. const getData = async () => {
  21. // loading.value = true;
  22. // await store.dispatch("Home/queryWorksChartData");
  23. loading.value = false
  24. }
  25. onMounted(() => {
  26. getData()
  27. let myChart = echarts.init(document.getElementById('radarChart'))
  28. // 绘制图表
  29. myChart.setOption({
  30. backgroundColor: '#FFF',
  31. tooltip: {},
  32. grid: {
  33. left: '20',
  34. right: '40',
  35. top: '-20',
  36. bottom: '0',
  37. containLabel: true,
  38. },
  39. radar: {
  40. radius: '60%',
  41. center: ['50%', '55%'],
  42. splitNumber: 5,
  43. nameGap: '15',
  44. name: {
  45. textStyle: {
  46. color: '#a8a8a8',
  47. },
  48. },
  49. axisLine: {
  50. lineStyle: {
  51. color: '#ebebeb',
  52. },
  53. },
  54. splitLine: {
  55. lineStyle: {
  56. width: 1,
  57. color: '#ebebeb',
  58. },
  59. },
  60. splitArea: {
  61. areaStyle: {
  62. color: ['#f8f8f8', '#fff'].reverse(),
  63. },
  64. },
  65. indicator: [
  66. {
  67. name: '谐波畸变率',
  68. max: 100,
  69. },
  70. {
  71. name: '电压平衡度',
  72. max: 100,
  73. },
  74. {
  75. name: '电压合格率',
  76. max: 100,
  77. },
  78. {
  79. name: '功率因数',
  80. max: 100,
  81. },
  82. {
  83. name: '电流平衡度',
  84. max: 100,
  85. },
  86. {
  87. name: '负载率',
  88. max: 100,
  89. },
  90. ],
  91. },
  92. series: [
  93. {
  94. name: 'Title✍',
  95. type: 'radar',
  96. symbolSize: 12,
  97. itemStyle: {
  98. borderColor: '#ebebeb',
  99. borderWidth: 2,
  100. },
  101. areaStyle: {
  102. opacity: 0.3,
  103. },
  104. data: [
  105. {
  106. itemStyle: {
  107. color: '#5eb6db',
  108. },
  109. value: [20, 33, 80, 50, 30, 40, 100],
  110. },
  111. ],
  112. },
  113. ],
  114. })
  115. window.addEventListener('resize', () => {
  116. myChart.resize()
  117. })
  118. })
  119. return {
  120. loading,
  121. total,
  122. num,
  123. }
  124. },
  125. })
  126. </script>
  127. <style lang="scss" scoped>
  128. .homeBoxCard {
  129. margin-bottom: 24px;
  130. ::v-deep(.el-card__header) {
  131. padding-left: 12px;
  132. padding-right: 12px;
  133. }
  134. ::v-deep(.el-card__body) {
  135. padding: 12px;
  136. font-size: 14px;
  137. line-height: 1.5715;
  138. }
  139. ::v-deep(.el-divider) {
  140. margin: 8px 0;
  141. }
  142. .num {
  143. font-size: 30px;
  144. color: #515a6e;
  145. }
  146. .height260 {
  147. height: 260px;
  148. }
  149. }
  150. </style>