如何在Apache Superset中将country_map划分为多个国家区域? [英] How to divide the country_map into more than just the country regions in Apache Superset?

查看:629
本文介绍了如何在Apache Superset中将country_map划分为多个国家区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Superset,特别是 country_map 来可视化数据。

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?

推荐答案

为了更改国家/地区地图,您需要从源代码构建Superset。
首先,在您的Github中派生Apache Superset存储库。然后将存储库克隆到您的设备并输入超级集文件夹:

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

第二个:

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

离开 venv 环境继续构建前端:

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

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

下一步,返回超级集目录并启动flask本地服务器:

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从 Apache Superset GitHub贡献页面

现在,关于国家地图的划分。我所做的是下载了一个新的 geojson 格式映射,并将超集映射替换为新映射。将新地图粘贴到此目录中。

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 

如果这是一个新国家,并且目录中还不存在,则还需要在控件中添加名称.jsx文件。文件位于此处:

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

打开文件并在 select_country中添加新的国家/地区:{...} 零件。我在 Superset可视化工具文档

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

要使新的国家/地区地图显示在网络浏览器中,您需要重新运行命令 npm run dev 在资产目录中,然后重新启动服务器。

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:如果您使用的是旧版本,请不要忘记升级npm。您需要 npm ci 命令

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

这篇关于如何在Apache Superset中将country_map划分为多个国家区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆