businessEnergyChart.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <script>
  2. import apiOperationAnalysis from "@/api/operation/apiOperationAnalysis";
  3. export default {
  4. data() {
  5. return {
  6. chart: null,
  7. option: {
  8. legend: {
  9. data: [
  10. '用电(kWh)',
  11. '用水(m³)',
  12. '用热(kWh)',
  13. '用冷(kWh)',
  14. '光伏(kWh)',
  15. ],
  16. selected: {
  17. '用电(kWh)': true,
  18. '用水(m³)': true,
  19. '用热(kWh)': false,
  20. '用冷(kWh)': false,
  21. '光伏(kWh)': true,
  22. }
  23. },
  24. grid: {
  25. left: '1%', //默认10%
  26. right: '1%', //默认10%
  27. bottom: '20px', //默认60
  28. top: '60px',
  29. containLabel: true
  30. //grid区域是否包含坐标轴的刻度标签
  31. },
  32. xAxis: {
  33. data: []
  34. },
  35. yAxis: [
  36. {
  37. type: 'value',
  38. nameTextStyle: {
  39. padding: [10, 0, 10, -30]
  40. },
  41. }
  42. ],
  43. dataZoom: this.$constant.ECHARTS_OPTION_DATAZOOM,
  44. tooltip: {
  45. trigger: 'axis',
  46. axisPointer: {
  47. type: 'shadow'
  48. },
  49. textStyle: {
  50. color: '#fff',
  51. align: 'left',
  52. fontSize: 14
  53. },
  54. axisLine: {//x坐标轴轴线
  55. show: true,
  56. lineStyle: {//x坐标轴轴线样式
  57. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  58. }
  59. },
  60. backgroundColor: 'rgba(0,0,0,0.8)',
  61. },
  62. series: [
  63. {
  64. name: '用电(kWh)',
  65. data: [],
  66. type: 'line',
  67. stack: 'a',
  68. yAxisIndex:0,
  69. smooth: true,
  70. showSymbol:false,
  71. lineStyle: {
  72. color: "#62CC97",
  73. width: 1,
  74. },
  75. itemStyle: {
  76. color: '#62CC97'
  77. },
  78. emphasis: {
  79. scale:1.5
  80. }
  81. },
  82. {
  83. name: '用水(m³)',
  84. data: [],
  85. type: 'line',
  86. stack: 'a',
  87. yAxisIndex:0,
  88. smooth: true,
  89. showSymbol:false,
  90. itemStyle: {
  91. color: '#3AA7E6'
  92. },
  93. lineStyle: {
  94. color: "#3AA7E6",
  95. width: 1,
  96. },
  97. emphasis: {
  98. scale:1.5
  99. },
  100. },
  101. {
  102. name: '用热(kWh)',
  103. data: [],
  104. type: 'line',
  105. stack: 'a',
  106. yAxisIndex:0,
  107. smooth: true,
  108. showSymbol:false,
  109. itemStyle: {
  110. color: '#4ACFB8'
  111. },
  112. lineStyle: {
  113. color: "#4ACFB8",
  114. width: 1,
  115. },
  116. emphasis: {
  117. scale:1.5
  118. },
  119. },
  120. {
  121. name: '用冷(kWh)',
  122. data: [],
  123. type: 'line',
  124. stack: 'a',
  125. yAxisIndex:0,
  126. smooth: true,
  127. showSymbol:false,
  128. itemStyle: {
  129. color: '#F4955F'
  130. },
  131. lineStyle: {
  132. color: "#F4955F",
  133. width: 1,
  134. },
  135. emphasis: {
  136. scale:1.5
  137. },
  138. },
  139. {
  140. name: '光伏(kWh)',
  141. data: [],
  142. type: 'line',
  143. stack: 'a',
  144. yAxisIndex:0,
  145. smooth: true,
  146. showSymbol:false,
  147. itemStyle: {
  148. color: '#F8797E'
  149. },
  150. lineStyle: {
  151. color: "#F8797E",
  152. width: 1,
  153. },
  154. emphasis: {
  155. scale:1.5
  156. },
  157. },
  158. ]
  159. },
  160. }
  161. },
  162. props: {
  163. height: Number,
  164. queryData: Object,
  165. },
  166. mounted() {
  167. this.$nextTick(()=>{
  168. this.init()
  169. })
  170. },
  171. methods: {
  172. init() {
  173. let chart = this.$echarts.init(this.$refs.myChart)
  174. this.chart = chart;
  175. this.$util.chartsResize(this.chart);
  176. chart.setOption(this.option)
  177. this.getData()
  178. },
  179. getData() {
  180. return apiOperationAnalysis.getEnergyTrendsTotal(this.queryData).then(res=>{
  181. let data = this.$util.dataUtil.covertDataToEcharts(res, ['power','water','hot','cold','cpv'])
  182. this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <template>
  189. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  190. </template>
  191. <style lang="less" scoped>
  192. </style>