How to divide the country_map into more than just the country regions in Apache Superset?

耗尽温柔 提交于 2019-12-25 03:39:36

问题


I am using Apache Superset, specifically country_map to visualize data.

Is it possible to slice the country maps into more areas than just the regions of the country? How can I achieve that?


回答1:


In order to make changes to country maps, you need to build Superset from sources. First, fork the Apache Superset repo in your Github. Then clone the repo to your device and enter superset folder:

git clone https://github.com/username/incubator-superset.git
cd incubator-superset

Second:

sudo pip install -r docs/requirements.txt
python3 setup.py build_sphinx

Next, create virtual environment and install superset:

virtualenv -p python3 venv # if virtualenv not found use: `sudo -H pip3 install virtualenv`
source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt # Here I got error "python setup.py egg_info" failed with error code 1. You can skip it or try pip install --upgrade setuptools
pip install -e .
fabmanager create-admin --app superset

pip install python-dotenv # just in case you don't already have it
superset db upgrade # if error pip install pandas==0.23.4 plus pip install sqlalchemy==1.2.18
superset load_examples 
superset init

Leave the venv environment to continue building the front-end:

deactivate # exit venv
cd superset/assets
npm ci
npm run dev

Next, go back to superset directory and start the flask local server:

cd superset
FLASK_ENV=development flask run -p 8088 --with-threads --reload --debugger

I got the instructions from Apache Superset GitHub Contributing page

Now, regarding the division of the country maps. What I did was download a new geojson format map and replace the superset map with the new map. Paste the new map in this directory.

cd incubator-superset/superset/assets/src/visualizations/CountryMap/countries 

If this a new country and does not already exist in the directory, you also need to add the name at controls.jsx file. File is located here:

cd incubator-superset/superset/assets/src/explore

Open the file and add the new country at the select_country: {...} component. I got the instruction at Superset Visualization Tools Doc

In order for the new country map to show up in the web browser, you need to rerun the command npm run dev at assets directory, and restart the server.

That's what worked for me. Hope it'll be helpful for future users.

PS: Don't forget to upgrade npm in case you have an old version. You'll need it for npm ci command



来源:https://stackoverflow.com/questions/54330796/how-to-divide-the-country-map-into-more-than-just-the-country-regions-in-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!