diff --git a/nezha-fronted/src/components/chart/chartDataFormat.js b/nezha-fronted/src/components/chart/chartDataFormat.js index 5fa6e0fca..59a9c9aa4 100644 --- a/nezha-fronted/src/components/chart/chartDataFormat.js +++ b/nezha-fronted/src/components/chart/chartDataFormat.js @@ -10,6 +10,9 @@ function none (value, index) { if (!numberWithEConvent(scientificNotationValue)) { return scientificNotationValue } + if (isNaN(value) || value=== null) { + return value + } return keepDoubleNumber(value) } function short (value, index, type = 1, dot) { @@ -327,6 +330,9 @@ function numberWithEConvent (num) { return num } } + if (isNaN(num) || num === null) { + return num + } return 0 } /* @@ -337,6 +343,9 @@ function numberWithEConvent (num) { * dot:保留的小数位, * */ function asciiCompute (num, ascii, units, dot = 2) { + if (isNaN(num) || num === null) { + return num + } const scientificNotationValue = formatScientificNotation(num, dot) if (!numberWithEConvent(scientificNotationValue)) { return scientificNotationValue @@ -443,6 +452,9 @@ function timeCompute (value, unit, dot = 0) { } // 保留两位有效数字 function keepDoubleNumber (num) { + if (num === null) { + return num + } const decimal = num.toString() let returnNum = '' if (num == 0) {