xufenglei
2018-07-24 fd35962de838e033a8964e0959c99572f02b15f0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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';
 
@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) {
    }
 
    ngOnInit() {
        const offlineChartData1 = [];
        const offlineChartData2 = [];
        const params = {size: '24'};
        this.http2.get(environment.SERVER_BASH_URL + 'demo/compare', {params: params}).subscribe((res: any) => {
          res.forEach(data => {
            offlineChartData1.push({
              x: data.time,
              y1: data.this_month_PM2_5,
              y2: data.last_month_PM2_5
            });
            offlineChartData2.push({
              x: data.time,
              y1: data.this_month_PM10,
              y2: data.last_month_PM10
            });
          });
        });
//        for (let i = 0; i < 20; i += 1) {
//            offlineChartData1.push({
//                x: new Date().getTime() + 1000 * 60 * 30 * i,
//                y1: Math.floor(Math.random() * 100) + 10,
//                y2: Math.floor(Math.random() * 100) + 10
//            });
//            offlineChartData2.push({
//                x: new Date().getTime() + 1000 * 60 * 30 * i,
//                y1: Math.floor(Math.random() * 100) + 10,
//                y2: Math.floor(Math.random() * 100) + 10
//            });
//        }
        this.offlineChartData1 = offlineChartData1;
        this.offlineChartData2 = offlineChartData2;
    }
 
    ngOnDestroy(): void {
    }
}