From 471bedfcc8adf55098b67c40c3a467753c11857f Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Mon, 23 Jul 2018 16:57:31 +0800
Subject: [PATCH] 环比 效果图
---
src/app/routes/home-page/home-page/home-page.component.ts | 87 ++++++++++++++++++++++++++++++-------------
1 files changed, 61 insertions(+), 26 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 5333df9..0535670 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
@@ -29,34 +29,39 @@
this.cardData.temperature = conRes.data.condition.temp;
this.cardData.api = aqiRes.data.aqi.value;
this.cardData.pm25 = aqiRes.data.aqi.pm25;
+ this.http.get('/aqi/forecast24hours',{base: this.cardData.pm25,range: 10}).subscribe(
+ (res: any) => {
+ this.aqiEchartsIntance.setOption(
+ {
+ series: [{type: 'line', data: res}]
+ }
+ )
+ }
+ );
+ this.http.get('/aqi/forecast24hours',{base: this.cardData.temperature,range: 5}).subscribe(
+ (res: any) => {
+ this.meteEchartsIntance.setOption(
+ {
+ series: [{type: 'line', data: res}]
+ }
+ )
+ }
+ );
}
}
);
this.http.get('/chart').subscribe((res: any) => {
- // this.webSite = res.visitData.slice(0, 10);
- this.salesData = res.salesData;
- // this.offlineChartData = res.offlineChartData;
- });
- this.http.get('/aqi/forecast24hours',{base: 25,range: 10}).subscribe(
- (res: any) => {
- this.aqiEchartsIntance.setOption(
- {
- series: [{type: 'line', data: res}]
- }
- )
- }
- );
- this.http.get('/aqi/forecast24hours',{base: 30,range: 8}).subscribe(
- (res: any) => {
- this.meteEchartsIntance.setOption(
- {
- series: [{type: 'line', data: res}]
- }
- )
- }
- );
+ res.offlineData.forEach((item: any) => {
+ item.chart = Object.assign([], res.offlineChartData);
+ });
+ this.data = res;
+ this.salesData = res.salesData;
+ this.loading = false;
+ this.changeSaleType();
+ });
+
}
-
+
public aqiChartOption = {};
public aqiEchartsIntance;
public aqiChartLoading = false;
@@ -66,11 +71,11 @@
public meteChartOption = {};
public meteEchartsIntance;
public meteChartLoading = false;
- private onMeteChartInit(e): void {
+ public onMeteChartInit(e): void {
this.meteEchartsIntance = e;
}
private reloadAqiChart(): void {
- // const timeList = this.grid.columns.map(item => item.text);
+ // const timeList = this.grid.columns.map(item => item.text);
if (!!this.aqiEchartsIntance) {
this.aqiChartOption = null;
this.aqiEchartsIntance.clear();
@@ -79,7 +84,7 @@
// 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 : this.newArray(0, 24, null, '���')}]});
@@ -147,4 +152,34 @@
Object.assign( defaultOption, opt);
Object.assign(chartOption, defaultOption);
}
+ //---------mock-------------------
+ data: any = {
+ salesData: [],
+ offlineData: []
+ };
+ sort(sortName, sortValue) {
+ this.data.searchData = [
+ ...(<any[]>this.data.searchData).sort((a, b) => {
+ if (a[ sortName ] > b[ sortName ]) {
+ return (sortValue === 'ascend') ? 1 : -1;
+ } else if (a[ sortName ] < b[ sortName ]) {
+ return (sortValue === 'ascend') ? -1 : 1;
+ } else {
+ return 0;
+ }
+ })
+ ];
+ }
+ loading = true;
+ salesType = 'all';
+ salesPieData: any;
+ salesTotal = 0;
+ changeSaleType() {
+ this.salesPieData = this.salesType === 'all' ? this.data.salesTypeData : (
+ this.salesType === 'online' ? this.data.salesTypeDataOnline : (
+ this.salesType === 'online2' ? this.data.salesTypeDataOnline2 : this.data.salesTypeDataOffline
+ )
+ );
+ if (this.salesPieData) this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0);
+ }
}
--
Gitblit v1.8.0