BusinessPvMoneyChart.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. '政府补贴',
  11. '节约金额',
  12. ]
  13. },
  14. grid: {
  15. left: '1%', //默认10%
  16. right: '1%', //默认10%
  17. bottom: '30%', //默认60
  18. top: '20%',
  19. containLabel: true
  20. //grid区域是否包含坐标轴的刻度标签
  21. },
  22. xAxis: {
  23. data: []
  24. },
  25. yAxis: [
  26. {
  27. type: 'value',
  28. nameTextStyle: {
  29. padding: [20, 0, 10, 0]
  30. },
  31. },
  32. ],
  33. dataZoom: [
  34. {
  35. type: 'slider',
  36. start: 0,
  37. end: 100,
  38. height: 12,
  39. },
  40. {
  41. type: 'inside',
  42. start: 0,
  43. end: 100,
  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: 'line',
  69. stack: 'a',
  70. yAxisIndex:0,
  71. smooth: true,
  72. showSymbol:false,
  73. lineStyle: {
  74. color: "#62CC97",
  75. width: 1,
  76. },
  77. itemStyle: {
  78. color: '#62CC97'
  79. },
  80. emphasis: {
  81. scale:1.5
  82. }
  83. },
  84. {
  85. name: '节约金额',
  86. data: [],
  87. type: 'line',
  88. stack: 'a',
  89. smooth: true,
  90. showSymbol:false,
  91. itemStyle: {
  92. color: '#3AA7E6'
  93. },
  94. lineStyle: {
  95. color: "#3AA7E6",
  96. width: 1,
  97. },
  98. emphasis: {
  99. scale:1.5
  100. },
  101. },
  102. ]
  103. },
  104. }
  105. },
  106. props: {
  107. height: Number,
  108. queryData: Object,
  109. },
  110. mounted() {
  111. this.$nextTick(()=>{
  112. this.init()
  113. })
  114. },
  115. methods: {
  116. init() {
  117. let chart = this.$echarts.init(this.$refs.myChart)
  118. this.chart = chart;
  119. this.$util.chartsResize(this.chart);
  120. chart.setOption(this.option)
  121. this.getData()
  122. },
  123. getData() {
  124. return apiOperationAnalysis.getEnergyTrendsAnalyseCpvInfo(this.queryData).then(res=>{
  125. let data = this.$util.dataUtil.covertDataToEcharts(res, ['governmentSubsidies','save'])
  126. this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <template>
  133. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  134. </template>
  135. <style lang="less" scoped>
  136. </style>