diff --git a/src/components/ECharts/index.vue b/src/components/ECharts/index.vue index 5546b64..6efbaaa 100644 --- a/src/components/ECharts/index.vue +++ b/src/components/ECharts/index.vue @@ -176,8 +176,11 @@ const generateOptions = computed(() => { let result = `${validParams[0].axisValue}<br/>` validParams.forEach(param => { - const unit = param.seriesName.includes('率') ? '%' : - param.seriesName.includes('量') ? '台' : '' + // 找到对应的系列配置 + const seriesConfig = config.series.find(s => s.name === param.seriesName) + // 从 labelFormatter 中提取单位,如果没有则根据名称判断 + const unit = seriesConfig?.labelFormatter?.includes('%') ? '%' : + seriesConfig?.labelFormatter?.includes('台') ? '台' : '' result += `${param.marker}${param.seriesName}: ${param.value}${unit}<br/>` }) diff --git a/src/views/activity/TestCenter.vue b/src/views/activity/TestCenter.vue index 4562b4d..c0d07da 100644 --- a/src/views/activity/TestCenter.vue +++ b/src/views/activity/TestCenter.vue @@ -364,7 +364,7 @@ const userGrowthConfig = { type: 'bar', color: '#67C23A', showLabel: true, - labelFormatter: '{c}' + labelFormatter: '{c}人' }, { name: '活跃用户',