From d1ccf7e1835b3c583da16d90a286e749d5e27c84 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期四, 07 十二月 2023 14:15:20 +0800 Subject: [PATCH] 修改无数据时段的算法 --- src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue b/src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue index fc5d996..a59fbd2 100644 --- a/src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue +++ b/src/views/risk_assessment/riskModel/components/CompDailyStatistic.vue @@ -1,16 +1,16 @@ <script> import exceptionApi from '@/api/exceptionApi.js' import lineChart from '@/utils/chartFunction/lineChart.js' -import index from '@/utils/risk_estimate_common_function/index.js' import time from '@/utils/time.js' +// import time from '@/utils/time.js' import FYLineChart from '@/components/chart/FYLineChart.vue' export default { props: { fetchParams: { type: Object, default: { - name: null, - number: null, + siteName: null, + mnCode: null, beginTime: null, endTime: null } @@ -34,7 +34,7 @@ watch: { fetchParams: { handler() { - if(this.fetchParams.name != '' && this.fetchParams.name != null){ + if(this.fetchParams.siteName != '' && this.fetchParams.siteName != null){ this.fetchDayAnalysisData() } }, @@ -46,40 +46,40 @@ methods: { // 鏍规嵁鐩墠绔欑偣锛屾湀浠斤紝鏌ユ姌绾垮浘鏃ョ粺璁℃暟鎹� fetchDayAnalysisData() { - exceptionApi - .analysisdata( - this.fetchParams.name, + exceptionApi.analysisdata( + this.fetchParams.siteName, this.fetchParams.beginTime, this.fetchParams.endTime, 'day' ) - .then((response) => { - const chartData = response.data.data - console.log('鏁版嵁涓�',chartData); - if (response.data.data.length == 0) { + .then(response => { + const chartData = response + if (chartData.length == 0) { return } - chartData.sort(time.compareByScore) - // 鍒嗘瀽鏁版嵁涓殑鏈�鏃╂椂闂� - let begin = chartData[0].lst - // 鍒嗘瀽鏁版嵁涓殑鏈�鏅氭椂闂� - let end = chartData[chartData.length - 1].lst + const timeArr = chartData.map(item => { + return item.lst + }) + // 鏃犳暟鎹殑鏃堕棿娈� - let noDataTimeInteval = lineChart.backNoDataInteval(begin, end) + let noDataTimeInterval = time.getMissingDays(this.fetchParams.beginTime, this.fetchParams.endTime,timeArr) // 鏃犳暟鎹厤缃椂闂存 - this.chart.areaColor = lineChart.getMarkArea(noDataTimeInteval) + this.chart.areaColor = lineChart.getMarkArea(noDataTimeInterval) this.setChart(chartData, this.fetchParams.beginTime, this.fetchParams.endTime) }) }, - // 閫夋嫨鍏朵粬鍊肩被鍨嬫椂 + /** + * 缁勪欢鎶樼嚎鍥剧殑閰嶇疆椤� + * @param锛� + * @returns锛� + */ setChart(cData, bt, et) { if (cData.length!=0) { // 鏋勫缓鎶樼嚎鍥緓,y鏁版嵁 let obj = lineChart.getLineChartXYData(cData, bt, et) - console.log('璁剧疆锛�',obj); this.chart.chartDataAvg = { x: obj.xData, y: obj.yAvg -- Gitblit v1.9.3