From 3d49dbbd9a5e15d14fc0a4388b17c19c0ac2e5f7 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 13 Jul 2018 11:06:06 +0800
Subject: [PATCH] Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_demo2
---
src/app/routes/home-page/home-page/home-page.component.ts | 94 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 84 insertions(+), 10 deletions(-)
diff --git a/src/app/routes/home-page/home-page/home-page.component.ts b/src/app/routes/home-page/home-page/home-page.component.ts
index d52b29f..0bb0017 100644
--- a/src/app/routes/home-page/home-page/home-page.component.ts
+++ b/src/app/routes/home-page/home-page/home-page.component.ts
@@ -8,24 +8,98 @@
styleUrls: ["./home-page.component.less"]
})
export class HomePageComponent implements OnInit {
- public cardData: {'api'?:number,'temperature'?:number,'windDirection'?: string,'pm2.5'?: number}
- = {};
+ public cardData: {'api'?:number,'temperature'?:number,'windDirection'?: string,'pm25'?: number} = {};
+
constructor(
private http:_HttpClient,
) {
}
-
+ salesData: any[] = [ ];
ngOnInit() {
zip(
- this.http.get('http://sapi.7drlb.com/api/mj?cityID=1102&apiKey=condition'),
- this.http.get('http://sapi.7drlb.com/api/mj?cityID=1102&apiKey=aqi')
+ this.http.get<any>('http://sapi.7drlb.com/api/mj?cityID=1102&apiKey=condition'),
+ this.http.get<any>('http://sapi.7drlb.com/api/mj?cityID=1102&apiKey=aqi')
).subscribe(
- ([conRes,aqiRes]) => {
- debugger;
- console.log(conRes);
- console.log(aqiRes);
+ ([conRes,aqiRes]) => {
+ if( conRes.code == 0 && aqiRes.code == 0 ) {
+ this.cardData.windDirection = conRes.data.condition.windDir;
+ this.cardData.temperature = conRes.data.condition.temp;
+ this.cardData.api = aqiRes.data.aqi.value;
+ this.cardData.pm25 = aqiRes.data.aqi.pm25;
+ }
}
- )
+ );
+ this.http.get('/chart').subscribe((res: any) => {
+ // this.webSite = res.visitData.slice(0, 10);
+ this.salesData = res.salesData;
+ // this.offlineChartData = res.offlineChartData;
+ });
+ }
+ public aqiChartOption
+ public aqiEchartsIntance;
+ public aqiChartLoading = false;
+ public onApiChartInit(e): void {
+ this.aqiEchartsIntance = e;
+ }
+ private reloadChart(): void {
+ // const timeList = this.grid.columns.map(item => item.text);
+ if (!!this.aqiEchartsIntance) {
+ this.aqiChartOption = null;
+ this.aqiEchartsIntance.clear();
+ }
+ // let series = null;
+ // if ( this.chartSelectedIndex < this.grid.data.length ) {
+ // series = [{type: 'line', data: this.grid.data[this.chartSelectedIndex]}];
+ // }
+
+ // this.initOpton(chartOption ,{ xAxis : [{data : []}]});
+ // this.aqiChartOption = true;
+ this.initOpton(this.aqiChartOption ,{ xAxis : [{data : []}]});
+ }
+ private initOpton(chartOption,opt: {[key: string]: object}) {
+ const defaultOption = {
+ title: {
+ left: 'center'
+ },
+ tooltip : {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'cross',
+ label: {
+ backgroundColor: '#6a7985'
+ }
+ }
+ },
+ legend: {
+ data: []
+ },
+ toolbox: {
+ feature: {
+ saveAsImage: {}
+ }
+ },
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true
+ },
+ xAxis : [
+ {
+ type : 'category',
+ boundaryGap : false
+ }
+ ],
+ yAxis : [
+ {
+ type : 'value'
+ }
+ ],
+ series : [
+ ]
+ };
+ $.extend(true, defaultOption, opt);
+ chartOption = defaultOption;
}
}
--
Gitblit v1.8.0