analysisChartBottomLeft3.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div>
  3. <div id="analysisChartBottomLeft3" @click="dialogVisible = true" style="width:3.4rem;height:2.2rem;"></div>
  4. <el-dialog title="一周 PH 趋势" :visible.sync="dialogVisible" width="1600px" @open="open" destroy-on-close append-to-body>
  5. <div id="analysisChartBottomLeft33" style="width:20rem;height:6rem;margin:0.5rem auto;"></div>
  6. </el-dialog>
  7. </div>
  8. </template>
  9. <script>
  10. import echartMixins from "@/utils/resizeMixins";
  11. export default {
  12. props: ['dashboarddata'],
  13. data() {
  14. return {
  15. chart: null,
  16. dialogVisible: false
  17. }
  18. },
  19. mixins: [echartMixins],
  20. mounted() {
  21. this.init();
  22. },
  23. methods: {
  24. opnenDialg(){
  25. this.dialogVisible = true
  26. },
  27. open(){
  28. this.$nextTick(() => {
  29. this.init2()
  30. })
  31. },
  32. init() {
  33. this.chart = this.echarts.init(document.getElementById("analysisChartBottomLeft3"), 'dark');
  34. const dateArray = [];
  35. const wasteArray = [];
  36. const rainArray = [];
  37. let data = this.dashboarddata.latest7DayData;
  38. for (let i = 0; i < data.length; i++) {
  39. dateArray[i]= data[i].pullDate.toString().substr(5, 5);
  40. wasteArray[i] = data[i].wastePh;
  41. rainArray[i] = data[i].rainPh;
  42. }
  43. dateArray.reverse();
  44. wasteArray.reverse();
  45. rainArray.reverse();
  46. let option = {
  47. backgroundColor: 'transparent',
  48. title: {
  49. text: '一周 PH 趋势',
  50. textStyle: {
  51. fontSize: 12
  52. }
  53. },
  54. tooltip: {
  55. trigger: 'axis'
  56. },
  57. legend: {
  58. data: ['Waste Water', 'Rain Water'],
  59. padding: [20, 0, 0, 0]
  60. },
  61. grid: {
  62. left: '3%',
  63. right: '4%',
  64. bottom: '3%',
  65. containLabel: true
  66. },
  67. toolbox: {
  68. feature: {
  69. }
  70. },
  71. xAxis: {
  72. type: 'category',
  73. boundaryGap: false,
  74. // data: [
  75. // this.c[0].pullDate.toString().substr(5, 5),
  76. // this.dashboarddata.latest7DayData[1].pullDate.toString().substr(5, 5),
  77. // this.dashboarddata.latest7DayData[2].pullDate.toString().substr(5, 5),
  78. // this.dashboarddata.latest7DayData[3].pullDate.toString().substr(5, 5),
  79. // this.dashboarddata.latest7DayData[4].pullDate.toString().substr(5, 5),
  80. // this.dashboarddata.latest7DayData[5].pullDate.toString().substr(5, 5),
  81. // this.dashboarddata.latest7DayData[6].pullDate.toString().substr(5, 5)
  82. // ],
  83. data: dateArray,
  84. axisLabel: {
  85. color: '#808080'
  86. },
  87. },
  88. yAxis: {
  89. type: 'value',
  90. axisLabel: {
  91. color: '#808080'
  92. },
  93. splitLine: {
  94. show: true,
  95. lineStyle:{
  96. color: 'rgba(255,255,255,.7)'
  97. }
  98. }
  99. },
  100. series: [
  101. {
  102. name: 'Waste Water',
  103. type: 'line',
  104. smooth: true,
  105. // data: [
  106. // this.dashboarddata.latest7DayData[0].wastePh,
  107. // this.dashboarddata.latest7DayData[1].wastePh,
  108. // this.dashboarddata.latest7DayData[2].wastePh,
  109. // this.dashboarddata.latest7DayData[3].wastePh,
  110. // this.dashboarddata.latest7DayData[4].wastePh,
  111. // this.dashboarddata.latest7DayData[5].wastePh,
  112. // this.dashboarddata.latest7DayData[6].wastePh
  113. // ],
  114. data: wasteArray,
  115. symbolSize: 10,
  116. color: '#5470c6',
  117. lineStyle: {
  118. width: 4,
  119. },
  120. itemStyle: {
  121. borderWidth: 3,
  122. borderColor: '#fff',
  123. }
  124. },
  125. {
  126. name: 'Rain Water',
  127. type: 'line',
  128. smooth: true,
  129. // data: [
  130. // this.dashboarddata.latest7DayData[0].rainPh,
  131. // this.dashboarddata.latest7DayData[1].rainPh,
  132. // this.dashboarddata.latest7DayData[2].rainPh,
  133. // this.dashboarddata.latest7DayData[3].rainPh,
  134. // this.dashboarddata.latest7DayData[4].rainPh,
  135. // this.dashboarddata.latest7DayData[5].rainPh,
  136. // this.dashboarddata.latest7DayData[6].rainPh
  137. // ],
  138. data: rainArray,
  139. symbolSize: 10,
  140. color: '#73c0de',
  141. lineStyle: {
  142. width: 4,
  143. },
  144. itemStyle: {
  145. borderWidth: 3,
  146. borderColor: '#fff',
  147. }
  148. },
  149. ]
  150. };
  151. this.chart.setOption(option);
  152. },
  153. init2() {
  154. this.chart2 = this.echarts.init(document.getElementById("analysisChartBottomLeft33"));
  155. const dateArray = [];
  156. const wasteArray = [];
  157. const rainArray = [];
  158. let data = this.dashboarddata.latest7DayData;
  159. for (let i = 0; i < data.length; i++) {
  160. dateArray[i]= data[i].pullDate.toString().substr(5, 5);
  161. wasteArray[i] = data[i].wastePh;
  162. rainArray[i] = data[i].rainPh;
  163. }
  164. dateArray.reverse();
  165. wasteArray.reverse();
  166. rainArray.reverse();
  167. let option = {
  168. backgroundColor: 'transparent',
  169. tooltip: {
  170. trigger: 'axis'
  171. },
  172. legend: {
  173. data: ['Waste Water', 'Rain Water'],
  174. padding: [30, 0, 0, 0]
  175. },
  176. grid: {
  177. left: '3%',
  178. right: '4%',
  179. bottom: '3%',
  180. containLabel: true
  181. },
  182. toolbox: {
  183. feature: {
  184. }
  185. },
  186. xAxis: {
  187. type: 'category',
  188. boundaryGap: false,
  189. // data: [
  190. // this.dashboarddata.latest7DayData[0].pullDate.toString().substr(5, 5),
  191. // this.dashboarddata.latest7DayData[1].pullDate.toString().substr(5, 5),
  192. // this.dashboarddata.latest7DayData[2].pullDate.toString().substr(5, 5),
  193. // this.dashboarddata.latest7DayData[3].pullDate.toString().substr(5, 5),
  194. // this.dashboarddata.latest7DayData[4].pullDate.toString().substr(5, 5),
  195. // this.dashboarddata.latest7DayData[5].pullDate.toString().substr(5, 5),
  196. // this.dashboarddata.latest7DayData[6].pullDate.toString().substr(5, 5)
  197. // ],
  198. data: dateArray,
  199. axisLabel: {
  200. color: '#808080'
  201. },
  202. },
  203. yAxis: {
  204. type: 'value',
  205. axisLabel: {
  206. color: '#808080'
  207. }
  208. },
  209. series: [
  210. {
  211. name: 'Waste Water',
  212. type: 'line',
  213. smooth: true,
  214. // data: [
  215. // this.dashboarddata.latest7DayData[0].wastePh,
  216. // this.dashboarddata.latest7DayData[1].wastePh,
  217. // this.dashboarddata.latest7DayData[2].wastePh,
  218. // this.dashboarddata.latest7DayData[3].wastePh,
  219. // this.dashboarddata.latest7DayData[4].wastePh,
  220. // this.dashboarddata.latest7DayData[5].wastePh,
  221. // this.dashboarddata.latest7DayData[6].wastePh
  222. // ],
  223. data: wasteArray,
  224. symbolSize: 10,
  225. color: '#5470c6',
  226. lineStyle: {
  227. width: 4,
  228. },
  229. itemStyle: {
  230. borderWidth: 3,
  231. borderColor: '#fff',
  232. }
  233. },
  234. {
  235. name: 'Rain Water',
  236. type: 'line',
  237. smooth: true,
  238. // data: [
  239. // this.dashboarddata.latest7DayData[0].rainPh,
  240. // this.dashboarddata.latest7DayData[1].rainPh,
  241. // this.dashboarddata.latest7DayData[2].rainPh,
  242. // this.dashboarddata.latest7DayData[3].rainPh,
  243. // this.dashboarddata.latest7DayData[4].rainPh,
  244. // this.dashboarddata.latest7DayData[5].rainPh,
  245. // this.dashboarddata.latest7DayData[6].rainPh
  246. // ],
  247. data: rainArray,
  248. symbolSize: 10,
  249. color: '#73c0de',
  250. lineStyle: {
  251. width: 4,
  252. },
  253. itemStyle: {
  254. borderWidth: 3,
  255. borderColor: '#fff',
  256. }
  257. },
  258. ]
  259. };
  260. this.chart2.setOption(option);
  261. }
  262. },
  263. destroyed() {
  264. window.onresize = null;
  265. }
  266. }
  267. </script>
  268. <style>
  269. </style>