pvPowerProfitChart.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script>
  2. import apiDashboard from "@/api/dashboard/apiDashboard";
  3. export default {
  4. data() {
  5. return {
  6. dataIndexes: ['saving', 'amountSubsidy'],
  7. option: {
  8. color: ['#80D4FF', '#FFDF80'],
  9. tooltip: {
  10. trigger: 'item'
  11. },
  12. legend: {
  13. bottom: '8%',
  14. left: 'center',
  15. icon: 'circle'
  16. },
  17. series: [
  18. {
  19. name: '金额',
  20. type: 'pie',
  21. center: ['50%','40%'],
  22. data: [
  23. { value: 0, name: '补贴金额' },
  24. { value: 0, name: '节约金额' },
  25. ],
  26. emphasis: {
  27. itemStyle: {
  28. shadowBlur: 10,
  29. shadowOffsetX: 0,
  30. shadowColor: 'rgba(0, 0, 0, 0.5)'
  31. }
  32. }
  33. }
  34. ]
  35. }
  36. }
  37. },
  38. props: {
  39. height: Number,
  40. queryData: Object
  41. },
  42. mounted() {
  43. this.$nextTick(()=>{
  44. this.initChart();
  45. this.getData();
  46. })
  47. },
  48. methods: {
  49. initChart() {
  50. let chart = this.$echarts.init(this.$refs.myChart)
  51. this.chart = chart;
  52. this.$util.chartsResize(this.chart);
  53. chart.setOption(this.option)
  54. },
  55. getData() {
  56. return apiDashboard.getPvProfitOverview(this.queryData).then(res=>{
  57. this.option.series[0].data[0].value = res.saving;
  58. this.option.series[0].data[1].value = res.amountSubsidy;
  59. this.chart.setOption(this.option);
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <template>
  66. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  67. </template>
  68. <style lang="less" scoped>
  69. </style>