Today I am honored to discuss with you how to make Python big data dynamic visualization big screen!

Of course, the expelled titles are all jokes, let’s go into today’s discussion exchange, I hope we can get their own analysis show.

preface

I believe that many people hope to have a board for each annual meeting of the company to do analysis, so today is coming!

Let’s take a look!

1. Prepare app.py

Start by creating a file called app.py

#! /usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 2020/8/26 14:48 # @Author : way # @Site : # @Describe: from flask import Flask, render_template from data import SourceData from data_corp import CorpData from data_job import JobData from flask import Flask,render_template from flask import Flask, render_template from data import SourceData from data_corp import CorpData from data_job import JobData import os app = Flask(__name__) @app.route('/') def index(): data = SourceData() return render_template('index.html', form=data, title=data.title) @app.route('/corp') def corp(): data = CorpData() return render_template('index.html', form=data, title=data.title) @app.route('/job') def job(): data = JobData() return render_template('index.html', form=data, title=data.title) if __name__ == "__main__": App. The run (host = '127.0.0.1, debug = True)Copy the code

Now that we have this, we can launch our boards, and then we can prepare the data

2. Prepare data.py

#! /usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 2020/8/26 14:48 # @Author : way # @Site : # @Describe: Class SourceDataDemo: def __init__(self): self.title = '12312' self.counter = {'name': '2020年 数 据 库 ', 'value': } self.echart1_data = {' title': 'echart1_data ', 'data':} self.echart1_data = {' title':' echart1_data ', 'data': [{" name ":" the road &bridge construction ", "value" : 47}, {" name ":" infrastructure ", "value" : 52}, {" name ":" real estate construction ", "value" : 90}, {" name ": "Government", "value" : 84}, {" name ":" overseas construction ", "value" : 79}, {" name ":" welfare ", "value" : 37}, {" name ":" advanced construction ", "value" : }}, 200] self. Echart2_data = {' title ':' fourth power provinces distribution ', 'data: [{" name ":" zhejiang ", "value" : 47}, {" name ":" Shanghai ", "value" : 52}, {" name ", "jiangsu province", "value" : 90}, {" name ":" guangdong ", "value" : 84}, {" name ":" Beijing ", "value" : 99}, {" name ":" shenzhen ", "value" : 37}, {" name ", "anhui province", "value" : 150},]} self. Echarts3_1_data = {' title ':' employees age distribution ', 'data: [{" name ":" under the age of 20, ", "value" : 7}, {" name ":" 20 to 29 ", "value" : 52}, {" name ":" 30-39 ", "value" : 90}, {" name ":" 40-49 ", "value" : 84}, {" name ": "Over 50", "value" : 99}]} self. Echarts3_2_data = {' title ':' TieSiJu engineering distribution in ', 'data: [{" name ":" e-commerce ", "value" : 10}, {" name ":" education ", "value" : 20}, {" name ":" IT/Internet ", "value" : 20}, {" name ":" financial ", "value" : 30}, {" name ": "Real estate", "value" : 40}, {" name ":" other ", "value" : 50},]} self. Echarts3_3_data = {' title ':' interest distribution of employees', 'data: [{" name ": "Car", "value" : 4}, {" name ":" travel ", "value" : 5}, {" name ":" finance ", "value" : 9}, {" name ":" education ", "value" : 8}, {" name ": "Software", "value" : 9}, {" name ":" other ", "value" : 9},]} self. Echart4_data = {' title ':' time performance trends', 'data: [{" name ": "Infrastructure", "value" : [3, 4, 3, 4, 3, 4, 3, 6, 2, 4, 2, 4, 3, 4, 3, 4, 3, 4, 3, 6, 2, 4, 4]}, {" name ":" real estate construction ", "value" : [5, 3, 5, 6, 1, 5, 3, 5, 6, 4, 6, 4, 8, 3, 5, 6, 1, 5, 3, 7, 2, 5, 8]}, ], 'xAxis': [' 01, 02, '03,' 04, '05,' 06, '07 and' 08 ', '9', '11', '12' and '13', '14' and '15', '16', '17', '18', 'the', '20', '21', '22', '23', '24'],} self. Echart5_data = {' title ':' provinces division distribution ', 'data: [{" name ":" zhejiang ", "value" : 2}, {" name ": "Shanghai", "value" : 3}, {" name ":" in jiangsu province ", "value" : 3}, {" name ":" guangdong ", "value" : 9}, {" name ":" Beijing ", "value" : 15}, {" name ": "Shenzhen", "value" : 18}, {" name ":" anhui province ", "value" : 20}, {" name ":" sichuan ", "value" : 13},]} self. Echart6_data = {" title ": 'first-tier cities project' and 'data' : [{" name ":" zhejiang ", "value" : 80, "value2" : 20, "color" : "01", the "radius" : [' 59% ', '70%']}, {" name ": "Shanghai", "value" : 70, "value2" : 30, "color" : "02", the "radius" : [' 49% ', '60%']}, {" name ":" guangdong ", "value" : 65, "value2" : 35, "color" : "3", "radius" : [' 39% ', '50%']}, {" name ":" Beijing ", "value" : 60, "value2" : 40, "color" : "4", "radius" : [' 29% ', '40%']}, {" name ":" shenzhen ", "value" : 50, "value2" : 50, "color" : "5", the "radius" : ] [' 20% ', '30%'},]} self. Map_1_data = {' symbolSize: 100, 'data: [{' name' : 'haimen', 'value: 239}, {" name ": 'ordos',' value: 231}, {' name ':' zhaoyuan ', 'value' : 203},]} @ property def echart1 (self) : data = self.echart1_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'series': [i.get("value") for i in data.get('data')] } return echart @property def echart2(self): data = self.echart2_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'series': [i.get("value") for i in data.get('data')] } return echart @property def echarts3_1(self): data = self.echarts3_1_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'data': data.get('data'), } return echart @property def echarts3_2(self): data = self.echarts3_2_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'data': data.get('data'), } return echart @property def echarts3_3(self): data = self.echarts3_3_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'data': data.get('data'), } return echart @property def echart4(self): data = self.echart4_data echart = { 'title': data.get('title'), 'names': [i.get("name") for i in data.get('data')], 'xAxis': data.get('xAxis'), 'data': data.get('data'), } return echart @property def echart5(self): data = self.echart5_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'series': [i.get("value") for i in data.get('data')], 'data': data.get('data'), } return echart @property def echart6(self): data = self.echart6_data echart = { 'title': data.get('title'), 'xAxis': [i.get("name") for i in data.get('data')], 'data': data.get('data'), } return echart @property def map_1(self): data = self.map_1_data echart = { 'symbolSize': data.get('symbolSize'), 'data': data.get('data'), } return echart class SourceData(SourceDataDemo): def __init__(self): """ super().__init__() self.title = 'Analysis of big data of Annual Performance of China Railway Fourth Bureau'Copy the code

Now the data is ready.

Three. Run the program

Let’s click app.py and start running the app! The following pop-up box appears.

Now we should copy http://127.0.0.1:5000/ and open it on the web page. You’ll see this! Is that what you want? You can make changes according to your own preferences! To sum up, today we took a look at how python’s big data screen is made. It is not easy to create, and we hope you can support it. Thank you!

Recently, many friends have sent messages to ask about learning Python. For easy communication, click on blue to join yourselfDiscussion solution resource base