diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 31cbecd0a..c987d3a8a 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -830,7 +830,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -1004,7 +1004,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 4777e87b4..f5a018892 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -737,7 +737,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -969,7 +969,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -1132,7 +1132,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -1803,7 +1803,6 @@ let copy=JSON.parse(JSON.stringify(data.data)); copy = copy.map(t=>parseFloat(t[1])) let sum = eval(copy.join('+')); - item['total'] = sum; } }) diff --git a/nezha-fronted/src/components/common/project/popData/lineChart.vue b/nezha-fronted/src/components/common/project/popData/lineChart.vue index 5c27d35f2..f86f9fd65 100644 --- a/nezha-fronted/src/components/common/project/popData/lineChart.vue +++ b/nezha-fronted/src/components/common/project/popData/lineChart.vue @@ -636,7 +636,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -894,7 +894,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; @@ -1051,7 +1051,7 @@ if(val===0){ val = Number(item.data[1]).toExponential(2); } - sum +=val; + sum += self.numberWithEConvent(val); str += `
`; str += `
${tip?(tip.alias?tip.alias:tip.name):item.seriesName}
`; str += `
`; diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js index 1045ccf5a..6170d34d8 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/main.js @@ -156,7 +156,33 @@ Vue.mixin({ vm.tools.showTopBtn = wrap.scrollTop > 50; vm.tools.tableHover = wrap.scrollTop > 50; }, 100)); - } + }, + numberWithEConvent(num) { + if (num) { + if ((("" + num).indexOf('E') != -1) || (("" + num).indexOf('e') != -1)) { + let regExp = new RegExp('^((\\d+.?\\d+)[Ee]{1}(\\d+))$', 'ig'); + let result = regExp.exec(num); + let resultValue = ""; + let power = ""; + if (result != null) { + resultValue = result[2]; + power = result[3]; + result = regExp.exec(num); + } + + if (resultValue != "") { + if (power != "") { + let powVer = Math.pow(10, power); + resultValue = resultValue * powVer; + return resultValue; + } + } + } else { + return num; + } + } + return 0; + }, }, computed: { getMenuList() {