From 73bb751e28b58125d11427be113060b3d8a3d138 Mon Sep 17 00:00:00 2001 From: wangqing Date: Wed, 24 Mar 2021 19:02:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20dashboard.vue=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/dashboard.vue | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/views/home/dashboard.vue b/src/views/home/dashboard.vue index b2946e4..b27401a 100644 --- a/src/views/home/dashboard.vue +++ b/src/views/home/dashboard.vue @@ -340,26 +340,30 @@ export default { }, getProjectSubmitSource() { this.$api.get('/user/project/report/source', {params: {projectKey: this.activeProjectKey}}).then(res => { - this.barChartOptionData.yAxis.data = res.data.map(item => { - return item.browserName ? item.browserName : '其他' - }) - this.barChartOptionData.series = [ - { - barWidth: 30, - name: '数量', - type: 'bar', - data: res.data.map(item => { - return item.count - }) - } - ] + if (res.data && res.data.length) { + this.barChartOptionData.yAxis.data = res.data.map(item => { + return item.browserName ? item.browserName : '其他' + }) + this.barChartOptionData.series = [ + { + barWidth: 30, + name: '数量', + type: 'bar', + data: res.data.map(item => { + return item.count + }) + } + ] + } }) }, getProjectSubmitDevice() { this.$api.get('/user/project/report/device', {params: {projectKey: this.activeProjectKey}}).then(res => { - this.pieChartOptionData.series[0].data = res.data.map(item => { - return {value: item.count, name: item.osName ? item.osName : '其他'} - }) + if (res.data && res.data.length) { + this.pieChartOptionData.series[0].data = res.data.map(item => { + return {value: item.count, name: item.osName ? item.osName : '其他'} + }) + } }) } }