pvPowerProfitChart.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script>
  2. import apiDashboard from "@/api/dashboard/apiDashboard";
  3. export default {
  4. data() {
  5. return {
  6. dataIndexes: ["subsidy", "saving","earning"],
  7. option: {
  8. tooltip: {
  9. formatter:function(params){
  10. return params.seriesName + " : " + params.value + '元';
  11. }
  12. },
  13. legend: {
  14. bottom: "8%",
  15. left: "center",
  16. icon: "circle",
  17. },
  18. series: [
  19. {
  20. name: "金额",
  21. type: "pie",
  22. unit:"元",
  23. radius: "60",
  24. center: ["50%", "40%"],
  25. data: [
  26. { value: 0, name: "补贴金额" },
  27. { value: 0, name: "节约金额" },
  28. { value: 0, name: "并网收入" },
  29. ],
  30. emphasis: {
  31. itemStyle: {
  32. shadowBlur: 10,
  33. shadowOffsetX: 0,
  34. shadowColor: "rgba(0, 0, 0, 0.5)",
  35. },
  36. },
  37. },
  38. ],
  39. },
  40. };
  41. },
  42. props: {
  43. height: Number,
  44. queryData: Object,
  45. },
  46. mounted() {
  47. this.$nextTick(() => {
  48. this.initChart();
  49. this.getData();
  50. });
  51. },
  52. methods: {
  53. initChart() {
  54. let chart = this.$echarts.init(this.$refs.myChart);
  55. this.chart = chart;
  56. this.$util.chartsResize(this.chart);
  57. this.option = this.$util.dataUtil.circleChartConfig(this.option)
  58. chart.setOption(this.option);
  59. },
  60. getData() {
  61. return apiDashboard.getPvProfitOverview(this.queryData).then((res) => {
  62. this.option.series[0].data = res.map((v) => {
  63. if (v.name === "subsidy") {
  64. return {
  65. value: v.value,
  66. name: "补贴金额",
  67. };
  68. } else if (v.name === "saving") {
  69. return {
  70. value: v.value,
  71. name: "节约金额",
  72. };
  73. } else if (v.name === "earning") {
  74. return {
  75. value: v.value,
  76. name: "并网收入",
  77. };
  78. }
  79. });
  80. this.option = this.$util.dataUtil.circleChartConfig(this.option)
  81. this.chart.setOption(this.option);
  82. });
  83. },
  84. },
  85. };
  86. </script>
  87. <template>
  88. <div
  89. style="width: 100%"
  90. :style="{ height: height + 'px' }"
  91. ref="myChart"
  92. ></div>
  93. </template>
  94. <style lang="less" scoped></style>