12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <script>
- import apiDashboard from "@/api/dashboard/apiDashboard";
- export default {
- data() {
- return {
- dataIndexes: ["subsidy", "saving","earning"],
- option: {
- tooltip: {
- formatter:function(params){
- return params.seriesName + " : " + params.value + '元';
- }
- },
- legend: {
- bottom: "8%",
- left: "center",
- icon: "circle",
- },
- series: [
- {
- name: "金额",
- type: "pie",
- unit:"元",
- radius: "60",
- center: ["50%", "40%"],
- data: [
- { value: 0, name: "补贴金额" },
- { value: 0, name: "节约金额" },
- { value: 0, name: "并网收入" },
- ],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: "rgba(0, 0, 0, 0.5)",
- },
- },
- },
- ],
- },
- };
- },
- props: {
- height: Number,
- queryData: Object,
- },
- mounted() {
- this.$nextTick(() => {
- this.initChart();
- this.getData();
- });
- },
- methods: {
- initChart() {
- let chart = this.$echarts.init(this.$refs.myChart);
- this.chart = chart;
- this.$util.chartsResize(this.chart);
- this.option = this.$util.dataUtil.circleChartConfig(this.option)
- chart.setOption(this.option);
- },
- getData() {
- return apiDashboard.getPvProfitOverview(this.queryData).then((res) => {
- this.option.series[0].data = res.map((v) => {
- if (v.name === "subsidy") {
- return {
- value: v.value,
- name: "补贴金额",
- };
- } else if (v.name === "saving") {
- return {
- value: v.value,
- name: "节约金额",
- };
- } else if (v.name === "earning") {
- return {
- value: v.value,
- name: "并网收入",
- };
- }
- });
- this.option = this.$util.dataUtil.circleChartConfig(this.option)
- this.chart.setOption(this.option);
- });
- },
- },
- };
- </script>
- <template>
- <div
- style="width: 100%"
- :style="{ height: height + 'px' }"
- ref="myChart"
- ></div>
- </template>
- <style lang="less" scoped></style>
|