pvPowerProfitChart.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. },
  41. mounted() {
  42. this.$nextTick(()=>{
  43. this.initChart();
  44. this.getData();
  45. })
  46. },
  47. methods: {
  48. initChart() {
  49. let chart = this.$echarts.init(this.$refs.myChart)
  50. this.chart = chart;
  51. chart.setOption(this.option)
  52. },
  53. getData() {
  54. apiDashboard.getPvProfitOverview({}).then(res=>{
  55. this.option.series[0].data[0].value = res.saving;
  56. this.option.series[0].data[1].value = res.amountSubsidy;
  57. this.chart.setOption(this.option);
  58. })
  59. }
  60. }
  61. }
  62. </script>
  63. <template>
  64. <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
  65. </template>
  66. <style lang="less" scoped>
  67. </style>