diff --git a/src/project/saas/AppDataStatistics/components/wechat.vue b/src/project/saas/AppDataStatistics/components/wechat.vue index 66421598..48a5c43c 100644 --- a/src/project/saas/AppDataStatistics/components/wechat.vue +++ b/src/project/saas/AppDataStatistics/components/wechat.vue @@ -78,10 +78,6 @@ export default { created() { this.getData() }, - mounted() { - this.getFriendsEcharts() - this.getGroupsEcharts() - }, methods: { getData() { // 居民好友 @@ -91,6 +87,7 @@ export default { this.friendsData = res.data.居民好友数 this.friendsMonth = this.friendsData.map(e=> e.month) this.friendsNumber = this.friendsData.map(e=> e.totalNumber) + this.getFriendsEcharts(this.friendsMonth,this.friendsNumber) } }) // 居民群 @@ -100,19 +97,20 @@ export default { this.groupsData = res.data.群成员数 this.groupsMonth = this.groupsData.map(e=> e.month) this.groupsNumber = this.groupsData.map(e=> e.totalNumber) + this.getGroupsEcharts(this.groupsMonth,this.groupsNumber) } }) }, - getFriendsEcharts() { + getFriendsEcharts(friendsMonth,friendsNumber) { let friendsDom = document.getElementById('friends'); - let myChart = echarts.init(friendsDom); + let myFriendsChart = echarts.init(friendsDom); let option = { tooltip: { trigger: "axis", }, xAxis: { type: 'category', - data: this.friendsMonth, + data: friendsMonth, axisTick: { show: false, } @@ -128,7 +126,7 @@ export default { }, series: [ { - data: this.friendsNumber, + data: friendsNumber, type: 'line', lineStyle: { color: '#3975C6', // 折线线条颜色 @@ -159,18 +157,18 @@ export default { } ] }; - option && myChart.setOption(option); + option && myFriendsChart.setOption(option); }, - getGroupsEcharts() { + getGroupsEcharts(groupsMonth,groupsNumber) { let groupsDom = document.getElementById('groups'); - let myChart = echarts.init(groupsDom); + let myGroupsChart = echarts.init(groupsDom); let option = { tooltip: { trigger: "axis", }, xAxis: { type: 'category', - data: this.groupsMonth, + data: groupsMonth, axisTick: { show: false, } @@ -186,7 +184,7 @@ export default { }, series: [ { - data: this.groupsNumber, + data: groupsNumber, type: 'line', lineStyle: { color: '#3975C6', // 折线线条颜色 @@ -217,7 +215,7 @@ export default { } ] }; - option && myChart.setOption(option); + option && myGroupsChart.setOption(option); } }, }