+
${params.name}
+
+
+ 占比
+ ${params.value}%
+
+
+
+ TGI
+ ${params.data.tgi || '-'}
+
+
+ `;
+ },
+ },
series: [
{
type: 'pie',
avoidLabelOverlap: false,
data: genderValueData.value,
+ label: {
+ show: false, // 关闭扇区外的文字
+ },
labelLine: {
- show: false, // 不显示引导线
+ show: false,
},
radius: ['40%', '55%'],
},
],
};
- if (option && typeof option === 'object') {
- myChart.setOption(option);
- }
+ myChart.setOption(option);
};
const drawAgeChart = () => {
@@ -269,7 +289,7 @@ const drawAgeChart = () => {
const xAxis = ageValueData.value.map((item) => item.age);
const yAxis = ageValueData.value.map((item) => item.rate * 100);
const yAxis2 = ageValueData.value.map((item) => item.tgi);
- const average = yAxis2.reduce((sum, val) => sum + val, 0) / yAxis2.length;
+ // const average = yAxis2.reduce((sum, val) => sum + val, 0) / yAxis2.length;
// 图表初始化(强制使用2D渲染)
const myChart = echarts.init(dom, null, {
@@ -289,19 +309,47 @@ const drawAgeChart = () => {
animation: false, // 小尺寸下关闭动画提升性能
tooltip: {
trigger: 'axis',
- confine: true, // 确保tooltip不超出容器
+ confine: true,
axisPointer: {
type: 'shadow',
label: {
- fontSize: 12, // 调小提示标签字号
+ fontSize: 12,
backgroundColor: 'rgba(0,0,0,0.7)',
},
},
+ backgroundColor: '#fff',
+ borderColor: 'rgba(0,0,0,0.05)',
+ borderWidth: 1,
+ textStyle: {
+ color: '#333',
+ fontSize: 14,
+ },
+ extraCssText: 'box-shadow:0 2px 8px 0 rgba(0,0,0,0.08);border-radius:8px;',
+ formatter: function (params) {
+ const name = params[0].name;
+ const percent = params[0].value;
+ const tgi = params[1].value;
+ return `
+