bug: fix problems caused by switching routes 70/96070/1
authorcyuamber <xuranyjy@chinamobile.com>
Fri, 20 Sep 2019 09:51:54 +0000 (17:51 +0800)
committercyuamber <xuranyjy@chinamobile.com>
Fri, 20 Sep 2019 09:52:08 +0000 (17:52 +0800)
Change-Id: I9558b3fd6b8df089a5da47a08ee89c069b4fcb34
Issue-ID: USECASEUI-306
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
usecaseui-portal/src/app/shared/components/charts/pie/pie.component.ts
usecaseui-portal/src/app/views/home/home.component.ts

index d22ffb0..85cf72e 100644 (file)
@@ -110,9 +110,9 @@ export class PieComponent implements OnInit {
     })
   }
 
-  resize(size: number){
+  resize(parentHeight: number, size: number){
     this.chartIntance.resize( {
-      height: size - 250
+      height: parentHeight - size
     })
   }
 
index 92e7e88..a7f312e 100644 (file)
@@ -31,7 +31,7 @@ export class HomeComponent implements OnInit {
   @HostBinding('@routerAnimate') routerAnimateState;
   @ViewChild('seriverChart') seriverChart;
   @ViewChild('services') services: ElementRef;
-  
+  resizeMark  
 
   constructor(
     private myhttp: HomesService,
@@ -49,18 +49,19 @@ export class HomeComponent implements OnInit {
     this.getHomeServiceBarNsData();
     this.getHomeServiceBarVnfData();
     this.getHomeServiceBarPnfData();
-    Observable.fromEvent(window,'resize')
+    this.resizeMark = Observable.fromEvent(window,'resize')
       .subscribe((event) => {
-        this.seriverChart.resize(this.services.nativeElement.offsetHeight)
+        this.seriverChart.resize(this.services.nativeElement.offsetHeight,250)
       })
   }
   
   ngAfterViewInit(){
-    this.seriverChart.resize(this.services.nativeElement.offsetHeight)
-    
-
+    this.seriverChart.resize(this.services.nativeElement.offsetHeight,250)
   }
 
+  ngOnDestroy(){
+    this.resizeMark.unsubscribe()
+  }
 
   // services
   serviceNumber: number = 0;