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 dataPercentObj = {};
|
||||||
let percentCount = 0;
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let dataName = data[i].name;
|
let dataName = data[i].name;
|
||||||
let value = data[i].value;
|
let value = data[i].value;
|
||||||
let percent = 100 - percentCount;
|
dataPercentObj[dataName] = new Number(((value / total) * 100).toFixed(2));
|
||||||
if (i !== data.length - 1) {
|
|
||||||
percent = new Number(((value / total) * 100).toFixed(0));
|
|
||||||
percentCount += percent;
|
|
||||||
}
|
|
||||||
dataPercentObj[dataName] = percent;
|
|
||||||
}
|
}
|
||||||
this.options.legend.formatter = (name) => {
|
this.options.legend.formatter = (name) => {
|
||||||
let target = 0;
|
let target = 0;
|
||||||
|
@ -124,13 +118,26 @@ export default {
|
||||||
target = data[i].value;
|
target = data[i].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return name + " | " + target + " " + dataPercentObj[name] + "%";
|
|
||||||
|
return name + " | " + target + " " + this.formatNumber( dataPercentObj[name], 2) + "%";
|
||||||
};
|
};
|
||||||
|
|
||||||
this.options.series[0].label.formatter = (params) => {
|
this.options.series[0].label.formatter = (params) => {
|
||||||
return title + "\n" + count;
|
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>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue