detailsCharts.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <el-dialog
  3. width="70%"
  4. @open="opened()"
  5. @closed="closed()"
  6. :show-close="true"
  7. class="dialogs"
  8. >
  9. <template #title>
  10. <div class="showTitles">
  11. <div class="stationName">
  12. <div class="titleName">{{ showData?.name?.name }}</div>
  13. <div class="titleNames" v-if="showData?.name?.names">
  14. ({{ showData?.name?.names }})
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <div class="bodyy">
  20. <div id="showEcharts" class="echarts"></div>
  21. </div>
  22. </el-dialog>
  23. </template>
  24. <script>
  25. import * as echarts from "echarts";
  26. export default {
  27. props: {
  28. showData: {
  29. type: String,
  30. default: "",
  31. },
  32. },
  33. updated() {
  34. this.showEcharts(this.showData);
  35. },
  36. methods: {
  37. showEcharts(showData) {
  38. let chartDom = document.getElementById("showEcharts");
  39. chartDom.removeAttribute("_echarts_instance_")
  40. let myChart = echarts.init(chartDom, "#ffffff");
  41. let option;
  42. option = {
  43. tooltip: {
  44. trigger: "axis",
  45. },
  46. legend: {
  47. show: true,
  48. data: showData.value.map((t) => {
  49. return t.title;
  50. }),
  51. right: 56,
  52. icon: "circle",
  53. itemWidth: 6,
  54. inactiveColor: "#606769",
  55. textStyle: {
  56. color: "#B3BDC0",
  57. fontSize: 12,
  58. },
  59. },
  60. xAxis: [
  61. {
  62. type: "category",
  63. boundaryGap: false,
  64. axisLabel: {
  65. interval: 60,
  66. showMinLabel: true,
  67. showMaxLabel: true,
  68. formatter: "{value}",
  69. fontSize: 14,
  70. textStyle: {
  71. color: "#606769",
  72. },
  73. },
  74. axisLine: {
  75. show: false,
  76. },
  77. data: showData.value[0].value.map((item) => {
  78. return item.text;
  79. }),
  80. },
  81. ],
  82. yAxis: {
  83. type: "value",
  84. axisLabel: {
  85. formatter: "{value}",
  86. fontSize: 14,
  87. },
  88. axisLine: {
  89. show: false,
  90. },
  91. splitLine: {
  92. show: true,
  93. lineStyle: {
  94. color: "#606769",
  95. type: "dashed",
  96. },
  97. },
  98. },
  99. series: [
  100. {
  101. name: showData.value[0].title,
  102. smooth: true,
  103. showSymbol: false,
  104. data: showData.value[0].value.map((item) => {
  105. return item.value;
  106. }),
  107. type: "line",
  108. lineStyle: {
  109. normal: {
  110. color: "rgba(75, 85, 174, 1)",
  111. width: 1,
  112. },
  113. },
  114. },
  115. {
  116. name: showData.value[1].title,
  117. smooth: true,
  118. showSymbol: false,
  119. data: showData.value[1].value.map((item) => {
  120. return item.value;
  121. }),
  122. type: "line",
  123. lineStyle: {
  124. normal: {
  125. color: "rgba(05, 187, 76, 1)",
  126. width: 1,
  127. },
  128. },
  129. },
  130. ],
  131. };
  132. option && myChart.setOption(option);
  133. },
  134. opened() {
  135. },
  136. closed() {
  137. this.$emit("closeds");
  138. },
  139. },
  140. };
  141. </script>
  142. <style scoped>
  143. .echarts {
  144. width: 1300px;
  145. height: 60vh;
  146. }
  147. .stationName {
  148. font-size: 20px;
  149. width: 400px;
  150. height: 45px;
  151. display: flex;
  152. flex-direction: row;
  153. align-items: baseline;
  154. justify-content: center;
  155. color: #ffffff;
  156. }
  157. .titleName {
  158. margin-top: 10px;
  159. }
  160. .titleNames {
  161. font-size: 12px;
  162. margin-left: 10px;
  163. margin-top: 10px;
  164. }
  165. </style>