cableTemChart.vue 4.7 KB

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