leftTop.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="cointan">
  3. <div class="title1">
  4. <div style="margin-left:25px;line-height: 22px;">近30日能耗管理</div>
  5. </div>
  6. <!-- 区域图 -->
  7. <div class="chart" ref="chart"></div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'leftTop',
  13. props: {
  14. msg: String
  15. },
  16. data() {
  17. return {
  18. }
  19. },
  20. mounted(){
  21. this.getEchartData()
  22. },
  23. methods:{
  24. // 用电用水
  25. getEchartData() {
  26. let _this = this;
  27. const chart = this.$refs.chart;
  28. var option = null;
  29. const myChart = this.$echarts.init(chart);
  30. option = {
  31. color: ['#00E0DB', '#43BAFF'],
  32. title: {
  33. text: ''
  34. },
  35. tooltip: {
  36. trigger: 'axis',
  37. axisPointer: {
  38. type: 'cross',
  39. label: {
  40. backgroundColor: '#0FEBFF'
  41. }
  42. }
  43. },
  44. legend: {
  45. type:'scroll',
  46. data: ['用电', '用水'],
  47. textStyle:{
  48. color:'#FFFFFF',
  49. fontSize:12,
  50. },
  51. // left: 460, //图例位置(可设置top,bottom,left,right)
  52. icon:'roundRect',//图形样式
  53. // itemHeight: 11, //修改icon图形大小
  54. // itemWidth:11,//图例图标的宽度
  55. },
  56. grid: {
  57. left: '1%',
  58. right: '8%',
  59. bottom: '2%',
  60. containLabel: true
  61. },
  62. xAxis: [
  63. {
  64. axisLabel: {
  65. show: true,
  66. height: 19,
  67. fontSize: 12,
  68. color: "#FFFFFF",//人数的颜色
  69. },
  70. axisLine: {
  71. show: true,
  72. lineStyle: {
  73. color: "#2E3F44",
  74. },
  75. },
  76. type: 'category',
  77. boundaryGap: false,
  78. data: ['02-01', '02-02', '02-03', '02-04', '02-05', '02-06', '02-07']
  79. }
  80. ],
  81. yAxis: [
  82. {
  83. alignTicks: true,
  84. name:'单位:kw/h',
  85. nameTextStyle: {
  86. color: "#00E0DB",
  87. },
  88. axisLabel: {
  89. show: true,
  90. height: 19,
  91. fontSize: 12,
  92. color: "#FFFFFF",
  93. },
  94. axisLine: {
  95. show: false,
  96. lineStyle: {
  97. color: "#FFFFFF",
  98. },
  99. },
  100. splitLine: {
  101. show: true,
  102. lineStyle: {
  103. type: [5, 10],
  104. dashOffset: 5,
  105. color:'#606060'
  106. }
  107. },
  108. type: 'value'
  109. },
  110. {
  111. name:'单位:t',
  112. nameTextStyle: {
  113. color: "#00E0DB",
  114. },
  115. axisLine: {
  116. show: false,
  117. },
  118. type: 'value',
  119. position: 'right',
  120. alignTicks: true,
  121. axisLabel: {
  122. show: true,
  123. height: 19,
  124. fontSize: 12,
  125. color: "#FFFFFF",
  126. },
  127. splitLine: {
  128. show: true,
  129. lineStyle: {
  130. type: [5, 10],
  131. dashOffset: 5,
  132. color:'#606060'
  133. }
  134. },
  135. }
  136. ],
  137. series: [
  138. {
  139. name: '用电',
  140. type: 'line',
  141. // stack: 'Total',
  142. smooth: true,
  143. yAxisIndex: 0,
  144. showSymbol: false,
  145. areaStyle: {
  146. opacity: 0.8,
  147. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
  148. {
  149. offset: 0,
  150. color: 'rgba(19, 255, 231, 1)'
  151. },
  152. {
  153. offset: 1,
  154. color: 'rgba(19, 255, 231, 0)'
  155. }
  156. ])
  157. },
  158. emphasis: {
  159. focus: 'series'
  160. },
  161. data: [30, 32, 71, 264, 90, 340, 250]
  162. },{
  163. name: '用水',
  164. type: 'line',
  165. // stack: 'Total',
  166. smooth: true,
  167. yAxisIndex: 1,
  168. showSymbol: false,
  169. areaStyle: {
  170. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
  171. {
  172. offset: 0,
  173. color: 'rgba(48, 97, 192, 1)'
  174. },
  175. {
  176. offset: 1,
  177. color: 'rgba(48, 97, 192, 0)'
  178. }
  179. ])
  180. },
  181. emphasis: {
  182. focus: 'series'
  183. },
  184. data: [120, 282, 111, 234, 220, 340, 310]
  185. },
  186. ]
  187. };
  188. myChart.setOption(option);
  189. myChart.off("click");
  190. myChart.on("click", function (params) {
  191. // console.log(params);
  192. _this.$emit("openPop");
  193. });
  194. window.addEventListener("resize", function () {
  195. myChart.resize();
  196. });
  197. this.$on("hook:destroyed", () => {
  198. window.removeEventListener("resize", function () {
  199. chart.resize();
  200. });
  201. });
  202. return option;
  203. },
  204. },
  205. }
  206. </script>
  207. <!-- Add "scoped" attribute to limit CSS to this component only -->
  208. <style scoped lang="scss">
  209. .cointan{
  210. width: 450px;
  211. height: 302px;
  212. background-image: url('../assets/index/litterbackground.png');
  213. background-size: 100%;
  214. }
  215. .title1{
  216. position: absolute;
  217. margin: 9px 0 0 10px;
  218. font-size: 20px;
  219. font-family : '优设标题黑';
  220. color: rgba(255, 255, 255, 1);
  221. font-weight: 400;
  222. }
  223. // 区域图
  224. .chart{
  225. position: absolute;
  226. margin: 60px 0 0 30px;
  227. width: 420px;
  228. height: 220px;
  229. }
  230. </style>