From 0a351689d792ee6027a051d9a7c007f7eaa08278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=81?= <18339727226@163.com> Date: Mon, 24 Jun 2024 14:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A6=E4=B8=8B=E8=A7=92=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chart/chart.vue | 6 +++--- src/components/chart/pieChart.vue | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/chart/chart.vue b/src/components/chart/chart.vue index 5b0bae4..95ab0ae 100644 --- a/src/components/chart/chart.vue +++ b/src/components/chart/chart.vue @@ -128,9 +128,9 @@ const init = (max: any, value: any) => { color: '#00214d', barGap: '-100%', }, - /* { + { type: 'bar', - data: [1], + data: [100], z: 0, silent: true, coordinateSystem: 'polar', @@ -138,7 +138,7 @@ const init = (max: any, value: any) => { roundCap: true, color: '#00214d', barGap: '-100%', - }, */ + }, ], } myChart.value.setOption(option); diff --git a/src/components/chart/pieChart.vue b/src/components/chart/pieChart.vue index 1ea164c..740cf9f 100644 --- a/src/components/chart/pieChart.vue +++ b/src/components/chart/pieChart.vue @@ -19,8 +19,8 @@ onMounted(() => { // resize(){ // this.myChart.resize(); // }, -const init=(max, value) =>{ - +const init = (max, value) => { + chartMax.value = max ? max : 100; chartValues.value = value ? value : 0; if (chartMax && chartValues) { @@ -29,7 +29,7 @@ const init=(max, value) =>{ if (chartRate.value === "100.0") { chartRate.value = "100"; // 如果百分比等于100,则更新为整数形式 } - + let option = { title: { text: (chartRate.value || '0.0') + '%', @@ -102,17 +102,6 @@ const init=(max, value) =>{ } ]) }, - /* { - type: 'bar', - data: [{ name: "新生总人数", value: chartMax.value }], - startAngle: 0, - z: 1, - coordinateSystem: 'polar', - barMaxWidth: 35, - roundCap: 1, - color: '#00214d', - barGap: '-100%', - }, */ { type: 'bar', data: [{ name: "新生总人数", value: chartMax.value }], @@ -124,11 +113,22 @@ const init=(max, value) =>{ color: '#00214d', barGap: '-100%', }, + { + type: 'bar', + data: [100], + z: 0, + silent: true, + coordinateSystem: 'polar', + barMaxWidth: 35, + roundCap: true, + color: '#00214d', + barGap: '-100%', + }, ], } option && myChart.value.setOption(option); } -defineExpose({init}) +defineExpose({ init }) \ No newline at end of file