| | |
| | | <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 |
| | | } |
| | |
| | | watch: { |
| | | fetchParams: { |
| | | handler() { |
| | | if(this.fetchParams.name != '' && this.fetchParams.name != null){ |
| | | if(this.fetchParams.siteName != '' && this.fetchParams.siteName != null){ |
| | | this.fetchDayAnalysisData() |
| | | } |
| | | }, |
| | |
| | | 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) { |
| | | // 构建折线图x,y数据 |
| | | let obj = lineChart.getLineChartXYData(cData, bt, et) |
| | | console.log('设置:',obj); |
| | | this.chart.chartDataAvg = { |
| | | x: obj.xData, |
| | | y: obj.yAvg |