mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
fix(测试跟踪): 测试计划报告,功能用例结果统计,统计结果为负数
--bug=1032979 --user=陈建星 【测试跟踪】测试计划-报告统计-功能用例统计分析-比例显示负数 https://www.tapd.cn/55049933/s/1437550
This commit is contained in:
parent
9273f459dd
commit
d69cd76d09
@ -106,16 +106,10 @@ export default {
|
||||
}
|
||||
|
||||
let dataPercentObj = {};
|
||||
let percentCount = 0;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let dataName = data[i].name;
|
||||
let value = data[i].value;
|
||||
let percent = 100 - percentCount;
|
||||
if (i !== data.length - 1) {
|
||||
percent = new Number(((value / total) * 100).toFixed(0));
|
||||
percentCount += percent;
|
||||
}
|
||||
dataPercentObj[dataName] = percent;
|
||||
dataPercentObj[dataName] = new Number(((value / total) * 100).toFixed(2));
|
||||
}
|
||||
this.options.legend.formatter = (name) => {
|
||||
let target = 0;
|
||||
@ -124,13 +118,26 @@ export default {
|
||||
target = data[i].value;
|
||||
}
|
||||
}
|
||||
return name + " | " + target + " " + dataPercentObj[name] + "%";
|
||||
|
||||
return name + " | " + target + " " + this.formatNumber( dataPercentObj[name], 2) + "%";
|
||||
};
|
||||
|
||||
this.options.series[0].label.formatter = (params) => {
|
||||
return title + "\n" + count;
|
||||
};
|
||||
},
|
||||
formatNumber(num, decimalPlaces) {
|
||||
let fixedNum = num.toFixed(decimalPlaces); // 先使用 toFixed 获取指定小数位数的字符串
|
||||
let parts = fixedNum.split("."); // 将整数部分和小数部分分开
|
||||
|
||||
// 如果小数部分存在,且小数部分的长度小于指定的小数位数,则补齐0
|
||||
if (parts.length > 1 && parts[1].length < decimalPlaces) {
|
||||
parts[1] = parts[1].padEnd(decimalPlaces, "0");
|
||||
}
|
||||
|
||||
// 将整数部分和小数部分重新拼接起来
|
||||
return parts.join(".");
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user