curveComB.vue 4.1 KB

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