本站开源地址httpsgithubcomcveoychatgpt-web赞助接口作者浏览器打开:httpsupload-bbsmiyoushecomupload202302282836840299b58bc87cf914ca57429efb22c0da351_746776194442819643jpg你当前使用的模型为gpt-35-turbo!template div class=title
可以在mounted方法中调用getuserstudy方法,获取leavetime的值,并将其赋值给pieOptionStudy中的data数组中的第二个对象的value属性,代码如下:
mounted() {
this.getuserstudy();
const pieChart1Dom = this.$refs.pieChart1;
const pieChart2Dom = this.$refs.pieChart2;
const pieChart1Instance = echarts.init(pieChart1Dom);
const pieChart2Instance = echarts.init(pieChart2Dom);
const pieOptionStudy = {
title: {
text: '学习时长',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a}
{b}: {c} ({d}%)'
},
legend: {
orient: 'vertical',
left: 10,
data: ['学习时长', '中途离开时长 ']
},
series: [
{
name: '任务完成情况',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '30',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{value: 1, name: '学习时长'},
{value: this.leavetime, name: '中途离开时长'}
]
}
]
};
const pieOptionTask = {
title: {
text: '任务完成情况',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a}
{b}: {c} ({d}%)'
},
legend: {
orient: 'vertical',
left: 10,
data: ['已完成', '未完成']
},
series: [
{
name: '任务完成情况',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '30',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{value: 16, name: '已完成'},
{value: 4, name: '未完成'}
]
}
]
};
pieChart1Instance.setOption(pieOptionStudy);
pieChart2Instance.setOption(pieOptionTask);
},
methods:{
getuserstudy(){
this.$net.get('/task/notfinish').then(resp => {
this.studytime=resp.data.data[0]
this.leavetime=resp.data.data[1]
this.finishtask=resp.data.data[2]
this.underfinishtask=resp.data.data[3]
// 将leavetime的值赋给pieOptionStudy中的data数组中的第二个对象的value属性
pieOptionStudy.series[0].data[1].value = this.leavetime;
});
}
}
原文地址: https://www.cveoy.top/t/topic/bdnS 著作权归作者所有。请勿转载和采集!