diff --git a/src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts b/src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts index 9d1acc1..fc11226 100644 --- a/src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts +++ b/src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts @@ -17,8 +17,19 @@ export class AddUnitOneComponent implements OnInit { this.setTimeoutObj = window.setTimeout(()=>{ this.initCharts() },0) + this.echartsData.eventEmit.subscribe((value: any) => { + if (value == 'echarts') { + setTimeout(() => { + this.indexBzt.resize() + }, 500); + + } + }); + } + //更新echarts视图 + updateEcharts(){ + this.indexBzt.resize() } - //组件销毁时 ngOnDestroy(){ window.clearTimeout(this.setTimeoutObj); diff --git a/src/app/statistic-analysis/home/home.component.ts b/src/app/statistic-analysis/home/home.component.ts index b9b000a..b713121 100644 --- a/src/app/statistic-analysis/home/home.component.ts +++ b/src/app/statistic-analysis/home/home.component.ts @@ -4,7 +4,6 @@ import { Router } from '@angular/router'; import { EchartsDataService } from '../echarts-data.service'; declare var echarts: any; declare var AMap: any; - declare var AMapUI: any; @Component({ selector: 'app-home', @@ -20,26 +19,30 @@ export class HomeComponent implements OnInit { ngOnInit() { this.emitService.eventEmit.subscribe((value: any) => { if (value == 'echarts') { - this.updateEcharts() + setTimeout(() => { + this.updateEcharts() + }, 500); } }); - window.setTimeout(()=>{ this.unitType() this.unitData() this.keyUnit() this.mapInit() //初始化地图 let that = this - window.addEventListener('resize', () => { + },0) + window.addEventListener('resize', () => { + setTimeout(() => { this.updateEcharts() - }) - window.addEventListener('keydown', (e) => { - if(e.keyCode == 122){ + }, 500); + }) + window.addEventListener('keydown', (e) => { + if(e.keyCode == 122){ + setTimeout(() => { this.updateEcharts() - } - }) - - },0) + }, 500); + } + }) } //更新echarts视图