Skip to content

Commit 0c59d7e

Browse files
committed
update analysis
1 parent 1c9a0fd commit 0c59d7e

12 files changed

Lines changed: 1990 additions & 192 deletions

package-lock.json

Lines changed: 1869 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/analysis/analysis.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { BrandComponent } from './crowd/brand/brand.component';
2121
import { OperatorsComponent } from './crowd/operators/operators.component';
2222
import { RegionComponent } from './crowd/region/region.component';
2323
import { EquipmentBrandComponent } from './equipment/brand/brand.component';
24+
import { PreferenceFieldComponent } from './preference/field/field.component';
2425

2526
@NgModule({
2627
imports: [
@@ -43,7 +44,8 @@ import { EquipmentBrandComponent } from './equipment/brand/brand.component';
4344
BrandComponent,
4445
OperatorsComponent,
4546
RegionComponent,
46-
EquipmentBrandComponent
47+
EquipmentBrandComponent,
48+
PreferenceFieldComponent
4749
],
4850
providers: [
4951
{provide: 'AnalysisService', useClass: AnalysisService}

src/app/analysis/analysis.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Injectable } from '@angular/core';
2-
import { Http } from '@angular/http';
32
import { HttpClient } from '@angular/common/http';
43
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
54
import { environment } from '../../environments/environment';
@@ -34,7 +33,7 @@ export class AnalysisService {
3433
return this._crowdOverview$.asObservable();
3534
}
3635

37-
constructor(private _http: Http, private http: HttpClient) {
36+
constructor(private http: HttpClient) {
3837
this._crowdApplist$ = new BehaviorSubject<any>([]);
3938
this._crowdCateList$ = new BehaviorSubject<any>([]);
4039
this._crowdDevice$ = new BehaviorSubject<any>([]);
@@ -51,14 +50,14 @@ export class AnalysisService {
5150

5251
getCrowdAppList() {
5352
const url = `${this.apiUrl}/crowdAppList.json`;
54-
return this._http.get(url).map(res => res.json().datas).subscribe(res => {
53+
return this.http.get(url).subscribe(res => {
5554
this._crowdApplist$.next(res);
5655
});
5756
}
5857

5958
getCrowdCateList() {
6059
const url = `${this.apiUrl}/crowdCateList.json`;
61-
return this._http.get(url).map(res => res.json().datas).subscribe(res => {
60+
return this.http.get(url).subscribe(res => {
6261
this._crowdCateList$.next(res);
6362
});
6463
}
@@ -72,7 +71,7 @@ export class AnalysisService {
7271

7372
scenesData() {
7473
const url = `${this.apiUrl}/scenes.json`;
75-
return this._http.get(url).map(res => res.json().datas).subscribe(res => {
74+
return this.http.get(url).subscribe(res => {
7675
this._scenes$.next(res);
7776
});
7877
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<mat-card>
2+
<mat-card-title>人群领域偏好</mat-card-title>
3+
<mat-card-content>
4+
<ngx-charts-bar-horizontal *ngIf="data?.length"
5+
[scheme]="colorScheme"
6+
[results]="data"
7+
[gradient]="gradient"
8+
[xAxis]="showXAxis"
9+
[yAxis]="showYAxis"
10+
[legend]="showLegend"
11+
[showXAxisLabel]="showXAxisLabel"
12+
[showYAxisLabel]="showYAxisLabel"
13+
(select)="onSelect($event)">
14+
</ngx-charts-bar-horizontal>
15+
</mat-card-content>
16+
</mat-card>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mat-card {
2+
margin: 5px;
3+
padding: 0;
4+
}
5+
6+
mat-card-title {
7+
padding: 16px 24px;
8+
}
9+
10+
mat-card-content {
11+
min-height: 400px;
12+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component, OnInit, Input } from '@angular/core';
2+
3+
@Component({
4+
selector: 'analysis-preference-field',
5+
templateUrl: './field.component.html',
6+
styleUrls: ['./field.component.scss']
7+
})
8+
export class PreferenceFieldComponent implements OnInit {
9+
10+
@Input() data: any;
11+
12+
// options
13+
showXAxis = true;
14+
showYAxis = true;
15+
gradient = false;
16+
showLegend = false;
17+
showXAxisLabel = true;
18+
xAxisLabel = 'Country';
19+
showYAxisLabel = true;
20+
yAxisLabel = 'Population';
21+
22+
colorScheme = {
23+
domain: ['#5AA454', '#A10A28', '#C7B42C', '#AAAAAA']
24+
};
25+
26+
constructor() {
27+
}
28+
29+
ngOnInit() {
30+
}
31+
32+
onSelect(event) {
33+
console.log(event);
34+
}
35+
36+
}

src/app/analysis/preference/preference.component.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
<div fxLayout="row" fxLayoutWrap>
22
<div fxFlex.gt-sm="50">
3-
<mat-card>
4-
<mat-card-title>人群领域偏好</mat-card-title>
5-
<mat-card-content>
6-
<canvas baseChart height="200px"
7-
[datasets]="barChartData"
8-
[labels]="barChartLabels"
9-
[options]="barChartOptions"
10-
[legend]="barChartLegend"
11-
[chartType]="barChartType"></canvas>
12-
</mat-card-content>
13-
</mat-card>
3+
<analysis-preference-field [data]="field_data"></analysis-preference-field>
144
</div>
155
<div fxFlex.gt-sm="50">
166
<mat-card>

src/app/analysis/preference/preference.component.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ mat-card-title {
1313
}
1414

1515
mat-card-content {
16-
padding: 0 24px 24px 24px;
16+
min-height: 400px;
1717
}
1818

19+
1920
.table {
2021
width: 100%;
2122
tr > td {
@@ -32,7 +33,8 @@ mat-card-content {
3233
}
3334

3435
.fixedHeight {
35-
max-height: 522px;
36+
max-height: 400px;
37+
min-height: 400px;
3638
overflow: auto;
3739
}
3840
.num {

src/app/analysis/preference/preference.component.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ import { Component, OnInit, Inject } from '@angular/core';
77
})
88
export class PreferenceComponent implements OnInit {
99

10-
public barChartOptions: any = {};
11-
public barChartLabels: string[] = [];
12-
public barChartType: string = 'horizontalBar';
13-
public barChartLegend: boolean = true;
14-
public barChartData: any[] = [
15-
{data: [], label: '活跃人数(万)'}
16-
];
10+
field_data: any = [];
1711

1812
coverRateListDatas: any[] = [];
1913
activeDatas: any[] = [];
@@ -22,49 +16,43 @@ export class PreferenceComponent implements OnInit {
2216
}
2317

2418
ngOnInit() {
19+
this._service.getCrowdCateList();
2520
this.getCrowdCateList();
2621
this.coverRateList();
22+
23+
this._service.getCrowdAppList();
2724
this.getCrowdAppList();
2825
}
2926

3027
getCrowdCateList() {
31-
this._service.getCrowdCateList();
3228

3329
this._service.crowdCateList$.subscribe(res => {
34-
const list = res.list;
35-
if (!list) {
36-
return;
37-
}
3830

39-
let crowdActiveNums = [];
40-
let categoryName = list.map(v => {
41-
crowdActiveNums.push(v.crowdActiveNums);
42-
return v.categoryName;
43-
});
31+
if (res.datas) {
32+
res.datas.list.map((item) => {
33+
this.field_data.push({
34+
name: item.categoryName,
35+
value: item.crowdActiveNums
36+
});
37+
});
38+
}
4439

45-
this.barChartLabels = categoryName;
46-
this.barChartData[0].data = crowdActiveNums;
4740
});
4841
}
4942

5043
coverRateList() {
5144
this._service.crowdCateList$.subscribe(res => {
52-
const coverRateList = res.coverRateList;
53-
if (!coverRateList) {
54-
return;
45+
if (res.datas) {
46+
this.coverRateListDatas = res.datas.coverRateList;
5547
}
56-
this.coverRateListDatas = coverRateList;
5748
});
5849
}
5950

6051
getCrowdAppList() {
61-
this._service.getCrowdAppList();
6252
this._service.crowdApplist$.subscribe(res => {
63-
const activeDatas = res.activeDatas;
64-
if (!activeDatas) {
65-
return;
53+
if (res.datas) {
54+
this.activeDatas = res.datas.activeDatas.datas;
6655
}
67-
this.activeDatas = activeDatas.datas;
6856
});
6957
}
7058

src/app/analysis/scene-portrait/scene-portrait.component.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
<mat-card>
33
<mat-card-title>场景概览</mat-card-title>
44
<mat-card-content>
5-
<canvas baseChart height="100px"
6-
[datasets]="bubbleChartData"
7-
[labels]="bubbleChartLabels"
8-
[options]="bubbleChartOptions"
9-
[legend]="bubbleChartLegend"
10-
[chartType]="bubbleChartType"></canvas>
5+
<ngx-charts-bubble-chart
6+
[results]="bubble"
7+
[legend]="showLegend"
8+
[xAxis]="showXAxis"
9+
[yAxis]="showYAxis"
10+
[showXAxisLabel]="showXAxisLabel"
11+
[showYAxisLabel]="showYAxisLabel"
12+
[xAxisLabel]="xAxisLabel"
13+
[yAxisLabel]="yAxisLabel"
14+
[scheme]="colorScheme">
15+
</ngx-charts-bubble-chart>
1116
</mat-card-content>
1217
</mat-card>
1318
</div>

0 commit comments

Comments
 (0)