From a39e94330a3132c9f3163fc97f7dd14b76a3f1af Mon Sep 17 00:00:00 2001 From: ngfchl Date: Wed, 7 Dec 2022 19:05:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=9B=BE=E8=A1=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=88=E6=9E=9C=EF=BC=8C=E5=85=BC=E5=AE=B9=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 6 ++- templates/auto_pt/status.html | 71 ++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/auto_pt/views.py b/auto_pt/views.py index a5c1a51..82fbefe 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -676,8 +676,10 @@ def site_data_api(request): } for (index, info) in enumerate(info_list) if index < len(info_list) - 1] ''' diff_info_list = { - info['date']: info_list[index + 1]['uploaded'] - info['uploaded'] if index < len( - info_list) - 1 else 0 for (index, info) in enumerate(info_list) if index < len(info_list) - 1 + info['date']: info['uploaded'] - info_list[index - 1]['uploaded'] if + info['uploaded'] - info_list[index - 1]['uploaded'] > 0 else 0 for + (index, info) in enumerate(info_list) if 0 < index < len(info_list) + } print(f'处理完后站点数据条数:{len(info_list)}') for date in date_list: diff --git a/templates/auto_pt/status.html b/templates/auto_pt/status.html index 777d8bf..44d69ed 100644 --- a/templates/auto_pt/status.html +++ b/templates/auto_pt/status.html @@ -346,13 +346,32 @@ direction="btt" size="96%" append-to-body - :title="site.name + '--历史数据'" style="background-color: rgba(227, 229, 229, 0.6);"> - {#
#} - {#

-历史数据

#} - {#
#} -
- +

-历史数据

+ + +
+
+
+ + 7天 + 15天 + 30天 + 两个月 + 三个月 + 半年 + 一年 + 全部 + + + 图例 + +
+ + @@ -400,6 +419,8 @@ sortStep: 1, showData: [], showAllHistory: false, + incrementData: {}, + dataLength: -7, } }, beforeMount() { @@ -556,7 +577,8 @@ {#this.ptData = res.data.data#} {#this.setPie()#} {#this.setCard()#} - id == 0 ? this.showAllIncrementHistory(res.data.data) : this.setLine(res.data.data) + this.incrementData = res.data.data + id == 0 ? this.showAllIncrementHistory() : this.setLine() } else { this.$message({ type: 'warning', @@ -571,7 +593,26 @@ }); }) }, - showAllIncrementHistory(data) { + changeLength() { + + }, + showAllIncrementHistory($event) { + console.log($event) + if (typeof $event == "object") { + this.showLegend = !this.showLegend + } + {#console.log(this.incrementData)#} + let dateList = this.incrementData.date_list.slice(this.dataLength) + {#console.log(dateList)#} + let diff = [] + this.incrementData.diff.forEach((item, index) => { + let diff_item = {} + diff_item = JSON.parse(JSON.stringify(item)); + {#console.log(item)#} + diff_item.data = item.data.slice(this.dataLength) + {#console.log(diff_item)#} + diff.push(diff_item) + }) let option = { title: { text: '每日增量--全部站点', @@ -623,7 +664,7 @@ extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);', // 附加阴影样式 }, legend: { - show: true, + show: this.showLegend, {#top: '3%',#} left: 'center', bottom: '12', @@ -640,7 +681,8 @@ }, toolbox: { feature: { - saveAsImage: {} + saveAsImage: {}, + dataZoom: {}, } }, xAxis: { @@ -652,7 +694,7 @@ axisLine: { onZero: false }, - data: data.date_list + data: dateList }, yAxis: { type: 'value', @@ -663,13 +705,15 @@ }, }, - series: data.diff, + series: diff, }; this.site.name = '全部站点' this.showSiteChart = true this.showAllHistory = true + this.showLegend ? option.grid.bottom = '25%' : option.grid.bottom = '3%' setTimeout(() => { this.chart = this.$refs.history_charts.chart + this.chart.clear() this.setChartOption(this.chart, option) }, 15) }, @@ -1054,7 +1098,8 @@ this.chart = this.$refs.charts.chart this.setChartOption(this.chart, option) }, - setLine(siteData) { + setLine() { + let siteData = this.incrementData this.site = siteData.site let dataList = siteData.site_status_list let uploadedList = []