ChartElecLines.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-10-08 17:24:29
  4. * @LastEditTime: 2021-12-21 10:07:31
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 存栏结构 - 存栏变动折线图
  7. * @FilePath: \hyyfClient\src\views\PdcData\analysis\ChartInventoryLines.vue
  8. -->
  9. <template>
  10. <div class="chart-inventory-lines">
  11. <div id="chartElecLines"></div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. myChart: null,
  19. };
  20. },
  21. props: {
  22. data: {
  23. type: Object,
  24. required: true,
  25. default: () => ({}),
  26. },
  27. },
  28. methods: {
  29. init() {
  30. let flag = "";
  31. if (this.data.month.length === 0) {
  32. flag = "暂无数据";
  33. }
  34. let options = {
  35. title: {
  36. text: "近七日重量统计",
  37. x: 30,
  38. y: 15,
  39. subtext: flag,
  40. },
  41. tooltip: {
  42. trigger: "axis",
  43. },
  44. // legend: {
  45. // data: ['头']
  46. // },
  47. color: ["#3aa0ff", "#4dcb73", "#fad337", "#f2637b", "#975fe4"],
  48. grid: {
  49. top: "20%",
  50. left: "10%",
  51. bottom: "10%",
  52. right: "10%",
  53. },
  54. xAxis: [
  55. {
  56. type: "category",
  57. // name: "月",
  58. data: this.data.month,
  59. axisPointer: {
  60. type: "shadow",
  61. },
  62. axisLine: {
  63. show: true,
  64. lineStyle: {
  65. color: "#6e7079",
  66. },
  67. },
  68. axisTick: {
  69. show: true,
  70. },
  71. },
  72. ],
  73. //[
  74. yAxis: {
  75. type: "value",
  76. name: "kg",
  77. // axisLabel: {
  78. // formatter: '{value} °C'
  79. // },
  80. axisLine: {
  81. show: true,
  82. lineStyle: {
  83. color: "#6e7079",
  84. },
  85. },
  86. axisTick: {
  87. show: false,
  88. },
  89. splitLine: {
  90. show: false,
  91. },
  92. },
  93. // {
  94. // type: 'value',
  95. // name: '湿度',
  96. // axisLabel: {
  97. // formatter: '{value} RH'
  98. // },
  99. // axisLine: {
  100. // show: false,
  101. // lineStyle: {
  102. // color: '#6e7079',
  103. // }
  104. // },
  105. // axisTick:{
  106. // show:false
  107. // },
  108. // // splitLine:{
  109. // // show:false
  110. // // }
  111. // }
  112. //],
  113. series: [
  114. {
  115. name: "重量",
  116. type: "line",
  117. smooth: false,
  118. data: this.data.elecList,
  119. itemStyle: {
  120. normal: {
  121. color: "#3aa0ff",
  122. lineStyle: {
  123. color: "#3aa0ff",
  124. },
  125. },
  126. },
  127. },
  128. // {
  129. // name: '湿度',
  130. // type: 'line',
  131. // smooth: false,
  132. // yAxisIndex: 1,
  133. // data: [20, 22, 33, 45, 63, 102, 23, 24, 23, 65, 50, 62]
  134. // }
  135. ],
  136. };
  137. this.myChart.setOption(options);
  138. },
  139. },
  140. mounted() {
  141. this.myChart = this.$echarts.init(
  142. document.getElementById("chartElecLines")
  143. );
  144. this.init();
  145. },
  146. watch: {
  147. data: {
  148. handler(newValue) {
  149. console.log(newValue);
  150. this.init();
  151. },
  152. deep: true,
  153. },
  154. },
  155. };
  156. </script>
  157. <style scoped>
  158. .chart-inventory-lines {
  159. /* display: inline-block; */
  160. width: 100%;
  161. height: 100%;
  162. }
  163. #chartElecLines {
  164. width: 100%;
  165. height: 100%;
  166. }
  167. </style>