Compare commits

..

2 Commits

Author SHA1 Message Date
A 5614ef750c try 2022-07-14 22:08:34 +08:00
A d349db0806 value全为0图表为灰色且显示“项目暂无进度”+图例显示 2022-07-14 21:53:08 +08:00
1 changed files with 107 additions and 38 deletions

View File

@ -56,7 +56,69 @@ export default {
getOption() {
//
let option = {
let isAllZero = this.dataList.every(item => {
// console.log(item,"item")
return item.value == 0
})
console.log(isAllZero, "isAllZero")
let option = null
if (isAllZero == true) {
for (let i = 0; i < this.dataList.length; i++) {
this.dataList[i].name = this.dataList[i].name + " 已完成工作项:" + this.dataList[i].value + "项"
}
console.log(this.dataList, "this.dataListgroup")
option = {
tooltip: {
trigger: 'item'
},
//
// graphic:{
// type:'text',
// left:'27%',
// top:'50%',
// style:{
// text:'',
// textAlign:'center',
// fill:'#000',
// }
// },
series: [
{
name: '统计',
type: 'pie',
center: ['35%', '55%'],
// radius: ['40%', '70%'],
avoidLabelOverlap: false,
label: {
show: true,
position: 'center',
formatter: '项目暂无进度'
},
emphasis: {
label: {
show: false,
fontSize: '40',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
itemStyle: {
normal: {
color: '#D3D3D3'
}
},
data: this.dataList
}
]
};
} else {
for (let i = 0; i < this.dataList.length; i++) {
this.dataList[i].name = this.dataList[i].name + "" + this.dataList[i].value + "人"
}
option = {
tooltip: {
trigger: 'item'
},
@ -64,8 +126,7 @@ export default {
{
name: '统计',
type: 'pie',
stillShowZeroSum: false,
center: ['45%', '55%'],
center: ['35%', '55%'],
// radius: ['40%', '70%'],
avoidLabelOverlap: false,
label: {
@ -84,13 +145,17 @@ export default {
},
data: this.dataList
}
]};
]
};
}
if (this.isLegend) {
option.legend = {
type: 'scroll',
orient: 'vertical',
// right: 10,
left: '80%',
left: '60%',
// right:'50%',
top: 20,
bottom: 20,
@ -102,13 +167,14 @@ export default {
//
initEcharts() {
this.$nextTick(() => {
this.myChart = echarts.init(document.getElementById(this.id));
// 使
this.myChart.setOption(this.getOption());
});
let that = this;
window.addEventListener('resize', function () {
console.log("addEventListener");
//console.log("addEventListener");
// resize
//that.$nextTick(()=>{
that.myChart.resize();
@ -118,6 +184,7 @@ export default {
//
updateEcharts() {
this.myChart.setOption(this.getOption(), true);
console.log(this.dataList, " this.dataList")
}
}
}
@ -128,9 +195,11 @@ export default {
width: 100%;
height: 100%;
display: flex;
.echarts_box {
flex-shrink: 0;
}
.list_box {
display: flex;
flex-direction: column;