Skip to content

Commit 014cdbf

Browse files
v1.0
v1.0
1 parent 7df27cb commit 014cdbf

File tree

3,111 files changed

+842968
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,111 files changed

+842968
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

backend/flask/apps/app.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
from flask import Flask, render_template,jsonify
2+
from pyecharts import options as opts
3+
from pyecharts.charts import Map
4+
from pyecharts.charts import Line
5+
from pyecharts.globals import ChartType, SymbolType
6+
from pyecharts.globals import ThemeType
7+
8+
from pyecharts.components import Table
9+
from pyecharts.options import ComponentTitleOpts
10+
import json
11+
12+
13+
from exam_01 import *
14+
from exam_02 import *
15+
from exam_03 import *
16+
from exam_04 import *
17+
18+
19+
app = Flask(__name__, template_folder="../templates", static_folder="../static")
20+
21+
22+
# 第二部分:路由配置
23+
# #############################历史数据查询###########################
24+
# 01. 页面数据请求服务
25+
@app.route("/")
26+
def index():
27+
cur = rt_index_base()
28+
# return render_template("dashboard.html", curnumber=cur)
29+
return render_template("index3.html", curnumber=cur)
30+
31+
32+
# 02. 图表数据查询
33+
@app.route("/histChart")
34+
def get_hist_order_chart():
35+
c = hist_order_base()
36+
return c.dump_options_with_quotes()
37+
38+
39+
# 03:订单商品构成模型
40+
# 03-01:页面渲染
41+
@app.route("/bar")
42+
def order_bar():
43+
cur = rt_index_base()
44+
return render_template("index5.html", curnumber=cur)
45+
46+
47+
# 03-02:图表数据查询
48+
@app.route("/barChart")
49+
def get_order_chart():
50+
c = category_order_base()
51+
return c.dump_options_with_quotes()
52+
53+
54+
# 04:地理位置分布图
55+
# 04.01 页面渲染
56+
@app.route("/map")
57+
def customer_map():
58+
cur = rt_index_base()
59+
return render_template("index4.html", curnumber=cur)
60+
61+
62+
# 04.02 图表数据
63+
@app.route("/mapChart")
64+
def get_customer_order_chart():
65+
c = customer_order_base()
66+
return c.dump_options_with_quotes()
67+
68+
69+
# 403错误
70+
@app.errorhandler(403)
71+
def miss(e):
72+
return render_template('error-403.html'), 404
73+
74+
75+
# 404错误
76+
@app.errorhandler(404)
77+
def error(e):
78+
return render_template('error-404.html'), 500
79+
80+
81+
# 500错误
82+
@app.errorhandler(500)
83+
def error(e):
84+
return render_template('error-500.html'), 500
85+
86+
87+
# 主函数
88+
if __name__ == "__main__":
89+
app.run()
90+
# 模板更改后立即生效
91+
app.jinja_env.auto_reload = True
92+
# 代码更改后立即生效
93+
app.run(DEBUG=True) # 1.0以后 debug = true不再支持
94+

backend/flask/apps/exam_01.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: UTF-8 -*-
2+
# 案例1:业务逻辑部分
3+
from data_01 import *
4+
5+
6+
# 第一部分:业务逻辑
7+
# 01. 实时指标监控
8+
def rt_index_base():
9+
paysum = pay_sum_query()
10+
ordersum = order_sum_query()
11+
inventsum = inventory_sum_query()
12+
13+
cur = {'paysum' : paysum, 'ordersum': ordersum, 'inventsum': inventsum}
14+
return cur
15+
16+
17+
# 02:历史数据趋势
18+
19+

backend/flask/apps/exam_02.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: UTF-8 -*-
2+
from flask import Flask, render_template,jsonify
3+
from pyecharts import options as opts
4+
from pyecharts.charts import Map
5+
from pyecharts.charts import Line
6+
from pyecharts.globals import ChartType, SymbolType
7+
from pyecharts.globals import ThemeType
8+
9+
from pyecharts.components import Table
10+
from pyecharts.options import ComponentTitleOpts
11+
import json
12+
13+
14+
# 案例2:数据逻辑部分
15+
from data_02 import *
16+
17+
18+
# 第一部分:业务逻辑
19+
# 01. 订单量历史数据变化趋势
20+
def hist_order_base():
21+
dataX, dataY = order_sum_query()
22+
# 订单数据
23+
c = (
24+
Line(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
25+
.add_xaxis(dataX)
26+
.add_yaxis("订单量", dataY, is_smooth=True)
27+
.set_global_opts(
28+
title_opts=opts.TitleOpts(title="日订单量历史数据趋势图"),
29+
yaxis_opts=opts.AxisOpts(
30+
type_="value",
31+
axistick_opts=opts.AxisTickOpts(is_show=True),
32+
splitline_opts=opts.SplitLineOpts(is_show=True),
33+
),
34+
xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
35+
)
36+
)
37+
return c
38+
39+
# 02:历史数据趋势
40+
41+

backend/flask/apps/exam_03.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# 案例3:订单商品构成模型
2+
from pyecharts.charts import Pie
3+
from pyecharts import options as opts
4+
5+
# 案例3:数据逻辑部分
6+
from data_03 import *
7+
8+
9+
# 业务逻辑
10+
# 02: 地图渲染
11+
def category_order_base():
12+
dataX, dataY = order_category_sum_query()
13+
data_pair = [list(z) for z in zip(dataX, dataY)]
14+
# 订单数据
15+
c = (
16+
Pie()
17+
.add("", data_pair)
18+
.set_global_opts(
19+
title_opts=opts.TitleOpts(title="商品类型构成图"),
20+
legend_opts=opts.LegendOpts(
21+
orient="vertical",
22+
pos_top="15%",
23+
pos_right="-4.5%"),
24+
)
25+
.set_series_opts(label_opts= opts.LabelOpts(formatter="{b}: {c} ({d}%)"),
26+
position="outside",
27+
background_color = "#eee",
28+
border_color="#aaa",
29+
border_width=1,
30+
border_radius=4
31+
)
32+
)
33+
return c
34+

backend/flask/apps/exam_04.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 客户地理位置分布图
2+
from pyecharts import options as opts
3+
import pymysql.cursors
4+
from pyecharts.charts import Map
5+
6+
# 案例4:数据逻辑部分
7+
from data_04 import *
8+
9+
10+
# 02: 地图渲染
11+
def customer_order_base():
12+
dataX, dataY = customer_sum_query()
13+
# 订单数据
14+
c = (
15+
Map(init_opts=opts.InitOpts(width="1200px", height="600px"))
16+
.add("", [list(z) for z in zip(dataX, dataY)], "world")
17+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
18+
.set_global_opts(title_opts=opts.TitleOpts(title="客户地理位置分布图"),
19+
visualmap_opts=opts.VisualMapOpts(max_=1600, split_number=8, is_piecewise=True)
20+
)
21+
22+
)
23+
return c

0 commit comments

Comments
 (0)