apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.48k stars 19.62k forks source link

[Bug] Cannot read properties of undefined (reading 'regions') -- GeoCreator.getFilledRegions #17291

Open shareeftabakhi opened 2 years ago

shareeftabakhi commented 2 years ago

Version

5.3.2

Link to Minimal Reproduction

No response

Steps to Reproduce

-Create a Geo Map -Display it

ChartOptions: any = { // backgroundColor: '#000', title: { text: '', left: 'center', textStyle: { color: '#2a333d' } }, geo: { map: 'world', roam: true, label: { emphasis: { show: false, } }, silent: true, itemStyle: { normal: { borderColor: '#111' }, emphasis: { areaColor: '#2a333d' }, }, }, series: [ { type: 'scatter', progressive: 1e6, coordinateSystem: 'geo', symbolSize: '15', zoomScale: 0.222, blendMode: 'source-over', large: true, postEffect: { enable: true }, dimensions: ['lng', 'lat'], silent: true, data: [] } ], };

this.client.get("/assets/worldmap.json").subscribe((data: any) => {
  var worldMap = echarts.getMap('world');
  if (worldMap == null) {
    echarts.registerMap('world', data);
  }
  this.LoadData();
});

-In load Data this.ChartOptions.series[0].data.push(item);

if (this.ChartInstance) { this.ChartInstance.setOption(this.ChartOptions); }

-Html

<div echarts [options]="ChartOptions" [theme]="Theme" class="chart" *ngIf="ChartOptions" style="height:100%; width:100%" (chartInit)="OnChartInit($event)"></div>

Current Behavior

A console error appears and the map does not whereas it was working fine for almost a year and suddenly stopped

image

Expected Behavior

the map to appear

Environment

- OS: Windows 
- Browser: Chrome
- Framework:Angular

Any additional comments?

No response

houminz commented 1 year ago

Meet the same problem on version v5.4.1. You can see the demo here https://codepen.io/librabyte/pen/dyjNPXW. Any suggestion would be appreciated, thanks for your efforts on this awesome project!

houminz commented 1 year ago

After reading docs from Echarts https://echarts.apache.org/handbook/en/basics/release-note/v5-upgrade-guide/#built-in-geojson-removed, here is the explain:

Built-in GeoJSON Removed v5 removes the built-in geoJSON (previously in the echarts/map folder). These geoJSON files were always sourced from third parties. If users still need them, they can go get them from the old version, or find more appropriate data and register it with ECharts via the registerMap interface.

houminz commented 1 year ago

fix example: https://codepen.io/librabyte/pen/yLqgydO

MohammedAlSafwan commented 1 year ago

@librabyte what was the fix exactly?

helgasoft commented 1 year ago

@MohammedAlSafwan, file /assets/worldmap.json does not exist anymore. Here is how to use the geoJson world file with your code.

aryang23 commented 1 year ago

How you then used it? @MohammedAlSafwan @librabyte