BusinessPvChart.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="myChart" ref="myChart" :style="{height: height+'px'}">
  3. </div>
  4. </template>
  5. <script>
  6. import apiOperationAnalysis from "@/api/operation/apiOperationAnalysis";
  7. export default {
  8. data() {
  9. return {
  10. option: {
  11. color: ['#80D4FF','#A6A6FF','#79F2E8','#FFDF80','#FF7C1F'],
  12. legend: {
  13. data: [
  14. '发电量',
  15. '能耗比',
  16. ]
  17. },
  18. grid: {
  19. left: '2%', //默认10%
  20. right: '2%', //默认10%
  21. bottom: '15%', //默认60
  22. top: '15%',
  23. containLabel: true
  24. //grid区域是否包含坐标轴的刻度标签
  25. },
  26. xAxis: {
  27. type: 'category',
  28. data: []
  29. },
  30. yAxis: [
  31. {
  32. name: 'kwh',
  33. type: 'value',
  34. nameTextStyle: {
  35. padding: [10, 0, 10, -20]
  36. },
  37. },
  38. {
  39. name: '能耗比(%)',
  40. type: 'value',
  41. nameTextStyle: {
  42. padding: [10, 0, 10, -30]
  43. },
  44. },
  45. ],
  46. tooltip: {
  47. trigger: 'axis',
  48. axisPointer: {
  49. type: 'shadow'
  50. },
  51. textStyle: {
  52. color: '#fff',
  53. align: 'left',
  54. fontSize: 14
  55. },
  56. axisLine: {//x坐标轴轴线
  57. show: true,
  58. lineStyle: {//x坐标轴轴线样式
  59. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  60. }
  61. },
  62. backgroundColor: 'rgba(0,0,0,0.8)',
  63. },
  64. series: [
  65. {
  66. name: '发电量',
  67. data: [],
  68. type: 'bar',
  69. barWidth: '30%',
  70. itemStyle: {
  71. color: '#3AA7E6'
  72. },
  73. backgroundStyle: {
  74. color: 'rgba(180, 180, 180, 0.2)'
  75. }
  76. },
  77. {
  78. name: '能耗比',
  79. data: [],
  80. type: 'line',
  81. smooth:true,
  82. showSymbol:false,
  83. yAxisIndex: 1,
  84. backgroundStyle: {
  85. color: 'rgba(180, 180, 180, 0.2)'
  86. }
  87. },
  88. ]
  89. },
  90. }
  91. },
  92. props: {
  93. height: Number,
  94. queryData: Object
  95. },
  96. mounted() {
  97. this.init();
  98. },
  99. methods: {
  100. init() {
  101. let chart = this.$echarts.init(this.$refs.myChart)
  102. this.chart = chart;
  103. this.$util.chartsResize(this.chart);
  104. chart.setOption(this.option)
  105. this.getData()
  106. },
  107. getData() {
  108. return apiOperationAnalysis.getEnergyTrendsAnalyseCpv(this.queryData).then(res=>{
  109. let data = this.$util.dataUtil.covertDataToEcharts(res, ['outputPower','powerGeneration'])
  110. this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="less" scoped>
  117. </style>