From eb7e64eb89c7d87fb84bc396cebc7264b14cbc16 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Mon, 19 Oct 2020 12:07:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Doverview=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=A1=8C=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=9B=BE=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/page/dashboard/overview/chart.vue | 6 +++--- .../src/components/page/dashboard/overview/overview2.vue | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index ab56b746b..e881ab054 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -96,13 +96,13 @@ if(!this.option){ this.option = chartConfig.getOption(this.chartType); } - if (legend && legendData) { + if (legend && legendData && legendData.length > 0) { legend.formatter = function(name) { let type = legendData.find(item => { return item[0] == name; }); - return `${name} (${type[1]}%)`; - } + return type ? `${name} (${type[1]}%)` : null; + }; this.$set(this.option, "legend", legend); } diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue index 7e9fb6980..15b58093d 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue @@ -359,13 +359,13 @@ let vm = this; let assetTotalCount = function() { let count = 0; - vm.assetData.typeStat.forEach(item => { + vm.assetData.typeStat && vm.assetData.typeStat.forEach(item => { count += item.total; }); return count; }(); - this.assetData.typeStat.forEach(item => { + vm.assetData.typeStat && this.assetData.typeStat.forEach(item => { legendData.push([item.name, (item.total*100/assetTotalCount).toFixed(2)]); typeSeriesData.push({name: item.name, value: item.total, up: item.pingUp, down: item.pingDown}); }); @@ -430,7 +430,7 @@ right: 25, icon: "circle", }; - this.$refs.assetTypePie.setSeries(series, legend, legendData); + this.assetData.typeStat && this.$refs.assetTypePie.setSeries(series, legend, legendData); this.$refs.assetTypePie.endLoading(); } resolve()