Recently, I worked on a project related to data visualization in the company. I used Superset, an enterprise BI data platform maintained by Airbnb, which is open source. Compared with tableau, a charging commercial software,Superset is maintained by open source. The following renderings:

And dozens of other chart formats

So without further ado, let’s start building.

1. Prepare

**Linux server CentOS7(Windows not overview in general missing WHL files in [this site](https://www.lfd.uci.edu/~gohlke/pythonlibs/) you can download the **python3.+ version (I’m using version 3.6.2 here)yum install the 163 mirror

Superset website

2. Installation environment

2.1 installation python3.6.2

Python3.6.2 installation and testing

2.2. Install the compilation environment

sudo yum install gcc gcc-c++ libffi-devel  openssl-devel libsasl2-devel openldap-develCopy the code

2.3 Update PIP and tools to use Python3 download

####pip3 install --upgrade setuptools pip Copy the code

2.4 Installing the VirtualEnv

 pip3 install virtualenvCopy the code

2.5 Entering the Virtual Environment

. ./venv/bin/activateCopy the code

2.6 Installing superset using Douban mirror source

pip3 install superset -i https://pypi.douban.com/simple Copy the code

Description 1:ImportError: No module named flask_compress/ext/XXX This is because the default flask version of Superset is greater than 1.0 and not too high. For other components, the default flask version is too low or too high

Pip3 uninstall flask pip3 install - http://pypi.douban.com/simple/ - I trusted - host pypi.douban.com flask = = 1.0Copy the code

Was unable to import superset Error:No module named ‘_sqlite3’ This is the default Python interpreter version 2.7 and 3.6 There are also online solutions to changing the default interpreter version or adding the SQlite3 module to the current compilation environment

2.7 Creating an Administrator User Name and Password

fabmanager create-admin --app superset Copy the code

No module named ‘_sqlite3

2.8 Initializing the Superset Database

superset db upgrade Copy the code

2.9 Loading the system case provided by the official

superset load_examples Copy the code

2.10 the initialization

superset init Copy the code

2.10 start the superset

superset run -p 8088 --with-threads --reload --debugger Copy the code

3. Start superset, connect to mysql data source, and create Charts according to the table

Enter IP address :8888 or IP address :8888/login/. The following page is displayed

3.1 Login Select Chinese in the upper right corner and enter the user name and password. 3.2 Installing a database dependency for connecting to the mysql data source

pip install mysqlclientCopy the code

3.3 Connecting to a Data Source

Click the + sign next to add filter criteriaConnecting to a Database

To connect data tables, click on the upper right to add filter criteria

Select the database input table name

Click the data table to enter the interface of creating Charts according to the table. Take the pie chart as an example: Select the data source icon type time interval Indicator value Grouping basis (here is gender)

Execute Query: Click Save to Save

At this point, the BI data platform icon generation is complete. Here’s how to introduce ICONS into your own projects

4. Turn the generated pie chart into HTML and embed it in your own project

Modify the config.py configuration file in superset to PUBLICROLEThe LIKE_GAMMA was changed to True to support cross-domain charting

Find the saved icon in “Charts” click on the top right Angle bracket to copy the iframe code

Embed the iframe tag in our own project.

Embedded chart Demo at www.songlei.online:8777

I hope to become a fellow traveler of Java technology with you