sameDay.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="_consume">
  3. <HeadlineTag value="异常震动(周)"></HeadlineTag>
  4. <div class="_consume_mains">
  5. <div ref="chartRef" style="width: 100%; height: 100%;"></div>
  6. </div>
  7. </div>
  8. </template>
  9. <script setup>
  10. import { ref, onMounted, onUnmounted } from 'vue';
  11. import * as echarts from 'echarts';
  12. import HeadlineTag from '@/components/HeadlineTag';
  13. const chartRef = ref(null);
  14. let chart = null;
  15. const generateRandomData = (length, max) => {
  16. const randomData = [];
  17. for (let i = 0; i < length; i++) {
  18. randomData.push(Math.floor(Math.random() * max));
  19. }
  20. return randomData;
  21. };
  22. const handleResize = () => {
  23. if (chart) {
  24. chart.resize();
  25. }
  26. };
  27. onMounted(() => {
  28. if (chartRef.value) {
  29. chart = echarts.init(chartRef.value);
  30. // 生成一周的日期数据
  31. const weekDays = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
  32. const option = {
  33. xAxis: {
  34. type: 'category',
  35. data: weekDays,
  36. axisLabel: {
  37. color: '#fff'
  38. },
  39. },
  40. tooltip: {
  41. trigger: 'axis',
  42. axisPointer: {
  43. type: 'cross',
  44. crossStyle: {
  45. color: '#999'
  46. }
  47. }
  48. },
  49. grid: {
  50. top: '10%',
  51. bottom: '10%',
  52. right: '0%',
  53. },
  54. yAxis: {
  55. type: 'value',
  56. axisLabel: {
  57. show: true,
  58. color: '#fff'
  59. },
  60. splitLine: {
  61. show: false,
  62. lineStyle: {
  63. color: '#44585e'
  64. }
  65. },
  66. axisTick: {
  67. show: false
  68. },
  69. },
  70. series: [
  71. // 仅保留曲线表示运行异常
  72. {
  73. name: '异常震动次数',
  74. type: 'line',
  75. data: generateRandomData(7, 50),
  76. lineStyle: {
  77. color: '#de4337',
  78. },
  79. showSymbol: false,
  80. smooth: true,
  81. areaStyle: {
  82. color: new echarts.graphic.LinearGradient(
  83. 0,
  84. 0,
  85. 0,
  86. 1,
  87. [{
  88. offset: 0,
  89. color: 'rgba(222, 67, 55, .6)',
  90. },
  91. {
  92. offset: 0.8,
  93. color: 'rgba(222, 67, 55, .2)',
  94. },
  95. ],
  96. false
  97. ),
  98. shadowColor: 'rgba(0, 0, 0, 0.1)',
  99. shadowBlur: 10,
  100. },
  101. }
  102. ]
  103. };
  104. chart.setOption(option);
  105. }
  106. window.addEventListener('resize', handleResize);
  107. });
  108. onUnmounted(() => {
  109. window.removeEventListener('resize', handleResize);
  110. if (chart) {
  111. chart.dispose();
  112. }
  113. });
  114. </script>
  115. <style lang="scss">
  116. ._divider {
  117. height: 1px;
  118. border: 1px dashed #168cdb;
  119. flex: 1;
  120. margin: 0 10px;
  121. }
  122. ._consume {
  123. display: flex;
  124. flex-direction: column;
  125. &_mains {
  126. margin: 10px 30px;
  127. flex: 1;
  128. display: flex;
  129. &_item {
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. padding: 10px;
  134. &_name {
  135. width: 30px;
  136. height: 30px;
  137. background: url("@/assets/images/content_circle_num.png");
  138. background-size: 100% 100%;
  139. background-position: center;
  140. background-repeat: no-repeat;
  141. // animation: scanning 4s linear infinite;
  142. border: 1px solid red;
  143. }
  144. &_flag {
  145. display: flex;
  146. align-items: center;
  147. gap: 3px;
  148. &_item {
  149. width: 30px;
  150. height: 30px;
  151. border: 3px dashed #168cdb;
  152. box-sizing: border-box;
  153. background: #0e6ead;
  154. color: #fff;
  155. border-radius: 50%;
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. font-size: 14px;
  160. }
  161. }
  162. }
  163. &_item:hover {
  164. cursor: pointer;
  165. background-image: linear-gradient(to right, #168cdb, transparent);
  166. }
  167. }
  168. }
  169. </style>