fix:作业批阅柱状图改为百分比显示; #321

Merged
yangws merged 1 commits from yangws into main 2024-10-15 16:36:23 +08:00
1 changed files with 7 additions and 1 deletions

View File

@ -32,6 +32,8 @@ function getColor(index) {
// //
function initChart() { function initChart() {
const myChart = echarts.init(chartRef.value); const myChart = echarts.init(chartRef.value);
const total = dataList.value.reduce((acc, cur) => acc + cur.value, 0); //
const options = { const options = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -70,7 +72,11 @@ function initChart() {
label: { label: {
show: true, show: true,
position: 'top', position: 'top',
formatter: '{c}人', formatter: params => {
const value = dataList.value[params.dataIndex].value;
const percentage = ((value / total) * 100).toFixed(2); //
return `${percentage}%`; //
},
color: '#333', color: '#333',
fontSize: 12 fontSize: 12
} }