// 环信码 export function getCreditCodeCount(data) { const { tag, countList } = data; const [first, second, third] = countList; const total = first + second + third; const p1 = Math.round((first / total) * 1000) / 10; const p2 = Math.round((second / total) * 1000) / 10; const p3 = Math.round((third / total) * 1000) / 10; if (total == 0) { return { period: tag, count: [], }; } else { return { period: tag, count: [ { name: '绿码', value: first, diff: total == 0 ? '0%' : `${p1}%`, color: '#13A34C', }, { name: '黄码', value: second, diff: total == 0 ? '0%' : `${p2}%`, color: '#FD9532', }, { name: '红码', value: third, diff: total == 0 ? '0%' : `${p3}%`, color: '#D10C0C', }, ], }; } }