import { environment } from '../../../../environments/environment';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { NzMessageService } from 'ng-zorro-antd';
|
import { _HttpClient } from '@delon/theme';
|
import { HttpClient } from '@angular/common/http';
|
import * as moment from 'moment';
|
import { DeviceService } from '@business/services/http/device.service';
|
import * as echarts from 'echarts';
|
|
@Component({
|
selector: 'statistics-analysis',
|
templateUrl: './analysis.component.html',
|
styleUrls: ['./analysis.component.less'],
|
providers: [DeviceService]
|
})
|
export class AnalysisComponent implements OnInit, OnDestroy {
|
|
offlineChartData1: any[] = [];
|
offlineChartData2: any[] = [];
|
|
constructor(
|
private deviceService: DeviceService,
|
private http: _HttpClient,
|
public msg: NzMessageService,
|
private http2: HttpClient) {
|
}
|
|
public option = {
|
title: {
|
text: '',
|
left: 'center'
|
},
|
tooltip: {
|
trigger: 'item',
|
axisPointer: {
|
type: 'cross'
|
}
|
},
|
legend: {
|
right: '10%',
|
top: '10%',
|
data: ['本月数据', '上月同期']
|
},
|
xAxis: {
|
type: 'category',
|
data: []
|
},
|
yAxis: {
|
type: 'value',
|
name: '单位:ug/m³'
|
},
|
series: [
|
{
|
data: [],
|
type: 'line',
|
smooth: true,
|
name: '本月数据'
|
}, {
|
data: [],
|
type: 'line',
|
smooth: true,
|
name: '上月同期'
|
}
|
]
|
};
|
|
ngOnInit() {
|
const offlineChartData = [[], [], [], []];
|
const params = {size: '24'};
|
this.http2.get(environment.SERVER_BASH_URL + 'demo/compare', {params: params}).subscribe((res: any) => {
|
res.forEach(data => {
|
offlineChartData[0].push(data.this_month_PM2_5);
|
offlineChartData[1].push(data.last_month_PM2_5);
|
offlineChartData[2].push(data.this_month_PM10);
|
offlineChartData[3].push(data.last_month_PM2_5);
|
this.option.xAxis.data.push(data.format_time);
|
});
|
|
const PM25 = echarts.init(document.getElementById('PM25'));
|
this.option.series[0].data = offlineChartData[0];
|
this.option.series[1].data = offlineChartData[1];
|
PM25.setOption(this.option, false);
|
window.onresize = PM25.resize;
|
|
const PM10 = echarts.init(document.getElementById('PM10'));
|
this.option.series[0].data = offlineChartData[2];
|
this.option.series[1].data = offlineChartData[3];
|
PM10.setOption(this.option, false);
|
window.onresize = PM10.resize;
|
});
|
}
|
|
ngOnDestroy(): void {
|
}
|
}
|