File was renamed from src/app/routes/analysis/query/query.component.ts |
| | |
| | | import { Component, OnInit, ViewChild } from '@angular/core'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria, PairData } from '@business/entity/data'; |
| | | import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data'; |
| | | import { TimeUnits, AreaRange, ResultCode } from '@business/enum/types.enum'; |
| | | import { SensorsService } from '@business/services/http/sensors.service'; |
| | | import { PageBean, ResultBean, Grid } from '@business/entity/grid'; |
| | |
| | | // 清空数据 |
| | | this.grid.data = []; |
| | | this.http.post(environment.SERVER_BASH_URL + '/report/line-chart', lineChartCriteria).subscribe( |
| | | (res: ResultBean<{[key: string]: Array<Array<PairData>>}>) => { |
| | | (res: ResultBean<{[key: string]: Array<Array<number>>}>) => { |
| | | if (res.code === 1) { |
| | | const data = res.data; |
| | | if (!!data) { |
| | |
| | | weight = !!weight ? weight : 101; |
| | | // this.gridSensors.push(sensor); |
| | | const sensorData = data[key][0].map( |
| | | pair => { |
| | | value => { |
| | | if (weight > 100) { |
| | | // pair.value 为null,权重后移 |
| | | weight = !!pair.value ? weight : weight + 1; |
| | | weight = !!value ? weight : weight + 1; |
| | | } |
| | | // 四舍五入,保留2位 |
| | | return !!pair.value ? String(Math.round(pair.value * 100) / 100) : '-'; |
| | | return !!value ? String(Math.round(value * 100) / 100) : '-'; |
| | | } |
| | | ); |
| | | this.grid.data.push({sensor: sensor, data: sensorData, weight: weight}); |
| | |
| | | } |
| | | // 报表标题暂存 防止联动 |
| | | public _chartTitleTemp = ''; |
| | | public _tableTitleTemp = ''; |
| | | public reloadChartTitle(): void { |
| | | const names = ['辖区', '地区', '时间', '项目']; |
| | | switch ( this.dataCondition.areaRange ) { |
| | |
| | | if ( this.grid.data.length > this.chartSelectedIndex) { |
| | | names[3] = this.grid.data[this.chartSelectedIndex].sensor.name; |
| | | } |
| | | const title = names.join(' ') + ' 报表'; |
| | | const title = names.join(' ') + ' 报表'; |
| | | if (title.trim() !== this._chartTitleTemp.trim()) { |
| | | this._chartTitleTemp = title; |
| | | } |
| | | const tableTile = names.slice(0, -1).join(' ') + ' 各项数据'; |
| | | if (tableTile.trim() !== this._tableTitleTemp.trim()) { |
| | | this._tableTitleTemp = tableTile; |
| | | } |
| | | } |
| | | public switchSensor(index: number): void { |
| | | this.chartSelectedIndex = index; |