diff --git a/src/views/backOfficeSystem/fourColorManage/warningControl/centerHome/components/WarningCount.vue b/src/views/backOfficeSystem/fourColorManage/warningControl/centerHome/components/WarningCount.vue index 6872e01..e99efa5 100644 --- a/src/views/backOfficeSystem/fourColorManage/warningControl/centerHome/components/WarningCount.vue +++ b/src/views/backOfficeSystem/fourColorManage/warningControl/centerHome/components/WarningCount.vue @@ -97,7 +97,11 @@ const createChartOption = (data, colors) => { }, formatter: (name) => { const item = data.find(d => d.name === name); - let percentage = ((item.value / total) * 100).toFixed(2); + // 确保value是有效数字,total不为0 + const value = Number(item.value) || 0; + const totalValue = Number(total) || 0; + let percentage = (totalValue > 0 && value > 0) ? ((value / totalValue) * 100).toFixed(2) : '0.00'; + // let percentage = ((item.value / total) * 100).toFixed(2); return `${name} ${item.value} {${item.colorType}|(${percentage}%)}` }