当我使用向下钻取(Highcharts)时,我的build-prod在angular 8中变得非常大
我在项目中使用了延迟加载。只要我使用钻孔图表,一切都正常。 在本例中,当我从项目中获取构建时,首先加载向下钻取的模块,main.js文件的大小变得非常大 我用海图来显示世界地图,我用这个方法来显示每个国家的省份当我使用向下钻取(Highcharts)时,我的build-prod在angular 8中变得非常大,angular,dictionary,highcharts,Angular,Dictionary,Highcharts,我在项目中使用了延迟加载。只要我使用钻孔图表,一切都正常。 在本例中,当我从项目中获取构建时,首先加载向下钻取的模块,main.js文件的大小变得非常大 我用海图来显示世界地图,我用这个方法来显示每个国家的省份 createDrillDownCountry(data: any, chart: any) { const country = data.drilldown, mapKey = 'countries/' + country + '/' + cou
createDrillDownCountry(data: any, chart: any) {
const country = data.drilldown,
mapKey = 'countries/' + country + '/' + country + '-all',
mapData = require(`@highcharts/map-collection/${mapKey}.geo.json`),
provinceData = Highcharts.geojson(mapData);
provinceData.forEach((el: any, i) => {
if (el.properties['hc-key'] === this.divisionsManagementService.currentDivision) {
el.selected = true;
}
if (Object.keys(this.allDivisions).length > 0 && this.allDivisions[country]) {
for (let index = 0; index < this.allDivisions[country].length; index++) {
if (this.allDivisions[country][index].prefix === el.properties['hc-key']) {
el.centerData = this.allDivisions[country][index];
el.value = i * 10;
break;
} else {
el.value = 0;
}
}
}
});
chart.addSeriesAsDrilldown(data, {
name: data.name,
data: provinceData,
events: {
click: (event) => {
if (this.addMode) {
if (event.point.value === 0 || event.point.value === undefined) {
this.clickedOnMap.emit(event);
}
} else {
if (event.point.value > 0) {
this.clickedOnMap.emit(event);
} else {
this.clickedOnMap.emit(false);
this.openAddPage.emit(event);
this.divisionsManagementService.currentDivision = event.point.properties['hc-key'];
}
}
}
},
allowPointSelect: true,
states: {
select: {
color: '#cadbff',
borderColor: '#9a9a9a',
dashStyle: 'dash'
}
},
tooltip: {
enabled: false
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
});
}
如果我删除这个方法,这很有趣。延迟加载可以正常工作。但是如果我用这个方法。模块从开始加载。更改此行
mapData = require(`@highcharts/map-collection/${mapKey}.geo.json`)
与
您使用了世界地图图表。你用一个演习来展示各省。到目前为止,对吗?构建时不懒惰吗?在哪里激发该方法?我从懒惰模块在ngOnInit中激发它这只发生在生产构建中?
import(`@highcharts/map-collection/${mapKey}.geo.json`).then((response) => {
const provinceData = Highcharts.geojson(response);
}