It’s actually very simple and will teach you how to easily create cool data visualization on a large screen.

Hello everyone, today I will share with you a Python visual large-screen project, GitHub address:https://github.com/TurboWay/big_screen

The project structure is simple and easy to use, and data can be visualized on a large screen by directly transferring data.If you like, remember to collect, follow and like.

Note: Technical exchange and source code acquisition methods are provided at the end of the article.

Install

Project relies on third-party modulesflask, so we need to install dependencies first, installation command:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple flask

Partial source code sharing

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author : way
# @Site : 
# @Describe:
import json
class SourceDataDemo:
def __init__(self):
self.title = 'Big data visualization display board general template'
self.counter = {'name': 'Total income in 2018', 'value': 12581189}
self.counter2 = {'name': 'Total expenditure in 2018', 'value': 3912410}
self.echart1_data = {
'title': 'Industry Distribution',
'data': [
{"name": "Supermarket store", "value": 47},
{"name": "Education and Training", "value": 52},
{"name": "real estate", "value": 90},
{"name": "Life Services", "value": 84},
{"name": "Car Sales", "value": 99},
{"name": "Tourist Hotel", "value": 37},
{"name": "Hardware and Building Materials", "value": 2},
]
}
self.echart2_data = {
'title': 'Provincial Distribution',
'data': [
{"name": "Zhejiang", "value": 47},
{"name": "Shanghai", "value": 52},
{"name": "Jiangsu", "value": 90},
{"name": "Guangdong", "value": 84},
{"name": "Beijing", "value": 99},
{"name": "Shenzhen", "value": 37},
{"name": "Anhui", "value": 150},
]
}
self.echarts3_1_data = {
'title': 'Age Distribution',
'data': [
{"name": "under 0 years old", "value": 47},
{"name": "20-29 years old", "value": 52},
{"name": "30-39 years old", "value": 90},
{"name": "40-49 years old", "value": 84},
{"name": "Age 50 and above", "value": 99},
]
}
self.echarts3_2_data = {
'title': 'Occupation Distribution',
'data': [
{"name": "e-commerce", "value": 10},
{"name": "Education", "value": 20},
{"name": "IT/Internet", "value": 20},
{"name": "Finance", "value": 30},
{"name": "student", "value": 40},
{"name": "Other", "value": 50},
]
}
self.echarts3_3_data = {
'title': 'Interest Distribution',
'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 Trend',
'data': [
{"name": "Android", "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": "IOS", "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', '08', '09', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24'],
}
self.echart5_data = {
'title': 'Province TOP',
'data': [
{"name": "Zhejiang", "value": 2},
{"name": "Shanghai", "value": 3},
{"name": "Jiangsu", "value": 3},
{"name": "Guangdong", "value": 9},
{"name": "Beijing", "value": 15},
{"name": "Shenzhen", "value": 18},
{"name": "Anhui", "value": 20},
{"name": "Sichuan", "value": 13},
]
}
self.echart6_data = {
'title': 'First-tier cities',
'data': [
{"name": "Zhejiang", "value": 80, "value2": 20, "color": "01", "radius": ['59%', '70%']},
{"name": "Shanghai", "value": 70, "value2": 30, "color": "02", "radius": ['49%', '60%']},
{"name": "Guangdong", "value": 65, "value2": 35, "color": "03", "radius": ['39%', '50%']},
{"name": "Beijing", "value": 60, "value2": 40, "color": "04", "radius": ['29%', '40%']},
{"name": "Shenzhen", "value": 50, "value2": 50, "color": "05", "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):
"""
Just overwrite the data according to the format of SourceDataDemo
"""
super().__init__()
self.title = 'Big data visualization display board general template'
class CorpData(SourceDataDemo):
def __init__(self):
"""
Just overwrite the data according to the format of SourceDataDemo
"""
super().__init__()
with open('corp.json', 'r', encoding='utf-8') as f:
data = json.loads(f.read())
self.title = data.get('title')
self.counter = data.get('counter')
self.counter2 = data.get('counter2')
self.echart1_data = data.get('echart1_data')
self.echart2_data = data.get('echart2_data')
self.echarts3_1_data = data.get('echarts3_1_data')
self.echarts3_2_data = data.get('echarts3_2_data')
self.echarts3_3_data = data.get('echarts3_3_data')
self.echart4_data = data.get('echart4_data')
self.echart5_data = data.get('echart5_data')
self.echart6_data = data.get('echart6_data')
self.map_1_data = data.get('map_1_data')
class JobData(SourceDataDemo):
def __init__(self):
"""
Just overwrite the data according to the format of SourceDataDemo
"""
super().__init__()
with open('job.json', 'r', encoding='utf-8') as f:
data = json.loads(f.read())
self.title = data.get('title')
self.counter = data.get('counter')
self.counter2 = data.get('counter2')
self.echart1_data = data.get('echart1_data')
self.echart2_data = data.get('echart2_data')
self.echarts3_1_data = data.get('echarts3_1_data')
self.echarts3_2_data = data.get('echarts3_2_data')
self.echarts3_3_data = data.get('echarts3_3_data')
self.echart4_data = data.get('echart4_data')
self.echart5_data = data.get('echart5_data')
self.echart6_data = data.get('echart6_data')
self.map_1_data = data.get('map_1_data')

run

First, we download the project locally from GitHub. Of course, we can also download it from the public accountPython juniorBackend replybig_screenGet it directly.

After the project is downloaded, we enter the project root path, as shown below:

Then, press and holdShiftpointright click, then selectOpen a command window here (W), enter the command after the command window opens:python app.pyStartup project.

After the project is started, we can access it by directly entering the address in the browser. Let’s take a look at the example below.

General template for big data visualization display boards:http://127.0.0.1:5000,As follows:

Large-screen visualization of 46 million enterprise data:http://127.0.0.1:5000/corp,As follows:

Xiamen 100,000 recruitment data (2020-09) large-screen visualization:http://127.0.0.1:5000/job,As follows:

use

  • Edit the SourceData class in data.py (or add a new class, if you want to add a new class, you need to edit app.py to add routing, please refer to CorpData/JobData)

  • Read your data from anywhere, fill it into the SourceData class according to the data format of SourceDataDemo

  • Run python app.py to see the effect of data changes

Contact information

Currently, a technical exchange group has been opened with more than 3,000 members. The best way to add comments is: source + direction of interest, which makes it easy to find like-minded friends. You can also join to obtain information.

Method 1. Add WeChat ID: dkl88191, remarks: from
Method 2. Search the public account on WeChat: Python learning and data mining, and reply in the background: Join the group

Related Posts

python: Some problems and solutions when starting to use tensorflow

graphviz.backend.execute.ExecutableNotFound: failed to execute WindowsPath(‘dot‘), make sure the Gra

Solve the problem of sorting after SQLite auto-increment ID modification:

The simplest Anaconda+Python3.7 installation tutorial on the Internet for Win10 (100% successful)

Anaconda environment cloning and migration

Pandas merge csv files

The difference between operating Pandas and Excel tables

Correspondence between Tensorflow and CUDA and cudnn versions

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*