fix(图表): 修复数值格式化遇到科学计数法时,数值无法完成格式化显示空的问题

This commit is contained in:
jianneng-fit2cloud
2026-06-04 10:33:15 +08:00
parent a753ccd934
commit 5330197a11

View File

@@ -110,6 +110,10 @@ function retain(value, n) {
if (!n) return Math.round(value)
const tran = Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
let tranV = tran.toString()
// 遇到科学计数法时用 toFixed(n) 转成普通小数字符串
if (/e/i.test(tranV)) {
tranV = tran.toFixed(n)
}
const newVal = tranV.indexOf('.')
if (newVal < 0) {
tranV += '.'