Browse Source

[完善]增加resize延时器

master
邵佳豪 4 years ago
parent
commit
746518516b
  1. 13
      src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts
  2. 25
      src/app/statistic-analysis/home/home.component.ts

13
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.setTimeoutObj = window.setTimeout(()=>{
this.initCharts() this.initCharts()
},0) },0)
this.echartsData.eventEmit.subscribe((value: any) => {
if (value == 'echarts') {
setTimeout(() => {
this.indexBzt.resize()
}, 500);
}
});
}
//更新echarts视图
updateEcharts(){
this.indexBzt.resize()
} }
//组件销毁时 //组件销毁时
ngOnDestroy(){ ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj); window.clearTimeout(this.setTimeoutObj);

25
src/app/statistic-analysis/home/home.component.ts

@ -4,7 +4,6 @@ import { Router } from '@angular/router';
import { EchartsDataService } from '../echarts-data.service'; import { EchartsDataService } from '../echarts-data.service';
declare var echarts: any; declare var echarts: any;
declare var AMap: any; declare var AMap: any;
declare var AMapUI: any; declare var AMapUI: any;
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@ -20,26 +19,30 @@ export class HomeComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.emitService.eventEmit.subscribe((value: any) => { this.emitService.eventEmit.subscribe((value: any) => {
if (value == 'echarts') { if (value == 'echarts') {
this.updateEcharts() setTimeout(() => {
this.updateEcharts()
}, 500);
} }
}); });
window.setTimeout(()=>{ window.setTimeout(()=>{
this.unitType() this.unitType()
this.unitData() this.unitData()
this.keyUnit() this.keyUnit()
this.mapInit() //初始化地图 this.mapInit() //初始化地图
let that = this let that = this
window.addEventListener('resize', () => { },0)
window.addEventListener('resize', () => {
setTimeout(() => {
this.updateEcharts() this.updateEcharts()
}) }, 500);
window.addEventListener('keydown', (e) => { })
if(e.keyCode == 122){ window.addEventListener('keydown', (e) => {
if(e.keyCode == 122){
setTimeout(() => {
this.updateEcharts() this.updateEcharts()
} }, 500);
}) }
})
},0)
} }
//更新echarts视图 //更新echarts视图

Loading…
Cancel
Save