evIndoorTemperature.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="p-echarts">
  3. <div class="pLegend">
  4. <i class="icon1"></i>按照策略执行
  5. <i class="icon2"></i>未按照策略执行
  6. <i class="icon3"></i>未按照策略执行,申诉通过
  7. <i class="icon4"></i>室内温度满足率
  8. <i class="icon5"></i>节能率
  9. </div>
  10. <div id="pCharts2" style="width: 100%;height: 100%;margin-top:20px;"></div>
  11. </div>
  12. </template>
  13. <script>
  14. var echarts = require("echarts");
  15. export default {
  16. data() {
  17. return {
  18. dataX: [],
  19. energyY: [],
  20. indoorY: [],
  21. strategy1: [],
  22. strategy2: [],
  23. strategy3: []
  24. };
  25. },
  26. props: ["energyDataList"],
  27. mounted() {
  28. this.$nextTick(function() {
  29. this.getDrawData();
  30. });
  31. },
  32. methods: {
  33. getDrawData() {
  34. this.dataX = [];
  35. this.energyY = [];
  36. this.indoorY = [];
  37. this.strategy1 = [];
  38. this.strategy2 = [];
  39. this.strategy3 = [];
  40. if (this.energyDataList) {
  41. this.energyDataList.forEach(el => {
  42. el.time = el.date.slice(4, 6) + "." + el.date.slice(6, 8);
  43. this.dataX.push(el.time);
  44. this.indoorY.push(
  45. el.tindoorFillRate ? el.tindoorFillRate.toFixed(2) : 0
  46. );
  47. this.energyY.push(
  48. el.energySavingRate ? el.energySavingRate.toFixed(2) : 0
  49. );
  50. if (el.chillerExecuteRateReal >= 75) {
  51. //绿色
  52. this.strategy1.push(2);
  53. this.strategy2.push(null);
  54. this.strategy3.push(null);
  55. } else if (el.chillerExecuteRate >= 75) {
  56. // 灰色
  57. this.strategy1.push(null);
  58. this.strategy2.push(null);
  59. this.strategy3.push(2);
  60. } else {
  61. this.strategy1.push(null);
  62. this.strategy2.push(2);
  63. this.strategy3.push(null);
  64. }
  65. // if (el.chillerExecuteRateReal < 75 && el.chillerExecuteRate >= 75) {
  66. // //红色
  67. // this.strategy2.push(2);
  68. // } else {
  69. // this.strategy2.push(null);
  70. // }
  71. // if (el.chillerExecuteRateReal < 75 || el.chillerExecuteRate < 75) {
  72. // //灰色
  73. // this.strategy3.push(2);
  74. // } else {
  75. // this.strategy3.push(null);
  76. // }
  77. });
  78. console.log(this.strategy3)
  79. this.drawIt();
  80. }
  81. },
  82. drawIt() {
  83. let myCharts = echarts.init(document.getElementById("pCharts2"));
  84. var colors = ["#34C724", "#8D9399", "#F54E45", "#00D6B9", "#0091FF"];
  85. var option = {
  86. color: colors,
  87. tooltip: {
  88. trigger: "axis",
  89. axisPointer: {
  90. type: "shadow"
  91. },
  92. formatter:function(params){
  93. return params[0].name +'<br/>'+params[0].seriesName+'<br/>'+'<i class="icon1"></i> 室内温度:'+ (params[1].value || 0) +'% <br/>'+'<i class="icon2"></i>节能率:' + (params[2].value || 0) + '%'
  94. }
  95. },
  96. grid: {
  97. right: "5%",
  98. left: "5%"
  99. },
  100. xAxis: [
  101. {
  102. type: "category",
  103. axisTick: {
  104. alignWithLabel: true
  105. },
  106. splitLine: {
  107. show: false
  108. },
  109. axisLine: {
  110. lineStyle: {
  111. color: "#8D9399"
  112. }
  113. },
  114. axisLabel: {
  115. interval: 0 //代表显示所有x轴标签显示
  116. },
  117. data: this.dataX
  118. }
  119. ],
  120. yAxis: [
  121. {
  122. type: "value",
  123. name: "节能率",
  124. axisLine: {
  125. lineStyle: {
  126. color: "#8D9399"
  127. }
  128. },
  129. splitLine: {
  130. show: false
  131. },
  132. min: 0,
  133. max: 100,
  134. position: "right",
  135. axisLabel: {
  136. formatter: "{value} %"
  137. }
  138. },
  139. {
  140. type: "value",
  141. show: false,
  142. name: "",
  143. min: 0,
  144. max: 1,
  145. position: "right",
  146. offset: 80,
  147. axisLine: {
  148. show: false
  149. },
  150. axisLabel: {
  151. formatter: function() {
  152. return "";
  153. }
  154. }
  155. },
  156. {
  157. type: "value",
  158. name: "室内温度满足率",
  159. axisLine: {
  160. lineStyle: {
  161. color: "#8D9399"
  162. }
  163. },
  164. splitLine: {
  165. show: false
  166. },
  167. position: "left",
  168. axisLabel: {
  169. formatter: "{value} %"
  170. }
  171. }
  172. ],
  173. series: [
  174. {
  175. name: "按照策略执行",
  176. type: "bar",
  177. barWidth: 38,
  178. data: this.strategy1
  179. },
  180. {
  181. name: "未按照策略执行",
  182. type: "bar",
  183. barWidth: 38,
  184. data: this.strategy2
  185. },
  186. {
  187. name: "未按照策略执行,申诉通过",
  188. type: "bar",
  189. barWidth: 38,
  190. data: this.strategy3
  191. },
  192. {
  193. name: "室内温度满足率",
  194. type: "line",
  195. yAxisIndex: 2,
  196. data: this.indoorY
  197. },
  198. {
  199. name: "节能率",
  200. type: "line",
  201. yAxisIndex: 2,
  202. data: this.energyY
  203. }
  204. ]
  205. };
  206. myCharts.setOption(option);
  207. myCharts.on("click", param => {
  208. this.$router.push("/evaluate/evTwoLevelMenu");
  209. if (param.seriesName == "室内温度满足率") {
  210. this.$router.push({
  211. path: "/evaluate/evTwoLevelMenu",
  212. query: { type: 1, name: param.name }
  213. });
  214. } else if (param.seriesName == "节能率") {
  215. this.$router.push({
  216. path: "/evaluate/evTwoLevelMenu",
  217. query: { type: 2, name: param.name }
  218. });
  219. } else {
  220. this.$router.push({
  221. path: "/evaluate/evTwoLevelMenu",
  222. query: { type: 3, name: param.name }
  223. });
  224. }
  225. });
  226. }
  227. },
  228. watch: {
  229. energyDataList: {
  230. immediate: true,
  231. handler(val, old) {
  232. if (old) {
  233. this.getDrawData();
  234. }
  235. }
  236. }
  237. }
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .p-echarts {
  242. width: 100%;
  243. height: 100%;
  244. #pCharts2 {
  245. width: 100%;
  246. height: 100%;
  247. }
  248. .pLegend {
  249. font-size: 12px;
  250. color: #000000;
  251. text-align: center;
  252. margin-top: 20px;
  253. }
  254. .icon1 {
  255. display: inline-block;
  256. width: 12px;
  257. height: 12px;
  258. background: rgba(52, 199, 36, 1);
  259. vertical-align: middle;
  260. margin-right: 3px;
  261. }
  262. .icon2 {
  263. display: inline-block;
  264. width: 12px;
  265. height: 12px;
  266. background: #f54e45;
  267. vertical-align: middle;
  268. margin-right: 3px;
  269. margin-left: 20px;
  270. }
  271. .icon3 {
  272. display: inline-block;
  273. width: 12px;
  274. height: 12px;
  275. background: #8d9399;
  276. vertical-align: middle;
  277. margin-right: 3px;
  278. margin-left: 20px;
  279. }
  280. .icon4 {
  281. display: inline-block;
  282. height: 6px;
  283. width: 16px;
  284. background: #00d6b9;
  285. border-radius: 3px;
  286. vertical-align: middle;
  287. margin-right: 3px;
  288. margin-left: 20px;
  289. }
  290. .icon5 {
  291. display: inline-block;
  292. height: 6px;
  293. width: 16px;
  294. background: rgba(0, 145, 255, 1);
  295. border-radius: 3px;
  296. vertical-align: middle;
  297. margin-right: 3px;
  298. margin-left: 20px;
  299. }
  300. }
  301. </style>