From 1c9a3762ef11ab85e116d39a6543e6b864c24653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=A8?= <666> Date: Tue, 15 Oct 2024 16:34:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BD=9C=E4=B8=9A=E6=89=B9?= =?UTF-8?q?=E9=98=85=E6=9F=B1=E7=8A=B6=E5=9B=BE=E6=94=B9=E4=B8=BA=E7=99=BE?= =?UTF-8?q?=E5=88=86=E6=AF=94=E6=98=BE=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../container/classOverview/distribution/echarts.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/views/classTask/container/classOverview/distribution/echarts.vue b/src/renderer/src/views/classTask/container/classOverview/distribution/echarts.vue index d139c2f..4ba8db2 100644 --- a/src/renderer/src/views/classTask/container/classOverview/distribution/echarts.vue +++ b/src/renderer/src/views/classTask/container/classOverview/distribution/echarts.vue @@ -32,6 +32,8 @@ function getColor(index) { // 初始化图表 function initChart() { const myChart = echarts.init(chartRef.value); + const total = dataList.value.reduce((acc, cur) => acc + cur.value, 0); // 计算总数 + const options = { tooltip: { trigger: 'axis', @@ -70,7 +72,11 @@ function initChart() { label: { show: true, position: 'top', - formatter: '{c}人', + formatter: params => { + const value = dataList.value[params.dataIndex].value; + const percentage = ((value / total) * 100).toFixed(2); // 计算百分比并保留两位小数 + return `${percentage}%`; // 显示为百分比形式 + }, color: '#333', fontSize: 12 } -- 2.44.0.windows.1