Compare commits
No commits in common. "1a447b30fb3bb0579ab1313bbd85b840384641f9" and "ea88aa959d25440ae43ce01f87e3fd3c170880c9" have entirely different histories.
1a447b30fb
...
ea88aa959d
|
@ -32,8 +32,6 @@ 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',
|
||||||
|
@ -72,11 +70,7 @@ function initChart() {
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: 'top',
|
position: 'top',
|
||||||
formatter: params => {
|
formatter: '{c}人',
|
||||||
const value = dataList.value[params.dataIndex].value;
|
|
||||||
const percentage = ((value / total) * 100).toFixed(2); // 计算百分比并保留两位小数
|
|
||||||
return `${percentage}%`; // 显示为百分比形式
|
|
||||||
},
|
|
||||||
color: '#333',
|
color: '#333',
|
||||||
fontSize: 12
|
fontSize: 12
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue