eleCurrentChart.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div id="eleCurrentChart" :style="{ width: '100%', height: '100% ' }"></div>
  3. </template>
  4. <script>
  5. //三相电压模拟数据
  6. // var yearData = [
  7. // {
  8. // data: [
  9. // [24, 40, 101, 134, 90, 230, 210, 230, 120, 230, 210, 120],
  10. // [30, 50, 110, 144, 110, 240, 228, 240, 130, 240, 220, 130],
  11. // [43, 61, 125, 153, 138, 250, 239, 264, 143, 260, 229, 160],
  12. // ],
  13. // },
  14. // ];
  15. export default {
  16. props: {
  17. getData: [],
  18. },
  19. name: "lineChart",
  20. data() {
  21. return {
  22. myChart: null,
  23. eleCurrentA: [],
  24. eleCurrentB: [],
  25. eleCurrentC: [],
  26. };
  27. },
  28. computed: {
  29. A: function () {
  30. var aa = [];
  31. this.eleCurrentA.forEach(function (item) {
  32. aa.push(item.Value);
  33. });
  34. return aa;
  35. },
  36. B: function () {
  37. var bb = [];
  38. this.eleCurrentB.forEach(function (item) {
  39. bb.push(item.Value);
  40. });
  41. bb.reverse()
  42. return bb;
  43. },
  44. C: function () {
  45. var cc = [];
  46. this.eleCurrentC.forEach(function (item) {
  47. cc.push(item.Value);
  48. });
  49. cc.reverse()
  50. return cc;
  51. },
  52. Time: function () {
  53. var time = [];
  54. this.eleCurrentC.forEach(function (item) {
  55. time.push(item.Time);
  56. });
  57. time.reverse()
  58. return time;
  59. },
  60. },
  61. mounted() {
  62. window.addEventListener("resize", () => {
  63. this.myChart.resize();
  64. });
  65. setTimeout(() => {
  66. console.log("子组件中的this.getData");
  67. console.log(this.getData);
  68. this.eleCurrentA = this.getData[7].LIST;
  69. this.eleCurrentB = this.getData[8].LIST;
  70. this.eleCurrentC = this.getData[9].LIST;
  71. this.draw();
  72. }, 100);
  73. },
  74. methods: {
  75. draw() {
  76. this.myChart = this.$echarts.init(
  77. document.getElementById("eleCurrentChart")
  78. );
  79. this.myChart.setOption({
  80. // 通过这个color修改两条线的颜色
  81. title: {
  82. text: "ABC三相电流",
  83. textStyle: {
  84. align: "center",
  85. color: "#fff",
  86. fontSize: ".225rem ",
  87. fontWeight: "400",
  88. },
  89. left: "center",
  90. },
  91. color: ["#60FF12", "#FF1212", "#26BFFF"],
  92. tooltip: {
  93. trigger: "axis",
  94. },
  95. // 图列组件
  96. legend: {
  97. show: true,
  98. itemGap: 50,
  99. textStyle: {
  100. color: "#fff",
  101. fontSize: ".225rem ",
  102. },
  103. bottom: "-2%",
  104. },
  105. grid: {
  106. left: "1%",
  107. right: "1%",
  108. top: "13%",
  109. bottom: "10%",
  110. containLabel: true, // 包含刻度文字在内
  111. },
  112. xAxis: {
  113. type: "category",
  114. boundaryGap: true,
  115. // data: [
  116. // "09:00",
  117. // "11:00",
  118. // "13:00",
  119. // "15:00",
  120. // "17:00",
  121. // "19:00",
  122. // "21:00",
  123. // "23:00",
  124. // "01:00",
  125. // "03:00",
  126. // "05:00",
  127. // "07:00",
  128. // ],
  129. data: this.Time,
  130. axisTick: {
  131. show: false, //去除刻度线
  132. },
  133. axisLabel: {
  134. color: "#4c9bfd", // 文本颜色
  135. },
  136. axisLine: {
  137. show: false, // 去除轴线
  138. },
  139. // boundaryGap: false
  140. },
  141. yAxis: {
  142. type: "value",
  143. axisTick: {
  144. show: false, //去除刻度线
  145. },
  146. axisLabel: {
  147. color: "#fff", // 文本颜色
  148. },
  149. axisLine: {
  150. show: false, // 去除轴线
  151. },
  152. splitNumber: 5,
  153. splitLine: {
  154. show: true,
  155. lineStyle: {
  156. color: "rgba(-11,72,255,.5)",
  157. },
  158. },
  159. },
  160. series: [
  161. {
  162. name: "A相",
  163. type: "line",
  164. smooth: false, // 曲线是否平滑显示
  165. // data: yearData[0].data[0],
  166. data: this.A,
  167. symbolSize: 10, //拐点圆的大小
  168. },
  169. {
  170. name: "B相",
  171. type: "line",
  172. smooth: false, // 曲线是否平滑显示
  173. // data: yearData[0].data[1],
  174. data: this.B,
  175. symbolSize: 10, //拐点圆的大小
  176. },
  177. {
  178. name: "C相",
  179. type: "line",
  180. smooth: false, // 曲线是否平滑显示
  181. // data: yearData[0].data[2],
  182. data: this.C,
  183. symbolSize: 10, //拐点圆的大小
  184. },
  185. ],
  186. });
  187. },
  188. },
  189. };
  190. </script>
  191. <style>
  192. </style>