From 029c1ef6d6dabccfab3043806d70c244a23784fe Mon Sep 17 00:00:00 2001 From: zhangyu Date: Fri, 1 Apr 2022 18:28:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E5=80=BC=E6=9C=89null=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/chartTimeSeries.vue | 4 ++-- .../src/components/common/js/tools.js | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 176f71254..fc97bc59a 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -132,8 +132,8 @@ export default { return Number(a[0]) - Number(b[0]) }) const valueSorted = datas.sort((a, b) => { - const a1 = isNaN(a[1]) ? 0 : Number(a[1]) - const b1 = isNaN(b[1]) ? 0 : Number(b[1]) + const a1 = isNaN(a[1]) && !a[1] ? 0 : Number(a[1]) + const b1 = isNaN(b[1]) && !b[1] ? 0 : Number(b[1]) return a1 - b1 }) minTime = timeSorted.length ? timeSorted[0][0] : '' diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 452e0ee94..dc16d239c 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -867,8 +867,8 @@ export function getMetricTypeValue (queryItem, type) { switch (type) { case 'min': { let min = copy.sort((x, y) => { - const x1 = isNaN(x[1]) ? 0 : x[1] - const y1 = isNaN(x[1]) ? 0 : y[1] + const x1 = isNaN(x[1]) && !x[1] ? 0 : x[1] + const y1 = isNaN(y[1]) && !y[1] ? 0 : y[1] return x1 - y1 })[0][1] if (isNaN(min)) { @@ -878,8 +878,8 @@ export function getMetricTypeValue (queryItem, type) { } case 'max': { let max = copy.sort((x, y) => { - const x1 = isNaN(x[1]) ? 0 : x[1] - const y1 = isNaN(x[1]) ? 0 : y[1] + const x1 = isNaN(x[1]) && !x[1] ? 0 : x[1] + const y1 = isNaN(y[1]) && !y[1] ? 0 : y[1] return y1 - x1 })[0][1] if (isNaN(max)) { @@ -889,7 +889,7 @@ export function getMetricTypeValue (queryItem, type) { } case 'avg': { copy = copy.map(t => { - const t1 = isNaN(t[1]) ? 0 : t[1] + const t1 = isNaN(t[1]) && !t[1] ? 0 : t[1] return parseFloat(t1) }) const sum = eval(copy.join('+')) @@ -906,7 +906,7 @@ export function getMetricTypeValue (queryItem, type) { } case 'total': { copy = copy.map(t => { - const t1 = isNaN(t[1]) ? 0 : t[1] + const t1 = isNaN(t[1]) && !t[1] ? 0 : t[1] return parseFloat(t1) }) const total = eval(copy.join('+')) @@ -914,16 +914,16 @@ export function getMetricTypeValue (queryItem, type) { } case 'range': { let min = copy.sort((x, y) => { - const x1 = isNaN(x[1]) ? 0 : x[1] - const y1 = isNaN(x[1]) ? 0 : y[1] + const x1 = isNaN(x[1]) && !x[1] ? 0 : x[1] + const y1 = isNaN(y[1]) && !y[1] ? 0 : y[1] return x1 - y1 })[0][1] if (isNaN(min)) { min = 0 } let max = copy.sort((x, y) => { - const x1 = isNaN(x[1]) ? 0 : x[1] - const y1 = isNaN(x[1]) ? 0 : y[1] + const x1 = isNaN(x[1]) && !x[1] ? 0 : x[1] + const y1 = isNaN(y[1]) && !y[1] ? 0 : y[1] return y1 - x1 })[0][1] if (isNaN(max)) {