12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <script>
- import apiDashboard from "@/api/dashboard/apiDashboard";
- export default {
- data() {
- return {
- dataIndexes: ['saving', 'amountSubsidy'],
- option: {
- color: ['#80D4FF', '#FFDF80'],
- tooltip: {
- trigger: 'item'
- },
- legend: {
- bottom: '8%',
- left: 'center',
- icon: 'circle'
- },
- series: [
- {
- name: '金额',
- type: 'pie',
- center: ['50%','40%'],
- data: [
- { 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);
- chart.setOption(this.option)
- },
- getData() {
- return apiDashboard.getPvProfitOverview(this.queryData).then(res=>{
- this.option.series[0].data[0].value = res.saving;
- this.option.series[0].data[1].value = res.amountSubsidy;
- this.chart.setOption(this.option);
- })
- }
- }
- }
- </script>
- <template>
- <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
- </template>
- <style lang="less" scoped>
- </style>
|