1a0b2b79 by xiaomiao

饼图调整

1 parent d85cf35a
......@@ -19,8 +19,8 @@
},
props: {
cdata: {
type: Object,
default: () => ({}),
type: Array,
default: () => ([]),
},
},
watch: {
......@@ -47,6 +47,7 @@
{
name: "Access From",
type: "pie",
radius: '60%',
avoidLabelOverlap: true,
label: {
formatter: (params) => {
......@@ -54,10 +55,17 @@
},
position: "outer",
alignTo: "edge",
margin: 5
margin: 10,
normal: {
show: true,
textStyle: {
fontSize: 12
}
},
},
data: newData.seriesData,
data: newData,
}
],
};
......
......@@ -10,9 +10,7 @@
export default {
data () {
return {
cdata: {
seriesData: [],
},
cdata: [],
getdata: [],
};
},
......@@ -22,44 +20,44 @@
mounted () {
this.addhousetotal();
window.addEventListener("resize", () => {
this.getdata = [];
this.cdata = [];
this.addhousetotal();
});
},
methods: {
async addhousetotal () {
if (this.getdata.length == 0) {
if (this.cdata == 0) {
this.getdata = [];
try {
let { result: res } = await work.addhousetotal();
res.map((item) => {
return this.cdata.seriesData.push({
return this.cdata.push({
name: `${item.fwyt + '(' + item.fwxz})`,
value: item.mj,
});
});
let delarr = this.cdata.sort(this.up)
this.setadat(delarr)
} catch (error) {
console.log("error", error);
}
}
let delarr = this.cdata.seriesData.sort(this.up)
this.setadat(delarr)
},
// 处理数据方法
setadat (delarr) {
this.cdata.seriesData = delarr.splice(0, 6);
this.cdata = delarr.splice(0, 6);
let sum = 0
for (var i = 0; i < delarr.length; i++) {
sum = sum + delarr[i].value
}
sum = sum.toFixed(2)
this.cdata.seriesData.push({
this.cdata.push({
name: "其他(其他种类)",
values: "其他种类",
value: sum,
......