curveComC.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div shadow="never" class="homeBoxCard" v-loading="loading">
  3. <div style="text-align: center;font-weight:bold">C相电流(A)</div>
  4. <div class="height300" id="curveComC" ref="curveComC" />
  5. </div>
  6. </template>
  7. <script>
  8. import { computed, defineComponent, onMounted, ref } from 'vue'
  9. import { useStore } from 'vuex'
  10. import * as echarts from 'echarts'
  11. export default defineComponent({
  12. name: 'CurveComC',
  13. setup() {
  14. const store = useStore()
  15. // 总数
  16. const total = computed(() => store.state.Home.worksChartData.total)
  17. // num
  18. const num = computed(() => store.state.Home.worksChartData.num)
  19. // 读取数据 func
  20. const loading = ref(true)
  21. const getData = async () => {
  22. // loading.value = true
  23. // await store.dispatch("Home/queryWorksChartData");
  24. loading.value = false;
  25. }
  26. onMounted(() => {
  27. getData()
  28. let myChart = echarts.init(document.getElementById('curveComC'))
  29. // 绘制图表
  30. myChart.setOption({
  31. tooltip: {
  32. trigger: 'axis',
  33. axisPointer: {
  34. type: 'shadow',
  35. },
  36. },
  37. legend: {
  38. show:false,
  39. data: ['平均值', '95%', '最大值'],
  40. // align: 'right',
  41. right: 60,
  42. itemWidth: 10,
  43. itemHeight: 10,
  44. itemGap: 35,
  45. },
  46. grid: {
  47. left: '3%',
  48. right: '4%',
  49. bottom: '3%',
  50. containLabel: true,
  51. },
  52. xAxis: [
  53. {
  54. type: 'category',
  55. data: [
  56. '1次',
  57. '3次',
  58. '5次',
  59. '7次',
  60. '9次',
  61. '11次',
  62. '13次',
  63. '15次',
  64. '17次',
  65. '19次 ',
  66. ],
  67. axisLine: {
  68. show: true,
  69. lineStyle: {
  70. color: '#444',
  71. width: 1,
  72. type: 'solid',
  73. },
  74. },
  75. axisTick: {
  76. show: false,
  77. },
  78. axisLabel: {
  79. show: true,
  80. color: '#444',
  81. },
  82. },
  83. ],
  84. yAxis: [
  85. {
  86. type: 'value',
  87. name: 'A',
  88. nameTextStyle: {
  89. color: '#444',
  90. },
  91. axisLabel: {
  92. formatter: '{value} ',
  93. },
  94. axisTick: {
  95. show: false,
  96. },
  97. axisLine: {
  98. show: false,
  99. lineStyle: {
  100. color: '#444',
  101. width: 1,
  102. type: 'solid',
  103. },
  104. },
  105. splitLine: {
  106. lineStyle: {
  107. color: '#444',
  108. },
  109. },
  110. },
  111. ],
  112. series: [
  113. {
  114. name: '平均值',
  115. type: 'bar',
  116. data: [20, 50, 80, 58, 83, 68, 57, 80, 42, 66],
  117. barWidth: 10, //柱子宽度
  118. barGap: '1', //柱子之间间距
  119. itemStyle: {
  120. normal: {
  121. color: '#5b82ee',
  122. opacity: 1,
  123. },
  124. },
  125. },
  126. {
  127. name: '95%',
  128. type: 'bar',
  129. data: [50, 70, 60, 61, 75, 87, 60, 62, 86, 46],
  130. barWidth: 10,
  131. barGap: '1',
  132. itemStyle: {
  133. normal: {
  134. color: '#f2e251',
  135. opacity: 1,
  136. },
  137. },
  138. },
  139. {
  140. name: '最大值',
  141. type: 'bar',
  142. data: [70, 48, 73, 68, 53, 47, 50, 72, 96, 86],
  143. barWidth: 10,
  144. barGap: '1',
  145. itemStyle: {
  146. normal: {
  147. color: '#fe8161',
  148. opacity: 1,
  149. },
  150. },
  151. },
  152. ],
  153. })
  154. window.onresize = function () {
  155. // 自适应大小
  156. myChart.resize()
  157. }
  158. })
  159. return {
  160. loading,
  161. total,
  162. num,
  163. }
  164. },
  165. })
  166. </script>
  167. <style lang="scss" scoped>
  168. .homeBoxCard {
  169. margin-bottom: 24px;
  170. ::v-deep(.el-card__header) {
  171. padding-left: 12px;
  172. padding-right: 12px;
  173. }
  174. ::v-deep(.el-card__body) {
  175. padding: 12px;
  176. font-size: 14px;
  177. line-height: 1.5715;
  178. }
  179. ::v-deep(.el-divider) {
  180. margin: 8px 0;
  181. }
  182. .num {
  183. font-size: 30px;
  184. color: #515a6e;
  185. }
  186. .height300 {
  187. height: 300px;
  188. }
  189. }
  190. </style>