VolkovLabs / business-charts

The Business Charts panel allows you to integrate charts and graphs created by the Apache ECharts library into your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
139 stars 17 forks source link

Could not add local geojson map #158

Closed alpglide closed 1 year ago

alpglide commented 1 year ago

add a local GeoJSON map to /var/lib/grafana/plugins/volkovlabs-echarts-panel/maps/mymap.json, and change the map files'owner to grafana:grafana (same ans USA.json and world.json). then configure echart option as: series: [ { name: 'my test map', type: 'map', roam: true, map: 'mymap', emphasis: { label: { show: true } }
} ] got error: _ECharts Execution Error Cannot read properties of undefined (reading 'regions') TypeError: Cannot read properties of undefined (reading 'regions') at e.getInitialData (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:2286651) at e.init (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1351510) at e.eval (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1306209) at Array.forEach () at bt (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1132336) at e.eval (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1305839) at t.topologicalTravel (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1298937) at e._mergeOption (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1305331) at e._resetOption (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1304577) at e.setOption (https://echarts.volkovlabs.io/public/plugins/volkovlabs-echarts-panel/module.js:2:1304298)_

If I change option from 'mymap' back to 'USA', then it works and show USA map. If I cope mymap.json to USA.json, and clear browser cache, then it still show USA map, not mymap. I am not sure where the echarts plugin read map files.

alpglide commented 1 year ago

If I use svg map. mymap does show up. but if I use mymap as backgroud and add other graph on top of it. (so totally two series: mymap, mygraph). When I try to zoom/drag, sometime, mymap zoom/drag only, sometime, mygraph zoom/drag only, occasionally, both mymap and mygraph zoom/drag at the same time(wanted effect).

mikhail-vl commented 1 year ago

@alpglide I have not used additional GeoJSON for a while and need to check why it's not loading the JSON file.

I remember we tested dynamic loading of Maps files in the issue: https://github.com/VolkovLabs/volkovlabs-echarts-panel/issues/30 and it worked. I will take a look.

alpglide commented 1 year ago

yes, dynamic loading of Maps files works. That's good enough. Thanks for your help.

mikhail-vl commented 1 year ago

@alpglide Thank you for confirming.

We updated the documentation with various examples: https://volkovlabs.io/plugins/volkovlabs-echarts-panel/maps/geojson/