@@ -7,13 +7,7 @@ import { Component, OnInit, Inject } from '@angular/core';
77} )
88export 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
0 commit comments